Home   Help Search Login Register  

Author Topic: I have just a tiny problem with setcaptive command...  (Read 1162 times)

0 Members and 1 Guest are viewing this topic.

Offline RolsRois

  • Members
  • *
  • I'm not sure of who i am anymore
    • Rambm Workshop
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?
Rambm Workshop, A New way of playing OFP
http://www.freewebs.com/rambm/
yes its on freewebs! Got a problem?

Offline savedbygrace

  • Intel Depot
  • Administrator
  • *****
  • Be swift to hear...slow to speak...slow to wrath.
Re: I have just a tiny problem with setcaptive command...
« Reply #1 on: 08 May 2009, 00:40:13 »
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...
Code: [Select]
(player hasweapon "m16")Then in the OnActivation field put this...
Code: [Select]
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


To check for multiple weapons, you will have to add them to the condition field by using the OR / || command between checks for example...
Code: [Select]
(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.

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re: I have just a tiny problem with setcaptive command...
« Reply #2 on: 08 May 2009, 09:50:09 »
Or maybe something along the lines of :
Code: [Select]
@ weapons player != []
player setCaptive false

Just a thought.  Not tested it.  The instruction:
Code: [Select]
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
« Last Edit: 08 May 2009, 09:53:51 by THobson »

Offline dr. seltsam

  • Members
  • *
Re: I have just a tiny problem with setcaptive command...
« Reply #3 on: 08 May 2009, 13:58:28 »
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:

Code: [Select]
@ count weapons p1 > 0
p1 setCaptive false
exit

 :)

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
Re: I have just a tiny problem with setcaptive command...
« Reply #4 on: 08 May 2009, 15:24:03 »
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