Raised This Month: $ Target: $400
 0% 

Is there a difference?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 08-03-2010 , 18:06   Is there a difference?
Reply With Quote #1

Is there a difference between:

PHP Code:
return PLUGIN_CONTINUE
and

PHP Code:
continue; 
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 08-03-2010 , 18:27   Re: Is there a difference?
Reply With Quote #2

continue is used in loops, it means start the next iteration of the closest loop.
Example:
Code:
for (new i = 0; i < 10; ++i) {     for (new j = 0; j < 10; ++j) {         if (j == i) continue;         server_print("j != i"); // this code won't be executed when j == i     } }
return PLUGIN_CONTINUE means you're returning the value of PLUGIN_CONTINUE, which is defined on amxmodx.inc
The function provider will check your return value and act based on it. For instance, in most cases if you return PLUGIN_HANDLED it will block the default action.
Seta00 is offline
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 08-03-2010 , 18:27   Re: Is there a difference?
Reply With Quote #3

As Seta said, there's difference (same post time )
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 08-03-2010 , 18:30   Re: Is there a difference?
Reply With Quote #4

Alright thanks. Now I never understood the loops. So basically, when using loops such as:

PHP Code:
new iPlayers[32];
new 
iNum;
get_playersiPlayersiNum"a" )

for( new 
0iNumi++ ) 
It will continue to add to "i" until it reaches iNum, then it will stop?
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 08-03-2010 , 18:33   Re: Is there a difference?
Reply With Quote #5

No, you must put a code block inside the loop. In Pawn, an empty code block is {}
Code:
new iPlayers[32]; new iNum; get_players( iPlayers, iNum, "a" ) for( new i = 0; i < iNum; i++ ){}
Seta00 is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 08-03-2010 , 18:38   Re: Is there a difference?
Reply With Quote #6

Quote:
Originally Posted by Seta00 View Post
No, you must put a code block inside the loop. In Pawn, an empty code block is {}
Code:
new iPlayers[32]; new iNum; get_players( iPlayers, iNum, "a" ) for( new i = 0; i < iNum; i++ ){}
Of course I just didn't feel I should put the rest in.
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 08-03-2010 , 19:50   Re: Is there a difference?
Reply With Quote #7

continue:
Code:
// this loop will skip over the iteration if x is equal to 6 for( new x = 1; x < 9; x++ ) {     if( x == 6 )         continue;             // code         // x will never equal 6 in this loop, since we skip over it at the beginning }

return PLUGIN_HANDLED:
Code:
/* this loop will end the function and return 1 (PLUGIN_HANDLED)    when x is equal to 6 */     for( new x = 1; x < 9; x++ ) {     if( x == 6 )         return PLUGIN_HANDLED;             // code         // x will never equal anything above 5 in this loop     // which is kind of unnecessary, since you can just change the condition to x < 6 }
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:09.


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