SA-MP Forums Archive
OnPlayerDeath spawn problem? - 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: OnPlayerDeath spawn problem? (/showthread.php?tid=576204)



OnPlayerDeath spawn problem? - baba1234 - 01.06.2015

When I die in game first time it spawns me in my cords but when I die second time it spawns me in that stupid village I tried everything and looked on every thread to fix this nothing helped. Nothing works please help I on a nerve wreck :O

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    PlayerInfo[killerid][pUbistva]++;
    PlayerInfo[playerid][pSmrti]++;
    Died[playerid] = 1;
    SetPlayerPos(playerid, 1714.8339, -1912.6870, 13.5666);
	SpawnPlayer(playerid);
	return 1;
}
public OnPlayerSpawn(playerid)
{
	if (Died[playerid] == 1) 
	{
		SetPlayerPos(playerid, 1714.8339, -1912.6870, 13.5666);
		SpawnPlayer(playerid);
		return 1;
	}
	return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
	SetPlayerPos(playerid, 1714.8339, -1912.6870, 13.5666);
	SpawnPlayer(playerid);
	return 1;
}



Re: OnPlayerDeath spawn problem? - J0sh... - 01.06.2015

Why do you spawn the player when he dies?
You don't need SpawnPlayer in the OnPlayerDeath callback.


Re: OnPlayerDeath spawn problem? - baba1234 - 01.06.2015

I did that out of frustration..


Re: OnPlayerDeath spawn problem? - baba1234 - 02.06.2015

Anyone?


Re: OnPlayerDeath spawn problem? - denNorske - 02.06.2015

1. Are you using any filterscripts that could cause this weird behaviour?
2. As mentioned above by jamester, you don't need to set position on OnPlayerDeath, because the OnPlayerSpawn will get called afterwards.
3. Did you add Died[MAX_PLAYERS] in frustration aswell? If not, remember to clear it when it has done it's job (set to 0 when spawned etc)
4. Don't call SpawnPlayer on OnPlayerDeath, read number 2 above.
5. It's smart to add messages on each callback for debugging, to see what happens. When you see a message, you will know where in the code what happens.

Try the above-mentioned stuff and se if it could solve your issues


Re: OnPlayerDeath spawn problem? - PowerPC603 - 02.06.2015

Try using SetSpawnInfo instead of SetPlayerPos.

Also, in your OnPlayerSpawn function, you force the player to re-spawn again, creating an endless loop.
Remove that.

You have to set your team, skin, and rotation to what you desire in this code (also weapons and ammo):
PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
    
PlayerInfo[killerid][pUbistva]++;
    
PlayerInfo[playerid][pSmrti]++;
    
Died[playerid] = 1;
    
SetSpawnInfo(playeridteamskin1714.8339, -1912.687013.5666rotation000000);
    
SpawnPlayer(playerid);
    return 
1;
}
public 
OnPlayerSpawn(playerid)
{
    if (
Died[playerid] == 1
    {
        
SetPlayerPos(playerid1714.8339, -1912.687013.5666);
        return 
1;
    }
    return 
1;
}
public 
OnPlayerRequestClass(playeridclassid)
{
    
SetSpawnInfo(playeridteamskin1714.8339, -1912.687013.5666rotation000000);
    
SpawnPlayer(playerid);
    return 
1;