[TUTORIAL] Correct MAX_PLAYERS: gMaxPlayers. Reduced timeouts.
#1

g-Max Players
Version: 0.2-Fixed
Description: Replace MAX_PLAYERS (200) to gMaxPlayers(Current online Players)

pawn Код:
#include <a_samp>

new gMaxPlayers;

public OnFilterScriptInit(){
  gMaxPlayers=0;
}

public OnPlayerConnect(playerid)
{
  if(gMaxPlayers < playerid) gMaxPlayers = playerid;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
  if(gMaxPlayers == playerid){
        for(new i = playerid-1; i >= 0; i--) {
            if(IsPlayerConnected(i)) {
                gMaxPlayers = i;
            break;
            }
        }
    }
    return 1;
}
Example:
pawn Код:
public Example();

public Example() {
    for(new i = 0; i < gMaxPlayers; i++){
      return 1;
    }
    return 1;
}
[img][/img]
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)