SA-MP Forums Archive
[Tutorial] How to create a Message on player connect & disconnect - 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: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] How to create a Message on player connect & disconnect (/showthread.php?tid=420633)



How to create a Message on player connect & disconnect - 007Skyfall - 06.03.2013

Hi Guys, this is my first tutorial and is about a message System, on player connect & Disconnect

Letґs GO!

1° In public OnPlayerConnect(playerid) paste this:

Code:
new Name[50]
GetPlayerName(playerid,Nombre,50);
format(Nombre,sizeof(Nombre),"{FFFFFF}*** {DF0101} %s {FFFFFF}Has joined the server!! .",Nombre);
SendClientMessageToAll(0xffffffff,Nombre);
Explication Of some things:

GetPlayerName(playerid,Nombre,50); ---> This obtains the name of the player

format(Nombre,sizeof(Nombre),"{FFFFFF}*** {DF0101} %s {FFFFFF}Has joined the server!! .",Nombre); ---> The message that show to all the server

SendClientMessageToAll(0xffffffff,Nombre); ---> Send the message to all the server
__________________________________________________ ____________________________________

2° Go to: public OnPlayerDisconnect(playerid, reason)

Code:
new
string[64],
name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
switch(reason)
{
case 0: format(string,sizeof string,"%s partiу del server. (Crash)",name);
case 1: format(string,sizeof string,"%s partiу del server. (Salio)",name);
case 2: format(string,sizeof string,"%s partiу del server. (Kick/Ban)",name);
}
SendClientMessageToAll(0xFFFFFFAA,string);
Explications of some things:

switch(reason) ---> The reason For which the player went out the server

{
case 0: format(string,sizeof string,"%s Has left the serve. (Reason: Crash)",name);
case 1: format(string,sizeof string,"%s Has left the server. (Reason: For if same)",name);
case 2: format(string,sizeof string,"%s Has left the server. (Reason: Kick/Ban)",name);
}
For kick, Ban or Crash

And... is all, sorry is my first tutorial and im bad for this