OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: RolsRois on 07 May 2009, 22:14:01
-
well in my mission the player is suppose to be captive until he holds a weapon, so i wish that if he holds a gun, handgun, or a grenade, he wont be a captive anymore.
anyone?
-
Hmmm, maybe I am overstepping my bounds a bit, but perhaps the hasweapon command could help you?
Create a Trigger and in it's COndition field put this...
(player hasweapon "m16")Then in the OnActivation field put this...
player setcaptive false
Of course the player will have to be captive first.
- Player can be replaced with any unitname
- m16 can be replaced with any model name
Weapon models can be found in the COMREF here (http://ofpec.com/COMREF/index.php?action=read&id=67)
To check for multiple weapons, you will have to add them to the condition field by using the OR / || command between checks for example...
(player hasweapon "m16") OR (player hasweapon "pipebomb") || (player hasweapon "uzi")
and so when the player picks up any of the listed models, he instantly becomes a wanted man by all enemies present
It's that simple.
-
Or maybe something along the lines of :
@ weapons player != []
player setCaptive false
Just a thought. Not tested it. The instruction:
weapons playerReturns an array of the weapons the player is carrying so as soon as the array is not empty the player should stop being a captive.
Edit:
The above assumes this change is done in a script. If you want to use a trigger the Condition field should be:
weapons player != []
and the Activation field should be:
player setCaptive false
-
OFP cannot compare arrays by default...
You can write a function for it, or...
... let's say your player has the name p1... then we use this script:
@ count weapons p1 > 0
p1 setCaptive false
exit
:)
-
That just shows how rusty I am :D
The count method should work well. Good catch. :good:
By the way you can refer to the player as player without giving that unit a name.
Just for completeness in case RolsRols wants to use a trigger:
Condition field should be: count weapons player > 0
Activation field should be: player setCaptive false