AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] How i can stop the Roundtime clock? (https://forums.alliedmods.net/showthread.php?t=131847)

schirodes 07-09-2010 15:27

[HELP] How i can stop the Roundtime clock?
 
This is the question, sorry for my english :P, im from Argentina, and... it is posible? STOP the RoundTime Clock in the Round whit a command, and activated the clock again? Similar to pause.

Hunter-Digital 07-10-2010 07:29

Re: [HELP] How i can stop the Roundtime clock?
 
Yes and no.

Use set_task() or something to constantly set the roundtimer to your desired value... that won't block round-end stuff... like "target saved", or "hostages have not been saved".

You can't actually detect the timer's actual time... you can detect it's start time (by hooking the event) and calculate.

Something like this:

PHP Code:

#include <amxmodx>

new bool:g_bPaused false

new Float:g_fTimerStart

new gMsg_RoundTime

public plugin_init()
{
      
register_event("RoundTime""event_roundTime""a")
      
register_clcmd("test""cmd_test")
      
register_clcmd("pausetimer""cmd_pausetimer")

      
gMsg_RoundTime get_user_msgid("RoundTime")
}

public 
event_roundTime()
{
      
g_fTimerStart = (read_data(1) ? get_gametime() : 0.0)
}

public 
cmd_test(id)
{
      if(
g_fTimerStart)
             
client_print(0print_chat"[debug] timer at: %.1f"get_gametime() - g_fTimerStart)
      else
             
client_print(0print_chat"[debug] timer not started")
}

public 
cmd_pausetimer(id)
{
      if(
g_bPaused)
            
event_pauseTimer(00)
      else
            
event_pauseTimer(1floatround(get_gametime() - g_fTimerStart))

      
client_print(idprint_chat"timer %s"g_bPaused "unpaused" "paused")

      
g_bPaused = !g_bPaused
}

public 
event_pauseTimer(iPauseiAt)
{
      if(!
iPause)
      {
            
remove_task(1)
            return
      }

      static 
iPauseAt

      
if(iAt)
           
iPauseAt iAt

      message_begin
(MSG_ALLgMsg_RoundTime)
      
write_short(iPauseAt)
      
message_end()

      
set_task(0.8"event_pauseTimer"1/* don't set task to 0, you can set it to anything but 0.. even negative values */


Code NOT tested in-game, but compiles.


All times are GMT -4. The time now is 07:11.

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