AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   returning values (https://forums.alliedmods.net/showthread.php?t=28007)

Locks 05-04-2006 22:51

returning values
 
What's the difference between

Code:
return
and
Code:
return PLUGIN_HANDLED

and
Code:
continue
Code:
return PLUGIN_CONTINUE

Xanimos 05-04-2006 23:04

if you just use return it would be the same as using return PLUGIN_CONTINUE

plain continue is used to skip the rest of the code in a particular iteration of a loop and go to the next.

There is more in the wiki

VEN 05-05-2006 04:50

Also search. There are a good explanation of return PLUGIN_*'s (by PM i think).

PM 05-05-2006 08:53

Quote:

Originally Posted by Suicid3
if you just use return it would be the same as using return PLUGIN_CONTINUE

Not exactly the same.

return; alone suggests that the function has no return value - it only suggests that you want to stop execution of the function. The fact that this acutally returns a zero (which, by chance, is what PLUGIN_CONTINUE is defined to) when used in a public function is an implementation detail.

Basically:
If a function has a return value (for your own (stock) function you can decide yourself, for public functions the host aplication (=AMXX) decides*), you should always use
Code:
return something
and also place such a return statement as the last one in the function (otherwise the compiler will moan).

If the function doesn't have a return value, it's not neccessary (and not encouraged) to put a single return at the end; and if you want to exit the function immediately, use
Code:
return


*) technically, all public functions have return a value to the host application. However, the host application can decide to ignore it. In that case the programmer should treat that function as a function without a return value - unless he wants to call it from his own code and return something; that's pretty unlikely though ;o

Urahara 05-05-2006 12:47

Ohayo PM-san! :D

continue and break are used to cycle in loops; break jumps out of the loop while continue jumps to the next state in the loop cycle!

hope that is helpful to you lock-san! :D


All times are GMT -4. The time now is 05:12.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.