Home   Help Search Login Register  

Author Topic: What OFP Does With Your Script File  (Read 4339 times)

0 Members and 1 Guest are viewing this topic.

Bluelikeu

  • Guest
What OFP Does With Your Script File
« on: 13 Jul 2005, 23:23:07 »
Hey all,

I'm starting this thread so that people understand what OFP does with your script file during the game. Through experience and testing, it can be concluded that the script file that you place in your mission directory is not loaded into the memory for later use. This means that the script file is read/re-read upon its execution. You may think that this quite possibly would slow down the initialization/proccesses within the script. However, this has not been concluded yet. The speed difference might be quite minimal had the entire script been put into memory considering the size of the script.

Since OFP does not load the script into memory, it it possible to edit the script externally outside OFP while the game is running. I know that many people have tried to edit it and it says that the 'file is already in use by another program.' This is because OFP reserves the file for its own usage. However, this can be exploited through the use of other programs that can 'steal' access to the file and force the system to refuse OFP access.

These are some reasons why this is good for us:
    1. This allows us to edit script during gameplay through the use of an external program that runs with OFP

    2. New programs/methods of changing one's scripts during gameplay may sprout up. This will allow mission designers/scripters to experience a new field in the scripting realm that allows for dynamic editing/swapping of script files during gameplay.

    3. Needs for such people who can edit/create these programs will now be useful to OFP Mod/Mission design teams.

So far, it appears that the proccess that loops go through within a script is still not fully understood. With more testing, I believe that we can find the answer to that question.
The file is not closed after one loop is completed, OFP simply goes back to the beginning of the loop and starts from there again, therefore, no editing can occur during loops.

Thanks for reading,
Bluelikeu
« Last Edit: 14 Jul 2005, 18:35:10 by Bluelikeu »

Offline Platoon Patton

  • Members
  • *
  • "Barbecue" CreateVehicle getpos LLama
Re:What OFP Does With Your Script File
« Reply #1 on: 14 Jul 2005, 17:47:48 »
Bluelikeu,

Yes U can change scripts in the editor,while OFP is running.OFP will simply execute the edited version when asked.But this is not working with PBO versions like u mentioned.And the reason is simple:MULTIPLAYER!

If U find a way to change scripts while the game is running,like u describe in your openingspost,it would simply mean the end of MP games...

Once a game is started the map is loaded into MPMissionCache,having the ability to change this folder/scripts while OFP is running would give clients a wildcard to edit the settings in any way they like ..Viewdistance,dammage player,etc could be changed on a clients machine without being able to notice anything.

No need to go in detail any further,and I also have no doubts about the good intentions of your post,but I think this is tricky and might lead to abuse.

I would like to ask to be careful when U investigate this subject further.


PP
http://www.platoon-clan.com/ We always wellcome dedicated OFP players :)

http://www.european-combat-league.com/index.php To play with us in the best OFP league ;)

Bluelikeu

  • Guest
Re:What OFP Does With Your Script File
« Reply #2 on: 14 Jul 2005, 17:54:54 »
Even if clients change the scripts in the cache, it will not change the game. It might change things for them during the game, but since the game is run off someone's server, the game itself it not affected. The OFP client simply recieves information, and only sends key/mouse input, and maybe a few other pieces, but nothing that can affect multiplayer. If scripts are too be changed, it must be done on the server's computer, and that is the only way that can be done.

Edit: Just to stress what I already said....The server handles everything, no abuse can occur from clients.
« Last Edit: 14 Jul 2005, 17:58:09 by Bluelikeu »

Bluelikeu

  • Guest
Re:What OFP Does With Your Script File
« Reply #3 on: 14 Jul 2005, 18:05:53 »
My test version is ready, but if people feel like it would cause problems, then please specify this...i'll be posting it in 1 hour, unless someone says no.

Offline Platoon Patton

  • Members
  • *
  • "Barbecue" CreateVehicle getpos LLama
Re:What OFP Does With Your Script File
« Reply #4 on: 14 Jul 2005, 18:14:24 »

Edit: Just to stress what I already said....The server handles everything, no abuse can occur from clients.

This is unfortunately not true m8.

Many scripts only run local (?(local player):[] exec "script.sqs").

It is possible to run the game while everybody has different lightsettings (daytime),as I found out when I
screwed the implementation of the random command in MP.Every client runs his own OFP,the server is just there to syncronise.
http://www.platoon-clan.com/ We always wellcome dedicated OFP players :)

http://www.european-combat-league.com/index.php To play with us in the best OFP league ;)

Bluelikeu

  • Guest
Re:What OFP Does With Your Script File
« Reply #5 on: 14 Jul 2005, 18:29:38 »
Yes, but this only occurs on the clients computer and does not affect the others. But ofcourse it is handly to be able to change the daylight. If your mission is pbod, i don't think that one can open it, without first decrypting it, which i don't know how to do.

I'll find a way to edit the prog so that there is some sort of security

Btw, for some reason before using my program i couldn't open the script files during the game. Thats why i made it, but now it seems that this change is permanent, maybe it was only by computer. Did anyone get the "cannot open this file because it is already in use" error when opening and editing your script file during the game?
« Last Edit: 14 Jul 2005, 18:30:35 by Bluelikeu »

Bluelikeu

  • Guest
Re:What OFP Does With Your Script File
« Reply #6 on: 14 Jul 2005, 18:47:17 »
I believe that people could access a script and change a script while playing in a mission. Right?

Just want to make sure that its just not me who could not open a script while I was in a mission. Please try this:

Open Operation Flashpoint

Load a mission from your mission editor(make sure that it has some scripts)

alt-tab, and try to open one one of the script files.

Tell me what happens after that

Thanks
« Last Edit: 14 Jul 2005, 19:09:22 by Bluelikeu »

Offline Platoon Patton

  • Members
  • *
  • "Barbecue" CreateVehicle getpos LLama
Re:What OFP Does With Your Script File
« Reply #7 on: 14 Jul 2005, 19:46:24 »
You can open and edit scripts in the editor,in the MP editor means the file is in Yellow.In SP U talk about a "custom mission".

-->Load a mission,alt-tab,U can now open\edit .sqs files.
If U execute the edited script OFP will just read the edited version.

You can open PBO-ed maps\missions (After U UNPBO it),when OFP is running (Green files in MP editor or Maps downloaded from a server),but you CANT edit them.(OFP will reply that the file is in use)

-->Join any server,vote yourself admin,choose a map,assign,click start,U recieve the map and U are ready to go.Now ALT-TAB,open OFP\MPMissionCache,UNPBO the map.

U can see all the UNPBO-ed info (READ only),but you cant change anything.(reasons why explained in previous posts)

Again my point:the ability to change these scripts while OFP is running would be horrible for MP gaming.
http://www.platoon-clan.com/ We always wellcome dedicated OFP players :)

http://www.european-combat-league.com/index.php To play with us in the best OFP league ;)

Bluelikeu

  • Guest
Re:What OFP Does With Your Script File
« Reply #8 on: 14 Jul 2005, 20:06:14 »
Ok, i see the problems, but the program couldn't affect anything even if it wanted to, at this stage.

"Again my point:the ability to change these scripts while OFP is running would be horrible for MP gaming. "

So you couldn't open script file from a mission while you are in the game playing a mission, while shooting tanks and stuff. Just want to make sure, because i might have been unable to do that all along, while others were. If you could already do that it defeats the purpose of the program

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re:What OFP Does With Your Script File
« Reply #9 on: 14 Jul 2005, 20:15:15 »
Please try this:

Open Operation Flashpoint

Load a mission from your mission editor(make sure that it has some scripts)

alt-tab, and try to open one one of the script files.

Tell me what happens after that

Thanks
I started a looping sqs in OFP (with a radio trigger), tabbed out, opened the script, made changes and saved it without any probs (using Chris' OFP Script Editor)...
Then went back to OFP and it was still looping the original script without any problems...
Although, OFP pauses it's activities (incl. scripts) when tabbed out...

Then I re-executed the script with the radio trigger again (without stopping the original loop) and then OFP ran the original loop (which basicly doesn't physically exist anymore) and the same edited loop...
« Last Edit: 14 Jul 2005, 20:16:14 by HateR_Kint »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Bluelikeu

  • Guest
Re:What OFP Does With Your Script File
« Reply #10 on: 14 Jul 2005, 20:29:56 »
hmm, for me its different, I start a script, start playing the mission, and the script is working and then ends(no loops). Then I alt-tab and edit the script and change a few things. Then call the script again and the script has changed, and does what i did to it.

Offline Mikero

  • Former Staff
  • ****
  • ook?
    • Linux Step by Step
Re:What OFP Does With Your Script File
« Reply #11 on: 14 Jul 2005, 20:59:36 »
Unfortunately Blue, you've made the wrong leap. A script, any script, is retained in memory for the duration of that script. The file from whence the script came is locked during that time, but it, the file and it's contents are *never* re read.

When the script 'exits' it's lifetime is over, and any subsequent calls via exec to the script re-read the file contents.

The best example of this is a script that never exits, ie a slow housekeeping script. You can even, exit ofp and start again, the file is NEVER re-read. You can alter it to your hearts content, it makes no difference.

Instead, the script content that *was* in memory, is retained in one of the xyz. fps files that are loaded on a game/mission/campaign restart.

This should explain the apparent discrepencies between what you vs others are reporting. Between exec and exit, the content of a script is retained in memory.
Just say no to bugz

Offline Baddo

  • Former Staff
  • ****
  • Reservist Jaeger
Re:What OFP Does With Your Script File
« Reply #12 on: 14 Jul 2005, 21:14:36 »
Hi Bluelikeu,

are you sure the 'something what you want but I'm not exactly sure what it is' can't be achieved with Kegetys' fwatch utility?

http://ofp.gamezone.cz/index.php?showthis=8361

It's for Windows only so it can't be used on Linux servers. But it might be a tool that can do the job you want, in SP missions.

If I understood your posts correctly, you want to have a way to dynamically create and manipulate data that is being fed to OFP while playing. And as far as I'm concerned, fwatch can do that.

I haven't had the time to play around with it but it's for sure a very interesting tool.

Bluelikeu

  • Guest
Re:What OFP Does With Your Script File
« Reply #13 on: 14 Jul 2005, 22:53:58 »
@mikero
You are right, the script goes into memory for the time being, however, once the script is finished, or forced to exit(by an outside force), OFP trashes it and re-reads it once the script is executed. I've tested it in-game with a small example program. I have two scripts, one that is a loop and executes and empty script file once every couple of seconds. I used the program to hold script file and write data to it, such as a hint command. When the looping script repeats the execute command, the hint command pops up in the game. This shows that the scripts are not held in long-term memory.

Well, the idea was to create an easy java editor for this. You could "insert", so to speak, scripts at certain times in the game, or even block OFP from running certain scripts, and even parts within a script. The tool would be mainly meant for "during play" editing of scripts and such. In the case of a single play mission, the mission maker could create his own "programme" for which he has planned for the user. Certain options that could not be easily used in scripting can be easily manipulated from outside OFP.. From what I understand fwatch only allows you to do certain things from within the scripts, for example, the 30 or so commands provided with it.

Btw, if you want fwatch to work on linux servers, use a program known as "Wine" it can be easily found online, just search into google, "Wine Linux".
« Last Edit: 15 Jul 2005, 00:14:46 by Bluelikeu »

Offline Baddo

  • Former Staff
  • ****
  • Reservist Jaeger
Re:What OFP Does With Your Script File
« Reply #14 on: 15 Jul 2005, 16:08:05 »
Btw, if you want fwatch to work on linux servers, use a program known as "Wine" it can be easily found online, just search into google, "Wine Linux".

Does OFP Linux dedicated server work in combination with fwatch running in Wine? Are you sure about that?

#Edit

...and I still think what you are trying to accomplish could be done with fwatch. You just would have to write the scripts so that they take advantage of fwatch's functions. You could pass data from an OFP script to fwatch, then modify it and bring it back and use in a script. Have I completely lost the track here...?
« Last Edit: 15 Jul 2005, 16:13:43 by Baddo »

Bluelikeu

  • Guest
Re:What OFP Does With Your Script File
« Reply #15 on: 15 Jul 2005, 18:50:20 »
Well, the point it to be able to edit/change/re-arrange the scripts while ofp is running not just add some extra commands like move my mouse here.

Offline Baddo

  • Former Staff
  • ****
  • Reservist Jaeger
Re:What OFP Does With Your Script File
« Reply #16 on: 15 Jul 2005, 19:43:57 »
#1

Does OFP Linux dedicated server work in combination with fwatch running in Wine? Are you sure about that?

#2

I am a bit confused of what you are trying to accomplish. If you are editing a mission then you are editing it. But wanting to "edit/change/re-arrange the scripts while ofp is running"... hmmm...

I can edit/change/re-arrange the scripts while OFP is running. I don't have a reason to rudely take control of a script file from OFP and alter it's contest 'on the fly' if that's what you are after here? Like OFP is in the middle of a script and you change the line X of that script and OFP would notice the change in that file without reloading it? Is that what you want?

Maybe it's just me, but I can't seem to get what is the thing you want to achieve in practice to benefit mission editing or playing somehow.

But anyways, keep trying.

:)

Bluelikeu

  • Guest
Re:What OFP Does With Your Script File
« Reply #17 on: 15 Jul 2005, 20:42:13 »
1. As you said before, fwatch does not work in linux. In order to it to have more compatibility you load the fwatch exe with wine. This may allow you to use fwatch while under linux. I believe that one goes into the kernel and goes to the directory of fwatch and then types:
winex fwatch.exe
this will increase the compatibility that linux has with fwatch, its quite simple.

Oh, and i believe that the latest version of Wine is called Winex, but i'm not sure.

2. Idea: change scripts while playing a mission. That is the main idea. But i want to make it a bit more grand, as in one creates their own schedule that edits the scripts. I not sure how to explain this....

Enter the name of a script:
carbomb.sqs
Enter the name of the script that you want it to be swapped with:
carbom.sqs  //With bigger explosion
Condition:
gametime == 100s

Why have both scripts taking up resources and doing the explosion, when you want it to have a bigger explosion "carbomb.sqs //with bigger explosion" It would get rid of the problem of having to synchronize the two scripts.

These wouldn't be the only options, but its just an example
« Last Edit: 15 Jul 2005, 20:43:52 by Bluelikeu »

DBR_ONIX

  • Guest
Re:What OFP Does With Your Script File
« Reply #18 on: 25 Jul 2005, 20:55:47 »
About.. a month ago? Maybe more, I had the same idea, to edit scripts via external program. Basicly what I did was use Visual BASIC to write two small programs, using WinSock.
When a message was sent from the client, it sent the data to the server program, which then created a script in the root of the flashpoint folder called ExternalChat.sqs or something.
Code: [Select]
?(1<= MessageRead):exit
player globalchat "#25/07/2005 20:17:59 : testing"
MessageRead=1
EXIT

Then the next ::
Code: [Select]
?(2<= MessageRead):exit
player globalchat "#25/07/2005 20:18:31 : testing again"
MessageRead=2
EXIT
etc

This was sort of usefull, the program (Same idea without a client, the "server" program gets info and creates the file) could get information from lots of places (Server computer, website database etc) and display this in game. The biggest problem was stoping it (OFP) showing the same message repeatedly, as there was no way of getting OFP to delete the file, thus the annoying ?(2<= MessageRead):exit stuff
(Program not released, as it's kinda fiddley to set up and of very limited use, but it's availbe if needed, email me if you want it :P
With FWATCH, you could create a file in FWATCH/mdb with the message, read this and display it in game, then delete the file with the delete command, so it's not read again, very easy/neat, I'll write this sometime :P)


This came from the idea that if I could take a screenshot, save it to the OFP folder and setobjecttexture it to something, so you could have real ingame intelligence,
but triggering the screenshot was impossible it seemed..
But... you can run a script from the OFP root, and a friend made a typo : [this] exec "script.exe" (was supposed to be script.sqs)

Hmm, could OFP trigger a program? Nope, got a weird error message (ASCII characters, with a |# unknowned character or something - OFP handles and script run as a text file).
So OFP can load a file from the OFP root, can a program watch this file and see if it's read.. Nope :(

Buut, I posted the idea on the BI forums (This thread, and after a few pages, kegetys suggested the idea that led of to FWATCH, which allowed OFP to create a file from a script, then in a program, check this exists, if so take a screenie, save it to OFP root, setobjecttexture it (thing setobjecttexture FORMAT ["../../%1.jpg",{fwatch code to read number from file}] -
The file was created by the VB program.. So if the file saved was 2.jpg, the number in that file was 2, i.e CurrentPhoto=2).
The setobjecttexture bit never really worked very well, it needed the mission to be reloaded, I never tried taking the screenshot in the intro video, but this could work, then you could pass the enemy position via an FWATCH file, so the random positions are the same in the main mission.

(Program can be downloaded here)

Changing the script works, I've not really tried with loops, but I'm almost certain OFP reads the script, and runs it, after it's finished, it'll forget the script. If it's run again, it'll read the file again, and run it.

A few interesting ideas I came up with while going though the above stuff (Quoted from OFPCamera readme)..
Quote
   *   Use a webcam, and similar idea to current program, to take picture of it, save it into root of OFP folder. Then setobjecttexture (Or possible using dialouges) somewhere. Pointless, but if the OFP server had a server program running, which recivied this image from each player, and sent it to others, it could have it's uses I suppose.
    * Sending stats to database via internet. Use FWATCH to create and write stats to a file, in the form
      player=dbr_onix
      rating=100
      misison=MyMission1
      Then to use a program to read of these stats, change the format to
      http://blah.com/handleStat.php?player=Ben&rating=100&mission=MyMission1
      And go to this URL. Then using PHP, enter these values into a database (Could be done in any server-side language, like Perl etc). You could then use this database to create stats for players etc. Or using dialouge ("Enter your squad name"-type thing), squad rankings on CTI servers, for example.
    * Use a program to write values to a file, then use FWATCH to read these values into OFP. Or (an idea that I made a while ago, VB->OFP) directly write a script, using varibles from inside the program. I wrote a VB program that recived a message using WinSock, which displayed the message in GlobalChat. A similar idea could be used to get these stats sent to the database back, and display them ingame (A ranking number beside player info on a dialouge, for example)
    * Use a similar idea, dynamicly create an image, download it to each client and use setobjecttexture, cutrsc, or similar.

Anyway, I think this is long enough... ::)
Hope this gives some people a few ideas, the program to send stats to a database, if secured by a password entered via a dialouge by an admin (so theres a final arugment on the URL, &password=whateveritis, and the script checks this on the server), so cheating potential is limited a lot, it could be cool. You could have a mission that reloads every 30mins, but people keep their weapons/ammo, health and position, and save the enemys position/health/ammo (unless their dead, a sort of body-delete script), same with vehicles, maybe create new vehicles for desroyed ones at a "repair center". This is possible via Sinews of War's concept, or FWATCH (I.e create a file for each player, a file for enemy units, enemy vehicles etc.
So ben.db :
Code: [Select]
health 0.4
wepons=m16
magazines=m16
mCount=2
pos=[2322,4342,4]
Then load the file FORMAT ["%1.db",name player])

Good luck to anyone who tries anything relating to this, it can (And probobaly will) open biig doors, and lead to big missions (Big missions can fit though small doors :P)
- Ben
Edit : WinSock, not FSock ::)
« Last Edit: 25 Jul 2005, 20:58:22 by DBR_ONIX »

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:What OFP Does With Your Script File
« Reply #19 on: 26 Jul 2005, 09:49:05 »
hmm - i was just flying over the posts here, but maybe this
info could be useful for you:

I once tried to implement an anti cheat system, server side controlled.

On the server there was an sqs file in mpmissions folder, which
contained some kind of anti cheat admin names.
Simply playernames to be compared from an array to the actual
participating players in the game to determine wether an admin
is present or not (to enable ACS for him or them).

OK, blablabla and so on....

Point is: it was an external script, not included to the pbo, and
it was only one the server. I could edit the script while the game
was running, and the effect of changes took place.

I just can't remember if it was: \..\mpmission\script.sqs
or \mpmissions\script.sqs - or something like this.

But you can use external open source scripts from pbo'ed missions - like addons to this, missions can do this.

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted