Join and Leave Messages [My First make] - 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)
+--- Thread: Join and Leave Messages [My First make] (
/showthread.php?tid=439760)
Join and Leave Messages [My First make] -
kosa451 - 26.05.2013
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
Re: Join and Leave Messages [My First make] -
jordy.kiesebrink - 26.05.2013
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
Re: Join and Leave Messages [My First make] -
PrivatioBoni - 26.05.2013
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.
Re: Join and Leave Messages [My First make] -
jordy.kiesebrink - 26.05.2013
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.
Re: Join and Leave Messages [My First make] -
DerickClark - 26.05.2013
Good job.
Re: Join and Leave Messages [My First make] -
Cameltoe - 26.05.2013
https://sampwiki.blast.hk/wiki/OnPlayerConnect
https://sampwiki.blast.hk/wiki/OnPlayerDisconnect
"good" job