How to do so when someone...
#1

How to do so when someone comes into my server to write: [JOIN] Name has joined the server. and when he came out from the server to its written [LEFT] Name has lefted this server? Something. Thanks in advance!
Reply
#2

pawn Код:
// under OnPlayerConnect

new string[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid,pname,sizeof(pname));
format(string,sizeof(string),"%s (%d) Has Joined The Server.",pname,playerid);
SendClientMessageToAll(grey,string);

//under OnPlayerDisconnect

new string[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid,pname,sizeof(pname));

switch(reason)
{
        case 0: format(string,sizeof(string),"%s (%d) Has Left The Server. (Timeout)",pname,playerid);
        case 1: format(string,sizeof(string),"%s (%d) Has Left The Server. (Quit)",pname,playerid);
        case 2: format(string,sizeof(string),"%s (%d) Has Left The Server. (Kicked)",pname,playerid);
        case 3: format(string,sizeof(string),"%s (%d) Has Left The Server. (Banned)",pname,playerid);
        SendClientMessageToAll(grey,string);
        return 1;
}
That will work 100%. Just change some stuff in the messages to what you desire.
Reply
#3

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

Edit: Too late
Reply
#4

Quote:
Originally Posted by grand.Theft.Otto
Посмотреть сообщение
pawn Код:
// under OnPlayerConnect

new string[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid,pname,sizeof(pname));
format(string,sizeof(string),"%s (%d) Has Joined The Server.",pname,playerid);
SendClientMessageToAll(grey,string);

//under OnPlayerDisconnect

new string[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid,pname,sizeof(pname));

switch(reason)
{
        case 0: format(string,sizeof(string),"%s (%d) Has Left The Server. (Timeout)",pname,playerid);
        case 1: format(string,sizeof(string),"%s (%d) Has Left The Server. (Quit)",pname,playerid);
        case 2: format(string,sizeof(string),"%s (%d) Has Left The Server. (Kicked)",pname,playerid);
        case 3: format(string,sizeof(string),"%s (%d) Has Left The Server. (Banned)",pname,playerid);
        SendClientMessageToAll(grey,string);
        return 1;
}
That will work 100%. Just change some stuff in the messages to what you desire.
There is no reason 3, only 0 1 and 2 which is both for kick and bans.
Reply
#5

Quote:
Originally Posted by admantis
Посмотреть сообщение
There is no reason 3, only 0 1 and 2 which is both for kick and bans.
Yeah I forgot about that, but oh well.
Reply
#6

Where would I add it?
Reply
#7

Quote:
Originally Posted by lowrida018
Посмотреть сообщение
Where would I add it?
It already says in the code that I posted...

When they join, you put it under onplayerconnect and when they leave, onplayerdisconnect...
Reply
#8

Oh, I am retarded, . Thanks.
Reply
#9

pawn Код:
new
        sStr[ 64 ], kName[ MAX_PLAYER_NAME ];

public OnPlayerConnect( playerid )
{
   GetPlayerName( playerid, kName, sizeof( kName ) );
   format( sStr, sizeof( sStr ), "%s has joined the server.", kName );
   return SendClientMessageToAll( 0xFFF000AA, sStr ), true;
}

public OnPlayerDisconnect( playerid, reason )
{
    GetPlayerName( playerid, kName, sizeof( kName ) );
    switch( reason )
    {
        case 0: format( sStr, sizeof( sStr ), "%s left the server. (Timed out)", kName );
        case 1: format( sStr, sizeof( sStr ), "%s left the server. (Leaving)", kName );
        case 2: format( sStr, sizeof( sStr ), "%s left the server. (Kicked/Banned)", kName );
    }
    return SendClientMessageToAll( 0xFFF000AA, sStr ), true;
}
Reply
#10

Oh, I am retarded, . Thanks.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)