What's the difference - 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: What's the difference (
/showthread.php?tid=633901)
What's the difference -
Nin9r - 09.05.2017
Hi there! What's the difference between:
Код HTML:
CMD:nameoff(playerid, params[])
{
if(PlayerData[playerid][pAdminLevel] >= 6)
{
for(new i = GetPlayerPoolSize(); i != -1; --i) ShowPlayerNameTagForPlayer(playerid, i, false);
GameTextForPlayer(playerid, "~W~Nametags ~R~off", 5000, 5);
return 1;
}
}
and
Код HTML:
CMD:nameoff(playerid, params[])
{
if(PlayerData[playerid][pAdminLevel] >= 6)
{
for(new i = GetPlayerPoolSize(); i != -1; --i) ShowPlayerNameTagForPlayer(playerid, i, false);
GameTextForPlayer(playerid, "~W~Nametags ~R~off", 5000, 5);
}
return 1;
}
Does it matter where return 1; is put?
Re: What's the difference -
Toroi - 09.05.2017
Yes. In the first example, you return the value of 1 only if the command issuer complies with the provided condition. In the case the player doesn't, the function wont return anything; the compiler will warn you about this.
In the second example, the command will return the value of 1 either the player complies with the condition or not, which is something you need for the command to execute and the warning to disappear.
Refer to the following link for more information about the return control.
https://sampwiki.blast.hk/wiki/Control_Structures#return
Re: What's the difference -
Nin9r - 09.05.2017
Thanks a lot !