Raised This Month: $ Target: $400
 0% 

Solved Wait N amount of seconds?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
blAck.
Member
Join Date: Jun 2018
Old 08-05-2018 , 08:53   Wait N amount of seconds?
Reply With Quote #1

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #define PLUGIN "New Plug-In" #define VERSION "1.0" #define AUTHOR "author" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)         register_clcmd("say /healme", "heal"); } public heal(id) {     new iHP = get_user_health(id);     set_user_health(id, iHP + 20);     return PLUGIN_HANDLED; } // How can I make that player must wait N amount of seconds b4 using that command again? // I know it's something with set_task but can you show me how please?

Last edited by blAck.; 08-05-2018 at 10:10.
blAck. is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-05-2018 , 09:00   Re: Wait N amount of seconds?
Reply With Quote #2

PHP Code:
#include < amxmodx >
#include < fun >

new g_iUseTime;

const 
g_iFreq 15;

public 
plugin_init( )
{    
    
register_clcmd"say /healme""@HealMe" );
}

@
HealMeid )
{
    new 
iTime floatroundget_gametime( ) );
    
    if( 
iTime >= g_iUseTime )
    {
        
g_iUseTime iTime g_iFreq;
        
        
set_user_healthidget_user_healthid ) + 15 );
    }
    
    else
    {
        
client_printidprint_center"You have to wait %d seconds until you can use this again."g_iUseTime iTime );
    }
    
    return 
PLUGIN_HANDLED;

__________________
edon1337 is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 08-05-2018 , 09:35   Re: Wait N amount of seconds?
Reply With Quote #3

Quote:
Originally Posted by edon1337 View Post
PHP Code:
#include < amxmodx >
#include < fun >

new g_iUseTime;

const 
g_iFreq 15;

public 
plugin_init( )
{    
    
register_clcmd"say /healme""@HealMe" );
}

@
HealMeid )
{
    new 
iTime floatroundget_gametime( ) );
    
    if( 
iTime >= g_iUseTime )
    {
        
g_iUseTime iTime g_iFreq;
        
        
set_user_healthidget_user_healthid ) + 15 );
    }
    
    else
    {
        
client_printidprint_center"You have to wait %d seconds until you can use this again."g_iUseTime iTime );
    }
    
    return 
PLUGIN_HANDLED;

Notice 1: g_iUseTime is single variable so in players this will mess things up
Notice 2: Better use float variable than converting float to int
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM

Last edited by Ghosted; 08-05-2018 at 09:35.
Ghosted is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-05-2018 , 10:12   Re: Wait N amount of seconds?
Reply With Quote #4

Quote:
Originally Posted by Ghosted View Post
Notice 1: g_iUseTime is single variable so in players this will mess things up
Notice 2: Better use float variable than converting float to int
1. It was just an example, this is Scripting help section after all.
2. Doesn't really matter.
__________________
edon1337 is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-05-2018 , 10:55   Re: Wait N amount of seconds?
Reply With Quote #5

Quote:
Originally Posted by edon1337 View Post
1. It was just an example, this is Scripting help section after all.
2. Doesn't really matter.
1. If it was just an example it's a really bad one. What's the point of providing a non working code?
2. It matters, you are loosing precision.
__________________
HamletEagle is offline
Old 08-05-2018, 13:26
edon1337
This message has been deleted by edon1337.
blAck.
Member
Join Date: Jun 2018
Old 08-05-2018 , 13:43   Re: Wait N amount of seconds?
Reply With Quote #7

Quote:
Originally Posted by HamletEagle View Post
1. If it was just an example it's a really bad one. What's the point of providing a non working code?
2. It matters, you are loosing precision.
Hey, chill. I tried the code and it works.
blAck. is offline
blAck.
Member
Join Date: Jun 2018
Old 08-05-2018 , 10:10   Re: Wait N amount of seconds?
Reply With Quote #8

Quote:
Originally Posted by edon1337 View Post
PHP Code:
#include < amxmodx >
#include < fun >

new g_iUseTime;

const 
g_iFreq 15;

public 
plugin_init( )
{    
    
register_clcmd"say /healme""@HealMe" );
}

@
HealMeid )
{
    new 
iTime floatroundget_gametime( ) );
    
    if( 
iTime >= g_iUseTime )
    {
        
g_iUseTime iTime g_iFreq;
        
        
set_user_healthidget_user_healthid ) + 15 );
    }
    
    else
    {
        
client_printidprint_center"You have to wait %d seconds until you can use this again."g_iUseTime iTime );
    }
    
    return 
PLUGIN_HANDLED;

This works perfectly! Ty
blAck. is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 08-05-2018 , 14:00   Re: Wait N amount of seconds?
Reply With Quote #9

It's not about me being happy or not. I just don't get the attitude.
__________________

Last edited by HamletEagle; 08-05-2018 at 14:01.
HamletEagle is offline
OnePL
BANNED
Join Date: May 2012
Location: GB
Old 08-05-2018 , 17:53   Re: Wait N amount of seconds?
Reply With Quote #10

PHP Code:
#include <amxmodx>
#include <fun>

new g_iPlayerNextUse[33];

public 
plugin_init() register_clcmd("say /health""Clcmd_Health");

public 
client_disconnected(idg_iPlayerNextUse[id] = 0;

public 
Clcmd_Health(id) {
    static 
iSysTime;
    
iSysTime get_systime();

    if(
g_iPlayerNextUse[id] > iSysTime) {
        
client_print(idprint_center"You have to wait %d seconds until you can use this again."g_iPlayerNextUse[id] - iSysTime);
        return;
    }

    
set_user_health(idget_user_health(id) + 20);
    
g_iPlayerNextUse[id] = iSysTime 15;

OnePL is offline
Send a message via ICQ to OnePL Send a message via AIM to OnePL Send a message via Yahoo to OnePL Send a message via Skype™ to OnePL
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 12:37.


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