How Do I Make It Say So and So Has Joined Your Server
#1

How Do I Make It Say So and So Has Joined Your Server

Like HayZatic Has Joined Your Server!

Or HayZatic Has Left Your Server!
Reply
#2

Go on wiki.sa-mp.com and type onplayerconnect

You should find something there.
Reply
#3

pawn Код:
public OnPlayerConnect(playerid)
{
    SendClientMessageToAll(color_yellow, "%s has Joined the server");
    return 1;
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    SendClientMessageToAll(color_yellow, "%s has Left the Server);
    return 1;
}
Reply
#4

Quote:
Originally Posted by BASITJALIL
Посмотреть сообщение
pawn Код:
public OnPlayerConnect(playerid)
{
    SendClientMessageToAll(color_yellow, "%s has Joined the server");
    return 1;
}
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    SendClientMessageToAll(color_yellow, "%s has Left the Server);
    return 1;
}
That wouldn't work..
Reply
#5

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
That wouldn't work..
wut's wrong?
Reply
#6

What's wrong in the code it works prefect for me
Reply
#7

Quote:
Originally Posted by BASITJALIL
Посмотреть сообщение
What's wrong in the code it works prefect for me
Actually, it will work but it will only send the following text exactly; "%d has joined the server!" As you can see, it doesn't actually state the players name and therefore that doesn't work like it should. Instead, you need to format the message and insert values for the iterators. Try this:

pawn Код:
public OnPlayerConnect(playerid)
{
    new szFormatString[55], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(szFormatString, sizeof(szFormatString), "%s(%d) has joined the server.", pName, playerid);
    SendClientMessageToAll(COLOR_HERE, szFormatString);
    return 1;
}
Reply
#8

THE CORRECT CODE IS


Код:
public OnPlayerConnect(playerid)
{
    new string[64], pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
    format(string,sizeof string,"%s has joined the server. Welcome!",pName);
    SendClientMessageToAll(0xFFFFFFAA,string);
    return 1;
Код:
public OnPlayerDisconnect(playerid, reason)
{
    new
        string[64],
        name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,MAX_PLAYER_NAME);
    switch(reason)
    {
        case 0: format(string,sizeof string,"%s left the server. (Timed out)",name);
        case 1: format(string,sizeof string,"%s left the server. (Leaving)",name);
        case 2: format(string,sizeof string,"%s left the server. (Kicked/Banned)",name);
    }
    SendClientMessageToAll(0xFFFFFFAA,string);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)