Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fun>
#include <csx>
#include <cstrike>
static const NAME[] = "Sticky Bombs"
static const AUTH[] = "hi mystic"
static const VERS[] = "1.0"
#define NADE_INT_OWNER EV_INT_iuser1
new bool:Thrown[33]
new enabled
new Expl
new Expl1
new Expl2
new Smoke
//new Trail
new gGrenade[] = "models/w_hegrenade.mdl"
/*------------------------------------------------------------------------------------------------*/
public plugin_init()
{
register_plugin(NAME, VERS, AUTH)
enabled = register_cvar("Sticky_Bombs", "1")
register_touch("grenade", "worldspawn", "Touch");
}
/*------------------------------------------------------------------------------------------------*/
public plugin_precache()
{
precache_model(gGrenade)
Expl = precache_model("sprites/shockwave.spr")
//Trail = precache_model("sprites/laserbeam.spr");
Expl1 = precache_model("sprites/zerogxplode.spr")
Expl2 = precache_model("sprites/explode1.spr")
Smoke = precache_model("sprites/steam1.spr")
}
public grenade_throw(id, greindex, wId)
{
if(wId == CSW_HEGRENADE)
{
if(!Thrown[id])
{
Thrown[id] = true
client_print(0, print_chat, "someone has thrown a grenade")
//message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
//write_byte(22)
//write_short(greindex)
//write_short(Trail)
//write_byte(10)
//write_byte(10)
//write_byte(225)
//write_byte(0)
//write_byte(0)
//write_byte(192)
//message_end()
}
}
return PLUGIN_HANDLED
}
/*------------------------------------------------------------------------------------------------*/
public Touch(grenade, wall)
{
if(get_pcvar_num(enabled))
{
new szModel[26]
new Owner = entity_get_edict(grenade, EV_ENT_owner)
entity_get_string(grenade, EV_SZ_model, szModel, 25);
if(!get_pcvar_num(enabled))
return PLUGIN_HANDLED
if(!equali(szModel, gGrenade) || !is_valid_ent(grenade))
return PLUGIN_HANDLED
client_print(0, print_chat, "he grenade has touched a wall")
new Float:nOrigin[3]
entity_get_vector(grenade, EV_VEC_origin, nOrigin);
remove_entity(grenade)
new nade = create_entity("info_target")
client_print(0, print_chat, "a new entity has been created")
entity_set_edict(nade, EV_ENT_owner, Owner);
entity_set_origin(nade, nOrigin)
entity_set_string(nade, EV_SZ_classname, "Sticky_Bomb");
entity_set_model(nade, gGrenade);
entity_set_int(nade, EV_INT_solid, 0)
client_print(0, print_chat, "stuff has been on entity")
entity_set_byte(nade, EV_BYTE_controller1, 125);
entity_set_byte(nade, EV_BYTE_controller2, 125);
entity_set_byte(nade, EV_BYTE_controller3, 125);
entity_set_byte(nade, EV_BYTE_controller4, 125);
client_print(0, print_chat, "controller shit has been on entity")
//entity_set_float(nade, EV_FL_animtime, 2.0)
//entity_set_float(nade, EV_FL_framerate, 1.0)
//set_rendering(nade, kRenderFxGlowShell, 225, 0, 0, kRenderGlow, 16)
}
return PLUGIN_CONTINUE
}
public client_PreThink(id)
{
if(!is_user_alive(id) || !Thrown[id])
return PLUGIN_HANDLED
new button = get_user_button(id)
if((button & IN_USE))
{
client_print(0,print_chat,"user pressed +use to explode the bomb!")
Sticky_Bomb(id)
}
return PLUGIN_HANDLED
}
public Sticky_Bomb(id)
{
client_print(0,print_chat,"now going to find the sticky bomb ent")
new Ent = find_ent_by_class(-1, "Sticky_Bomb")
while(Ent > 0)
{
client_print(0,print_chat,"we have found it!")
if(entity_get_edict(Ent,EV_ENT_owner) == id)
{
client_print(0,print_chat,"ent owner = the id")
new origin[3], Float:originH[3]
entity_get_vector(Ent, EV_VEC_origin, originH)
FVecIVec(originH,origin)
Explode(origin)
client_print(0,print_chat,"explode!@")
remove_entity(Ent)
client_print(0,print_chat,"ent has been removed")
}
Ent = find_ent_by_class(Ent, "Sticky_Bomb")
}
return PLUGIN_HANDLED
}
public Explode(origin[3])
{
client_print(0,print_chat,"messages are starting")
message_begin(MSG_BROADCAST,SVC_TEMPENTITY);
write_byte(21)
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2])
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2] + 385)
write_short(Expl)
write_byte(0)
write_byte(0)
write_byte(6)
write_byte(80)
write_byte(0)
write_byte(225)
write_byte(0)
write_byte(0)
write_byte(192)
write_byte(0)
message_end()
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(3)
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2])
write_short(Expl1)
write_byte(30)
write_byte(30)
write_byte(0)
message_end()
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(3)
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2])
write_short(Expl2)
write_byte(25)
write_byte(30)
write_byte(0)
message_end()
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(116)
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2])
write_byte(46)
message_end()
message_begin(MSG_BROADCAST, SVC_TEMPENTITY, origin)
write_byte(5)
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2])
write_short(Smoke)
write_byte(39)
write_byte(5)
}
public client_connect(id)
{
Thrown[id] = false
}
public client_disconnect(id)
{
Thrown[id] = false
}
when i throw one it sais msg 22 was not yet sent or something and then crash.
P.S. hi mystic