Home   Help Search Login Register  

Author Topic: Scripts activated by triggers in mp are not local?  (Read 2007 times)

0 Members and 1 Guest are viewing this topic.

Mr.Pibb

  • Guest
Scripts activated by triggers in mp are not local?
« on: 31 Jan 2005, 00:15:46 »
Hi,

 Heres the issue, have been looking about to see if scripts executed by triggers are always run on ALL computers. Heres the activation line of the trigger in question:

 [thislist,Town0] exec "Main\SetTownSide.sqs"

Now then, the script here that runs will run on ALL computers, not just the computer of the player that had activated it, correct?

 And lastly, therefore, in the script executed by this trigger, 'player' is a non-usable reference, because it will reference every player, being the script is running on all puters, as also 'local player' would be useless also in the script?

 Thanks

 Pibb
« Last Edit: 31 Jan 2005, 00:16:06 by Mr.Pibb »

CopyrightPhilly

  • Guest
Re:Scripts activated by triggers in mp are not local?
« Reply #1 on: 31 Jan 2005, 00:21:57 »
i would be interested in finding the true answer for this also...

first thing i would do is for the triggers condition use

?(local player)

but this is a good question because i have thought of it before but couldnt be *BEEP*ed to worked it out... can anyone tell us what the correct way to doing this is?

Mr.Pibb

  • Guest
Re:Scripts activated by triggers in mp are not local?
« Reply #2 on: 31 Jan 2005, 01:08:46 »
 I know you guys hate it when I put in lengthy scripts ::), but I wanted to put down what I have for the script that is being activated by the trigger I mentioned in the first reply. The script does work when I test it using different players, but of course it hasnt been tested with multiple players.
 The desired effect is to get the 'player' or unit(s) that is within the trigger area and set a flag to that units side. The script is a modified cti script, and so far it works perfect (with only me as one player testing tho).

 The #GetPlayerAtFlag part is really the clincher here, that part I am hoping will only execute for the 'player' that activated the trigger, not activate for every dang player in the game.

Once again, the trigger that activates this script is activated by Anyone, with activation line:[thislist,Town0] exec "Main\SetTownSide.sqs"


 Does this appear as it would function properly with 8 players?

SetTownSide.sqs:

Code: [Select]
;Last modified 4/15/3
;Script usage:  [Unit,Town] Exec "SetTownSide.sqs"

_units = _this Select 0
_town = _this Select 1

_count = 0
_westUnits = 0
_eastUnits = 0
_resistanceUnits = 0
_totalUnits = Count _units
_playerUnits = 0
_rogueCounter = 0
_rogueUnits = 0

;Count qualifying units.
#CountUnit

   _unit = _units Select _count
   _position = GetPos _unit
   _count = _count + 1

              ? (_unit == player) && (_position Select 2 < 3):hint format ["%1  is at flag post, no res in area",player];_playerUnits = _playerUnits + 1
   ? (Side _unit == west) && (_position Select 2 < 3):_westUnits = _westUnits + 1
   ? (Side _unit == east) && (_position Select 2 < 3):_eastUnits = _eastUnits + 1
   ? (Side _unit == resistance) && (_position Select 2 < 3):_resistanceUnits = _resistanceUnits + 1
              ? (Side _unit != west) && (Side _unit != east) && (Side _unit != resistance) && (Side _unit != civilian) && (_position Select 2 < 3):hint format ["%1  is at flag post, no res in area",player];_rogueUnits = _rogueUnits + 1

   ? (_count < _totalUnits):goto "CountUnit"

? (_playerUnits > _eastUnits) && (_playerUnits > _resistanceUnits):goto "GetPlayerAtFlag"
? (_westUnits > _eastUnits) && (_westUnits > _resistanceUnits):;goto "GetPlayerAtFlag"
? (_eastUnits > _westUnits) && (_eastUnits > _resistanceUnits) && (_eastUnits > _playerUnits):_side = 1;goto "SetTownSide"
? (_resistanceUnits > _westUnits) && (_resistanceUnits > _eastUnits) && (_resistanceUnits > _playerUnits):_side = 2;goto "SetTownSide"
? (_rogueUnits > _eastUnits) && (_rogueUnits > _resistanceUnits):goto "GetPlayerAtFlag"

Exit

#GetPlayerAtFlag

?!(local player):exit
? (_playerUnits > 1); hint format ["this should only execute no flag change when 2 or more players in flag zone"];Exit
? (player == WestAlphaLeader):_side = 3;goto "SetTownSide"
? (player == WestBravoLeader):_side = 4;goto "SetTownSide"
? (player == WestCharlieLeader):_side = 5;goto "SetTownSide"
? (player == WestDeltaLeader):_side = 6;goto "SetTownSide"
? (player == WestEchoLeader):_side = 7;goto "SetTownSide"
? (player == WestFoxtrotLeader):_side = 8;goto "SetTownSide"
? (player == WestGolfLeader):_side = 9;goto "SetTownSide"
? (player == WestHotelLeader):_side = 10;goto "SetTownSide"

Exit




#SetTownSide

? (Side player == west) && (_rogueCounter == 0):goto "PlayerIsNotRogue"

   @ !(setTown)

   setTown = true;PublicVariable "setTownSide"
   setTownSideTown = _town;PublicVariable "setTownSideTown"
   setTownSide = _side;PublicVariable "setTownSide"


#PlayerIsNotRogue

_rogueCounter = 1
? _town == Town0 && flagtown0:goto "SetTownSide"
? _town == Town2 && flagtown2:goto "SetTownSide"
? _town == Town3 && flagtown3:goto "SetTownSide"
? _town == Town4 && flagtown4:goto "SetTownSide"
? _town == Town5 && flagtown5:goto "SetTownSide"
? _town == Town6 && flagtown6:goto "SetTownSide"
? _town == Town8 && flagtown8:goto "SetTownSide"
? _town == Town9 && flagtown9:goto "SetTownSide"
? _town == Town10 && flagtown10:goto "SetTownSide"
? _town == Town11 && flagtown11:goto "SetTownSide"
? _town == Town13 && flagtown13:goto "SetTownSide"
? _town == Town14 && flagtown14:goto "SetTownSide"
? _town == Town16 && flagtown16:goto "SetTownSide"
? _town == Town18 && flagtown18:goto "SetTownSide"
? _town == Town19 && flagtown19:goto "SetTownSide"
Exit

 Pibb
« Last Edit: 31 Jan 2005, 01:14:41 by Mr.Pibb »

Offline Killswitch

  • Members
  • *
  • Peace, cheese and ArmA
Re:Scripts activated by triggers in mp are not local?
« Reply #3 on: 31 Jan 2005, 10:53:58 »
Hi,  Heres the issue, have been looking about to see if scripts executed by triggers are always run on ALL computers.

Trigger conditions are evaluated on ALL machines.
Due to that, the On Activation field is performed on ALL machines, should the mission designer want that. Most often he/she does and whatever is in the On Activation field is run on ALL machines.

Now, why do I state that in a slightly vague way? Consider this: one can imagine forumulating the condition so as to make it evaluate to true only for certain computers. Examples:

Example 1 - trigger condition that eventually runs code on all machines
(Trigger goes off just after 5 am in the morning)
Code: [Select]
dayTime>5Example 2 - trigger condition that will run it's On Activation code on only one machine
(Trigger activates on machine where the player calling himself "Joe" is playing)
Code: [Select]
name player=="Joe"
Quote
Heres the activation line of the trigger in question:
Code: [Select]
[thislist,Town0] exec "Main\SetTownSide.sqs"Now then, the script here that runs will run on ALL computers, not just the computer of the player that had activated it, correct?
Yes, that is quite possible, again, depending on how the trigger condition is set up.

Quote
And lastly, therefore, in the script executed by this trigger, 'player' is a non-usable reference, because it will reference every player, being the script is running on all puters, as also 'local player' would be useless also in the script?
I'm not sure what you mean by "will reference every player". The command player will return different values on each computer. On computer A, player will give you a reference to the unit played by Mr A, on computer B you'll get a reference to the unit played by Mrs B and on a dedicated server, the command will return a non-valid value ("scalar bool array....", IIRC). So I wouldn't exactly call it unusable. You just need to keep this in mind depending on what you want to do in the script.

Furthermore, "local player" will return the value true on all client (player) computers and false on the dedicated server.

Ok, that takes care of your first post. Hope it helps!
« Last Edit: 31 Jan 2005, 11:04:46 by Killswitch »

Mr.Pibb

  • Guest
Re:Scripts activated by triggers in mp are not local?
« Reply #4 on: 31 Jan 2005, 20:16:24 »
 Thanks Killswitch.

I understand everything you have written, looks like I need to modify the script a little, but really, thanks, an excellent description of something I have been trying to fully understand for sometime now, and couldnt find anything as descriptive as what you have just given.

I can see also that I really need to hook up with someone to test this stuff with, mp testing is so limited when its just me and I really need to check on more than one player at once, but all in do time.

 Pibb


Mr.Pibb

  • Guest
Re:Scripts activated by triggers in mp are not local?
« Reply #5 on: 31 Jan 2005, 22:09:42 »
 Once again thanks Killswitch, got the script re-worked and its functioning fine with the changes that should make it work properly on each players computer.

 Pibb

(guess I'll solve this now ::))