OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: Zombie on 06 Feb 2005, 16:13:48
-
I need a script that will detect whether a tank or APC is manned by 2 (or 3) players. I want to force players in an MP game to man a tank as gunner and driver, so if someone just jumps in the drivers seat, the tank won't go unless a player jumps in as gunner, and vice versa. Seems an application of the crew command, but can't figure out what to do next.
Another twist is, once a tank is manned and entered in to combat, sometimes one but not all crew members will be killed, so the tank needs to be useable for the survivor. Hope this makes sense...............
-
Ideas you could implement that would help you achieve your goals
1) remove and when ready add fuel to the vehicle
... xx setfuel 0
... xx setfuel 1
2) Run a "getin" and "getout"eventhandler on the vehicle
... makes for an easy and efficient way to monitor your crew count
... eg getin activates script that:
..... checks crew count
..... adds fuel to vehicle if crewcount >1
..... locks the vehicle if crewcount >1, so they cant get out
... eg "getout" activates script that:
..... checks crew count
..... removes fuel from vehicle if crewcount <2
3) runs a "hit" eventhandler on the vehicle
... runs a script that:
.....checks to see damage
.......... if damage is bad, unlocks vehicle so crew can escape
.......... runs a crew count check, if <2 removes fuel
hope that gives you an idea how to approach your problem
-
couldn't figure out eventhandlers, so I use this script:
#start
_vcl = _this select 0
? (getdammage _vcl) => .5 :goto "end"
? count crew _vcl == 1 :goto "warn"
goto "start"
#warn
player groupchat "Damn, I need another crewmember, I better call one"
_vcl setfuel 0
@count crew _vcl ==2
_vcl lock true
player groupchat "That's better, let's go"
_vcl setfuel 1
@ (getdammage _vcl) => .5: _vcl lock false
#end
exit
problem is, the getdammage lines return unknown operator..I know I am missing something simple....anyone see it?
-
#start
~1
_vcl = _this select 0
? (getdammage _vcl) > 0.49 :goto "end"
? count crew _vcl == 1 :goto "warn"
goto "start"
#warn
player groupchat "d**n, I need another crewmember, I better call one"
_vcl setfuel 0
@count crew _vcl >1
_vcl lock true
player groupchat "That's better, let's go"
_vcl setfuel 1
@ (getdammage _vcl) >0.49: _vcl lock false
#end
exit
***************************************************
how to use eventhandlers.
Place the following lines in the init field of the vehicle
(remember to use a ; between each line
this addEventHandler ["Getin", {_this exec "myGetin.sqs"}]
this addEventHandler ["GetOut", {_this exec "myGetout.sqs"}]
this addEventHandler ["Hit", {_this exec "myHit.sqs"}]
and then just run what scripts are needed for each event