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



OnPlayerDeath problem - exclide1 - 02.07.2013

Hello. I have a simple event system script that on join saves players team to a variable, and sets it back when event is over, they leave or die.

Код:
new teamcrap[MAX_PLAYERS];

CMD:enter(playerid, params[])
{
teamcrap[playerid] = GetPlayerTeam(playerid);
return 1;
}
It works fine when they leave with a cmd or when I end the event and sets their team correctly. But it's somehow bugged on the player death. I have this command to check what team I'm in:

Код:
CMD:showteam(playerid,params[])
{
new shitt[50];
new asd = GetPlayerTeam(playerid);
format(shitt, sizeof(shitt), "team is %i", asd);
SendClientMessage(playerid, -1, shitt);
return 1;
}
And after I /kill myself in the event it actually sets me to the correct team, but after I spawn it's set to 255 (NO_TEAM). When I /kill myself again, it sets me to correct team. And this is the OnPlayerDeath code:

Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != INVALID_PLAYER_ID)
    {
	SendClientMessage(playerid, -1, "you die");
    }
    SetPlayerTeam(playerid, teamcrap[playerid]);
    return 1;
}
I'd be really glad if someone could help me with this, been trying to fix this for a few hours now...


Re: OnPlayerDeath problem - Cjgogo - 02.07.2013

Copy and delete this:
pawn Код:
SetPlayerTeam(playerid, teamcrap[playerid]);
And paste it into OnPlayerSpawn.


Re: OnPlayerDeath problem - Anak - 02.07.2013

i think you need this:

pawn Код:
public OnPlayerSpawn(playerid)
{
    SetPlayerTeam(playerid, teamcrap[playerid]);
    // else code for OnPlayerSpawn.
    return 1;
}



Re: OnPlayerDeath problem - exclide1 - 02.07.2013

Quote:
Originally Posted by Cjgogo
Посмотреть сообщение
Copy and delete this:
pawn Код:
SetPlayerTeam(playerid, teamcrap[playerid]);
And paste it into OnPlayerSpawn.
Thanks, I guess this will do as a solution, lol.