Raised This Month: $ Target: $400
 0% 

Timer


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
RuRuRu612754
Senior Member
Join Date: Sep 2011
Old 06-21-2012 , 21:16   Timer
Reply With Quote #1

Hello

i create the timer referring to the other scripts or manual
compile fail ...
where is problem?

best regards,

PHP Code:
#include <amxmodx>
#include <colorchat>
#include <hamsandwich>
#include <fakemeta>

new timer_time[33]

public 
plugin_init()
{
    
RegisterHam(Ham_Use"func_button""function_button"0)
}

public 
function_button(entid)
{
    new 
target[32]
    
pev(entpev_targettarget31)

    if(
equali(target"counter_start"))
    {
        
cmd_start_timer(id)
    }
    if(
equali(target"counter_off"))
    {
        
cmd_end_timer(id)
    }
}

public 
cmd_start_timer(id)
{
    
timer_time[id] = get_gametime()

    
ColorChat(idGREEN"^x04[Timer] ^x01Timer has start")
}

public 
cmd_end_timer(id)
{
    new 
time[32] = get_gametime() - timer_time[id]

    
cmd_finish(idtime)

    
ColorChat(idGREEN"^x04[Timer] ^x01Timer has end")
}

public 
cmd_finish(idFloat:time)
{
    new 
name[32]
    new 
user[32]

    
get_user_name(idname31)
    
get_user_authid(iduser31)

    new 
iminute floatround(time 60.0floatround_floor)
    new 
isecond floatround(time iminute 60.0floatround_floor)
    new 
imilisecond floatround((time - (iminute 60.0 isecond)) * 100.0floatround_floor)

    
ColorChat(idGREEN"^x04[Timer] %s (%s) finish in %i:%i.%i"nameuseriminuteisecondimilisecond)

RuRuRu612754 is offline
hornet
AMX Mod X Plugin Approver
Join Date: Mar 2010
Location: Australia
Old 06-21-2012 , 22:01   Re: Timer
Reply With Quote #2

For starters, time is really time() - a function that retrieves the time, therefore you can't use it as a variable name. You also have no reason to make that variable a 32 cell array - your only using it local to that function as a temporary value.
Also, get_gametime() returns a float so you can't assign that value to an integer variable.
__________________
Quote:
vBulletin Tip #42: Not much would be accomplished by merging this item with itself.

Last edited by hornet; 06-21-2012 at 22:02.
hornet is offline
RuRuRu612754
Senior Member
Join Date: Sep 2011
Old 06-21-2012 , 22:26   Re: Timer
Reply With Quote #3

@hornet

thanks for answer
to resolve it?
RuRuRu612754 is offline
GordonFreeman (RU)
Veteran Member
Join Date: Jan 2010
Location: Uzbekistan
Old 06-21-2012 , 22:34   Re: Timer
Reply With Quote #4

Code:
new time[32]

Code:
new Float:time

do not use array for it
__________________
The functional way is the right way
GordonFreeman (RU) is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-22-2012 , 01:14   Re: Timer
Reply With Quote #5

There are few things missing to detect more buttons, i suggest you install the attached plugin, and in your plugin just use the following code :

PHP Code:
#include <amxmodx>

#define Start 0
#define Stop 1

forward client_use_button(idiButtonType)

public 
plugin_init()
{

}

public 
client_use_button(idiButtonType)
{
    if( 
iButtonType == Stop )
    {
        
// stop timer here
    
}
    else
    {
        
// start timer here
    
}

Attached Files
File Type: sma Get Plugin or Get Source (kz_buttons.sma - 613 views - 6.9 KB)
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
RuRuRu612754
Senior Member
Join Date: Sep 2011
Old 06-22-2012 , 02:20   Re: Timer
Reply With Quote #6

@GordonFreeman (RU)
thanks for answer
i use ConnorMcLeod version
thanks for you

@ConnorMcLeod
thanks for answer
i use this
thanks for you

How do I become advanced developers like you do?
RuRuRu612754 is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 06-22-2012 , 10:58   Re: Timer
Reply With Quote #7

Loose few years of your time on this forum
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
kramesa
Veteran Member
Join Date: Feb 2011
Location: Brazil
Old 06-22-2012 , 11:11   Re: Timer
Reply With Quote #8

Quote:
Originally Posted by ConnorMcLeod View Post
Loose few years of your time on this forum
__________________
kramesa is offline
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 06:16.


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