What exactly does 'return 1;' do and why do we need it?
#3

In some callbacks, it's used to determine if an action should be completed or prevented. Take OnPlayerUpdate as an example, if you return 0 in OnPlayerUpdate, it'll prevent the new data sent from being synced to other players, where as if you return 1, it'll sync to other players.

In functions, it's usually used to return a certain value such as a player's admin level for example.

pawn Код:
GetAdminLevel(playerid)
{
    return playersAdminLevel[playerid];
}
You don't need return 1 here because you're trying to make this function return the player's admin level.

Return 1 isn't something you need everywhere, but you should have it in your functions and callbacks because lets say you're making a command and you feel lazy so you want to do something like

pawn Код:
return SendClientMessage(playerid, -1, "Hello world...");
This will run all of the code inside of the SendClientMessage function and it will return the value which is returned from the function SendClientMessage, which would be 1.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)