SA-MP Forums Archive
How Do I Make It Say So and So Has Joined Your Server - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How Do I Make It Say So and So Has Joined Your Server (/showthread.php?tid=261339)



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

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!


Re: How Do I Make It Say So and So Has Joined Your Server - Lorenc_ - 13.06.2011

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

You should find something there.


Re: How Do I Make It Say So and So Has Joined Your Server - BASITJALIL - 13.06.2011

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;
}



Re: How Do I Make It Say So and So Has Joined Your Server - Lorenc_ - 13.06.2011

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..


Re: How Do I Make It Say So and So Has Joined Your Server - jot16 - 13.06.2011

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


Re: How Do I Make It Say So and So Has Joined Your Server - BASITJALIL - 13.06.2011

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


Re: How Do I Make It Say So and So Has Joined Your Server - Scenario - 13.06.2011

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;
}



Re: How Do I Make It Say So and So Has Joined Your Server - Bmxerlmao5288 - 13.06.2011

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;
}