What's the difference
#1

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?
Reply
#2

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
Reply
#3

Thanks a lot !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)