When player died problem.
#1

Whenever a player dies, it's like randomly happens the player gets stuck and he won't respawn, only if someone else will shot him once again.

Here's my OnPlayerDeath function:
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid != playerid)
    {
        new str[128];
        WepLevel[ killerid ] ++;
        Kills[ killerid ] ++;
        Kills[ playerid ] = 0;
        SetPlayerHealth( killerid, 100.0 );
        if(Kills[ killerid ] == 5 || Kills[ killerid ] == 10 || Kills[ killerid ] == 15)
        {
            SendClientMessage( killerid, COLOR_LIGHTGREEN, "You've gained some extra health and armour!");
            SetPlayerHealth( killerid, 100.0 );
            SetPlayerArmour( killerid, 100.0 );
        }
        TextDrawShowForPlayer(playerid, KillDieDraw[playerid]);
        TextDrawShowForPlayer(killerid, KillDieDraw[killerid]);
        format(str, sizeof(str), "~p~You have been killed by ~y~%s", GetNameEx(killerid));
        TextDrawSetString(KillDieDraw[playerid], str);
        format(str, sizeof(str), "~p~You have just killed ~y~%s", GetNameEx(playerid));
        TextDrawSetString(KillDieDraw[killerid], str);
        SetPVarInt(playerid, "KillDieDraw", 5);
        SetPVarInt(killerid, "KillDieDraw", 5);
        if( GetPlayerWeapon( killerid ) == 4 )
        {
            if( WepLevel[ playerid ] != 1)
            {
                SendClientMessage( playerid, COLOR_LIGHTBLUE, "*** You have leveled down! you've died by a knife ***" );
                WepLevel[ playerid ] --;
            }
        }
        GiveWeaponByLevel( killerid );
    }
    SetPVarInt(playerid, "HasDied", 1);
    return 1;
}
Reply
#2

do you use OnPlayerStateChange with PLAYER_STATE_WASTED?
Reply
#3

No, I do not.
Reply
#4

Weird. Try adding SetPlayerHealth(playerid, 0.0); on top just to make sure that the player dies.
Reply
#5

Ive tried. doesn't work..
Reply
#6

What's suppose to happen when a player dies?
Reply
#7

Nothing special, he must respawn.
Reply
#8

Have you tried using SetSpawnInfo then SpawnPlayer at the last part?
Reply
#9

Ill try when I get home, Hope its gonna work.
Reply
#10

It should. Actually, just use SetSpawnInfo since OnPlayerSpawn is being called by OnPlayerDeath.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)