AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Plugin Help (https://forums.alliedmods.net/showthread.php?t=172108)

asdfdsdf 11-15-2011 12:41

Plugin Help
 
hello i have a zombie mod server and on that is a countdown remix from here on allied the coders name i forgot but the problem with plugin is when it counts it counts from 10 zp delay on my server is 10 but it counts 10 and on hudmessage its a 9, 9 is 8 etc and on last 1 it again says 10 here is the code whats wrong with sry for bad englisch

PHP Code:

/*********************************************
==============================================
* Infection Countdown For Zombie Plague 4.3+ *
==============================================
Description:
Remake version of zp_server_addon_countdown
by Mr. Apple, borrowed some code from
bcdhud_timer by SAMURAI

Modules:
- csx (for Countdown HUD Message)

Changelog:
1.0 Initial release

 Credits:
 - AMXModx Team (AMXModX 1.8.1)
 - Mercylezz (Zombie Plague 4.3)
 - SAMURAI (bcdhud_timer)
 - Mr. Apple (zp_server_addon_countdown)
********************************************/

#include <amxmodx>
#include <csx>
#include <amxmisc>
#include <zombieplague>

#define PLUGIN "[ZP] Infection Countdown"
#define VERSION "1.0"
#define AUTHOR "Dels"

new countdown_timer;
new 
g_msgsync;
const 
TASK_ID 1603;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);    
    
register_event("HLTV""event_round_start""a""1=0""2=0");
    
    
//needed for smooth countdown display
    
g_msgsync CreateHudSyncObj();
}
 
public 
plugin_precache()
{
    
precache_sound("fvox/ten.wav");
    
precache_sound("fvox/nine.wav");
    
precache_sound("fvox/eight.wav");
    
precache_sound("fvox/seven.wav");
    
precache_sound("fvox/six.wav");
    
precache_sound("fvox/five.wav");
    
precache_sound("fvox/four.wav");
    
precache_sound("fvox/three.wav");
    
precache_sound("fvox/two.wav");
    
precache_sound("fvox/one.wav");
}

public 
event_round_start()
{
    
//bugfix
    
remove_task(TASK_ID);
    
    
countdown_timer get_cvar_num("zp_delay") - 0;
    
set_task(4.0"countdown"TASK_ID);
}

public 
countdown()
{    
    new 
speak[10][] = { 
    
"fvox/one.wav"
    
"fvox/two.wav"
    
"fvox/three.wav"
    
"fvox/four.wav"
    
"fvox/five.wav"
    
"fvox/six.wav"
    
"fvox/seven.wav"
    
"fvox/eight.wav"
    
"fvox/nine.wav"
    
"fvox/ten.wav" 
    
}

    if (
countdown_timer 1)
    {         
        
emit_sound(0CHAN_VOICEspeak[countdown_timer-1], 1.0ATTN_NORM0PITCH_NORM);
        
set_hudmessage(17900, -1.00.2820.021.00.010.110);    
        
//show_hudmessage(0, "Infection on %i", countdown_timer-1); //old way to display message, little flicker
        
ShowSyncHudMsg(0g_msgsync"Infection on %i"countdown_timer-1); //the new way
    
}
    --
countdown_timer;
        
    if(
countdown_timer >= 1)
    {
        
set_task(1.0"countdown"TASK_ID);
    }
    else
    {
        
emit_sound(0CHAN_VOICEspeak[9], 1.0ATTN_NORM0PITCH_NORM);
        
remove_task(TASK_ID);
    }
}

/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/ 


Dark Style 11-15-2011 14:16

Re: Plugin Help
 
Code:

ShowSyncHudMsg(0, g_msgsync, "Infection on %i", countdown_timer-1); //the new way
//--->
ShowSyncHudMsg(0, g_msgsync, "Infection on %i", countdown_timer);
countdown_timer-1;

(For what i understood)

Korxu 11-15-2011 14:20

Re: Plugin Help
 
Quote:

Originally Posted by Dark Style (Post 1597045)
Code:

ShowSyncHudMsg(0, g_msgsync, "Infection on %i", countdown_timer-1); //the new way
//--->
ShowSyncHudMsg(0, g_msgsync, "Infection on %i", countdown_timer);
countdown_timer-1;

(For what i understood)

Well, on the first use you show the value of "countdown_timer" less one, but the value don't change never. With the second use, you show the value of "countdown_timer" and later you remove one from this value.

asdfdsdf, you understand it?

asdfdsdf 11-16-2011 09:45

Re: Plugin Help
 
ye i will try it now thx for the help

asdfdsdf 11-16-2011 09:56

Re: Plugin Help
 
i just tried it but it wont work now it counts right but on 2 i get infected en then it says 10 again weird before i never had this problem heres the code

PHP Code:

/*********************************************
==============================================
* Infection Countdown For Zombie Plague 4.3+ *
==============================================
Description:
Remake version of zp_server_addon_countdown
by Mr. Apple, borrowed some code from
bcdhud_timer by SAMURAI

Modules:
- csx (for Countdown HUD Message)

Changelog:
1.0 Initial release

 Credits:
 - AMXModx Team (AMXModX 1.8.1)
 - Mercylezz (Zombie Plague 4.3)
 - SAMURAI (bcdhud_timer)
 - Mr. Apple (zp_server_addon_countdown)
********************************************/

#include <amxmodx>
#include <csx>
#include <amxmisc>
#include <zombieplague>

#define PLUGIN "[ZP] Infection Countdown"
#define VERSION "1.0"
#define AUTHOR "Dels"

new countdown_timer;
new 
g_msgsync;
const 
TASK_ID 1603;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR);    
    
register_event("HLTV""event_round_start""a""1=0""2=0");
    
    
//needed for smooth countdown display
    
g_msgsync CreateHudSyncObj();
}
 
public 
plugin_precache()
{
    
precache_sound("fvox/ten.wav");
    
precache_sound("fvox/nine.wav");
    
precache_sound("fvox/eight.wav");
    
precache_sound("fvox/seven.wav");
    
precache_sound("fvox/six.wav");
    
precache_sound("fvox/five.wav");
    
precache_sound("fvox/four.wav");
    
precache_sound("fvox/three.wav");
    
precache_sound("fvox/two.wav");
    
precache_sound("fvox/one.wav");
}

public 
event_round_start()
{
    
//bugfix
    
remove_task(TASK_ID);
    
    
countdown_timer get_cvar_num("zp_delay") - 1;
    
set_task(4.0"countdown"TASK_ID);
}

public 
countdown()
{    
    new 
speak[10][] = { 
    
"fvox/one.wav"
    
"fvox/two.wav"
    
"fvox/three.wav"
    
"fvox/four.wav"
    
"fvox/five.wav"
    
"fvox/six.wav"
    
"fvox/seven.wav"
    
"fvox/eight.wav"
    
"fvox/nine.wav"
    
"fvox/ten.wav" 
    
}

    if (
countdown_timer 1)
    {         
        
emit_sound(0CHAN_VOICEspeak[countdown_timer-1], 1.0ATTN_NORM0PITCH_NORM);
        
set_hudmessage(17900, -1.00.2820.021.00.010.110);    
        
//show_hudmessage(0, "Infection on %i", countdown_timer-1); //old way to display message, little flicker
        
ShowSyncHudMsg(0g_msgsync"Infection on %i"countdown_timer-1); //the new way
//--->
ShowSyncHudMsg(0g_msgsync"Infection on %i"countdown_timer);
countdown_timer-1;
    }
    --
countdown_timer;
        
    if(
countdown_timer >= 1)
    {
        
set_task(1.0"countdown"TASK_ID);
    }
    else
    {
        
emit_sound(0CHAN_VOICEspeak[9], 1.0ATTN_NORM0PITCH_NORM);
        
remove_task(TASK_ID);
    }
}

/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/ 


drekes 11-16-2011 10:56

Re: Plugin Help
 
This should help you understand how a countdown works.

Also you don't have to precache the number sounds, they are default sounds so everybody has them.

And instead of having a const with the sounds, check the num_to_word native.
You can see how that works in my countdown plugin here


All times are GMT -4. The time now is 08:26.

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