Raised This Month: $12 Target: $400
 3% 

Help / Support ZP Countdown


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
notblade0299
Junior Member
Join Date: Nov 2017
Old 02-13-2023 , 18:48   ZP Countdown
Reply With Quote #1

Hey
Code:
#include <amxmodx>
#include <amxmisc>
#include <dhudmessage>

#define PLUGIN "Countdown"
#define VERSION "1.0"
#define AUTHOR "MooxnS"

public plugin_init()
{
	register_plugin(PLUGIN, VERSION, AUTHOR)	
	register_event("HLTV", "event_round_start", "a", "1=0", "2=0") 
}

public plugin_precache()
{
	precache_sound("zombie_plague/countdown/start.wav")
	precache_sound("zombie_plague/countdown/20secs.wav")
	precache_sound("zombie_plague/countdown/10.wav")
	precache_sound("zombie_plague/countdown/9.wav")
	precache_sound("zombie_plague/countdown/8.wav")
	precache_sound("zombie_plague/countdown/7.wav")
	precache_sound("zombie_plague/countdown/6.wav")
	precache_sound("zombie_plague/countdown/5.wav")
	precache_sound("zombie_plague/countdown/4.wav")
	precache_sound("zombie_plague/countdown/3.wav")
	precache_sound("zombie_plague/countdown/2.wav")
	precache_sound("zombie_plague/countdown/1.wav")
}

// SetEvents
public event_round_start()
{
	set_task(1.0, "roundmusic")
	set_task(3.0, "countdown")
}

// StartTasks
public roundmusic()
{
	set_task(1.0, "zero")
}

public countdown()
{
	set_task(1.0, "twenty")
	set_task(2.0, "nineteen")
	set_task(3.0, "eighteen")
	set_task(4.0, "seventeen")
	set_task(5.0, "fifteen")
	set_task(6.0, "fourteen")
	set_task(7.0, "thirteen")
	set_task(8.0, "twelve")
	set_task(9.0, "eleven")
	set_task(10.0, "ten")
	set_task(11.0, "nine")
	set_task(12.0, "eight")
	set_task(13.0, "seven")
	set_task(14.0, "six")
	set_task(15.0, "five")
	set_task(16.0, "four")
	set_task(17.0, "three")
	set_task(18.0, "two")
	set_task(19.0, "one")
}

public zero()
{
	client_cmd(0, "spk zombie_plague/countdown/start")
}

public twenty()
{
	client_print(0, print_center, "Infection starts in: 20")
	client_cmd(0, "spk zombie_plague/countdown/20secs")
}

public nineteen()
{
	client_print(0, print_center, "Infection starts in: 19")
}

public eighteen()
{
	client_print(0, print_center, "Infection starts in: 18")
}

public seventeen()
{
	client_print(0, print_center, "Infection starts in: 17")
}

public sixteen()
{
	client_print(0, print_center, "Infection starts in: 16")
}

public fifteen()
{
	client_print(0, print_center, "Infection starts in: 15")
}

public fourteen()
{
	client_print(0, print_center, "Infection starts in: 14")
}

public thirteen()
{
	client_print(0, print_center, "Infection starts in: 13")
}

public twelve()
{
	client_print(0, print_center, "Infection starts in: 12")
}

public eleven()
{
	client_print(0, print_center, "Infection starts in: 11")
}

public ten()
{
	client_print(0, print_center, "Infection starts in: 10")
	client_cmd(0, "spk zombie_plague/countdown/10")
}

public nine()
{
	client_print(0, print_center, "Infection starts in: 9")
	client_cmd(0, "spk zombie_plague/countdown/9")
}

public eight()
{
	client_print(0, print_center, "Infection starts in: 8")
	client_cmd(0, "spk zombie_plague/countdown/8")
}

public seven()
{
	client_print(0, print_center, "Infection starts in: 7")
	client_cmd(0, "spk zombie_plague/countdown/7")
}

public six()
{
	client_print(0, print_center, "Infection starts in: 6")
	client_cmd(0, "spk zombie_plague/countdown/6")
}

public five()
{
	client_print(0, print_center, "Infection starts in: 5")
	client_cmd(0, "spk zombie_plague/countdown/5")
}

public four()
{
	client_print(0, print_center, "Infection starts in: 4")
	client_cmd(0, "spk zombie_plague/countdown/4")
}

public three()
{
	client_print(0, print_center, "Infection starts in: 3")
	client_cmd(0, "spk zombie_plague/countdown/3")
}

public two()
{
	client_print(0, print_center, "Infection starts in: 2")
	client_cmd(0, "spk zombie_plague/countdown/2")
}

public one()
{
	client_print(0, print_center, "Infection starts in: 1")
	client_cmd(0, "spk zombie_plague/countdown/1")
}
Can anyone shorten the code, make it more efficient, and also check for an roundEnd.
I have an autorestart on map_change so when it does it overlaps with 2 tasks, making annoying double sounds.
notblade0299 is offline
JusTGo
Veteran Member
Join Date: Mar 2013
Old 02-14-2023 , 04:13   Re: ZP Countdown
Reply With Quote #2

Try this:

PHP Code:
#include <amxmodx>

#define PLUGIN "Countdown"
#define VERSION "1.0"
#define AUTHOR "MooxnS"

#define TASK_COUNTDOWN 458496
new g_iCountdown

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)    
    
register_event("HLTV""event_round_start""a""1=0""2=0"
}

public 
plugin_precache()
{
    
precache_sound("zombie_plague/countdown/start.wav")
    
precache_sound("zombie_plague/countdown/20secs.wav")
    
precache_sound("zombie_plague/countdown/10.wav")
    
precache_sound("zombie_plague/countdown/9.wav")
    
precache_sound("zombie_plague/countdown/8.wav")
    
precache_sound("zombie_plague/countdown/7.wav")
    
precache_sound("zombie_plague/countdown/6.wav")
    
precache_sound("zombie_plague/countdown/5.wav")
    
precache_sound("zombie_plague/countdown/4.wav")
    
precache_sound("zombie_plague/countdown/3.wav")
    
precache_sound("zombie_plague/countdown/2.wav")
    
precache_sound("zombie_plague/countdown/1.wav")
}

// SetEvents
public event_round_start()
{
    
remove_task(TASK_COUNTDOWN)
    
g_iCountdown 24
    set_task
(1.0"OnCountdown"TASK_COUNTDOWN__"b")
}

public 
OnCountdown() {
    if(
g_iCountdown == 22) {
        
client_cmd(0"spk zombie_plague/countdown/start")
    }
    else if(
g_iCountdown <= 20) {
        
client_print(0print_center"Infection starts in: %d"g_iCountdown)

        if(
g_iCountdown == 20) {
            
client_cmd(0"spk zombie_plague/countdown/20secs")
        } else if(
g_iCountdown <= 10){
            
client_cmd(0"spk zombie_plague/countdown/%d"g_iCountdown)

            if(
g_iCountdown == 1) {
                
remove_task(TASK_COUNTDOWN)
            }
        }
    }

    
g_iCountdown--

__________________

Last edited by JusTGo; 02-14-2023 at 04:15.
JusTGo is offline
notblade0299
Junior Member
Join Date: Nov 2017
Old 02-14-2023 , 05:56   Re: ZP Countdown
Reply With Quote #3

set_task(1.0, "OnCountdown", TASK_COUNTDOWN, _, _, "b")

"TASK_COUNTDOWN, _, _, "b")" what does this part mean? (trying to learn)

native set_task(Float:time, const function[], id = 0, const any:parameter[] = "", len = 0, const flags[] = "", repeat = 0);
notblade0299 is offline
metal_upa
Senior Member
Join Date: Jun 2016
Old 02-14-2023 , 09:14   Re: ZP Countdown
Reply With Quote #4

Try this, i believe it has no duplicate countdown anymore. You need to set at least mp_freezetime 1.0 or 2.0
Spoiler

Last edited by metal_upa; 02-14-2023 at 09:22.
metal_upa is offline
Sh0pke
Junior Member
Join Date: Oct 2017
Location: Republic of Serbia
Old 03-14-2023 , 10:30   Re: ZP Countdown
Reply With Quote #5

https://forums.alliedmods.net/showthread.php?t=340213

Check out my plugin it has everything you need and even more. There's 2 versions of the plugin if you want the simple one.
__________________
INFECTION
COUNTDOWN MANAGER

The best countdown plugin for every zombie mod!
DOWNLOAD
Sh0pke is offline
Send a message via ICQ to Sh0pke Send a message via AIM to Sh0pke Send a message via Yahoo to Sh0pke Send a message via Skype™ to Sh0pke
Reply


Thread Tools
Display Modes

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 08:12.


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