Raised This Month: $91 Target: $400
 22% 

Solved [help] cooldown on client print function ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Neon123
Senior Member
Join Date: Jan 2016
Old 03-21-2016 , 12:35   [help] cooldown on client print function ?
Reply With Quote #1

hi , i need a cooldown in client_print, I use a command that has one task for 300 seconds , When I want to return to use it say client_print(id, print_chat, "You must wait %s seconds to use this")

Last edited by Neon123; 03-25-2017 at 22:28.
Neon123 is offline
Artifact
Veteran Member
Join Date: Jul 2010
Old 03-21-2016 , 12:48   Re: [help] cooldown on client print function ?
Reply With Quote #2

Something like this?
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

new not_allow 
new cTime

public plugin_init() {
    
    
register_clcmd("Your Command""cmd")
    
cTime register_cvar("cmd_allow_for""300")
}

public 
cmd(id)
{    
    new 
sTime get_pcvar_num(cTime)
    
//If is not allow to use that command
    
if(not_allow)
        
// Print to player that command is not allowed
        
client_print(idprint_chat"You must wait %s seconds to use this"sTime)
    
    
//here your cmd
    
    //When we use that command now block it
    
not_allow true
    
//Make a task to allow this command
    
set_task(300.0"allow")
}
//////////////////////////
//
//    Simple task
//    Func
//
//////////////////////////
public allow(id)
    
not_allow false 
__________________
Artifact is offline
Neon123
Senior Member
Join Date: Jan 2016
Old 03-21-2016 , 13:02   Re: [help] cooldown on client print function ?
Reply With Quote #3

thank you !
Neon123 is offline
Old 03-21-2016, 13:51
siriusmd99
This message has been deleted by siriusmd99. Reason: nvm, all the script above is wrong.
Neon123
Senior Member
Join Date: Jan 2016
Old 03-21-2016 , 13:52   Re: [help] cooldown on client print function ?
Reply With Quote #4

the plugin says
You must wait , seconds to use this

says "," and not the seconds
Neon123 is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 03-21-2016 , 14:02   Re: [help] cooldown on client print function ?
Reply With Quote #5

Artifact , if you are not experienced in scripting then don't post wrong scripts because other people can have the same problem and they can use wrong script and thinking that they were doing something wrong but not the script itself.
siriusmd99 is offline
icimaro1337
Junior Member
Join Date: Jan 2016
Location: Moldova, Chisinau
Old 03-21-2016 , 14:33   Re: [help] cooldown on client print function ?
Reply With Quote #6

PHP Code:
#include amxmodx

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Admin"

new g_pDelayCvar

new Float:g_flDelay[33]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
g_pDelayCvar register_cvar("amx_command_delay""300")
    
    
register_clcmd("say /test""ClCmdTest")
}
public 
ClCmdTest(iClient)
{
    if(
get_gametime() < g_flDelay[iClient])
    {
        
client_print(iClientprint_chat"* You must wait %d second to use this command!"floatround(g_flDelay[iClient] - get_gametime()))
        
        return 
PLUGIN_HANDLED
    
}
    
    new 
flDelayTime get_pcvar_float(g_pDelayCvar)
    
    
g_flDelay[iClient] = get_gametime() + flDelayTime
    
    
return PLUGIN_CONTINUE


Last edited by icimaro1337; 03-21-2016 at 14:34.
icimaro1337 is offline
Send a message via Skype™ to icimaro1337
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 03-21-2016 , 14:52   Re: [help] cooldown on client print function ?
Reply With Quote #7

Nice, I optimized a little bit your code:

PHP Code:
#include amxmodx

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Admin"

new g_pDelayCvar

new g_flDelay[33]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
g_pDelayCvar register_cvar("amx_command_delay""300")
    
    
register_clcmd("say /test""ClCmdTest")
}
public 
ClCmdTest(iClient)
{
    new 
gametimeget_gametime()
    if(
gametime g_flDelay[iClient])
    {
        
client_print(iClientprint_chat"* You must wait %d second(s) to use this command!"g_flDelay[iClient] - gametime))
        
        return 
PLUGIN_HANDLED
    
}
    
    
    
g_flDelay[iClient] = gametime get_pcvar_num(g_pDelayCvar)
    
    return 
PLUGIN_CONTINUE

siriusmd99 is offline
Artifact
Veteran Member
Join Date: Jul 2010
Old 03-21-2016 , 15:35   Re: [help] cooldown on client print function ?
Reply With Quote #8

Quote:
Originally Posted by siriusmd99 View Post
Artifact , if you are not experienced in scripting then don't post wrong scripts because other people can have the same problem and they can use wrong script and thinking that they were doing something wrong but not the script itself.
It's just fast example, just idea, not plugin. I'm not exp. and I'll learn for a life again I died stupid
__________________
Artifact is offline
Neon123
Senior Member
Join Date: Jan 2016
Old 03-21-2016 , 16:51   Re: [help] cooldown on client print function ?
Reply With Quote #9

plugin says
* You must wait -1073741824 second to use this command!
Neon123 is offline
[email protected]
Veteran Member
Join Date: May 2008
Location: France Marne
Old 03-21-2016 , 21:23   Re: [help] cooldown on client print function ?
Reply With Quote #10

Quote:
Originally Posted by siriusmd99 View Post
Artifact , if you are not experienced in scripting then don't post wrong scripts because other people can have the same problem and they can use wrong script and thinking that they were doing something wrong but not the script itself.
I return to you that word. Mastering the variable types is one of the thing people should learn first.

PHP Code:
#include <amxmodx>

#define PLUGIN "Cooldown type command"
#define VERSION "1.0"
#define AUTHOR "Freeman"

#define MAX_PLAYERS 32

new CvarCooldown
new Float:CommandNextTime[MAX_PLAYERS+1]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)

    
CvarCooldown register_cvar("amx_cmd_cooldown""60")

    
register_clcmd("say /test""cmd_test")
}
public 
cmd_test(id)
{
    new 
Float:gametime get_gametime()
    new 
Float:command_next_time CommandNextTime[id]

    if( 
gametime command_next_time )
    {
        new 
Float:timeleft command_next_time gametime
        client_print
(idprint_chat"You must wait %.0f second%s to use this command"timeleft, (1.0 <= timeleft 2.0) ? "s" "")

        return
    }

    
CommandNextTime[id] = gametime get_pcvar_float(CvarCooldown)

    
// Your command code here


Last edited by [email protected]; 03-21-2016 at 21:29.
Fr33m@n 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 04:26.


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