Players Alive counter doesn't go down OnPlayerDisconnect
#4

Check this!

pawn Код:
/*
    ~Changelog~

    - You had everything done inside the loop which caused some problems. Now everything related to 'playerid' (who disconnects) is done outside the loop.
    - After moving code outside the for loop, I realized that the loop was only used for those TextDrawShowForPlayer which I don't think you need at all.
        So I completely deleted the loop code because it wasn't needed at all. You're just wasting RPCs. Just show the textdraws once they enter DM mode.
    - Fixed string size and used some trick instead of that if/elseif statement.
    - Removed SetPlayerHealth because it wasn't needed at all.

*/


public OnPlayerDisconnect(playerid, reason)
{
    if(pInfo[playerid][DM]) // If this player is in DM mode
    {
        new alive[4]; // Size needs to be 4 not 3. You probably forgot to count the null terminator: '\0'
        AlivePlayers -=1; // Decrease the alive players count
        /*
        the '%02d' trick will do what you wanted to do with those if/elseif statements
        i.e. 01, 02, 03, ... 10, 11 ...
        */

        format(alive, sizeof(alive), "%02d", AlivePlayers);
        TextDrawSetString(numberal, alive); // This will update the textdraw for whoever it was shown to, therefore you don't need to keep showing it over and over.
    }
    return 1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)