|
发表于 2010-2-6 03:02:45
|
显示全部楼层
来自 中国–广西–钦州
本帖最后由 csqz 于 2010-2-6 03:10 编辑
//***********************************************************************
//* Bomb countdown timer v. 0.1 for AMX by Martin J. Van der Cal *
//* *
//* Shows a countdown timer in the center of the screen on all *
//* clients, once the bomb has been planted *
//* *
//***********************************************************************
#include <amxmod>
#include <amxmisc>
#define MAX_CHAR_NAME 32
#define MAX_CHAR_MESSAGE 25
#define MAX_NUMBER_PLAYERS 32
#define TERRORIST_ID 1
#define COUNTER_TERRORIST_ID 2
#define BOMBCOUNTDOWN_TASK_ID 8038
new g_iBomberID, g_iDefuserID, g_iC4Timer
// Inform players of planting or defusing attempts
public InformPlantDef(iID)
{
new iArrPlayerIDs[MAX_NUMBER_PLAYERS]
new sName[MAX_CHAR_NAME]
new nPlayers
new sMessage[MAX_CHAR_MESSAGE]
// Get the name of the planter/defuser
get_user_name(iID, sName , MAX_CHAR_NAME-1)
// If he/she is a terrorist...
if (get_user_team(iID) == TERRORIST_ID)
{
get_players(iArrPlayerIDs, nPlayers, "e", "TERRORIST")
g_iBomberID = iID
sMessage = ""
}
// If he/she is a counter terrorist...
else
{
get_players(iArrPlayerIDs, nPlayers, "e", "CT")
g_iDefuserID = iID
sMessage = ""
}
// For every player in the same team
for (new iPlayer=0; iPlayer<nPlayers; iPlayer++)
{
// If it isnt the planter/defuser
if (iArrPlayerIDs[iPlayer] != iID)
{
// Inform the teammate about the plant/defuse attempt
client_print(iArrPlayerIDs[iPlayer], print_center, "", sName, sMessage)
}
}
}
// Stops the bomb countdown
public DisableBomb()
{
g_iC4Timer = 0
remove_task(BOMBCOUNTDOWN_TASK_ID)
}
// Called when someone planted the bomb
public PlantedBomb()
{
new sName[MAX_CHAR_NAME]
get_user_name(g_iBomberID, sName, MAX_CHAR_NAME-1)
client_print(0, print_center, "", sName)
g_iC4Timer = get_cvar_num("mp_c4timer")
set_task(1.0, "BombCountdown", BOMBCOUNTDOWN_TASK_ID, "", 0, "b")
}
public eRestart(){
eEndRound()
}
public eEndRound(){
new g_iC4Timer1 = g_iC4Timer - 1
g_iC4Timer1 = -2
remove_task(8038)
}
// Called while bomb is ticking
public BombCountdown()
{
new g_iC4Timer1 = g_iC4Timer - 1
if (g_iC4Timer1 == 30 || g_iC4Timer1 == 20)
{
new temp[64]
num_to_word(g_iC4Timer1, temp, 63)
format(temp, 63, "^"vox/%s seconds until explosion^"", temp)
play_sound(temp)
}
else if (g_iC4Timer1 < 11)
{
new temp[64]
num_to_word(g_iC4Timer1, temp, 63)
format(temp, 63, "^"vox/%s^"", temp)
play_sound(temp)
}
// If we havent reached 0 yet, print number of seconds to blow
if (--g_iC4Timer > 0) {
if (g_iC4Timer1 > 10)
set_hudmessage(0, 255, 0, -1.0, 0.80, 0, 0.5, 0.5, 0.6, 0.6, 1)
else if (g_iC4Timer1 > 5)
set_hudmessage(255, 255, 0, -1.0, 0.80, 0, 0.5, 0.5, 0.6, 0.6, 1)
else
set_hudmessage(255, 0, 0, -1.0, 0.80, 0, 0.5, 0.5, 0.6, 0.6,1)
show_hudmessage(0, "C4剩余时间: %d秒", g_iC4Timer )
}
// Else, the bomb has exploded and we remove the countdown timer task
else
remove_task(8038)
}
public plugin_precache(){
precache_sound( "vox/activated.wav")
precache_sound( "vox/and.wav")
precache_sound( "vox/atomic.wav")
precache_sound( "vox/destroyed.wav")
precache_sound( "vox/detected.wav")
precache_sound( "vox/detonation.wav")
precache_sound( "vox/device.wav")
precache_sound( "vox/die.wav")
precache_sound( "vox/doop.wav")
precache_sound( "vox/eight.wav")
precache_sound( "vox/eighteen.wav")
precache_sound( "vox/eighty.wav")
precache_sound( "vox/eleven.wav")
precache_sound( "vox/explosion.wav")
precache_sound( "vox/fifteen.wav")
precache_sound( "vox/fifty.wav")
precache_sound( "vox/five.wav")
precache_sound( "vox/four.wav")
precache_sound( "vox/fourteen.wav")
precache_sound( "vox/fourty.wav")
precache_sound( "vox/hello.wav")
precache_sound( "vox/hours.wav")
precache_sound( "vox/minutes.wav")
precache_sound( "vox/nine.wav")
precache_sound( "vox/nineteen.wav")
precache_sound( "vox/ninety.wav")
precache_sound( "vox/one.wav")
precache_sound( "vox/remaining.wav")
precache_sound( "vox/rocket.wav")
precache_sound( "vox/second.wav")
precache_sound( "vox/seconds.wav")
precache_sound( "vox/seven.wav")
precache_sound( "vox/seventeen.wav")
precache_sound( "vox/seventy.wav")
precache_sound( "vox/six.wav")
precache_sound( "vox/sixteen.wav")
precache_sound( "vox/sixty.wav")
precache_sound( "vox/ten.wav")
precache_sound( "vox/thirteen.wav")
precache_sound( "vox/thirty.wav")
precache_sound( "vox/three.wav")
precache_sound( "vox/twelve.wav")
precache_sound( "vox/twenty.wav")
precache_sound( "vox/two.wav")
precache_sound( "vox/until.wav")
precache_sound( "vox/warning.wav")
precache_sound( "vox/weapon.wav")
precache_sound( "vox/woop.wav")
return PLUGIN_CONTINUE
}
public play_sound(sound[])
{
new players[32], pnum
get_players(players, pnum, "c")
new i
for (i = 0; i < pnum; i++)
{
if (is_user_connecting(players))
continue
client_cmd(players, "spk %s", sound)
}
}
// Called when bomb has been defused
public DefusedBomb()
{
new sName[MAX_CHAR_NAME]
get_user_name(g_iDefuserID, sName, MAX_CHAR_NAME)
client_print(0,print_center,"", sName)
client_print(g_iDefuserID,print_center,"", sName)
DisableBomb()
}
public plugin_init()
{
register_plugin("Bomb Countdown","0.1","Van der Cal")
// Bomb events
register_event("SendAudio", "PlantedBomb", "a", "2&%!MRAD_BOMBPL")
register_event("SendAudio", "DefusedBomb", "a", "2&%!MRAD_BOMBDEF")
register_event("SendAudio", "DisableBomb", "a", "2&%!MRAD_terwin","2&%!MRAD_ctwin","2&%!MRAD_rounddraw")
register_event("TextMsg" , "DisableBomb", "a", "2&#Game_C","2&#Game_w")
register_event("TextMsg","eRestart","a","2&#Game_C","2&#Game_w")
register_event("SendAudio", "eEndRound", "a", "2&%!MRAD_terwin","2&%!MRAD_ctwin","2&%!MRAD_rounddraw")
register_event("BarTime" , "InformPlantDef", "be", "1=10", "1=5","1=3")
return PLUGIN_CONTINUE
} |
|