Raised This Month: $ Target: $400
 0% 

Delay before re-use


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Davidos
Senior Member
Join Date: Feb 2005
Old 12-02-2007 , 13:37   Delay before re-use
Reply With Quote #1

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?
__________________
Roar.
Davidos is offline
alien
Senior Member
Join Date: Aug 2005
Location: London || Slovakia
Old 12-02-2007 , 13:48   Re: Delay before re-use
Reply With Quote #2

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 ...   }
__________________
alien is offline
Send a message via ICQ to alien
Old 12-02-2007, 13:55
Davidos
This message has been deleted by Davidos.
Davidos
Senior Member
Join Date: Feb 2005
Old 12-02-2007 , 15:11   Re: Delay before re-use
Reply With Quote #3

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.
__________________
Roar.

Last edited by Davidos; 12-02-2007 at 17:10.
Davidos is offline
Reply


Thread Tools
Display Modes

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 11:00.


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