Code:
/*************************************************************************************************************
AMX Ultimate Fake C4
Version: 0.2.2
Author: KRoTaL
0.1 Release
0.2 Fixed the crash that happened when you planted 2 fake c4s at the same place + minor changes
0.2.2 Added the "Bomb is planted" radio sound + minor changes
Players can plant fake c4s with the "amx_fakec4" command.
These fake c4s look real: model + sounds + ledglow.
Players can defuse fake c4s (more quickly with a defuse kit).
If you defuse a fake c4, you'll see a nice message. :)
Fake c4s last mp_c4timer seconds.
Plant fake c4s around the real bomb if you want to annoy the ct team. :d
Cvars:
fakec4_adminonly 0 - 0: all the terrorists can plant fake c4s
1: only the admins with the ADMIN_SLAY flag can plant fake c4s
fakec4_ctdefuse 1 - 0: all the players can defuse fake c4s
1: only the ct team can defuse fake c4s
fakec4_maxnum 1 - sets the maximum number of fake c4s a player is allowed to plant in a round
Setup (AMX 0.9.9):
Install the amx file.
Put this file on your server:
sound/djeyl/witch.wav
Enable VexdUM (both in metamod's plugins.ini and amx's modules.ini)
*************************************************************************************************************/
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fun>
#define ADMIN_FAKEC4 ADMIN_SLAY
//ENGLISH
new fakec4_msg1[] = "The bomb has been planted!"
new fakec4_msg2[] = "Defusing bomb WITH Defuse kit."
new fakec4_msg3[] = "Defusing bomb WITHOUT Defuse kit."
//FRANCAIS
//new fakec4_msg1[] = "La bombe a ete placee !"
//new fakec4_msg2[] = "Desamorce la bombe AVEC le kit de desamorcage."
//new fakec4_msg3[] = "Desamorce la bombe SANS le kit de desamorcage."
#define MAX_FAKEC4 64
// Taken from amxmodx
#define OFFSET_DEFUSE_PLANT 193
#define HAS_DEFUSE_KIT (1<<16)
new spr_ledglow
new Float:c4_timer[MAX_FAKEC4]
new c4_num
new c4_count[33]
new bool:defusing[33]
public plugin_init()
{
register_plugin("Ultimate Fake C4","0.2.2","KRoTaL")
register_concmd("amx_fakec4","plant_c4",-1,": plants a fake c4")
register_cvar("fakec4_adminonly", "0")
register_cvar("fakec4_ctdefuse", "1")
register_cvar("fakec4_maxnum", "1")
register_event("ResetHUD","reset_hud","b")
register_event("TextMsg", "remove_c4", "a", "2&#Game_C", "2&#Game_w")
register_event("SendAudio", "remove_c4", "a", "2=%!MRAD_terwin", "2=%!MRAD_ctwin", "2=%!MRAD_rounddraw")
c4_num = 0
}
public plugin_precache()
{
precache_sound("djeyl/witch.wav")
precache_sound("weapons/c4_plant.wav")
precache_sound("weapons/c4_disarm.wav")
precache_sound("weapons/c4_beep1.wav")
precache_sound("weapons/c4_beep2.wav")
precache_sound("weapons/c4_beep3.wav")
precache_sound("weapons/c4_beep4.wav")
precache_sound("weapons/c4_beep5.wav")
precache_sound("radio/bombpl.wav")
precache_model("models/w_c4.mdl")
spr_ledglow = precache_model("sprites/ledglow.spr")
}
public reset_hud(id)
{
defusing[id] = false
c4_count[id] = 0
}
public remove_c4()
{
new iEntity = find_entity(-1, "fake_c4")
while(iEntity > 0)
{
if(task_exists(1234567+iEntity))
remove_task(1234567+iEntity)
if(task_exists(2345678+iEntity))
remove_task(2345678+iEntity)
remove_entity(iEntity)
iEntity = find_entity(-1, "fake_c4")
}
c4_num = 0
return PLUGIN_CONTINUE
}
public plant_c4(id)
{
if( !(get_user_flags(id) & ADMIN_FAKEC4) && get_cvar_num("fakec4_adminonly") == 1)
{
console_print(id, "You have no access to that command")
return PLUGIN_HANDLED
}
if(c4_count[id] >= get_cvar_num("fakec4_maxnum"))
{
console_print(id, "You can only plant %d fake c4(s) in a round.", get_cvar_num("fakec4_maxnum"))
client_print(id, print_chat, "You can only plant %d fake c4(s) in a round.", get_cvar_num("fakec4_maxnum"))
return PLUGIN_HANDLED
}
new c4_ent = create_entity("info_target")
if(c4_ent == 0)
{
return PLUGIN_HANDLED_MAIN
}
entity_set_string(c4_ent, EV_SZ_classname, "fake_c4")
entity_set_int(c4_ent, EV_INT_solid, 2)
entity_set_int(c4_ent, EV_INT_movetype, 6)
entity_set_model(c4_ent, "models/w_c4.mdl")
new Float:MinBox[3], Float:MaxBox[3]
MinBox[0]=-1.0
MinBox[1]=-1.0
MinBox[2]=-0.000001
MaxBox[0]=1.0
MaxBox[1]=1.0
MaxBox[2]=0.000001
entity_set_size(c4_ent, MinBox, MaxBox)
new Float:PlayerOrigin[3]
entity_get_vector(id, EV_VEC_origin, PlayerOrigin)
entity_set_origin(c4_ent, PlayerOrigin)
entity_set_edict(c4_ent, EV_ENT_owner, id)
set_task(1.8, "reset_owner", c4_ent)
emit_sound(c4_ent, CHAN_WEAPON, "weapons/c4_plant.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
client_print(0, print_center, fakec4_msg1)
client_cmd(0, "spk radio/bombpl.wav")
c4_timer[c4_num] = get_cvar_float("mp_c4timer") - 1.48
new param[3]
param[0]= c4_ent
param[1]= c4_num
set_task(2.0,"c4_ledglow",1234567+c4_ent,param,2,"b")
set_task(1.48,"c4_sound",2345678+c4_ent,param,2,"b")
c4_num++
c4_count[id]++
return PLUGIN_CONTINUE
}
public reset_owner(c4_ent)
{
entity_set_edict(c4_ent, EV_ENT_owner, 33)
}
public c4_ledglow(param[])
{
new c4_ent = param[0]
new Float:forigin[3], origin[3]
entity_get_vector(c4_ent, EV_VEC_origin, forigin)
FVecIVec(forigin, origin)
origin[2] = origin[2] + 5
message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
write_byte(23)
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2])
write_short(spr_ledglow)
write_byte(3)
write_byte(3)
write_byte(255)
message_end()
return PLUGIN_CONTINUE
}
public c4_sound(param[])
{
new c4_ent = param[0]
new c4num = param[1]
if(c4_timer[c4num] >= 34)
{
emit_sound(c4_ent, CHAN_WEAPON, "weapons/c4_beep1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
}
if(c4_timer[c4num] < 34 && c4_timer[c4num] >= 24)
{
emit_sound(c4_ent, CHAN_WEAPON, "weapons/c4_beep2.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
}
if(c4_timer[c4num] < 24 && c4_timer[c4num] >= 15)
{
emit_sound(c4_ent, CHAN_WEAPON, "weapons/c4_beep3.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
}
if(c4_timer[c4num] < 15 && c4_timer[c4num] >= 6)
{
emit_sound(c4_ent, CHAN_WEAPON, "weapons/c4_beep4.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
}
else if(c4_timer[c4num] < 6)
{
if(c4_timer[c4num] <= 0)
{
emit_sound(c4_ent, CHAN_WEAPON, "djeyl/witch.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
remove_task(1234567+c4_ent)
remove_task(2345678+c4_ent)
remove_entity(c4_ent)
return PLUGIN_CONTINUE
}
emit_sound(c4_ent, CHAN_WEAPON, "weapons/c4_beep5.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
}
c4_timer[c4num] -= 1.48
return PLUGIN_CONTINUE
}
public client_prethink(id)
{
if(c4_num > 0 && (get_cvar_num("fakec4_ctdefuse") == 0 || get_user_team(id) == 2))
{
if(get_user_button(id) & IN_USE)
{
if(defusing[id])
{
set_user_maxspeed(id, -1.0)
return PLUGIN_CONTINUE
}
new targetid, body
get_user_aiming(id, targetid, body)
if(targetid)
{
new c4ClassName[32]
entity_get_string(targetid, EV_SZ_classname, c4ClassName, 31)
if(equal(c4ClassName,"fake_c4"))
{
new origin1[3], origin2[3], Float:forigin2[3]
get_user_origin(id, origin1)
entity_get_vector(targetid, EV_VEC_origin, forigin2)
FVecIVec(forigin2, origin2)
new distance = get_distance(origin1,origin2)
if(distance < 72)
{
defusing[id] = true
set_user_maxspeed(id, -1.0)
emit_sound(targetid, CHAN_WEAPON, "weapons/c4_disarm.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
if(get_offset_int(id, OFFSET_DEFUSE_PLANT) & HAS_DEFUSE_KIT)
{
message_begin( MSG_ONE, 108, {0,0,0}, id )
write_byte( 5 )
write_byte( 0 )
message_end()
new param[3]
param[0] = targetid
param[1] = id
set_task(5.0, "defused", 3456789+id, param, 2)
client_print(id,print_center,fakec4_msg2)
}
else
{
message_begin( MSG_ONE, 108, {0,0,0}, id )
write_byte( 10 )
write_byte( 0 )
message_end()
new param[3]
param[0] = targetid
param[1] = id
set_task(10.0, "defused", 3456789+id, param, 2)
client_print(id,print_center,fakec4_msg3)
}
}
}
}
else if(defusing[id])
{
set_user_maxspeed(id, 240.0)
defusing[id] = false
remove_task(3456789+id)
message_begin( MSG_ONE, 108, {0,0,0}, id )
write_byte( 0 )
write_byte( 0 )
message_end()
}
}
else if(defusing[id])
{
set_user_maxspeed(id, 240.0)
defusing[id] = false
remove_task(3456789+id)
message_begin( MSG_ONE, 108, {0,0,0}, id )
write_byte( 0 )
write_byte( 0 )
message_end()
}
}
return PLUGIN_CONTINUE
}
public defused(param[])
{
new c4_ent = param[0]
new id = param[1]
emit_sound(c4_ent, CHAN_WEAPON, "djeyl/witch.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
remove_task(1234567+c4_ent)
remove_task(2345678+c4_ent)
remove_entity(c4_ent)
set_hudmessage(255, 255, 255, -1.0, 0.3, 0, 0.01, 6.0, 0.01, 0.01, 2)
show_hudmessage(id, "YOU HAVE DEFUSED A FAKE BOMB, YOU IDIOT! HAHAHAHA!")
defusing[id] = false
set_user_maxspeed(id, 240.0)
return PLUGIN_CONTINUE
}
teh script. help pls?