Jump to content

Recommended Posts

Hi, how to use these two code together ?

 

i made 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
};

i call this file from init.sqf : execVM "respawnOnLeader.sqf";

 

Then i made groups for exemple Vip group with the leader being AI soldier in Vip base, so only vip players in the same group can respawn in Vip base, that works, also i have a respawn module in normal base so Vip's can choose which base to respawn.

 

But one thing that is not working is for other groups, when they are killed, they respawn where they died. That's not what i want. Other players, non-vip players have to respawn on squad leader (which is human player not AI), that's what normally this code does, but its not working.

 

So i have the other piece of code i found but don't know how to put it together with the other code here above, maybe someone can help me with this ?

// Call from init.sqf with:
// [] execVM "data\scripts\respawnOnLeader.sqf";

if (not isDedicated) then {
    [] spawn {
        waitUntil { alive player };
        player addEventHandler ["KILLED", {
            [] spawn
            {
                private ["_leader", "_spawnPos"];
                waitUntil { alive player };
                _leader = leader player;
                if ((alive _leader) and (player != _leader)) then {
                    // Move the player just behind the leader, but ensure they arrive on the ground.
                    _spawnPos = (vehicle _leader) modelToWorld [0, -2, 0];
                    _spawnPos set [2, 0]; // Ensure respawn on the ground.
                    player setPos _spawnPos;
                };
            };
        }];
    };
};

This code doesn't work at all, but i need the player to respawn behind Team leader and not respawn where he died.

Btw why in this code here above it begins with "if (not isDedicated) then {" ?

 

how can i merge these two codes to work together ?

so that a player in squad gets killed he will respawn 2 meters behind squad leader, and if Squad Leader is dead then player choose another respwan. ( i use base respawn + menuposition)

That is what this code should do but it has no effects.

 

Exemple:

//working code !

if(isDedicated) exitWith {};
_side = side player;
waituntil {
"respawn_guerrila" setMarkerPosLocal (getPos leader player);
"respawn_west" setMarkerPosLocal (getPos leader player);
sleep 0.5;
0 > 1
};

//not working code but needed !

// Call from init.sqf with:
// [] execVM "data\scripts\respawnOnLeader.sqf";

if (not isDedicated) then {
    [] spawn {
        waitUntil { alive player };
        player addEventHandler ["KILLED", {
            [] spawn
            {
                private ["_leader", "_spawnPos"];
                waitUntil { alive player };
                _leader = leader player;
                if ((alive _leader) and (player != _leader)) then {
                    // Move the player just behind the leader, but ensure they arrive on the ground.
                    _spawnPos = (vehicle _leader) modelToWorld [0, -2, 0];
                    _spawnPos set [2, 0]; // Ensure respawn on the ground.
                    player setPos _spawnPos;
                };
            };
        }];
    };
};

Ho to merge these script code together ?

 

Is this not working because i use squad leader in place of Team leader unit in my mission ?

Share this post


Link to post
Share on other sites

Ok so until someone gives me some help, response,

 

i tried this code:

if(isDedicated) exitWith {};
_side = side player;
waitUntil { alive player };
        player addEventHandler ["KILLED", {
            [] spawn
            {
                private ["_leader", "_spawnPos"];
                waitUntil { alive player };
                _leader = leader player;
                if ((alive _leader) and (player != _leader)) then {
                    // Move the player just behind the leader, but ensure they arrive on the ground.
                    _spawnPos = (vehicle _leader) modelToWorld [0, -2, 0];
                    _spawnPos set [2, 0]; // Ensure respawn on the ground.
                    player setPos _spawnPos;
                };
              while { true } do {
                "respawn_guerrila" setMarkerPosLocal (getPos leader player);
                "respawn_west" setMarkerPosLocal (getPos leader player);
                sleep 0.5;
                0 > 1
			    };	
            };
        }];

apperently it works, but only once ! and it doesn't take in account distance settings

 

if player is dead the respawn marker moves to base, if player dies again it don't work any more !

it seems its working only on first respawn then its broken, everybody can respawn on their dead bodies even team leader, that is not what we want.

 

could someone take a look at this ?

 

what the code should do:

the player has to respawn only on alive team leader or his squad when killed, with a correct name respawn (player name) and 2 meters behind him, if team leader is dead the player respawn at base.

 

what the code should not do:

the player can respawn where he died, even if he is not team leader, the team leader can respawn where he died.

Share this post


Link to post
Share on other sites

This should be what you're looking for (create a file and name it initPlayerLocal.sqf and copy and paste this code into it):

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"
	};
}];

Be sure you set your mission's respawn type to "Base". You can do that in description.ext by typing:

respawn = 3

//OR

respawn = "BASE"

For help setting up the respawn properly you can see the wiki page for description.ext here, and click here to go directly to the respawn entry (you will have to scroll up a little to see everything).

  • Like 1

Share this post


Link to post
Share on other sites

This should be what you're looking for (create a file and name it initPlayerLocal.sqf and copy and paste this code into it):

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"
	};
}];

Be sure you set your mission's respawn type to "Base". You can do that in description.ext by typing:

respawn = 3

//OR

respawn = "BASE"

For help setting up the respawn properly you can see the wiki page for description.ext here, and click here to go directly to the respawn entry (you will have to scroll up a little to see everything).

 

Ok thanks for the help i appreciate that, i'm gonna try your code !

 

Do i need my code aswell ? with yours ?

Share this post


Link to post
Share on other sites

This should be what you're looking for (create a file and name it initPlayerLocal.sqf and copy and paste this code into it):

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"
	};
}];

Be sure you set your mission's respawn type to "Base". You can do that in description.ext by typing:

respawn = 3

//OR

respawn = "BASE"

For help setting up the respawn properly you can see the wiki page for description.ext here, and click here to go directly to the respawn entry (you will have to scroll up a little to see everything).

 

 

this is my initplayerlocal.sqf : where do i put your code here ?

//------------------- client executions
_null = [] execVM "scripts\diary.sqf";
_null = [] execVM "scripts\restrictions.sqf";

if( !hasInterface ) exitWith {}; 
waitUntil { !isNull player }; 
waitUntil { local player };
player setVariable["hideticker",true];

fnc_reservedSlot = {
	player enableSimulationGlobal false;
	( "reserved" call BIS_fnc_rscLayer ) cutText [ "This is a reserved slot. Reserved slots are clearly marked in the lobby as ( **Vip Slot** ) . Please rejoin using a different slot.", "BLACK OUT", 1, true ];
	sleep 10;
	endMission "NOT_ALLOWED";
};

Share this post


Link to post
Share on other sites

Ok this worked, with my code and yours, player in a squad is able to respawn on leader, but if there is no leader, the player can respawn on his body !

that's not what we need.

 

so with my logic, i knew it was because of dead body waiting on the ground to dissapear, cause in arma 3 corpse removal counter only fires when player has respawned, that's why its broken and player can respawn on dead bodies if team leader is dead.

 

so what to add in the code above or elsewhere, to prevent players from respawning on dead bodies ? OR

 

How to remove body immediatly when a player is killed, so that dead bodies can not be used for respawn ?

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

×