OnPlayerDeath spawn problem?
#1

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

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

I did that out of frustration..
Reply
#4

Anyone?
Reply
#5

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
Reply
#6

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;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)