AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Wait N amount of seconds? (https://forums.alliedmods.net/showthread.php?t=309729)

blAck. 08-05-2018 08:53

Wait N amount of seconds?
 
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?

edon1337 08-05-2018 09:00

Re: Wait N amount of seconds?
 
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;



Ghosted 08-05-2018 09:35

Re: Wait N amount of seconds?
 
Quote:

Originally Posted by edon1337 (Post 2608282)
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

blAck. 08-05-2018 10:10

Re: Wait N amount of seconds?
 
Quote:

Originally Posted by edon1337 (Post 2608282)
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

edon1337 08-05-2018 10:12

Re: Wait N amount of seconds?
 
Quote:

Originally Posted by Ghosted (Post 2608292)
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.

HamletEagle 08-05-2018 10:55

Re: Wait N amount of seconds?
 
Quote:

Originally Posted by edon1337 (Post 2608302)
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.

blAck. 08-05-2018 13:43

Re: Wait N amount of seconds?
 
Quote:

Originally Posted by HamletEagle (Post 2608312)
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.

HamletEagle 08-05-2018 13:53

Re: Wait N amount of seconds?
 
Quote:

Originally Posted by blAck. (Post 2608332)
Hey, chill. I tried the code and it works.

Hey, chill, it doesn't work. But you can decide not to trust me and Ghosted. Test with 2 players or more. It is going to store everybody's time in the same variable.

edon, please, just stop. You made a mistake, it's not the end of the world. Stop arguing for the sake of arguing, it is much better if you simply say "yeah, my bad" or move on, instead of coming with silly excuses.
Anyway, it's not going to ever work properly, be it first or last round. That's not the issue.

blAck. 08-05-2018 13:57

Re: Wait N amount of seconds?
 
Quote:

Originally Posted by HamletEagle (Post 2608335)
Hey, chill, it doesn't work. But you can decide not to trust me and Ghosted. Test with 2 players or more. It is going to store everybody's time in the same variable.

edon, please, just stop. You made a mistake, it's not the end of the world. Stop arguing for the sake of arguing, it is much better if you simply say "yeah, my bad" or move on, instead of coming with silly excuses.
Anyway, it's not going to ever work properly, be it first or last round. That's not the issue.

Ok then.. Can you tell me what's the right code for what I'm looking?

edon1337 08-05-2018 13:59

Re: Wait N amount of seconds?
 
Quote:

Originally Posted by HamletEagle (Post 2608335)
edon, please, just stop. You made a mistake, it's not the end of the world. Stop arguing for the sake of arguing, it is much better if you simply say "yeah, my bad" and move on, instead of coming with silly excuses.
Anyway, it's not going to ever work properly, be it first or last round. That's not the issue.

Perhaps you should see that I instantly deleted the comment.

PHP Code:

#include < amxmodx > 
#include < fun > 

new Float:g_fUseTime33 ];

const 
Float:g_fFreq 15.0

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


public 
client_connectid )
g_fUseTimeid ] = 0.0;

@
HealMeid 

    new 
Float:fTime get_gametime( ); 
     
    if( 
fTime >= g_fUseTimeid ] ) 
    { 
        
g_fUseTimeid ] = fTime g_fFreq
         
        
set_user_healthidget_user_healthid ) + 15 ); 
    } 
     
    else 
    { 
        
client_printidprint_center"You have to wait %d seconds until you can use this again."floatroundg_fUseTimeid ] - fTime ) ); 
    } 
     
    return 
PLUGIN_HANDLED


Happy now?


All times are GMT -4. The time now is 12:37.

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