Raised This Month: $32 Target: $400
 8% 

Solved Time limit for use


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ho83
Senior Member
Join Date: Aug 2020
Location: iran
Old 11-25-2020 , 17:51   Time limit for use
Reply With Quote #1

Solved Thanks to @fysiks

Last edited by ho83; 11-26-2020 at 07:50.
ho83 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-26-2020 , 00:56   Re: Add Time
Reply With Quote #2

Here is an example of how to require a wait time between two consecutive uses of a command. So, if you would like to attempt the change yourself, you can reference this example. Otherwise, someone else can use it as an example to add it to your plugin:

PHP Code:
#include <amxmodx>

new g_iWaitTime 45 // Seconds
new g_iLastTime[33// Timestamp of the last time the user has used the command

public plugin_init()
{
    
register_clcmd("say mycmd""myCmd")
}

public 
client_connect(id)
{
    
g_iLastTime[id] = 0
}

public 
myCmd(id)
{
    if( 
get_systime() > g_iLastTime[id] + g_iWaitTime )
    {
        
// Execute the command's functionality
        
client_print(idprint_chat"Command Executed!!")

        
// Update the 'last use' timestamp
        
g_iLastTime[id] = get_systime()
    }
    else
    {
        
// Command was used too soon
        
client_print(idprint_chat"You must wait %d seconds between usage of command"g_iWaitTime)
    }
    return 
PLUGIN_HANDLED

__________________
fysiks is offline
ho83
Senior Member
Join Date: Aug 2020
Location: iran
Old 11-26-2020 , 04:42   Re: Delete
Reply With Quote #3

@fysiks Thanks Sir Solved.
ho83 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 11-26-2020 , 07:20   Re: Delete
Reply With Quote #4

So where did the thread go? How is this now useful to other people?
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
ho83
Senior Member
Join Date: Aug 2020
Location: iran
Old 11-26-2020 , 07:48   Re: Delete
Reply With Quote #5

Sorry. I will be careful sir.

Last edited by ho83; 11-26-2020 at 07:48.
ho83 is offline
Mordekay
Squirrel of Fortune
Join Date: Apr 2006
Location: Germany
Old 11-27-2020 , 10:02   Re: Time limit for use
Reply With Quote #6

Quote:
Originally Posted by Rules
Do not blank out posts or threads. If you posted a question and later solve your problem, post the solution for others to find.
__________________

Mordekay 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 19:21.


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