Player Data Resets upon death
#1

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

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

Thank you!
I can't give you reputation for some reason.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)