Player-ID
#1

How to make when a People connect, that the ID is too screened? Like "Player X [ID X] has joined the server.". Also with his Playerid.
Reply
#2

pawn Код:
public OnPlayerConnect(playerid)
{
    new name[MAX_PLAYER_NAME], string[128];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "%s [ID %d] has joined the server", name,playerid);
    SendClientMessageToAll(-1, string);
    return 1;
}
Reply
#3

Let me explain the above command.

pawn Код:
public OnPlayerConnect(playerid) //This callback gets called each time a player connectes to your server
{
    new name[MAX_PLAYER_NAME], string[128]; //Creating a new string called "name" its size is 24(MAX_PLAYER_NAME = 24), creating another string called "string" and with the size of 128(Maximum SA-MP Text output)
    GetPlayerName(playerid, name, sizeof(name)); //Getting our name(playerid) and storing it in our string "name". If you login with the name "TestMaster" our "name" string will store your name "TestMaster" because we added this function(GetPlayerName)
    format(string, sizeof(string), "%s [ID %d] has joined the server", name,playerid); // Formating our "string" that we just created. Now if you go ingame with the name "TestMaster" our string "string" will get formated like this: TestMaster [ID: 0] has joined the server
    SendClientMessageToAll(-1, string); //Sending our formated string "string".
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)