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(playerid, killerid, reason)
{
PlayerInfo[killerid][pUbistva]++;
PlayerInfo[playerid][pSmrti]++;
Died[playerid] = 1;
SetSpawnInfo(playerid, team, skin, 1714.8339, -1912.6870, 13.5666, rotation, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
return 1;
}
public OnPlayerSpawn(playerid)
{
if (Died[playerid] == 1)
{
SetPlayerPos(playerid, 1714.8339, -1912.6870, 13.5666);
return 1;
}
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetSpawnInfo(playerid, team, skin, 1714.8339, -1912.6870, 13.5666, rotation, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
return 1;
}