AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   how to stop a function? (https://forums.alliedmods.net/showthread.php?t=89673)

Owyn 04-09-2009 08:45

how to stop a function?
 
edit: thx, i made an addition check not to allow 2nd execution of function in short-time, should work now i hope



PHP Code:

public plugin_init() {
register_clcmd("say""function");
}

public function(
id)
{
    new 
said[192]
    new 
ij
    
new cheatername[32]
    
get_user_name(idcheatername32)
    
read_args(said192)
    
    for(
sizeof (CheatReports) ; i++)
    {
         if(
containi(saidCheatReports[i][j]) != -1)
        {
            
set_task(3.3,"nodb");
            if(
cheater_1 == 0)
            {
                
action1(id)
                return 
PLUGIN_HANDLED
            
}
        }

    }
    
    for(
sizeof (CheatReports2) ; i++)
    {
        if(
containi(saidCheatReports2[i][j]) != -1)
        {
            
set_task(3.3,"nodc");
            if(
cheater_2 == 0)
            {
                
action2(id)
                return 
PLUGIN_HANDLED
            
}
        }
    }
    
    return 
PLUGIN_CONTINUE
    


hi, i want to stop function() when action1() is executed and not to let action2() to execute, i thought return PLUGIN_HANDLED should do that but it doesn't, action2() is still executed after action1() if they both met conditions

purple_pixie 04-09-2009 08:53

Re: how to stop a function?
 
Are you certain it isn't just doing action2() 3 seconds later?

return'ing out of the function will absolutely certainly stop anything after the "return" from happening

Owyn 04-09-2009 08:54

Re: how to stop a function?
 
no, i have logging, action1() and action2() were executed in the same second

purple_pixie 04-09-2009 08:56

Re: how to stop a function?
 
And function() is only called once?


All times are GMT -4. The time now is 02:18.

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