doomnet 23 Posted August 28, 2015 HI, I have put together with the help of many here and internet a team leader mobile respawn script. but there is still a problem when team leader is dead and other player of his group also, the player can respawn on his own dead body, also team leader can respawn on his dead body. so what to add in the code below or elsewhere, to prevent players from respawning on their own dead bodies ? respawnOnLeader.sqf if(isDedicated) exitWith {}; _side = side player; waituntil { "respawn_guerrila" setMarkerPosLocal (getPos leader player); "respawn_west" setMarkerPosLocal (getPos leader player); sleep 0.5; 0 > 1 }; initPlayerLocal.sqf player addEventHandler ["Respawn", //I believe this would be a better event handler for this situation { if (leader player != player) && {alive (leader player)}) then //make sure player is not the group leader and that the group leader is alive { _groupLead = leader player; player setPos ([_groupLead, 2, -(direction _groupLead)] call BIS_fnc_relPos); //not sure if this will work as I expect it to, if it doesn't, delete this line and remove the forward-slashes from the line below // player setPos ([_groupLead, 2, (direction _groupLead) * -1] call BIS_fnc_relPos); } else { systemChat "Group leader was not alive, you have respawned at base."; //If either condition is met, respawn the player at base //this will show the same message even if the player is the group leader, it will still work but look a little unrefined. "Of course the group leader was not alive, I WAS the group leader" }; }]; Thanks for helping me out its been 3 days now i'm searching, trying, learning that's not bad but server is down because of this problem. Share this post Link to post Share on other sites
SilentSpike 84 Posted August 28, 2015 You can use onPlayerRespawn.sqf to automatically run code when the player respawns: params ["_newUnit","_oldUnit","_respawn","respawnDelay"]; if !(isNull _oldUnit) then { _leader = leader _newUnit; if (alive _leader) then { [_newUnit, _leader] call BIS_fnc_moveToRespawnPosition; }; }; See event scripts for more information 1 Share this post Link to post Share on other sites
Donald Flatulence 19 Posted August 28, 2015 Hey, I'm afraid I'm not great at scripting, but I wanted to try and help - this may be totally useless and non functional but here goes... Using the checks you have coded to establish whether or not the leader is alive (and his group), should the checks be failed (everyone is dead) then execute code such as "respawn_west" setMarkerPosLocal (getMarkerPos "BaseMarker"); Where "BaseMarker" is a marker placed on the base respawn location. Perhaps the check could be included as part of the constant respawn position update? Eg: While {true} do { If {CODE TO CHECK IF LEADER AND GROUP ARE ALIVE} then { "respawn_guerrila" setMarkerPosLocal (getPos leader player); "respawn_west" setMarkerPosLocal (getPos leader player); sleep 0.5;} else {"respawn_guerrila" setMarkerPosLocal (getMarkerPos "BaseMarker"); "respawn_west" setMarkerPosLocal (getMarkerPos "BaseMarker"); sleep 0.5;} }; Note the above will need modification and possibly fixing, but if the idea would work for you... Hope I haven't wasted your time, Ed 1 Share this post Link to post Share on other sites
dreadedentity 278 Posted August 29, 2015 Hey, I couldn't get back to you very soon. I left to go to work pretty soon after I posted that code for you, then I went out for a night on the town afterwards. Anyway, I have no idea what is causing this behavior. Could you post a dropbox link for the mission? 1 Share this post Link to post Share on other sites
doomnet 23 Posted August 29, 2015 Hello, yesterday i tried a lot of different settings, with the above codes given by the members, but i couldn't make it working. the only think that works is the player can respawn on the team leader, that works ! but if there is no team leader, player can respawn on his own dead body, The team leader also can respawn on his own dead body when killed ! I really don't understand it, so i thought, its because of dead bodies removal that starts only after respawn, so i decided to try a script to remove bodies instantly, but the result is the same, player can respawn where he died. Share this post Link to post Share on other sites
doomnet 23 Posted August 29, 2015 You can use onPlayerRespawn.sqf to automatically run code when the player respawns: params ["_newUnit","_oldUnit","_respawn","respawnDelay"]; if !(isNull _oldUnit) then { _leader = leader _newUnit; if (alive _leader) then { [_newUnit, _leader] call BIS_fnc_moveToRespawnPosition; }; }; See event scripts for more information thanks for this, but i couldn't make it working ! Also onPlayerRespawn.sqf doesn't fire if in description.ext respawnOnstart is set to -1. so to test it i changed to 1 or even 0 and adapted your code with the variables i already have in the code above ? anyways i tried both ! In your code you use _leader = leader _new unit; so i changed it to _groupLead = leader player _newUnit; ? anyways when i tried your code it breaks my team leader respawn, both codes won't work. BTW , can i use your code checking if the player is alive like new or old unit in another file or place, because i have to use onplayerRespawn set to-1 Anyways, i tried a lot of different settings, the problem still there, everybody is able to respwawn on his dead body when killed. Share this post Link to post Share on other sites
doomnet 23 Posted August 29, 2015 Hey, I couldn't get back to you very soon. I left to go to work pretty soon after I posted that code for you, then I went out for a night on the town afterwards. Anyway, I have no idea what is causing this behavior. Could you post a dropbox link for the mission? no problem m8, i can send you my mission, if you find out and fix this, i give you Vip slot !!! XD tell me when you are online i will send in private ! thanks Share this post Link to post Share on other sites
doomnet 23 Posted August 29, 2015 Hey, I'm afraid I'm not great at scripting, but I wanted to try and help - this may be totally useless and non functional but here goes... Using the checks you have coded to establish whether or not the leader is alive (and his group), should the checks be failed (everyone is dead) then execute code such as "respawn_west" setMarkerPosLocal (getMarkerPos "BaseMarker"); Where "BaseMarker" is a marker placed on the base respawn location. Perhaps the check could be included as part of the constant respawn position update? Eg: While {true} do { If {CODE TO CHECK IF LEADER AND GROUP ARE ALIVE} then { "respawn_guerrila" setMarkerPosLocal (getPos leader player); "respawn_west" setMarkerPosLocal (getPos leader player); sleep 0.5;} else {"respawn_guerrila" setMarkerPosLocal (getMarkerPos "BaseMarker"); "respawn_west" setMarkerPosLocal (getMarkerPos "BaseMarker"); sleep 0.5;} }; Note the above will need modification and possibly fixing, but if the idea would work for you... Hope I haven't wasted your time, Ed thanks m8 your code seems very logic yes and should work if i have the right check in it with If. Respawn works with the code i have, but if no team leader is connected or is dead players can respawn on their own bodies. that's the problem i try to fix ! Share this post Link to post Share on other sites
dreadedentity 278 Posted August 29, 2015 no problem m8, i can send you my mission, if you find out and fix this, i give you Vip slot !!! XD tell me when you are online i will send in private ! thanks Just send it anytime in a PM, I'll get it whenever I look at the forum again Share this post Link to post Share on other sites