OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: ROBINO on 04 Aug 2005, 19:33:15
-
Hi, i'm simply trying to run different scripts on different comps during a MP game, and I have succeded. However, the code below is running off a server machine as I log-in as a client (when MY unit is named either "play1" or "play2" and the other unit is made AI). When I log-into the server as the ONLY client I would hope that only 1 action is added to my avatar's action list, but 2 are added! How is this ? How can my comp think that both "play1" AND "play2" units are local ? Why would it think "play2" is a player unit ?
What are the rules of localism ? Why does the code work when the people logged into the server is >1 ?
_unit = _this select 0
? local server: exit
? local _unit && play1 == player && not local server: [0,1,0,0,0,0,1,1,0,0] exec "bf\addaction.sqs"; exit
? local _unit && play2 == player && not local server: [0,1,0,0,0,0,1,1,0,0] exec "bf\addaction.sqs"; exit
exit
-
What is in addaction.sqs? The problem might be in there. Or not.
Locally added actions can be seen globally I think. For example, you add an action to player BoB on his computer only. RoB goes near BoB in game and sees the action in his action menu.
It's the same as if you add an action to a flagpole. Everyone can see it in their action menu when they go near the flagpole, no matter on whose computer it's been set up.
Maybe. :)
-
If the AI is under your command, will it not be local to your machine as well? If you put the AI in a different group or make it the leader, does that remove the problem?
If so, search the forums for a thread about differentiating between AI and real players.
My experience with addAction is that it is seen only on the machine on which the command is executed.
-
as Mr Peanut stated
If you as a player are the leader of your group
Then all units in that group are under local control on your client
so if you add an action to a unit in your group, that action is local to your client and any effects it causes during the running of the script are only going to be local, unless you public variable or cause a trigger activation through it
Adding action to vehicles (unmanned) or objects is still local but seen by all
eg
if you add an action to an ammo crate, the action is available to all clients when they get near enough.
However if say the action is to createvehicle a crew served mgun then each player will be able to create one, not just 1 machine gun)
and therefore if your intention was to allow the players side the ability to create 1 machine gun in the mission and there are 12 players, they will infact be able to create 12
ofcourse as nearly always in ofp there are workarounds for this
-
It's always worked for me to only check if the unit I want to have the action is the right one, i.e in the script that adds the action, check if the unit I want to have the action is player, if not exit. And if a action is added on only 1 computer, then it only shows on that computer. I've added actions to vehicle for only leader of a group without anyone else seeing it.