Join and Leave Messages [My First make]
#1

Joining Message:

Код:
public OnPlayerConnect(playerid)
{
    new pname[MAX_PLAYER_NAME], string[22 + MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(string, sizeof(string), "%s has joined the server", pname);
    SendClientMessageToAll(0xAAAAAAAA, string);
    return 1;
}
Now join text done.


Leave Message:

Код:
public OnPlayerDisconnect(playerid, reason)
{
    new pname[MAX_PLAYER_NAME], string[39 + MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname)); 
    switch(reason)
    {
        case 0: format(string, sizeof(string), "%s has left the server. (Lost Connection)", pname);
        case 1: format(string, sizeof(string), "%s has left the server. (Leaving)", pname);
        case 2: format(string, sizeof(string), "%s has left the server. (Kicked)", pname);
    } 
    SendClientMessageToAll(0xAAAAAAAA, string);
    return 1;
}
If you want to make 1 more case you can do like this , EXAMPLE:

Код:
public OnPlayerDisconnect(playerid, reason)
{
    new pname[MAX_PLAYER_NAME], string[39 + MAX_PLAYER_NAME];
    GetPlayerName(playerid, pname, sizeof(pname)); 
    switch(reason)
    {
        case 0: format(string, sizeof(string), "%s has left the server. (Lost Connection)", pname);
        case 1: format(string, sizeof(string), "%s has left the server. (Leaving)", pname);
        case 2: format(string, sizeof(string), "%s has left the server. (Kicked)", pname);
        case 3: format(string, sizeof(string), "%s has left the server. (Relogging)", pname);
    } 
    SendClientMessageToAll(0xAAAAAAAA, string);
    return 1;
}
Hope it worked
Reply
#2

Why you posted this in the scriping help?, you are not really making a question and asking for scripting help!

This is more like a short tutorial.. you should post this here: http://forum.sa-mp.com/forumdisplay.php?f=70
Reply
#3

This isn't even a tutorial. It merely shows snippers of code instead of actually explaining how to do it. Though, I'm sure this will be helpful to some.
Reply
#4

therefor I said a short tuturial. and indeed its not really finshed to call it a tut.
post it in the right section and optimalise your tut by explaining why you did something.
and how you reached the result.
Reply
#5

Good job.
Reply
#6

https://sampwiki.blast.hk/wiki/OnPlayerConnect
https://sampwiki.blast.hk/wiki/OnPlayerDisconnect

"good" job
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)