returns - 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: returns (
/showthread.php?tid=628493)
returns -
Watermelonnable - 11.02.2017
hi !
I'm trying to learn pawn and I still don't get where should I use return 0 or 1, can someone explain it ?
Re: returns -
DandyCorleone - 11.02.2017
u can use return 1;
in last your script
Re: returns -
DandyCorleone - 11.02.2017
u can use return 1;
in last your script
Re: returns -
Watermelonnable - 11.02.2017
Quote:
Originally Posted by DandyCorleone
u can use return 1;
in last your script
|
But, why return 1 instead of return 0 ?
Re: returns -
StrikerZ - 11.02.2017
https://sampwiki.blast.hk/wiki/Control_Structures#return
Re: returns -
Watermelonnable - 11.02.2017
Quote:
Originally Posted by Sunehildeep
|
Ok, I think i understand it a little bit more.
So, what happen if i return 1 value or if I return 0 value ?
For example on this code:
PHP код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/lanzacohetes", cmdtext, true, 10) == 0)
{
SendClientMessage(playerid, COLOR_WHITE,"[SERVIDOR]: Se te ha sido concedido un lanzacohetes.");
GivePlayerWeapon(playerid, 36, 500);
return 1;
}
If you can explain me in a no-programmer language it would be better, what happens line by line and what happens when it reach the return line, with 1 value and 0 value
Re: returns -
Vince - 11.02.2017
A return-statement passes control back to the function that called this function in the first place, i.e. "return to where you were before". In this particular case it's the server process. The server process examines the returned result to decide whether to send the "unknown command" message or not (0/1).
I suggest you read the language guide, specifically the section on operators and expressions (starting page 105):
https://dl.dropboxusercontent.com/u/.../pawn-lang.pdf