SA-MP Forums Archive
Return Statements - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Return Statements (/showthread.php?tid=278303)



Return Statements - M4z - 21.08.2011

I'm a beginner at Pawn, I don't understand what the return statements are used for. Can anyone explain them to me alongside with some examples of there use.
Basically, I don't understand the purpose of them and I have no idea when I would use return 1; or return 0; If anyone could clear this up for me, it would be very much appreciated!


Re: Return Statements - Cameltoe - 21.08.2011

https://sampwiki.blast.hk/wiki/Keywords:Statements


Re: Return Statements - mprofitt - 21.08.2011

Quote:
Originally Posted by M4z
View Post
I'm a beginner at Pawn, I don't understand what the return statements are used for. Can anyone explain them to me alongside with some examples of there use.
Basically, I don't understand the purpose of them and I have no idea when I would use return 1; or return 0; If anyone could clear this up for me, it would be very much appreciated!
The return statement ends a function and sets the result of the function. It
need not appear at the very end of the function; early exits are permitted.

A function can only have a single return value —that is, a return statement in a function
may only contain one expression.

If a function has one output value, you typically use a return statement; if a function has
more output values, you use reference arguments.

http://www.compuphase.com/pawn/Pawn_Language_Guide.pdf