[Help]Joined the server message!
#1

I would really like to add into my script where it says _ has joined the server! The message that appears to admins and tells them when someone joins and leaves a server! i really love this message and would like for anyone to send me the code that I need to add!! I am still new to scripting so I do not know what I need to add and where! I can do everything else as long as someone sends me the message and tells me where in script to place the code! Thank you! Your help will be greatly appreciated!
Reply
#2

What you want is a string. Also, if you only want it to show for Admins you'll need to loop through all the players to do this.
When somebody connects to your server, OnPlayerConnect will be called.

pawn Код:
public OnPlayerConnect(playerid)
{
    new
      Name[MAX_PLAYER_NAME], // This is also a form of string, that will be used to store the players name.
      string[128]; // Amount of cells (characters) in the string. 128 characters is more then needed, but easier.
     
    GetPlayerName(playerid, Name, sizeof(Name)); // Now the players name that just connecteds name is set under Name.
    format(string, sizeof(string), "%s has joined the server!", Name); // %s is used as a string. And the string we used is the "Name" we got earlier. If you didn't use GetPlayerName it won't show.

    for (new i=0; i<MAX_PLAYERS; i++) // Loop
    {
        if (IsPlayerConnected(i) && IsPlayerAdmin(i)) // If any player is connected, and an admin they will get this message.
        {
          SendClientMessage(i, 0xFFFFFFFF, string); // Client message to send the string. (In white)
        }
    }
    return true;
}

public OnPlayerDisconnect(playerid, reason)
{
    new
      Name[MAX_PLAYER_NAME],
      string[128];
     
    GetPlayerName(playerid, Name, sizeof(Name)); // Get the players name once again.
     
    switch (reason) // Toggle between reasons how the player disconnected.
    {
      case 0: format(string, sizeof(string), "%s has left the server. [Timeout]", Name);
      case 1: format(string, sizeof(string), "%s has left the server. [Left]", Name);
      case 2: format(string, sizeof(string), "%s has left the server. [Kick/Ban]", Name);
    }
    for (new i=0; i<MAX_PLAYERS; i++) // Loop
    {
        if (IsPlayerConnected(i) && IsPlayerAdmin(i)) // If any player is connected, and an admin they will get this message.
        {
          SendClientMessage(i, 0xFFFFFFFF, string); // Client message to send the string. (In white)
        }
    }
    return true;
}
Hope I helped.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)