Jump to content
Sign in to follow this  
ZNorQ

2 Questions; Local Player and ...

Recommended Posts

I've found a couple of strange concepts in a MP mission I had a glance at, and I don't understand why they use these;

A) Triggers with the condition local player

>> When is the player not local?

B) A #END trigger that has the "onActivation" code forceEnd

>> Is it really necessary to use forceEnd in a #END trigger??

ZNorQ

Share this post


Link to post
Share on other sites

Check this page for more informations about locality:

Locality in Multiplayer

1. A player is not local on a dedicated server? I think i still have some problems with this too. whistle.gif

2. A END trigger do not need the "forceEnd" b.t.w. forceEnd didn't work in ArmA as far as i know.

Share this post


Link to post
Share on other sites

A)Local player.

Ensures the code is executed (or not) on the player and not the server. For example: You want the player who enters a trigger area to start a cutscene but you dont want the other players (who are not in the trigger) to see it. Triggers are global so thats my assumption.

B)forceEnd

Its explained there, a way to terminate a mission without an end trigger but its old and not even recomended so i dont know why people use it when they already have a end# trigger.

Someone correct me if im wrong smile_o.gif .

edit:

I desperatly need a resource about JIP, i've searched this and other places and i cant find any decent information about it, what must be considered to keep everyone in sync crazy_o.gif .

Share this post


Link to post
Share on other sites
Check this page for more informations about locality:

Locality in Multiplayer

Yepp, know about this one, and been using it frequently, just that I can't understand why one would use local player. I thought players where always local.

1. A player is not local on a dedicated server? I think i still have some problems with this too. whistle.gif

I believe player = objnull (or somehting like that) on dedicated server.

2. A END trigger do not need the "forceEnd" b.t.w. forceEnd didn't work in ArmA as far as i know.

Well, as I said, I can't understand why one would put forceEnd in an END trigger.. What I didn't know though, is that forceEnd doesn't work in ArmA.. (I've never used the function)

ZNorQ

Share this post


Link to post
Share on other sites
A)Local player.

Ensures the code is executed (or not) on the player and not the server. For example: You want the player who enters a trigger area to start a cutscene but you dont want the other players (who are not in the trigger) to see it. Triggers are global so thats my assumption.

Ok, but as far as I can see, the only reason for using local player is that this is the quickest way to activate trigger, as opposed to player in thislist. Otherwise, it wouldn't be logical to use local player, as players are always local.. (As far as I know.). Not sure how it would react on a dedicated server, as I think I've read that player == objNull there..?

B)forceEnd

Its explained there, a way to terminate a mission without an end trigger but its old and not even recomended so i dont know why people use it when they already have a end# trigger.

Someone correct me if im wrong smile_o.gif .

Ehr, I know what it does, I'm not quite sure why they used it in an END trigger.. wink_o.gif

Share this post


Link to post
Share on other sites
Quote[/b] ]

A)Local player.

Ensures the code is executed (or not) on the player and not the server. For example: You want the player who enters a trigger area to start a cutscene but you dont want the other players (who are not in the trigger) to see it. Triggers are global so thats my assumption.

If you set the condition to local player it will trigger for all clients since player is local on all clients, its just that player is not the same character on all clients. If you want an area trigger to be activated only for the player in the area you use the condition player in thislist.

Quote[/b] ]I desperatly need a resource about JIP, i've searched this and other places and i cant find any decent information about it, what must be considered to keep everyone in sync  .

Ive been able to overcome some JIP sync issues but not all it seems. What is it you want to keep in sync between players?

Share this post


Link to post
Share on other sites
B) A #END trigger that has the "onActivation" code forceEnd

 >> Is it really necessary to use forceEnd in a #END trigger??

ForceEnd is a must have for me on missions with a spectating script.

My expiriences: If players are using the camera view in the moment the mission ends, the mission does not end very often for one or more from this players, and the server (which has ended the mission) is waiting for ever.

Share this post


Link to post
Share on other sites
ForceEnd is a must have for me on missions with a spectating script.

My expiriences: If players are using the camera view in the moment the mission ends, the mission does not end very often for one or more from this players, and the server (which has ended the mission) is waiting for ever.

Ok, then it would actually be a good idea to add forceEnd in END triggers if it remedies such events. Hopefully this doesn't cause other problems..

Thanks for the info, HeinBloed.

ZNorQ

Share this post


Link to post
Share on other sites

Update:

Okay I moved all the below into a wiki page, thought it would fit there smile_o.gif

http://community.bistudio.com/wiki/6thSense.eu:EG

Reply to original post, but also posts by others etc smile_o.gif

Player Object

[*] Player is indeed a null object on server

[*] You can not verify if an object is a null object by testing: object == objNull because objNull doesn't equal anything, not even itself, you must use: isNull object

[*] To test if a certain object is a player, use: isPlayer object

[*] player is a variable, just like any other variable. A variable can contain different values. In this case the variable "player" contains an Object.

The value of the variable "player" is:

Server: a null object

Clients: the object (vehicle) that represents the player on this computer

If there are 3 player slots in game,

player1 I name: p1

player2 I name: p2

player3 I name: p3

then on p3's computer:

player == p3

you can access the other players through the variables: p1 and p2

on p2's computer:

player == p2

and you can access the other players through the variables: p1 and p3

etc. etc.

[*] To get a list of all (connected)player-objects in the mission, which gets updated every 5 seconds:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">T_players = [];

T_trig = createTrigger ["EmptyDetector",getArray(configFile >> "CfgWorlds" >> worldName >> "centerPosition")];

T_trig setTriggerType "NONE";

T_trig setTriggerActivation ["ANY", "PRESENT", true];

T_trig setTriggerArea [30000, 30000, 0, false ];

T_trig setTriggerStatements ["this", "", ""];

private ["_ar"];

while {true} do

{

_ar = [];

{ if (isPlayer _x) then { _ar = _ar + [_x] } } forEach (list T_trig);

T_players = [] + _ar;

sleep 5;

};T_Players (array) will contain the current player objects. The list is automaticly cleared of dead players or players who left.

If you execute this on every machine: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{ _x globalChat ("Really, My name is: " + name _x) } forEach T_Players;Then on every machine it will apear as if all players wrote "Really, My name is: (name)" in globalChat.

Player/Server/JIP

The Basics:

[*] To only run something on dedicated server or serverClient: isServer

[*] To only run something on clients, and never on dedicated server or serverClient: !isServer

[*] To only run something on clients or server Clients: !(isNull player)

JIP Script example to figure out what the machine exactly is, in init.sqf or sorts: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">T_INIT = false;

T_Server = false; T_Client = false; T_JIP = false;

if (isServer) then

{

T_Server = true;

if (!(isNull player)) then { T_Client = true };

T_INIT = true;

} else {

T_Client = true;

if (isNull player) then

{

T_JIP = true;

[] spawn { waitUntil { !(isNull player) }; T_INIT = true };

} else {

T_INIT = true;

};

};Any script that has to work with the player object will have to wait until T_INIT == true:

waitUntil { T_INIT };

Conditions to use:

[*] Dedicated Server: T_Server && !T_Client

[*] Dedicated Server or ServerClient: T_Server

[*] ClientOnly: T_Client && !T_Server

[*] Client or ServerClient: T_Client

[*] Client or ServerClient, NOT JIP: T_Client && !T_JIP

[*] JIP Client: T_JIP

Locallity:

[*] Players are local to their own machine

[*] AI Are local to the server, unless they are part of a team lead by a player, in that case, that AI is local to the player teamleader machine.

[*] Empty Vehicles are local to the server

[*] Controlled Vehicles are local to the machine of the driver (incase of AI, this is by default the server, incase of player, this is the player's machine. Again, if the AI is part of a group lead by a player, the vehicle will be local to the player teamleader machine)

[*] The locallity of functions is documented in the biki

[*] Functions like: Say, sideChat, globalChat, groupChat etc. etc. are executed locally. So if you want to execute them on every computer, you will have to make sure that the script runs on every computer smile_o.gif

[*] setFuel, setDammage, setSpeed, etc. etc. effects are global, so basicly you can run the script that uses these functions on every machine, but only execute the function there where the vehicle is local, e.g: if (local _veh) then { _veh setDammage 0.5 };

[*] Triggers created in editor are global; they exist on all machines, and they run on all machines (conditions checked, onActivation/onDeActivation executed when condition is true etc)

[*] Triggers created in scripts are local and only exist/run on the machine where they got created.

[*] Most eventHandlers are local. This means that the eventHandler only executes on the machine where the unit who triggered the eventHandler, is local. Some events are global, like getIn, getOut, Fired and Init. A complete list you can find here: http://community.bistudio.com/wiki/Armed_Assault:_EventHandlers_List

General

[*] IMHO best practice would be to keep as much as possible server sided, because this should result in the least complex scripting and least amount of data sending/receiving. Only interface elements should reside on Clients, or functionality that only interacts with the player himself or his machine.

[*] Every variable that you 'publicVariabled' will be sent to JIP players. The value of these variables do not equal the current value of the variable, but instead, the value as it was at the moment it was 'publicVariabled'.

[*] Every vehicleInit that has been set (object setVehicleInit "blablalba"; processInitCommands), is synchronized to JIP Players

[*] There is no general rule of thumb available for Join in Progress compatible scripting etc, at least not to my knowledge. Basicly it all depends on what you are making, what the functionality is, and how this relates to Multiplayer. Basicly you have to keep all the above in mind while developing for Join in Progress compatible projects.

Interesting functions for Multiplayer:

[*] publicVariable

[*] addPublicVariableEventHandler

[*] setVehicleInit

[*] processInitCommands

[*] clearVehicleInit

[*] isPlayer

[*] local

You can find some more info in my answers here:

[*] http://www.flashpoint1985.com/cgi-bin....t=71130

[*] http://www.flashpoint1985.com/cgi-bin....6;st=15

[*] http://www.flashpoint1985.com/cgi-bin....98&st=0

Share this post


Link to post
Share on other sites

That really helps smile_o.gif.

But i still feel a bit unsure about how JIP clients receive the updated status of a running mission.

Are current mission time and weather changes broadcasted automatically to a JIP client?

Objstatus, do i need to use publicVariable to make sure the JIP client receives the correct status of mission objectives in their briefings? (or does Arma do this on its own? )

Markers.. if i change a marker (setmarkertype, colour, etc) in some trigger code will the JIP client receive the updated state of my marker?

Im a bit paranoid, yes..

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×