How to do so when someone... - 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 to do so when someone... (
/showthread.php?tid=254022)
How to do so when someone... -
Join7 - 08.05.2011
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!
Re: How to do so when someone... -
grand.Theft.Otto - 08.05.2011
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.
Re: How to do so when someone... -
Laronic - 08.05.2011
https://sampwiki.blast.hk/wiki/OnPlayerConnect
https://sampwiki.blast.hk/wiki/OnPlayerDisconnect
Edit: Too late
Re: How to do so when someone... -
admantis - 08.05.2011
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.
Re: How to do so when someone... -
grand.Theft.Otto - 08.05.2011
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.
Re: How to do so when someone... -
lowrida018 - 08.05.2011
Where would I add it?
Re: How to do so when someone... -
grand.Theft.Otto - 08.05.2011
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...
Re: How to do so when someone... -
lowrida018 - 08.05.2011
Oh, I am retarded,

. Thanks.
Re: How to do so when someone... -
The Knight - 08.05.2011
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;
}
Re: How to do so when someone... -
lowrida018 - 08.05.2011
Oh, I am retarded,

. Thanks.