AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Delay before re-use (https://forums.alliedmods.net/showthread.php?t=63893)

Davidos 12-02-2007 13:37

Delay before re-use
 
While I'm at my question spree, I might aswell throw this one in.

How does one make it so there is a certain delay between the use of a command?

For example, the command punch makes it so that a certain user loses 35 hp.
I want a 'SET' ammount of seconds it needs before you can punch again.

I know it works some way with gametime and stuff but unfortunatly, my skills are still as much as of a ten year old script kiddy.

Hmmkay?

alien 12-02-2007 13:48

Re: Delay before re-use
 
I'm using so-called ACFP (Anti command-flood protection) routines I did for my needs. Might be helpful to you ...

Code:
#define ACFP_TOLERANCE 3 new ACFP_memory[32]; override_ACFP(id)   {     ACFP_memory[id] = 0;     return;   } bool:passed_ACFP(id, print_target)   {     new t = get_systime();     if (t - ACFP_memory[id] >= ACFP_TOLERANCE)       {         ACFP_memory[id] = t;         return true;       }     switch (print_target)       {         case print_chat: chat(id, "Anti-Command-Flood: %d sec.", ACFP_TOLERANCE);         case print_console: console(id, "Anti-Command-Flood: %d sec.", ACFP_TOLERANCE);         case print_center: center(id, "Anti-Command-Flood: %d sec.", ACFP_TOLERANCE);       }     return false;   }

To use it, I just call it like this:

Code:
public my_console_command(id)   {     if (!passed_ACFP(id, print_console)) return PLUGIN_HANDLED;     // command code here ...   }

Davidos 12-02-2007 15:11

Re: Delay before re-use
 
Nope, seriously not working.

I'm trying this simple code:

Code:
    new currentTime = get_systime()     if(lastbite[id] + 5 > currentTime)     {         client_print(id,print_chat,"You can't eat that fast...")         return PLUGIN_HANDLED     }     lastbite[id] = currentTime

To tell ya the truth, this is for a quick 1 day zombie mod.

Anyone got an idea why this code is wrong?
Apparently it thinks it's 5 minutes or something cause it ain't working.


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

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