Home   Help Search Login Register  

Author Topic: How to exit script for all players if specific unit is playercontrolled.  (Read 2046 times)

0 Members and 1 Guest are viewing this topic.

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Hi again.

I know about the player and IsPlayer commands but I still can't figure out how to solve this scripting problem.

The script runs on all computers, it involves voices and playmoves so it has to be that way. But then I want it to exit it on all computers if one specific unit is player controlled.
If I have " ? IsPlayer _unit : exit " or " ? _unit == player : exit "it will only exit on the single players computer. Basically: How can I use IsPlayer or player commands and make that register on all computers? Hope you could understand my babble.

Cheers

Laggy
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Well, in
Code: [Select]
? _unit == player : exit
You are saying "if the unit is the local player, then exit". This means that yes, it can only ever exit on one machine.

However, in
Code: [Select]
? isPlayer _unit : exit
You are saying "exit if unit is controlled by a player, whether local or not", so this should work, assuming that _unit is correctly set on every computer. I suspect that you aren't setting the value of _unit correctly on the other machines (it is a local variable, so it can't have been set by publicVariable from another machine. I'd suggest trying using a formatted hint to check whether it is the expected value).
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Hi there and thanks for your input.

This is the setup:
In my mission there is only one group that has playable units, so every player will be part of the same group called squad.
The script runs on every groupmember unit through "{[_x] exec "casualty.sqs"} foreach units squad" set in init.sqs which should mean that each script is running on every computer since mission start.
I have already tried the script in MP with good results and the only questionmark is the exit script running on specific unit for all computers if specific unit is playercontrolled. I guess you answered my question with your info about the IsPlayer command.
My current solution looks like this:

#startofscript#

_unit = _this select 0

#loopcheck

? _unit == player : wronguy = _unit; Publicvariable "wronguy"; exit

~ 1

? _unit == wronguy : wronguy = ObjNull; exit
? damage _unit > 0.6 AND alive _unit AND vehicle _unit == _unit : goto "casualty"

goto "loopcheck"


#endofscript#

The script continues further but the only questionable stuff is what's above.

The new solution after your input would be like this:

#startofscript#

_unit = _this select 0

#loopcheck

? IsPlayer _unit : exit

~ 1

? damage _unit > 0.6 AND alive _unit AND vehicle _unit == _unit : goto "casualty"

goto "loopcheck"


#endofscript#

Do you think this will work? Thanks alot again.

Laggy



And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.


Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Thanks all.

Will use this script in an upcoming MP mission. I think you'll like it as it adds alot of stress for the groupmembers and realism.

Cheers

Laggy
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.