AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Zombie Plague Mod (https://forums.alliedmods.net/forumdisplay.php?f=126)
-   -   Help / Support ZP Countdown (https://forums.alliedmods.net/showthread.php?t=341817)

notblade0299 02-13-2023 18:48

ZP Countdown
 
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.

JusTGo 02-14-2023 04:13

Re: ZP Countdown
 
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--



notblade0299 02-14-2023 05:56

Re: ZP Countdown
 
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);

metal_upa 02-14-2023 09:14

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

Sh0pke 03-14-2023 10:30

Re: ZP Countdown
 
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.


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

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