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

Count


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Intouchable
Senior Member
Join Date: Mar 2012
Old 03-20-2012 , 09:05   Count
Reply With Quote #1

How to do to count with hud like this 5, 4, 3, 2, 1?
Intouchable is offline
killergirl
Senior Member
Join Date: Jul 2010
Old 03-20-2012 , 09:20   Re: Count
Reply With Quote #2

PHP Code:
new count

public plugin_init(){
    
//
    
set_task(1.0"count"___"b")
}

public 
count(){
    
set_hudmessage(25500, -1.0, -1.006.012.0)
    
show_hudmessage(0"%d"count)
    
    
count++


Last edited by killergirl; 03-20-2012 at 09:20.
killergirl is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-20-2012 , 09:35   Re: Count
Reply With Quote #3

1. Variables and functions cannot have the same names.
2. Yours counts up and his example is down.
3. Looping repeatedly doesn't show him how to have a max.

Code:
#define TASK_ID_COUNTDOWN 1234 #define StopCountDown() remove_task(TASK_ID_COUNTDOWN) new gCountDownSeconds; StartCountDown(seconds) {     StopCountDown();         gCountDownSeconds = seconds;         set_task(1.0, "TaskCountDown", TASK_ID_COUNTDOWN, _, _, "a", seconds); } public TaskCountDown() {     set_hudmessage(.holdtime = 1.1);     show_hudmessage(0, "CountDown: %d", gCountDownSeconds);         gCountDownSeconds--; }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Intouchable
Senior Member
Join Date: Mar 2012
Old 03-20-2012 , 12:21   Re: Count
Reply With Quote #4

Then how to do on this code?? To be perfectly
PHP Code:
new screen[33]
new 
msg_screenfade
new hud_sync
new count

new sound[][] = {
    
"five.wav",
    
"four.wav",
    
"three.wav",
    
"two.wav",
    
"one.wav",
    
""
}

public 
plugin_precache() for(new i=0i<5i++) precache_sound(sound[i])

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("HLTV""event_round_start""a""1=0""2=0")
    
RegisterHam(Ham_Spawn"player""player_spawn"1)
    
msg_screenfade get_user_msgid("ScreenFade")
    
hud_sync CreateHudSyncObj()
}

public 
event_round_start(id
{
    
count 0;
    
arrayset(screen033);

    
set_task(1.0"task_out"0__"a"5); 
}
    
public 
player_spawn(id
{
    if(!
screen[id] && get_user_team(id) == 1
    {
        
message_begin(MSG_ONEmsg_screenfade_id)
        
write_short(5// duration
        
write_short(6// hold time
        
write_short(FFADE_STAYOUT// fade type
        
write_byte(0// red
        
write_byte(0// green
        
write_byte(0// blue
        
write_byte(255// alpha
        
message_end()
        
        
client_cmd(id"spk /sound/%s"sound[0])
        
        
set_hudmessage(02550, -1.00.4006.05.0)
        
        
ShowSyncHudMsg(idhud_sync"%d"count)
        
entity_set_int(idEV_INT_flagsentity_get_int(idEV_INT_flags) | FL_FROZEN)
    }
    
screen[id] = true
}
        
    
public 
task_out() 
{
    static 
i
    count
++
    
    new 
players[32], num
    get_players
(playersnum"eh""TERRORIST"
    
    for(
i=0i<numi++) client_cmd(players[i], "spk /sound/%s"sound[count])

    if(
count == 5
    {
        for(
i=0i<numi++) 
        {
            
message_begin(MSG_ONEmsg_screenfade_players[i])
            
write_short((1<<12)) // duration
            
write_short(0// hold time
            
write_short(FFADE_OUT// fade type
            
write_byte(0// red
            
write_byte(0// green
            
write_byte(0// blue
            
write_byte(255// alpha
            
message_end()
            
entity_set_int(players[i], EV_INT_flagsentity_get_int(players[i], EV_INT_flags) & ~FL_FROZEN)
        }
    }


Last edited by Intouchable; 03-21-2012 at 08:46.
Intouchable is offline
tuty
Veteran Member
Join Date: Jul 2008
Location: UK
Old 03-20-2012 , 12:32   Re: Count
Reply With Quote #5

a suggestion, use num_to_word for your sound numbers
__________________

Last edited by tuty; 03-20-2012 at 12:32.
tuty is offline
Send a message via ICQ to tuty Send a message via AIM to tuty
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 03-20-2012 , 17:04  
Reply With Quote #6

Exo if its a know. Number cant you use a loop? I dont think hes requesting it to be 1 second apart
Doc-Holiday is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-20-2012 , 17:15   Re: Count
Reply With Quote #7

Quote:
Originally Posted by Doc-Holiday View Post
Exo if its a know. Number cant you use a loop? I dont think hes requesting it to be 1 second apart
I figured a countdown in the HUD would be at intervals like everyone else asks for.

Without an interval, it would be even simpler:

Code:
FormatCountDown(seconds, output[], output_len) {     new len;     while(seconds > 0) {         len += formatex(output[len], output_len - len, "%s%d", len ? ", " : "", seconds);         seconds--;     }     return len; }

Code:
new message[32]; FormatCountDown(5, message, charsmax(message)); set_hudmessage(); show_hudmessage(0, "%s", message);

A loop for an interval, if that's what you meant, would look like this:
Code:
#define TASK_ID_COUNTDOWN 1234 #define StopCountDown() remove_task(TASK_ID_COUNTDOWN) StartCountDown(seconds) {     StopCountDown();         new params[1];     for(new i = 0; i < seconds; i++) {         params[0] = seconds - i;                 if(i) {             set_task(float(i), "TaskCountDown", TASK_ID_COUNTDOWN, params, sizeof(params));         } else {             TaskCountDown(params);         }     } } public TaskCountDown(params[]) {     set_hudmessage(.holdtime = 1.1);     show_hudmessage(0, "CountDown: %d", params[0]); }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Intouchable
Senior Member
Join Date: Mar 2012
Old 03-21-2012 , 08:47   Re: Count
Reply With Quote #8

So how to do on this code?
PHP Code:
new screen[33]
new 
msg_screenfade
new hud_sync
new count

new sound[][] = {
    
"five.wav",
    
"four.wav",
    
"three.wav",
    
"two.wav",
    
"one.wav",
    
""
}

public 
plugin_precache() for(new i=0i<5i++) precache_sound(sound[i])

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("HLTV""event_round_start""a""1=0""2=0")
    
RegisterHam(Ham_Spawn"player""player_spawn"1)
    
msg_screenfade get_user_msgid("ScreenFade")
    
hud_sync CreateHudSyncObj()
}

public 
event_round_start(id
{
    
count 0;
    
arrayset(screen033);

    
set_task(1.0"task_out"0__"a"5); 
}
    
public 
player_spawn(id
{
    if(!
screen[id] && get_user_team(id) == 1
    {
        
message_begin(MSG_ONEmsg_screenfade_id)
        
write_short(5// duration
        
write_short(6// hold time
        
write_short(FFADE_STAYOUT// fade type
        
write_byte(0// red
        
write_byte(0// green
        
write_byte(0// blue
        
write_byte(255// alpha
        
message_end()
        
        
client_cmd(id"spk /sound/%s"sound[0])
        
        
set_hudmessage(02550, -1.00.4006.05.0)
        
        
ShowSyncHudMsg(idhud_sync"%d"count)
        
entity_set_int(idEV_INT_flagsentity_get_int(idEV_INT_flags) | FL_FROZEN)
    }
    
screen[id] = true
}
        
    
public 
task_out() 
{
    static 
i
    count
++
    
    new 
players[32], num
    get_players
(playersnum"eh""TERRORIST"
    
    for(
i=0i<numi++) client_cmd(players[i], "spk /sound/%s"sound[count])

    if(
count == 5
    {
        for(
i=0i<numi++) 
        {
            
message_begin(MSG_ONEmsg_screenfade_players[i])
            
write_short((1<<12)) // duration
            
write_short(0// hold time
            
write_short(FFADE_OUT// fade type
            
write_byte(0// red
            
write_byte(0// green
            
write_byte(0// blue
            
write_byte(255// alpha
            
message_end()
            
entity_set_int(players[i], EV_INT_flagsentity_get_int(players[i], EV_INT_flags) & ~FL_FROZEN)
        }
    }

Intouchable is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 03-21-2012 , 09:37   Re: Count
Reply With Quote #9

I just gave you 3 different examples of count downs.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Intouchable
Senior Member
Join Date: Mar 2012
Old 03-21-2012 , 09:57   Re: Count
Reply With Quote #10

I will test it now..

Last edited by Intouchable; 03-21-2012 at 10:01. Reason: s
Intouchable 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 16:46.


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