This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Delay in looping statement


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
rastafari
Senior Member
Join Date: May 2011
Old 11-17-2012 , 10:50   Delay in looping statement
Reply With Quote #1

I need help in the following code to delay the 'for' looping.
Actually it looks like this, but it would start it all over again to forever.
I need something to replace the 'set_task' to delay it, without making a new variable to the whole code.
PHP Code:
public Thingy()
{
    new 
i
    
for (i=0i<10i++)
    {
        
//executed stuff
        
set_task(2.0"Thingy",0);
    }
    
    return 
PLUGIN_HANDLED;

__________________
rastafari is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 11-17-2012 , 11:03   Re: Delay in looping statement
Reply With Quote #2

PHP Code:
func(){
    new 
param[1]
    
param[0] = 0
    set_task
(2.0"Thingy"0param1
    
//Thingy(param) // <-- use this instead of set_task above if you want first execution without delay
}

public 
Thingy(param[]){
    new 
param[0]
    
//executed stuff
    
    
if(++param[0] < 10)
        
set_task(2.0"Thingy"0param1)

__________________
Impossible is Nothing
Sylwester is offline
rastafari
Senior Member
Join Date: May 2011
Old 11-17-2012 , 11:49   Re: Delay in looping statement
Reply With Quote #3

Thanks for the fast reply, but I don't really understand how to call the 'Thingy' function in your code.
__________________
rastafari is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 11-17-2012 , 11:56   Re: Delay in looping statement
Reply With Quote #4

Just call function func(), it will start the loop. If you want first execution without delay then in func() comment set_task(...) and uncomment Thingy(param).
__________________
Impossible is Nothing
Sylwester is offline
rastafari
Senior Member
Join Date: May 2011
Old 11-17-2012 , 12:42   Re: Delay in looping statement
Reply With Quote #5

Well I still don't understand since you never used the i in your code and I tried to compile, but it said: symbol is never used 'func' and bunch of 'loose of indentation'.
Called func with this:
PHP Code:
register_clcmd"command" "func" ,ADMIN_LEVEL_E); 
__________________
rastafari is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 11-17-2012 , 13:56   Re: Delay in looping statement
Reply With Quote #6

To call it like this you need to make the func() public. The "i" in my code is unused because I assumed you were using it in your "//executed stuff", so I added it there to make it easier for you. Loose indentation has nothing to do with how the plugin works, indent your code properly to get rid of it (maybe you mixed tabs with spaces).
__________________
Impossible is Nothing
Sylwester is offline
rastafari
Senior Member
Join Date: May 2011
Old 11-17-2012 , 14:18   Re: Delay in looping statement
Reply With Quote #7

Alright I got it now thanks for explaining all.
__________________
rastafari 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 23:37.


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