Player Data Resets upon death - 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: Player Data Resets upon death (
/showthread.php?tid=510858)
Player Data Resets upon death -
AndySedeyn - 02.05.2014
Hello folks
I'm not sure if the title information specifies my problem but I will explain it anyways.
What happens is; if I die, I will be set in CJ skin and send to the Character Selection screen. If I then relog, I spawn dead in CJ skin and I will be send to the character selection screen instantly.
So let me give you a concrete example:
I drive around with my car and I flip. My car explodes and I die. My skin will change to the CJ skin(0) and I'm able to click the arrows to change skin. If I click spawn, it doesn't work.
What I want to do is: If a player dies, he will be spawned back to the original spawn place.
OnPlayerDeath:
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
PlayerInfo[killerid][pKills]++;
PlayerInfo[playerid][pDeaths]++;
SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], 2129.1775,35.4770,26.3709, 179, 0, 0, 0, 0, 0, 0);
SpawnPlayer(playerid);
return 1;
}
OnPlayerRequestSpawn
pawn Код:
public OnPlayerRequestSpawn(playerid)
{
return 0;
}
OnPlayerRequestSpawn
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
return 0;
}
Help is much appreciated!
Sincerely
Bible
Re: Player Data Resets upon death -
Konstantinos - 02.05.2014
When you're saying "back to the original spawn place", do you mean to those coordinates you set there? You should set the player's position in OnPlayerSpawn and not when a player dies. Also check if the killerid is valid player to prevent run time error 4: Array index out of bounds from being caused.
pawn Код:
public OnPlayerSpawn(playerid)
{
SetPlayerSkin(playerid, PlayerInfo[playerid][pSkin]);
SetPlayerPos(playerid, 2129.1775, 35.4770, 26.3709);
SetPlayerFacingAngle(playerid, 180.0);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if (killerid != INVALID_PLAYER_ID) PlayerInfo[killerid][pKills]++;
PlayerInfo[playerid][pDeaths]++;
return 1;
}
Re: Player Data Resets upon death -
AndySedeyn - 02.05.2014
Thank you!
I can't give you reputation for some reason.