17.08.2015, 07:23
You can make a simple loop to check connected players ... will be easiest and short to write :
PHP код:
#include <a_samp>
#if defined MAX_PLAYERS // Check if MAX_PLAYERS it's defined
#undef MAX_PLAYERS // If yes , we will undefine it
#endif // if we have an #if , we need #endif ..
#define MAX_PLAYERS 50 // Define server slots | Modify there .
public OnPlayerConnect(playerid) // Public OnPlayerConnect
{ // Open bracket
new count, String[46]; // We create an initialiser (count) and a string with the cellsize 46 (String)
for(new i; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i)) count++; // Make a loop across all server ids (slots ...) , check if any it's connected . If a player it's connected we will give count += 1 (Or count++)
// count = players connected .
format(String, sizeof(String), "SERVER INFO:There are %i players online.", count); // Format our string with the text from " "
SendClientMessage(playerid, -1, String); // Print the message to player who connected in white color .
} // Close the bracket ~~~~ Much simplest , i think