Raised This Month: $ Target: $400
 0% 

HUD Countdown


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ex1ne
Senior Member
Join Date: Oct 2011
Location: Norway
Old 12-11-2011 , 06:02   HUD Countdown
Reply With Quote #1

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)
}
Ex1ne is offline
Kidev
Veteran Member
Join Date: Jun 2010
Location: France
Old 12-11-2011 , 07:59   Re: HUD Countdown
Reply With Quote #2

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 ].
__________________
Kidev is offline
Devil259
Veteran Member
Join Date: Dec 2009
Location: France (59)
Old 12-11-2011 , 11:53   Re: HUD Countdown
Reply With Quote #3

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-- ) }
__________________
You can do anything you set your mind to, man.

Devil259 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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