AlliedModders

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

Ex1ne 12-11-2011 06:02

HUD Countdown
 
Hey, i made a vipmenu plugin for my server, and i have a question.
On the menu, there is a "Noclip for 10 seconds [CT]" option.
How can i make it count down? Preferably via HUD.

If you need, here is everything that has anything to do with the noclip option.
Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <cstrike>
#include <hamsandwich>
#include <fun>
#include <colorchat>

new bool:NoclipUsed[33];

new const prefix[] = "^4[.Mp3 VIP] ~ ^3"

new szName[33], szPlayerName[33]

public plugin_init()
{
        register_plugin("Jailbreak VIP", "0.9", "Ex1ne")
       
        register_clcmd("say /vipmenu", "CmdVipMenu")
        register_clcmd("say /vm", "CmdVipMenu")
        register_clcmd("say_team /vipmenu", "CmdVipMenu")
        register_clcmd("say_team /vm", "CmdVipMenu")
        RegisterHam(Ham_Spawn, "player", "fw_spawn_player", 1)
}
public CmdVipMenu(id)
{
        if(!(get_user_flags(id) & ADMIN_LEVEL_H))
        {
                ColorChat(id, GREY, "%s Only^4 VIPs^3 can open this menu.", prefix)
                return PLUGIN_HANDLED
        }
        if(!is_user_alive(id)) //Thank's Larcyn <3
        {
                ColorChat(id, GREY, "%s You need to be alive to open this menu.", prefix)
                return PLUGIN_HANDLED
        }
        new szText[555 char]
        formatex(szText, charsmax(szText), "\y.Mp3 JB VIP Menu!")
        new VipMenu = menu_create(szText, "VipMenuHandle")
        formatex(szText, charsmax(szText), "\rGive yourself Noclip for 10 seconds! \y[CT]")
        menu_additem(VipMenu, szText, "4", 0)

***menu handle blabla***
                case 4: HandleNoclip(id)

***HANDLE***
public HandleNoclip(id)
{
        if(!is_user_alive(id))
        {
                ColorChat(id, GREY, "%s You need to be alive to use this!", prefix)
                return PLUGIN_HANDLED
        }
        if (get_user_team(id) != 2)
        {
                ColorChat(id, GREY, "%s Only Counter-Terrorists can use noclip!", prefix)
                return PLUGIN_HANDLED
        }
        if(NoclipUsed[id] == true)
        {
                ColorChat(id, GREY, "%s You have allready used your Noclip!", prefix)
                return PLUGIN_HANDLED
        }
        set_task(10.0, "RemoveNoclip", id)
        ColorChat(0, GREY, "%s ^4%s^3 Now has noclip for 10 seconds!", prefix, szName)
        set_user_noclip(id, 1)
        NoclipUsed[id] = true
        return PLUGIN_CONTINUE
}
public RemoveNoclip(id)
{
        set_user_noclip(id, 0)
        ColorChat(id, GREY, "%s You no longer have noclip.", prefix)
}


Kidev 12-11-2011 07:59

Re: HUD Countdown
 
Create a task to 1.0 and create a global array specific to each player (countDown[ 33 ] for example). Set the variable to 10, lauch the task and each time it's called, decrement countDown[ id ]. Then, if countDown[ id ] = 0, remove the task and the noclip.
To show the countdown, you just have to show countDown[ id ].

Devil259 12-11-2011 11:53

Re: HUD Countdown
 
Code:
#include <amxmodx> #define TASKID  1996 #define SECONDS 10 new iSeconds public plugin_init() {     register_plugin( "Countdown Example", "1.0", "Wrecked" )         register_logevent( "LogEventRoundStart", 2, "1=Round_Start" ) } public LogEventRoundStart() {     if( task_exists( TASKID ) )         remove_task( TASKID )             iSeconds = SECONDS     set_task( 1.0, "TaskShowCountdown", TASKID, _, _, "a", SECONDS ) } public TaskShowCountdown() {     set_hudmessage( 120, 120, 120, 0.50, 0.50, 0, 0.1, 0.8, 0.1, 0.1, -1 )     show_hudmessage( 0, "Seconds Remaining: %i", iSeconds-- ) }


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

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