Help with respawn system
#1

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;
}
Reply
#2

Show onplayerdeath
Reply
#3

Try SetPlayerHealth(playerid, 50.0);
Reply
#4

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

bump
Reply
#6

Код:
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)
Reply
#7

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)