[Tutorial] How to display current online players(OnPlayerConnect)
#5

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 countString[46]; // We create an initialiser (count) and a string with the cellsize 46 (String)
    
for(new ii<MAX_PLAYERSi++) 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(Stringsizeof(String), "SERVER INFO:There are %i players online."count); // Format our string with the text from "  "
    
SendClientMessage(playerid, -1String); // Print the message to player who connected in white color .
// Close the bracket ~~~~ Much simplest , i think 
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)