Jump to content
Sign in to follow this  
Dashers

Multiplayer respawning.

Recommended Posts

I am trying to create a single script to handle all my respawning for all controllable players on a multiplayer mission. From what I can tell addEventHandler["killed",blah] is the best way of doing this.

I need the script to intercept the respawn and change weapons and reposition various different controllable units.

I can get a script to execute happily, but it's bent on telling me who the killer was, and not who just died. I'm not planning on creating a different script for each and every player.

The second problem is, I can't seem to get the script to work more than once. Once the player is dead the event is discarded.

Could anybody help me in something like this?

Cheers,

Dash.

Share this post


Link to post
Share on other sites

If you are to controll humans only add one trigger

x: 0

y: 0

activated by: none

type: none

condition: !(alive player)

onActivation:

onDeactivation*: [player] exec "yourcontrollscript.sqs"

yourcontrollscript.sqs

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_soldier = _this select 0

removeAllWeapons _soldier

_soldier addMagazine "yourWeapon"

_soldier addWeapon "yourWeapon"

and so on...

exit

worth trying?

*or what it is called

Share this post


Link to post
Share on other sites

Aye, this what I used to do originally, the down side to this is you have to create one for every single unit it. I was hoping the event handlers would be able to allow me to create one simple thing.

Share this post


Link to post
Share on other sites
Aye, this what I used to do originally, the down side to this is you have to create one for every single unit it.  I was hoping the event handlers would be able to allow me to create one simple thing.

Well, it depends if you are using different classes and sides.

sides can be catched, classes not (as far as I know)

if you are using sides, add

[player,side player] exec "script.sqs"

Can you please tell us exactly what you are trying todo?

(player/classes/sides) etc

Share this post


Link to post
Share on other sites
I can get a script to execute happily, but it's bent on telling me who the killer was, and not who just died.  I'm not planning on creating a different script for each and every player.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">unit adeventhandler ["killed",{_this exec "test.sqs"}]

test.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_deadman=_this select 0

_killer=_this select 1

Well, it depends if you are using different classes and sides.

sides can be catched, classes not (as far as I know)

You can check unit class via typeOf command.

Share this post


Link to post
Share on other sites
You can check unit class via typeOf command.

Cool, I'm influenced by version 1.46 that's all

Share this post


Link to post
Share on other sites

this works for any side and gives the player the weapons and ammo he (nearly) had before he died. only one trigger is needed, this works again and again:

in init.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">...

DeadBody=ObjNull

...

trigger:

x: 0

y: 0

activated by: none

type: none

repeating

condition: !alive player

onActivation: ["Killed",player] exec "RespawnManagement.sqs"

onDeactivation: ["Respawn",player] exec "RespawnManagement.sqs"

RespawnManagement.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_mode=_this select 0

goto _mode

exit

;***********************************************

#Killed

_player=_this select 1

DeadBody=_player

exit

;***********************************************

#Respawn

_player=_this select 1

DeadBody setpos [0,0,0]

removeallweapons _player

_player addmagazine _x" foreach magazines DeadBody

_player addweapon _x" foreach weapons DeadBody

_player selectweapon primaryweapon _player

deletevehicle DeadBody

exit

Share this post


Link to post
Share on other sites
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">unit adeventhandler ["killed",{_this exec "test.sqs"}]

test.sqs:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_deadman=_this select 0

_killer=_this select 1

It is all one side, but multiple infantry classes.

The script works fine the first time currently, but I cannot get it work a second time.

I have tried adding this to the end, and changing the _this to _deadman (being a reserved variable), but it refuses to work a second time.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_deadman addEventHandler["killed","_this exec {respawn.sqs}"]

Currently my test respawn.sqs script is:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_deadman = _this select 0

_killer = _this select 1

hint format["%1 killed %2", name _killer, name _deadman]

~5

_deadman addEventHandler["killed","_deadman exec {respawn.sqs}"]

The wait was to wait for the respawn before adding a new event, but no difference.

Share this post


Link to post
Share on other sites

Ok, yes, after much pondering the only thing I can't get working is the adding another event handler after a respawn.

I will only ever work once, and I can't figure out a way of adding it again (in a script). I am trying to put off making 24 odd triggers for each unit that might respawn.

Share this post


Link to post
Share on other sites

this one of you will work nearly:

Quote[/b] ]<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_deadman = _this select 0

_killer = _this select 1

hint format["%1 killed %2", name _killer, name _deadman]

~5

_deadman addEventHandler["killed","_deadman exec {respawn.sqs}"]

change the last line to:

player addEventHandler["killed","player exec {respawn.sqs}"]

Share this post


Link to post
Share on other sites

This then won't pass the correct variables back into the script would it?

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_deadguy = _this select 0

_killer = _this select 1

~2

removeallweapons _deadguy

player addEventHandler["killed","player exec {respawn.sqs}"]

_deadguy and _killer won't work the next time round surely?

Share this post


Link to post
Share on other sites

the eventhandler should be used with this parameters:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">unit addEventHandler["killed","_this exec {script.sqs}"]

_deadguy and _killer are set at the moment the player dies.

after respawning, a new object (soldier) is created and the player controls the new soldier. you can get the new player controlled soldier with the handle "player".

you must make the pause long enough to get the player when he controlls his new created soldier.

or maybe you try this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_deadguy = _this select 0

_killer = _this select 1

@alive player

removeallweapons _deadguy

player addEventHandler["killed","_this exec {respawn.sqs}"]

the dead body remains there as _deadguy and so you can remove the weapons or also the body.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×