SA-MP Forums Archive
Help with respawn system - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help with respawn system (/showthread.php?tid=660100)



Help with respawn system - slxsh - 25.10.2018

I am trying to make a paintball system. So, I made a function to give weapons, teleport and change the virtual world and put it under 'OnPlayerSpawn'. However, whenever the player dies and respawns it instantly dies again then respawns then dies again and again. Not sure what's the problem. but here's the code.
Код:
public OnPlayerSpawn(playerid)
{   if(pInfo[playerid][pbstatus]==true){
	pbrespawn(playerid);
	}
	return 1;
}
Here is the 'pbrespawn' function-
Код:
public pbrespawn(playerid)
{
    new rand;
	rand=random(4);
    switch(rand)
    {
    	case 0: SetPlayerPos(playerid,-1679.0305,1376.4728,12.3906);
		case 1:	SetPlayerPos(playerid,-1641.2963,1401.5313,7.1875);
		case 2:	SetPlayerPos(playerid,-1648.1776,1369.9368,7.1797);
		case 3: SetPlayerPos(playerid,-1692.3961,1353.3668,9.8047);
	}
    GivePlayerWeapon(playerid,pbarena[PB_ACTIVE][wep1],999);
	GivePlayerWeapon(playerid,pbarena[PB_ACTIVE][wep2],999);
	SetPlayerHealth(playerid,pbarena[PB_ACTIVE][pbhp]);
	SetPlayerArmour(playerid,pbarena[PB_ACTIVE][pbarmor]);
	SetPlayerVirtualWorld(playerid,1);
	return 1;
}



Re: Help with respawn system - GameOvr - 25.10.2018

Show onplayerdeath


Re: Help with respawn system - DIRTYBYT3 - 25.10.2018

Try SetPlayerHealth(playerid, 50.0);


Re: Help with respawn system - slxsh - 26.10.2018

Quote:
Originally Posted by ******
Посмотреть сообщение
Is pbarena[PB_ACTIVE][pbhp] correct, not 0?
It's not 0.


Re: Help with respawn system - slxsh - 28.10.2018

bump


Re: Help with respawn system - Infin1ty - 28.10.2018

Код:
pInfo[playerid][pbstatus]==true
what does this dictate?

also here's a better solution for your spawning.

Код:
        // top of your script
	enum e_spawns
	{
		Float:x,
		Float:y,
		Float:z
	} 

	new Float:pbspawns[][e_spawns] = {
		{-1679.0305,1376.4728,12.3906},
		{-1641.2963,1401.5313,7.1875},
		{-1648.1776,1369.9368,7.1797},
		{-1692.3961,1353.3668,9.8047}
	};

        // replacing your existing code
	SetPlayerPos(playerid, pbspawns[playerid][x], pbspawns[playerid][y], pbspawns[playerid][z]);
(untested but should work in theory)


Re: Help with respawn system - slxsh - 28.10.2018

Quote:
Originally Posted by Infin1ty
Посмотреть сообщение
Код:
pInfo[playerid][pbstatus]==true
what does this dictate?

also here's a better solution for your spawning.

Код:
        // top of your script
	enum e_spawns
	{
		Float:x,
		Float:y,
		Float:z
	} 

	new Float:pbspawns[][e_spawns] = {
		{-1679.0305,1376.4728,12.3906},
		{-1641.2963,1401.5313,7.1875},
		{-1648.1776,1369.9368,7.1797},
		{-1692.3961,1353.3668,9.8047}
	};

        // replacing your existing code
	SetPlayerPos(playerid, pbspawns[playerid][x], pbspawns[playerid][y], pbspawns[playerid][z]);
(untested but should work in theory)
Код:
pInfo[playerid][pbstatus]==true
It's to check whether a player is inside a paintball arena.