OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: Chomps on 24 Dec 2002, 05:37:44

Title: Executing something for all players...
Post by: Chomps on 24 Dec 2002, 05:37:44
Okay, so I have a script that allows a chopper to pick up a jeep or something and move it somewhere else and drop it via the action menu.  It works fine in single player, but in multiplayer, the jeep will be picked up, but it will not drop off.

I suspect the reason is that the dropping of the jeep is controlled by a global variable that is checked for in the jeep's setPos loop (it consistantly places the jeep under the chopper until it sees that variable turns false, then it terminates the loop and lets the jeep drop)

The variable is switched to false in a script that is activated by an action.  Perhaps the variable is not switching to false for all players?

The variable is not local, it was defined without the underscore in front.  Any suggestions?
Title: Re:Executing something for all players...
Post by: Ranger on 24 Dec 2002, 19:36:22
I had a question a several days ago about the publicVariable command that no one helped me to answer.  However, in my research about the command, I think it'll do exactly what you need.

If I'm not mistaken, you use publicVariable everytime you assign a new value to a global variable, which will then broadcast the variable's new value to all clients.  So, relating to your code, immediately after changing the value to false for your variable, put the following code:

publicVariable varName

Where varName is the name of your variable.

Hope it works.  Good luck.
Title: Re:Executing something for all players...
Post by: Chomps on 24 Dec 2002, 20:21:02
Thank you!  I think that is exactly what I needed!   ;D

(I cannot be sure until I test it in MP, but I am confident it should work.)
Title: Re:Executing something for all players...
Post by: Allie on 24 Dec 2002, 20:34:46
dont think u guys there

hi bytheway,
i'm busy too with multiplayer scripting and in scumball's airstrike u have same prob u need to exec script on all client computers you even have to declare public variables and transport them to all SQS scripts.

this howfar i am, i'm sure u guys problems have to do with same issue

snYper has made promise (If he has time) to explore the multiplayer scripting !!!

i really can do all but in multiplayer you have some tricks with local server stuff and more !!!!

hope more get to this issue
Title: Re:Executing something for all players...
Post by: Tactician on 25 Dec 2002, 15:56:18
Far as I know, publicVariable will not work on a private variable (_variable).

A way around this could be to only run the setPos on the server, since all vehicles are local to it when empty (I think).  For all setPos lines, try putting ?(local Server): in front (with the gamelogic named server of course).  If there are other messages like radio or hint boxes, you could have other complications with script flow.  If you posted the script we could probably help you more..

See either of my multiplayer tutorials for some background on publicVariable usage.  I ought to write something on just publicVariable without all that flag crap, but oh well..
Title: Re:Executing something for all players...
Post by: Chomps on 25 Dec 2002, 19:06:34
It is not a private variable I am working with.
Title: Re:Executing something for all players...
Post by: Tactician on 25 Dec 2002, 21:54:20
Ah yes.  Damn me for not comprehending what I read :-[