[Tutorial] sSiddhant Tutorial 2# Join Message - 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] sSiddhant Tutorial 2# Join Message (
/showthread.php?tid=615844)
sSiddhant Tutorial 2# Join Message -
Siddhant240201 - 28.08.2016
sSiddhant Tutorial 2# Join Message
Hi, guys this is my second tutorial on How to make Join Messages. This is for those players who are new to Pawn and wanted to make their own server. Ok..So let's begin
First of all we are gonna make an array to store players name
Quote:
new sname[MAX_PLAYER_NAME];
|
Ok! Now we have created a new array which will store the name of every player. This new array sname will be created with size of MAX_PLAYER_NAME which is defined 24 in samp.inc
Quote:
new str[22+MAX_PLAYERS_NAME];
|
Now, we have created a String array which will store the message. The size of this array is 48 so that both player's name (sname, 24 chars) and message (" has joined the server.", 23 chars) and an invisible NUL-byte to terminate the string fit into our array.
Now we will get the player name
Quote:
GetPlayerName(playerid, sname, sizeof(sname));
|
The Above command will get the name of the playerid which has just joined the server and will store it in the variable sname with a max length of sizeof(sname), the size of sname (which was 24).
Now, lets format that String Variable which we have created.
Quote:
format(str,sizeof(str),"%s has joined the Server,sname");
|
Ok! for understanding this command I have to tell you about Strings.
The first parameter allows us to specify where we want to have the formatted string. We created the string array for this purpose earlier. The second parameter is the max length of the formatted string. That will be the size of the string. The third parameter is the actual string we want to format. %s is a placeholder for another string. Using the forth parameter we specify that it should be replaced with sname. That way we will have "<player's name> has joined the server." in the string array. This is taken from samp wikia
In this way we can use as much arguments we want after the third argument and we can put in the message using %s. So basically, this command will format the string and store it in the same array.
Now let's send this message to all users
Quote:
SendClientMessageToAll(-1, str);
|
This Command will send message to all players in color -1 which is white and that message will be <player> has joined the server which is stored in the str array which we created and formatted earlier. Now put the whole script which we created under this Callback.
Quote:
public OnPlayerConnect(playerid)
{
//put your script here
}
|
This Callback is called when a player connect to the server.
This is for now. I will most more tutorials soon. Hope you like this Please Comment and Give suggestions for my next tutorial. See you Soon!