04.03.2019, 15:56
Why the value is set to -1 ? It should be simply 0, and yes your code is correct @RJTabish, (except your indentation..) but don't forget to add every exception, such as OnPlayerDeath, then, OnPlayerDisconnect, you will have to check if he is in the game or not, add a boolean variable for that:
pawn Код:
new
CountPUBGPlayers,
bool:gInGame[MAX_PLAYERS];
CMD:enter(playerid)
{
if(gInGame[playerid]) return 1;
gInGame[playerid] = true;
CountPUBGPlayers++;
UpdateAliveTD();
return 1;
}
CMD:exit(playerid)
{
if(!gInGame[playerid]) return 1;
gInGame[playerid] = true;
CountPUBGPlayers--;
UpdateAliveTD();
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
cmd_exit(playerid);
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
cmd_exit(playerid);
return 1;
}
UpdateAliveTD()
{
new string[10];
format(string, sizeof string, "%d alive", CountPUBGPlayers);
TextDrawSetString(Textdrawpubg100, string);
return 1;
}