Raised This Month: $51 Target: $400
 12% 

Command cooldown for all players


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HowToRuski
Senior Member
Join Date: Feb 2019
Location: Hungary
Old 05-04-2023 , 09:35   Command cooldown for all players
Reply With Quote #1

Is there a way this cooldown is affecting everyone once the command has been executed from console?

I have this here, but its still only affect the player who used it...
PHP Code:

new Float:g_lastCodeUseTime[MAXPLAYERS];

if (
get_gametime() - g_lastCodeUseTime[id] < 6)
    {
        
client_print(idprint_console"Wait a bit before using this command again...")
        return 
PLUGIN_HANDLED;
    } 
HowToRuski is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 05-04-2023 , 16:47   Re: Command cooldown for all players
Reply With Quote #2

new Float:g_lastCodeUseTime;

if (get_gametime() - g_lastCodeUseTime < 6)
jimaway is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 05-04-2023 , 18:24   Re: Command cooldown for all players
Reply With Quote #3

omits the id
__________________
mlibre is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-05-2023 , 00:17   Re: Command cooldown for all players
Reply With Quote #4

Quote:
Originally Posted by mlibre View Post
omits the id
What are you talking about? jimaway's suggestion is all that is needed.
__________________
fysiks is offline
HowToRuski
Senior Member
Join Date: Feb 2019
Location: Hungary
Old 05-05-2023 , 05:27   Re: Command cooldown for all players
Reply With Quote #5

Quote:
Originally Posted by jimaway View Post
new Float:g_lastCodeUseTime;

if (get_gametime() - g_lastCodeUseTime < 6)
Thanks, worked
HowToRuski is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 05-05-2023 , 18:53   Re: Command cooldown for all players
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
What are you talking about? jimaway's suggestion is all that is needed.
I mean that same compared to the original g_lastCodeUseTime[id] -> g_lastCodeUseTime
__________________
mlibre is offline
tikpop
New Member
Join Date: May 2023
Old 05-06-2023 , 01:28   Re: Command cooldown for all players
Reply With Quote #7

Most of the Chicken Express restaurants open in the morning at 10:00 AM/100 AM and close in the evening at 10:00 PM. On regular days means Monday to Friday. chicken express holiday hours
tikpop is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-06-2023 , 20:25   Re: Command cooldown for all players
Reply With Quote #8

Quote:
Originally Posted by mlibre View Post
I mean that same compared to the original g_lastCodeUseTime[id] -> g_lastCodeUseTime
You should use more words to explain what you're saying instead of just saying three random words.
__________________
fysiks is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 05-06-2023 , 20:56   Re: Command cooldown for all players
Reply With Quote #9

well a word to the wise is enough, I take this opportunity to emphasize that i use the GG translator friend ;) this AI does not help much, let's say
__________________
mlibre is offline
Fuck For Fun
Veteran Member
Join Date: Nov 2013
Old 05-13-2023 , 12:18   Re: Command cooldown for all players
Reply With Quote #10

Quote:
Originally Posted by HowToRuski View Post
Is there a way this cooldown is affecting everyone once the command has been executed from console?

I have this here, but its still only affect the player who used it...
PHP Code:

new Float:g_lastCodeUseTime[MAXPLAYERS];

if (
get_gametime() - g_lastCodeUseTime[id] < 6)
    {
        
client_print(idprint_console"Wait a bit before using this command again...")
        return 
PLUGIN_HANDLED;
    } 
You mean something like that:
HTML Code:
new g_LastCommandTime[MAXPLAYERS];
const Float:COMMAND_COOLDOWN_TIME = 10.0; // seconds

public CmdMyCommand(client)
{
    // Create own cvar toggle
    if (get_pcvar_num(g_CmdMyCommandEnabled) == 0)
    {
        client_print(client, print_console, "This command is currently disabled.");
        return PLUGIN_HANDLED;
    }

    if (get_gametime() < g_LastCommandTime[client])
    {
        client_print(client, print_console, "Wait a bit before using this command again...");
        return PLUGIN_HANDLED;
    }

    // Do something here...

    g_LastCommandTime[client] = get_gametime() + COMMAND_COOLDOWN_TIME;
    return PLUGIN_HANDLED;
}

Last edited by Fuck For Fun; 05-13-2023 at 12:19.
Fuck For Fun is offline
Send a message via Skype™ to Fuck For Fun
Reply



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


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