OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: filth on 15 Sep 2008, 17:20:52
-
can't seem to locate an answer to this on the site, so please help.
i have a scud set up in a multiplayer mission that i've added an action to (setting the publicvariable etc correctly).
what i would like is to be able to name the person who uses the action so that the others can see who's performed it...
in a 'hint' preferably, but failing that, a sidechat remark.
any pointers?
ta.
-
dirty boy!
The script that you call from an addAction passes some values via the _this variable. From our own OFPEC ComRef:
So an example of an action-based script goes like this:
_obj = _this select 0
_man = _this select 1
_index = _this select 2
If you want to remove the action from the object immediately after it's triggered, use this line along with the above:
_obj removeAction _index
So in your script _this select 1 is the person performing the action. So you need to add to your script.
ScudOperator = _this select 1; publicVariable "ScudOperator"Add a trigger to your mission with Condition
not isNull ScudOperatoronActivation
hint format ["%1 is a first class wanker!", name ScudOperator]onDeactivation
ScudOperator = objNullFinally in your init.sqs
ScudOperator = objNull
-
nutter ;), thx for the brilliant reply once more. :yes: only thing is, i'm a little confused by the first part of the explanation. ??? i'm not sure where this should go:
So an example of an action-based script goes like this:
_obj = _this select 0
_man = _this select 1
_index = _this select 2
If you want to remove the action from the object immediately after it's triggered, use this line along with the above:
_obj removeAction _index
or this:
ScudOperator = _this select 1; publicVariable "ScudOperator"
i'll explain. i have set up a system where when any west player gets in the scud, it triggers the action adding sequence, which goes like this:
i have a trigger set up set to condition:
{(side _x) == west} count crew scud1 > 0
with this is the onactivation field:
disarmmissile1action = scud1 addAction ["Disable detonation", "disarmmissile1sequencestart.sqs"];
the disarmmissile1sequencestart.sqs goes like this:
startdisarmmissile1script = TRUE
publicVariable "startdisarmmissile1script"
i have a trigger set up with the condition:
startdisarmmissile1script
and in the onactivation field reads:
[] exec "disarmmissile1.sqs"
which in turn leads to the following script:
scud1 removeAction disarmmissile1action
scud1 say "disarm"
~6
scud1disarmed = true
hint "Missile detonation system disarmed."
scud1notdisarmed = false
exit
in addition to this, i also have another set of triggers and scripts which go one step further and 'reprogram the missile co-ordinates'. (pretty much exactly the same as the previous set of stuff).
then i have the following triggers set up should someone launch the scud without doing BOTH procedures:
trigger 1 conditions:
scud1launched && scud1notdisarmed
on activation:
[] exec "livemissilelaunch.sqs"
that script goes like this:
scud1 removeAction disarmmissile1action
scud1 removeAction reprogrammissile1action
scud2 removeAction disarmmissile2action
scud2 removeAction reprogrammissile2action
~1
hint "Some muppet launched a live missile."
end4 = true
exit
trigger 2 conditions are:
scud1disarmed && scud1launched && scud1notreprogramed
and this activates:
[] exec "missileheadedforwrongtarget.sqs";
and that script runs like this:
scud1 removeAction disarmmissile1action
scud1 removeAction reprogrammissile1action
scud2 removeAction disarmmissile2action
scud2 removeAction reprogrammissile2action
~1
hint "Some muppet launched a nuclear missile at a major target in the USA."
end4 = true
exit
both lead to a condition which ends the mission. to make things even more complicated, i have a second missile with the same set of triggers and conditions, so the whole thing exists twice.
i understand the trigger and init tasks, but i'm not sure where to put the action script stuff. any help, much appreciated. cheers buster.
-
You are very very close! You should read the tutorial on addAction with explains that a _this gets passed automatically to the called script, and that the _this is an array holding the object with the action, the player who did the action, and the action id.
disarmmissile1sequencestart.sqs
scud1op = _this select 1
publicVariable "scud1op"
startdisarmmissile1script = TRUE
publicVariable "startdisarmmissile1script"disarmmissile1.sqs
scud1 removeAction disarmmissile1action
scud1 say "disarm"
~6
scud1disarmed = true
hint format ["Missile detonation system disarmed by: %1",name scud1op]
scud1notdisarmed = false
exit
How do you detect that the scud is fired?
-
ok brilliant. cheers, will read the tut. :good: and will change the disarmmissile1sequencestart.sqs and disarmmissile1.sqs accordingly and also apply this to the reprograming scripts.
i also need the livemissilelaunch.sqs and the missileheadedforwrongtarget.sqs to work in such a way that 'some muppet' is named (and shamed) also. presumably i don't need the addaction complexities for these scripts as they aren't addaction based. they are, however, dependant on the scud being launched without both of the previous conditions being satisfied. this is the livemissilelaunch.sqs script as it stands:
scud1 removeAction disarmmissile1action
scud1 removeAction reprogrammissile1action
scud2 removeAction disarmmissile2action
scud2 removeAction reprogrammissile2action
~1
hint "Some muppet launched a live missile."
end4 = true
exit
i'm detecting that the scud has been fired using a trigger with the condition:
scudState scud1 > 3
which sets the condition scud1launched = true
this, in turn fires a trigger with the conditions:
scud1launched && scud1notdisarme
and this trigger activates the livemissilelaunch.sqs
is there a simpler way of naming the person who launched the scud incorrectly? does the fact that the scud already has the launch action built in, rather than me adding this action manually, change things?
thanks m8. perhaps the tut will explain, but i thought i'd post this now, in case it doesn't.
-
You're pretty much screwed trying to get the name of the person who launched the scud. All you can do is state the entire crew in the scud when it was launched. You'll have to use separate triggers/scripts for each scud.
So in your script I think the best you can do is this.
_crew = crew scud1
_names = ""
if (count _crew > 0) then { {_names = _names + (name _x) + " "} forEach _crew; _names = " by one of the following muppets:" + _names + "!"} else {_names = " by one of you stupid muppets!"}
scud1 removeAction disarmmissile1action
scud1 removeAction reprogrammissile1action
scud2 removeAction disarmmissile2action
scud2 removeAction reprogrammissile2action
~1
hint ("Live missile launched" + _names)
end4 = true
exit
You could add a snippet to the scud that only lets a player get in the scud's driver seat...
Add to scud init
this addEventHandler ["GetIn", {if ((_this select 1 != "Driver")) then {[_this select 0, _this select 2] exec "smallpausetheneject.sqs"}}]smallpausetheneject.sqs
_car = _this select 0
_man = _this select 1
hint "Only the driver's seat muppet!"
~1.5
_man action ["Eject", _car]
If you add this then you can change the first script to:
_muppet = ""
if (count _crew > 0) then { _muppet = " by " + (name driver scud) + "!"} else {_muppet = " by an unknown muppet!"}
scud1 removeAction disarmmissile1action
scud1 removeAction reprogrammissile1action
scud2 removeAction disarmmissile2action
scud2 removeAction reprogrammissile2action
~1
hint ("Live missile launched" + _muppet)
end4 = true
exit
-
thx m8. adding the snippet to the scud's init works a treat. the script as it stood didn't work, but i just added:
_crew = crew scud1and changed this line:
if (count _crew > 0) then { _muppet = " by " + (name driver scud) + "!"} else {_muppet = " by an unknown muppet!"}to:
if (count _crew > 0) then { _muppet = " by " + (name driver scud1) + "!"} else {_muppet = " by an unknown muppet!"}and it works perfectly. thanks fella. sorted. :good:
-
Glad you caught my drunken bugs and got it working.