OnPlayerDeath problem
#1

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

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

i think you need this:

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

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)