AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Timer (https://forums.alliedmods.net/showthread.php?t=188069)

RuRuRu612754 06-21-2012 21:16

Timer
 
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)



hornet 06-21-2012 22:01

Re: Timer
 
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.

RuRuRu612754 06-21-2012 22:26

Re: Timer
 
@hornet

thanks for answer
to resolve it?

GordonFreeman (RU) 06-21-2012 22:34

Re: Timer
 
Code:
new time[32]
:arrow:
Code:
new Float:time

do not use array for it

ConnorMcLeod 06-22-2012 01:14

Re: Timer
 
1 Attachment(s)
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
    
}



RuRuRu612754 06-22-2012 02:20

Re: Timer
 
@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?

ConnorMcLeod 06-22-2012 10:58

Re: Timer
 
Loose few years of your time on this forum

kramesa 06-22-2012 11:11

Re: Timer
 
Quote:

Originally Posted by ConnorMcLeod (Post 1733842)
Loose few years of your time on this forum

:3


All times are GMT -4. The time now is 06:16.

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