Created
October 11, 2015 07:31
-
-
Save Zaur-Lumanov/49ce41a2691b2d35d7ac to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if defined _fep_included | |
#endinput | |
#endif | |
#define _fep_included | |
#include <a_samp> | |
//------------------------------------------------------------------------------ | |
#define ForEachPlayer(%0) for(new index_%0=0, %0=ConnectedPlayerList[0]; index_%0<ConnectedPlayers; %0=ConnectedPlayerList[++index_%0]) | |
#define GetConnectedPlayers() ConnectedPlayers | |
//------------------------------------------------------------------------------ | |
new ConnectedPlayers; | |
new ConnectedPlayerList[MAX_PLAYERS+1];//Loop would bug when server is full D: (Without +1) | |
//------------------------------------------------------------------------------ | |
public OnPlayerConnect(playerid) | |
{ | |
if(!IsPlayerNPC(playerid)) | |
AddPlayer(playerid); | |
return CallLocalFunction("FEP_OnPlayerConnect","i",playerid); | |
} | |
#if defined _ALS_OnPlayerConnect | |
#undef OnPlayerConnect | |
#else | |
#define _ALS_OnPlayerConnect | |
#endif | |
#define OnPlayerConnect FEP_OnPlayerConnect | |
forward FEP_OnPlayerConnect(playerid); | |
public OnPlayerDisconnect(playerid,reason) | |
{ | |
RemovePlayer(playerid); | |
return CallLocalFunction("FEP_OnPlayerDisconnect","ii",playerid,reason); | |
} | |
#if defined _ALS_OnPlayerDisconnect | |
#undef OnPlayerDisconnect | |
#else | |
#define _ALS_OnPlayerDisconnect | |
#endif | |
#define OnPlayerDisconnect FEP_OnPlayerDisconnect | |
forward FEP_OnPlayerDisconnect(playerid,reason); | |
//------------------------------------------------------------------------------ | |
stock AddPlayer(playerid) | |
{ | |
if(ConnectedPlayers>=MAX_PLAYERS || playerid<0 || playerid>=MAX_PLAYERS) | |
return 0; | |
ConnectedPlayerList[ConnectedPlayers++]=playerid; | |
return 1; | |
} | |
stock RemovePlayer(playerid) | |
{ | |
for(new i=0;i<ConnectedPlayers;i++) | |
{ | |
if(ConnectedPlayerList[i]==playerid) | |
{ | |
ConnectedPlayers--; | |
ConnectedPlayerList[i]=ConnectedPlayerList[ConnectedPlayers]; | |
return 1; | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment