AlliedModders

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

krysteksulek 11-04-2013 20:21

Countdown plugin
 
Hi.
I want to do simple plugin, which will show hudmessage with timer.
I have this code:

Code:

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

#define TASKK 3481

new timer[33]

public plugin_init()
{
    register_plugin(PLUGIN, VERSION, AUTHOR)
    register_clcmd("say /test", "times");
}
public times(id)
{   
    client_print(id, print_chat, "Starting...");
    timer[id] = 30
   
    if(task_exists(id + TASKK))
    {
        remove_task( id + TASKK )
    }
    set_task( 10.0, "count", id + TASKK, _, _, "b" )
   
    return PLUGIN_CONTINUE
}
public count(task_id)
{
    new id = task_id - TASKK
 
    set_hudmessage(255, 255, 255, 0.03, 0.3, 0, 6.0, 60.0)
    show_hudmessage( id, "You have just: %d minutes", timer[id] )
   
    timer[id] -= 1
   
    if(timer[id] <= 0)
    {
        if( task_exists(task_id) )
        {
            remove_task( task_id )
        }
    }
}

}

I don't know how to show hudmessage at once by type cmd /test. Now it appear's after 60 sec.
A i want to ask if show_hudmessage( 0, not 'id', will be better. If yes - how to write it with task id?
And how to not dissapear HUD when for example: client will die or respawn.

I hope you will help.


All times are GMT -4. The time now is 23:17.

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