Icaruk 14 Posted May 19, 2014 (edited) I can't test it alone, and I'm not sure if it will affect just to the player that respawned: onPlayerRespawn.sqf _unit = _this select 0; _unit allowdamage false; sleep 5; _unit allowdamage true; Edited May 19, 2014 by Icaruk Share this post Link to post Share on other sites
lappihuan 178 Posted May 19, 2014 from where is the unit passed? respawn EH or what? And yes if you use spawn to execute this as function or execVM as script so sleep works, this should protect spwaned unti for 5 sec if _unit is passed correctly to this code. Share this post Link to post Share on other sites
Icaruk 14 Posted May 19, 2014 (edited) from where is the unit passed?respawn EH or what? And yes if you use spawn to execute this as function or execVM as script so sleep works, this should protect spwaned unti for 5 sec if _unit is passed correctly to this code. When someone dies, he will execute automatically the "onPlayerRespawn.sqf". I'm trying to affect just to the guy that respawns, and not other people. Edited May 19, 2014 by Icaruk Share this post Link to post Share on other sites
SilentSpike 84 Posted May 19, 2014 (edited) I'd use this: https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Respawn edit: Keep in mind that allowDamage has local effect (according to the biki). Well, there's actually conflicting information there. It says that it has global effect at the top, but local under the "multiplayer:" section. It also says that the arguments must be local, but that wasn't the case when I used it before. Edited May 19, 2014 by SilentSpike Share this post Link to post Share on other sites
Icaruk 14 Posted May 19, 2014 So on the unit's init: this addEventHandler ["Respawn", {execVM "myProtectionScript.sqf"}]; myProtectionScript.sqf _unit = _this select 0; _unit allowdamage false; sleep 5; _unit alowdamage false; I'm still with the initial problem xD Share this post Link to post Share on other sites
Belbo 461 Posted May 19, 2014 What exactly is your problem? You're trying to protect someone after he's being respawned? Then this should work. I'd test with the sleep though, how long you'll actually need it to be. I corrected your syntax though: this addEventHandler ["Respawn", {[color="#FF0000"]_this[/color] execVM "myProtectionScript.sqf"[color="#FF0000"];[/color]}]; _unit = _this select 0; _unit allowdamage false; sleep 5; _unit al[color="#FF0000"]l[/color]owdamage [color="#FF0000"]true[/color]; Share this post Link to post Share on other sites
Tajin 348 Posted May 19, 2014 (edited) Command has to be executed where object is local and as long as object does not change locality the effect of this command will be global. anyway, you only need to add this to your init.sqf (I assume you want all players to have that kind of spawn-protection): player addEventHandler ["Respawn", { player allowdamage false; sleep 5; player allowdamage true; }]; Yes, it'll only affect the player who respawed. Edited May 19, 2014 by Tajin my bad, pasted the wrong code :P Share this post Link to post Share on other sites
Belbo 461 Posted May 19, 2014 player addEventHandler ["killed", { player allowdamage false; sleep 5; player allowdamage true; }]; EVH "Killed" would only be triggered once the unit is killed (so you would have to add the respawn time to the sleep). Share this post Link to post Share on other sites
Tajin 348 Posted May 19, 2014 I know, that was just a copy/paste mistake. ;) Share this post Link to post Share on other sites
Belbo 461 Posted May 19, 2014 I know, that was just a copy/paste mistake. ;) It could work though, I suppose, couldn't it? Share this post Link to post Share on other sites
Tajin 348 Posted May 19, 2014 Certainly, with a "sleep" or a "waitUntil{alive player}" it could. It's just a bit pointless, isn't it? ;) Share this post Link to post Share on other sites
Belbo 461 Posted May 19, 2014 Certainly, with a "sleep" or a "waitUntil{alive player}" it could.It's just a bit pointless, isn't it? ;) :icon_wink: Share this post Link to post Share on other sites
Icaruk 14 Posted May 19, 2014 anyway, you only need to add this to your init.sqf (I assume you want all players to have that kind of spawn-protection): player addEventHandler ["Respawn", { player allowdamage false; sleep 5; player allowdamage true; }]; Yes, it'll only affect the player who respawed. I wanted this, I was confused about the syntax, so I couldn't not write it. Thanks for help guys! <3 Share this post Link to post Share on other sites
Belbo 461 Posted May 19, 2014 I wanted this, I was confused about the syntax, so I couldn't not write it.Thanks for help guys! <3 If you want to be thorough though, you should put that in the initPlayerLocal.sqf, so it'll be executed for JIP-players too. Just sayin'. Share this post Link to post Share on other sites
whiztler 135 Posted May 19, 2014 I don't think you need the EH. onPlayerRespawn.sqf (first 2 params are the same as are passed into Respawn event handler) [<newUnit>,<oldUnit>,<respawn>,<respawnDelay>] Your snippet from your OP should work fine for each player that respawns (local) _unit = _this select 0; _unit allowdamage false; sleep 5; _unit allowdamage true; Share this post Link to post Share on other sites