Home   Help Search Login Register  

Author Topic: Eventhandler "killed" in adding a global action to the dead body  (Read 1843 times)

0 Members and 4 Guests are viewing this topic.

Offline The_Mark

  • Members
  • *
What I have here is an eventhandler (killed) launching a script local to the killed member of the player squad. The object of that script is to add an action to the dead body that is visible for all players, so anyone can activate the action to respawn the dead (ie. teleport the instantly-spawned-but-away-teleported-soldier to the location of the body). Surprisingly, this doesn't work straight away. The scripts that I'm using are these (derived from the old revive respawn by doolittle):

The script launched by the eventhandler
Code: [Select]
;hint format ["dead: %1",_this]
_string = _this select 0
_body= call _string
_grp=group _body



enableradio false
[(call _string)] join grpNull
enableradio true

?_body == player: [player,_string,_body] exec "cam.sqs"
?local _body && _body!=player:[ObjNull,_string,_body] exec "cam.sqs"

~1
[server,_body,_string,_grp] call {deadpeople2=deadpeople2+[[_this select 1,format [{"%1"},_this select 2],_this select 3]]}


[server,_string] call {deadpeople=deadpeople + [_this select 1]}

tmpDead=_body
tmpDeadName=_string
~random 5
publicvariable "tmpDead"
publicvariable "tmpDeadName"

exit

This script was first used to add the action, but obviously that action was utterly local to the dead man, which is somewhat redundant. The solution should've been the following script, ran locally by every player to add the action to the body locally. The script is launched in the init.sqs by a foreach command for each member of the player squad.

Code: [Select]
?_this!=player:exit ; AIs don't need this

tmpdead=ObjNull
tmpdeadname=ObjNull
#loop
~0.5
?isNull tmpDead:goto "loop"

tmpDead addaction [format ["Revive %1", name (call tmpDeadName)],"revive.sqs"]

tmpdead=ObjNull
tmpdeadname=ObjNull
publicVariable "tmpDead"
publicVariable "tmpDeadname"

goto "loop"

exit

The script works well for the server with AI loons, but the other players can see no revive action for anyone, and no non-server player receives the action to their body when killed. Any ideas on how this could work as intended?

The revive script itself works just fine.
Silent enim leges inter arma.

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
There are two methods that could be used

1) The best, which utilises coc_ns, which makes it possible to send over the network strings and arrays_body
however if you have never used it, then it could be a long hhaul for you.
However i strongly recommend getting to grips with it

2) More simple 99.9% effective
instead of running the present script from the killed event, run the following instead

Quote
tx_deadman = _this select 0; publicvariable "Tx_deadman"

and then have the following script,  lets call it Deadmonitor.sqs started from the Init.sqs running continuously in the background

DeadMonitor.sqs
Quote
~2
?!(local player): exit
tx_deadman = objnull

#START
   @ ! isnull tx_deadman
_body = tx_deadman
   [_body] exec"your old killed event handler script.sqs"
   tx_deadman = objnull
     goto "START"

what will happen

1) unit dies
2) killed event script public variables the unit object as tx_deadman, which until that point was objnull, (doesnt exist)
3) On each players machine (?!local player) which allows testing on a combined server/client, a script is running waiting for tx_deadman to exist as something
4) once this occurs, it starts the revive script system up and then tells the client that tx_deadman does not exist anymore, but wqait for it to once again exist





Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline The_Mark

  • Members
  • *
Yes, well, that's what my script currently is supposed to do, but with some additional stuff unrelated to the revive script itself (ie. the spaghetti all over the first piece of script). tmpDead is your tx_deadman and is set by the eventhandler script and broadcast by publicvariable, and the status of tmpDead is then monitored by a script running an all clients leading to the addition on the revive action. Just that this doesn't work. With the debugging I've managed to do I'm certain that the monitoring script (the second piece) runs as intended on all clients. It would seem that the variable isn't made correctly public, or something to that effect.

Unless... The server-side monitoring script is too much ahead of the clients, and broadcasts the tmpDead=ObjNull -message to the clients before they have a chance to notice the change of the variable from ObjNull to a body... gah. I have to check that thing again. Could that be possible?  :blink:
Silent enim leges inter arma.