Home   Help Search Login Register  

Author Topic: identifying a player's name who is responsible for an action...  (Read 2476 times)

0 Members and 1 Guest are viewing this topic.

Offline filth

  • Members
  • *
  • Who's the bad man?
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.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
dirty boy!
The script that you call from an addAction passes some values via the _this variable. From our own OFPEC ComRef:
Quote
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.
Code: [Select]
ScudOperator = _this select 1; publicVariable "ScudOperator"Add a trigger to your mission with Condition
Code: [Select]
not isNull ScudOperatoronActivation
Code: [Select]
hint format ["%1 is a first class wanker!", name ScudOperator]onDeactivation
Code: [Select]
ScudOperator = objNullFinally in your init.sqs
Code: [Select]
ScudOperator = objNull
« Last Edit: 17 Sep 2008, 13:45:50 by Mr.Peanut »
urp!

Offline filth

  • Members
  • *
  • Who's the bad man?
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:
Quote
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:
Quote
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:
Quote
{(side _x) == west} count crew scud1 > 0

with this is the onactivation field:
Quote
disarmmissile1action = scud1 addAction ["Disable detonation", "disarmmissile1sequencestart.sqs"];

the disarmmissile1sequencestart.sqs goes like this:
Quote
startdisarmmissile1script = TRUE
publicVariable "startdisarmmissile1script"

i have a trigger set up with the condition:
Quote
startdisarmmissile1script
and in the onactivation field reads:
Quote
[] exec "disarmmissile1.sqs"

which in turn leads to the following script:
Quote
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:
Quote
scud1launched && scud1notdisarmed
on activation:
Quote
[] exec "livemissilelaunch.sqs"

that script goes like this:
Quote
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:
Quote
scud1disarmed && scud1launched && scud1notreprogramed
and this activates:
Quote
[] exec "missileheadedforwrongtarget.sqs";

and that script runs like this:
Quote
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.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
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
Code: [Select]
scud1op = _this select 1
publicVariable "scud1op"
startdisarmmissile1script = TRUE
publicVariable "startdisarmmissile1script"
disarmmissile1.sqs
Code: [Select]
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?
« Last Edit: 18 Sep 2008, 02:04:50 by Mr.Peanut »
urp!

Offline filth

  • Members
  • *
  • Who's the bad man?
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:

Quote
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:
Quote
scudState scud1 > 3
which sets the condition scud1launched = true

this, in turn fires a trigger with the conditions:
Quote
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.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
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.
Code: [Select]
_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
Code: [Select]
this addEventHandler ["GetIn", {if ((_this select 1 != "Driver")) then {[_this select 0, _this select 2] exec "smallpausetheneject.sqs"}}]smallpausetheneject.sqs
Code: [Select]
_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:
Code: [Select]
_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
« Last Edit: 19 Sep 2008, 00:26:12 by Mr.Peanut »
urp!

Offline filth

  • Members
  • *
  • Who's the bad man?
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:
Code: [Select]
_crew = crew scud1and changed this line:
Code: [Select]
if (count _crew > 0) then { _muppet = " by " + (name driver scud) + "!"} else {_muppet = " by an unknown muppet!"}to:
Code: [Select]
if (count _crew > 0) then { _muppet = " by " + (name driver scud1) + "!"} else {_muppet = " by an unknown muppet!"}and it works perfectly. thanks fella. sorted.  :good:

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Glad you caught my drunken bugs and got it working.
urp!