SA-MP Forums

SA-MP Forums (https://forum.sa-mp.com/index.php)
-   Tutorials (https://forum.sa-mp.com/forumdisplay.php?f=70)
-   -   [Tutorial] 'Welcome to my server' messages. (https://forum.sa-mp.com/showthread.php?t=450809)

Sh4rp 28/09/2019 10:56 AM

Re: 'Welcome to my server' messages.
 
Nice tutorial, but... how can I make the welcome message appear after the "Connected to [servername]" message?

Kwarde 28/09/2019 04:54 PM

Re: 'Welcome to my server' messages.
 
Quote:

Now, since we want the message to be sent to the player, we need to add a return. Since we want it to be sent, the return as to be 1. So this is our final code:
So if I don't add this return the message will not be received by the player?

SiaReyes 30/09/2019 07:22 AM

Re: 'Welcome to my server' messages.
 
Quote:

Originally Posted by Kwarde (Post 4115335)
So if I don't add this return the message will not be received by the player?


It's a callback return but the code return.
You can learn about returns from here:
https://wiki.sa-mp.com/wiki/Control_Structures#return

Quote:

Originally Posted by Sh4rp (Post 4115302)
Nice tutorial, but... how can I make the welcome message appear after the "Connected to [servername]" message?

Put the code at top of OnPlayerConnect.

Sh4rp 30/09/2019 02:22 PM

Re: 'Welcome to my server' messages.
 
Quote:

Originally Posted by SiaReyes (Post 4115525)
It's a callback return but the code return.
You can learn about returns from here:
https://wiki.sa-mp.com/wiki/Control_Structures#return



Put the code at top of OnPlayerConnect.

Thanks for the reply, but nothing has changed. :confused:
Code:
Code:

public OnPlayerConnect(playerid)
{
        GetPlayerName(playerid, pName, sizeof(pName));
        new string[124];
        new string2[124];
        new string3[124];
        format(string, sizeof(string), "Benvenuto sulla Sharp's Development Gamemode %s!", pName);
        format(string2, sizeof(string2), "Versione %s del %s.", GMVersion, GMLastUpdate);
        SendClientMessage(playerid, COLOR_GREEN, string);
        SendClientMessage(playerid, -1, string2);
        SendClientMessage(playerid, -1, "Sviluppata da Sharp.  Contatto Discord: @Sharp#1708.");
        format (string3, sizeof(string3), "%s si unito al server!", pName);
        SendClientMessageToAll(COLOR_GREEN, string3);
        return 1;
}

Result:
https://i.gyazo.com/4a7b0c15ee20dd87...46b7f9a90c.png

Kwarde 30/09/2019 02:55 PM

Re: 'Welcome to my server' messages.
 
Quote:

Originally Posted by SiaReyes (Post 4115525)
It's a callback return but the code return.
You can learn about returns from here:
https://wiki.sa-mp.com/wiki/Control_Structures#return

Don't worry I know how returns work, I was actually trying to be sarcastic because that is kinda my thing. What I ws trying to say was that the line I quoted is incorrect information(I'll quote again:)
Quote:

since we want the message to be sent to the player, we need to add a return
This line from the tutorial kinda says that the return is required if you want to send the message, which is incorrect. No matter if you use a return or not, the message will be sent -assuming this script is in the gamemode script.

Tht is what the return does in OnPlayerConnect. It either passes the callback to the next filterscript (return 1), or block other scripts from using the callback (return 0).

This really should be made clear in the tutorial (@Twizted) for you might mislead people this way who are new to scripting.

@Sh4rp:
Just use a timer with a slight delay (eg. 250ms)-> more or less if needed.
Instead of adding one or more timers for the messages, you could slightly delay the entire OnPlayerConnect() code. Just make a public function called OnPlayerConnect2 or so and put all your OnPlayerConnect code in there. And off course set a timer in the current OnPlayerConnect() callback.

Rikossport2 20/10/2019 11:13 AM

Re: 'Welcome to my server' messages.
 
Well explained tutorial


All times are GMT. The time now is 03:07 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.