Half-Life и Adrenaline Gamer форум
http://aghl.ru/forum/

[HELP] CountDown speed !
http://aghl.ru/forum/viewtopic.php?f=12&t=2421
Страница 1 из 1

Автор:  abdobiskra [ 01 апр 2016, 18:46 ]
Заголовок сообщения:  [HELP] CountDown speed !

Hello I'm having a problem in the countdown when using this function numbers go down very quickly
is there a problem ?

Код:
public count(id)
{
     static count[33]
     if (!count[id])
     {
          count[id] = 60
     }

     set_hudmessage(255, 0, 0, 0.36.0, 0.24, 0, 6.0, 12.0)
     show_hudmessage(id, "You have time %d", count[id])
     
     count[id]--
     set_task(1.0, "count", id)
}

Автор:  Lev [ 01 апр 2016, 20:09 ]
Заголовок сообщения:  Re: [HELP] CountDown speed !

Check all set_task's in your plugin that they are using different "id"'s for different tasks.

Автор:  abdobiskra [ 02 апр 2016, 18:29 ]
Заголовок сообщения:  Re: [HELP] CountDown speed !

Yeah !
Now I want to stop time, what should I do for it?
Код:
new g_HudSyncObj

public plugin_init() {
   register_plugin(PLUGIN, VERSION, AUTHOR)
   register_clcmd("say /hud", "count")   
   g_HudSyncObj = CreateHudSyncObj()
   // Add your code here...
}
public count(id)
{

     static count[33]
     
     if (!count[id])
     {
          count[id] = 10
     }

     set_hudmessage(255, 255, 0, -1.0, 0.25, 2, 0.1, 2.0, 0.01, 2.0, 3)
     ShowSyncHudMsg(id, g_HudSyncObj, "You have time %d", count[id])
     
     if (count[id] == 0)
     {
         set_hudmessage(255, 255, 0, -1.0, 0.25, 2, 0.1, 2.0, 0.01, 2.0, 3)
          ShowSyncHudMsg(id, g_HudSyncObj, "")
    return
     }
     count[id]--
     set_task(1.0, "count", id)
}

Автор:  Kuma77 [ 02 апр 2016, 18:42 ]
Заголовок сообщения:  Re: [HELP] CountDown speed !

if you want stop timer at 0 just catch the counter when its 0 sec and return PLUGIN_HANDLED, or reset task to 0.0 .
just like this
Код:
if (count[id] == 0)
     {
         set_hudmessage(255, 255, 0, -1.0, 0.25, 2, 0.1, 2.0, 0.01, 2.0, 3)
         ShowSyncHudMsg(id, g_HudSyncObj, "")
         set_task(0.0, "count", id) // i am not sure about that
         return PLUGIN_HANDLED
     }


btw , use other method to count your time !!!!!

Автор:  abdobiskra [ 02 апр 2016, 19:07 ]
Заголовок сообщения:  Re: [HELP] CountDown speed !

Kuma77

remain the same problem?

Автор:  Lev [ 02 апр 2016, 19:51 ]
Заголовок сообщения:  Re: [HELP] CountDown speed !

abdobiskra
In your case to stop repeating the task just do bypass set_task.
To stop already scheduled task you can use remove_task.

Your logic is wrong here:
Код:
     if (count[id] == 0)
     {
         set_hudmessage(255, 255, 0, -1.0, 0.25, 2, 0.1, 2.0, 0.01, 2.0, 3)
          ShowSyncHudMsg(id, g_HudSyncObj, "")
    return
     }
     count[id]--
You should decrease first.
Код:
     count[id]--
     if (count[id] == 0)
     {
         set_hudmessage(255, 255, 0, -1.0, 0.25, 2, 0.1, 2.0, 0.01, 2.0, 3)
          ShowSyncHudMsg(id, g_HudSyncObj, "")
    return
     }
Or something like that. Because in your current code after decreasing to zero you schedule task again and it sets counter to 10 because it is 0.

Автор:  abdobiskra [ 02 апр 2016, 21:42 ]
Заголовок сообщения:  Re: [HELP] CountDown speed !

Цитата:
To stop already scheduled task you can use remove_task.

Yeah i forget this :good:

Страница 1 из 1 Часовой пояс: UTC + 5 часов [ Летнее время ]
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/