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

[ZP] Countdown


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
strangeguy
Senior Member
Join Date: Mar 2019
Old 12-08-2019 , 08:22   [ZP] Countdown
Reply With Quote #1

Hi!
I'm looking for this script countdown with different colors
strangeguy is offline
StarMpK
Member
Join Date: Feb 2014
Location: Romania , Cluj
Old 12-08-2019 , 22:05   Re: [ZP] Countdown
Reply With Quote #2

hi , try this one.
for working properly put "zp_delay 18" in your zp config

/*============================================ ====================================
-----------------------------------
-*- [ZP] Extra Addon: Countdown -*-
-----------------------------------

~~~~~~~~~~~~~~~
- Description -
~~~~~~~~~~~~~~~

This will countdown until someone will turn into zombie.

~~~~~~~~~~~~~~~
- To do list! -
~~~~~~~~~~~~~~~

Go to zombieplague.cfg and find zp_delay 10 change to zp_delay 15.
( cstrike / addons / amxmodx / configs / zombieplague.cfg )

~~~~~~~~~~~~~~~
- Changelog -
~~~~~~~~~~~~~~~

- Version: 1.0 (April 1 2012)
* Public release.

============================================= ===================================*/

#include <amxmodx>
#include <amxmisc>
#include <dhudmessage>

/*============================================ ====================================
[Defines]
============================================= ====================================*/

#define PLUGIN "[ZP] Extra Addon: Countdown"
#define VERSION "1.0"
#define AUTHOR "MercedeS"

/*============================================ ====================================
[Plugin init]
============================================= ====================================*/

public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)

register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
}

/*============================================ ====================================
[Precaches]
============================================= ====================================*/

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

/*============================================ ====================================
[Round start event]
============================================= ====================================*/

public event_round_start()
{
set_task(5.0, "countdown")
}

/*============================================ ====================================
[Countdown]
============================================= ====================================*/

public countdown()
{
set_task(1.0, "ten")
set_task(2.0, "nine")
set_task(3.0, "eight")
set_task(4.0, "seven")
set_task(5.0, "six")
set_task(6.0, "five")
set_task(7.0, "four")
set_task(8.0, "three")
set_task(9.0, "two")
set_task(10.0, "one")
set_task(11.0, "zero")
}

public ten()
{
set_hudmessage(0, 180, 255, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10)
show_hudmessage(0, "-= 10 =-^n[**********]")
client_cmd(0, "spk zombie_plague/10")
}

public nine()
{
set_hudmessage(0, 180, 255, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10)
show_hudmessage(0, "-= 9 =-^n[*********]")
client_cmd(0, "spk zombie_plague/9")
}

public eight()
{
set_hudmessage(0, 180, 255, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10)
show_hudmessage(0, "-= 8 =-^n[********]")
client_cmd(0, "spk zombie_plague/8")
}

public seven()
{
set_hudmessage(0, 180, 255, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10)
show_hudmessage(0, "-= 7 =-^n[*******]")
client_cmd(0, "spk zombie_plague/7")
}

public six()
{
set_hudmessage(0, 180, 255, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10)
show_hudmessage(0, "-= 6 =-^n[******]")
client_cmd(0, "spk zombie_plague/6")
}

public five()
{
set_hudmessage(0, 180, 255, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10)
show_hudmessage(0, "-= 5 =-^n[*****]")
client_cmd(0, "spk zombie_plague/5")
}

public four()
{
set_hudmessage(0, 180, 255, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10)
show_hudmessage(0, "-= 4 =-^n[****]")
client_cmd(0, "spk zombie_plague/4")
}

public three()
{
set_hudmessage(0, 180, 255, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10)
show_hudmessage(0, "-= 3 =-^n[***]")
client_cmd(0, "spk zombie_plague/3")
}

public two()
{
set_hudmessage(255, 180, 0, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10)
show_hudmessage(0, "-= 2 =-^n[**]")
client_cmd(0, "spk zombie_plague/2")
}

public one()
{
set_hudmessage(255, 50, 0, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10)
show_hudmessage(0, "-= 1 =-^n[*]")
client_cmd(0, "spk zombie_plague/1")
}


public zero()
{
set_hudmessage(255, 0, 0, -1.0, 0.28, 2, 0.02, 3.0, 0.01, 0.1, 10)
show_hudmessage(0, "Humans get Ready !^nThe Fight Starts Now!")
client_cmd(0, "spk zombie_plague/0")
}

/*============================================ ====================================
END
============================================= ====================================*/

Last edited by StarMpK; 12-08-2019 at 22:06.
StarMpK is offline
thEsp
BANNED
Join Date: Aug 2017
Old 12-09-2019 , 10:56   Re: [ZP] Countdown
Reply With Quote #3

Quote:
Version: 1.0 (April 1 2012)
Explains everything .
thEsp is offline
strangeguy
Senior Member
Join Date: Mar 2019
Old 12-09-2019 , 13:24   Re: [ZP] Countdown
Reply With Quote #4

Quote:
Originally Posted by StarMpK View Post
hi , try this one.
for working properly put "zp_delay 18" in your zp config

/*============================================ ====================================
-----------------------------------
-*- [ZP] Extra Addon: Countdown -*-
-----------------------------------

~~~~~~~~~~~~~~~
- Description -
~~~~~~~~~~~~~~~

This will countdown until someone will turn into zombie.

~~~~~~~~~~~~~~~
- To do list! -
~~~~~~~~~~~~~~~

Go to zombieplague.cfg and find zp_delay 10 change to zp_delay 15.
( cstrike / addons / amxmodx / configs / zombieplague.cfg )

~~~~~~~~~~~~~~~
- Changelog -
~~~~~~~~~~~~~~~

- Version: 1.0 (April 1 2012)
* Public release.

============================================= ===================================*/

#include <amxmodx>
#include <amxmisc>
#include <dhudmessage>

/*============================================ ====================================
[Defines]
============================================= ====================================*/

#define PLUGIN "[ZP] Extra Addon: Countdown"
#define VERSION "1.0"
#define AUTHOR "MercedeS"

/*============================================ ====================================
[Plugin init]
============================================= ====================================*/

public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)

register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
}

/*============================================ ====================================
[Precaches]
============================================= ====================================*/

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

/*============================================ ====================================
[Round start event]
============================================= ====================================*/

public event_round_start()
{
set_task(5.0, "countdown")
}

/*============================================ ====================================
[Countdown]
============================================= ====================================*/

public countdown()
{
set_task(1.0, "ten")
set_task(2.0, "nine")
set_task(3.0, "eight")
set_task(4.0, "seven")
set_task(5.0, "six")
set_task(6.0, "five")
set_task(7.0, "four")
set_task(8.0, "three")
set_task(9.0, "two")
set_task(10.0, "one")
set_task(11.0, "zero")
}

public ten()
{
set_hudmessage(0, 180, 255, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10)
show_hudmessage(0, "-= 10 =-^n[**********]")
client_cmd(0, "spk zombie_plague/10")
}

public nine()
{
set_hudmessage(0, 180, 255, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10)
show_hudmessage(0, "-= 9 =-^n[*********]")
client_cmd(0, "spk zombie_plague/9")
}

public eight()
{
set_hudmessage(0, 180, 255, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10)
show_hudmessage(0, "-= 8 =-^n[********]")
client_cmd(0, "spk zombie_plague/8")
}

public seven()
{
set_hudmessage(0, 180, 255, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10)
show_hudmessage(0, "-= 7 =-^n[*******]")
client_cmd(0, "spk zombie_plague/7")
}

public six()
{
set_hudmessage(0, 180, 255, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10)
show_hudmessage(0, "-= 6 =-^n[******]")
client_cmd(0, "spk zombie_plague/6")
}

public five()
{
set_hudmessage(0, 180, 255, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10)
show_hudmessage(0, "-= 5 =-^n[*****]")
client_cmd(0, "spk zombie_plague/5")
}

public four()
{
set_hudmessage(0, 180, 255, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10)
show_hudmessage(0, "-= 4 =-^n[****]")
client_cmd(0, "spk zombie_plague/4")
}

public three()
{
set_hudmessage(0, 180, 255, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10)
show_hudmessage(0, "-= 3 =-^n[***]")
client_cmd(0, "spk zombie_plague/3")
}

public two()
{
set_hudmessage(255, 180, 0, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10)
show_hudmessage(0, "-= 2 =-^n[**]")
client_cmd(0, "spk zombie_plague/2")
}

public one()
{
set_hudmessage(255, 50, 0, -1.0, 0.28, 2, 0.02, 1.0, 0.01, 0.1, 10)
show_hudmessage(0, "-= 1 =-^n[*]")
client_cmd(0, "spk zombie_plague/1")
}


public zero()
{
set_hudmessage(255, 0, 0, -1.0, 0.28, 2, 0.02, 3.0, 0.01, 0.1, 10)
show_hudmessage(0, "Humans get Ready !^nThe Fight Starts Now!")
client_cmd(0, "spk zombie_plague/0")
}

/*============================================ ====================================
END
============================================= ====================================*/
Thank you <3
strangeguy is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-09-2019 , 14:15   Re: [ZP] Countdown
Reply With Quote #5

@StarMpK - for the good of all of us, put codes in [php] or [code] tags.

@strangeguy - the code provided is terrible and you should not use it. The same thing can be achieved with 90% less lines and much better structure.

Use a single repeating "set_task" with a global variable for the counter that is reduced every second, put the sounds in a list and use the same name as the current countdown number to avoid redundant code.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Watermelonnable
Member
Join Date: Feb 2017
Old 12-10-2019 , 07:47   Re: [ZP] Countdown
Reply With Quote #6

I improved the code based on OciXCrom comment. It compiled fine but I didn't test it.

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Plugin Name"
#define VERSION "1.0"
#define AUTHOR "Plugin Author"

new g_CurrentSecond;

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

public 
plugin_precache() 
{
    new 
precacheString[32];

    for (new 
011i++) {
        
formatex(precacheStringcharsmax(precacheString), "zombie_plague/%d.wav"i);
        
precache_sound(precacheString);
    }
}

public 
event_round_start() 
{
    
set_task(5.0"Countdown");
}

public 
Countdown() 
{
    
set_task(1.0"RealCountdown"0""0"a"11);
}

public 
RealCountdown()
{
    new 
hudMessage[32];
    new 
playSoundString[32];
    
formatex(hudMessagecharsmax(hudMessage), "-= %d =-^n[**********]"g_CurrentSecond);
    
formatex(playSoundStringcharsmax(playSoundString), "spk zombie_plague/%d"g_CurrentSecond);
    
set_hudmessage(0180255, -1.00.2820.021.00.010.110);
    
show_hudmessage(0hudMessage);
    
client_cmd(0playSoundString);
    
g_CurrentSecond--;


Last edited by Watermelonnable; 12-10-2019 at 07:48.
Watermelonnable is offline
StarMpK
Member
Join Date: Feb 2014
Location: Romania , Cluj
Old 12-10-2019 , 07:53   Re: [ZP] Countdown
Reply With Quote #7

Yeah well you forgot to make the last hud message to last 3 seconds

Last edited by StarMpK; 12-10-2019 at 07:54.
StarMpK is offline
Watermelonnable
Member
Join Date: Feb 2017
Old 12-10-2019 , 10:19   Re: [ZP] Countdown
Reply With Quote #8

Quote:
Originally Posted by StarMpK View Post
Yeah well you forgot to make the last hud message to last 3 seconds
Try this one:

PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Plugin Name"
#define VERSION "1.0"
#define AUTHOR "Plugin Author"

new g_CurrentSecond;

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

public 
plugin_precache() 
{
    new 
precacheString[32];

    for (new 
011i++) {
        
formatex(precacheStringcharsmax(precacheString), "zombie_plague/%d.wav"i);
        
precache_sound(precacheString);
    }
}

public 
event_round_start() 
{
    
set_task(5.0"Countdown");
}

public 
Countdown() 
{
    
set_task(1.0"RealCountdown"0""0"a"11);
}

public 
RealCountdown()
{
    new 
hudMessage[32];
    new 
playSoundString[32];

    if (
g_CurrentSecond == 0) {
       
formatex(hudMessagecharsmax(hudMessage), "Humans get Ready !^nThe Fight Starts Now!"); 
       
set_hudmessage(25500, -1.00.2820.023.00.010.110);
    } else {
        
formatex(hudMessagecharsmax(hudMessage), "-= %d =-^n[**********]"g_CurrentSecond);
        
set_hudmessage(0180255, -1.00.2820.021.00.010.110);
    }
    
    
formatex(playSoundStringcharsmax(playSoundString), "spk zombie_plague/%d"g_CurrentSecond);
    
client_cmd(0playSoundString);
    
show_hudmessage(0hudMessage);
    
g_CurrentSecond--;


Last edited by Watermelonnable; 12-10-2019 at 10:19.
Watermelonnable is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 12-10-2019 , 13:53   Re: [ZP] Countdown
Reply With Quote #9

@StarMpK - nobody really said that the last one should be 3 seconds.

@Watermelonnable - the "HLTV" event is called when the freeze time starts, so if the server has freeze time, the countdown will start at a wrong time. I assume it starts 5 seconds after round start, so you should use:

Code:
register_logevent("event_round_start", 2, "1=Round_Start")

Furthermore, you are setting the timer to 10 when the plugin starts, you should do it when the round starts instead.

Also, a small optimization - you don't need the "hudMessage" and "playSoundString" variables, you can format the strings directly in "show_hudmessage" and "client_cmd" - they use the same arguments as "formatex".

PS: "amxmisc" is not needed.

@strangeguy - if you're looking for a full plugin, you should use the Plugin Request section. This section here is for learning to code. So, if you're willing to learn - you should go ahead and do the changes I mentioned above. Also, the code above doesn't feature random colors, so try and do that as well - it's pretty simple.
__________________

Last edited by OciXCrom; 12-10-2019 at 13:55.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Watermelonnable
Member
Join Date: Feb 2017
Old 12-10-2019 , 19:58   Re: [ZP] Countdown
Reply With Quote #10

Quote:
Originally Posted by OciXCrom View Post
@StarMpK - nobody really said that the last one should be 3 seconds.

@Watermelonnable - the "HLTV" event is called when the freeze time starts, so if the server has freeze time, the countdown will start at a wrong time. I assume it starts 5 seconds after round start, so you should use:

Code:
register_logevent("event_round_start", 2, "1=Round_Start")

Furthermore, you are setting the timer to 10 when the plugin starts, you should do it when the round starts instead.

Also, a small optimization - you don't need the "hudMessage" and "playSoundString" variables, you can format the strings directly in "show_hudmessage" and "client_cmd" - they use the same arguments as "formatex".

PS: "amxmisc" is not needed.

@strangeguy - if you're looking for a full plugin, you should use the Plugin Request section. This section here is for learning to code. So, if you're willing to learn - you should go ahead and do the changes I mentioned above. Also, the code above doesn't feature random colors, so try and do that as well - it's pretty simple.
Thank you for your feedback man! I'll keep those in mind for the future
Watermelonnable 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 05:34.


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