Im trying to get this plugin working right , but every time i switch to AWP my server crashes. The wierd part is there are no run time errors showing up . Any idea what would make this crash ?
Code:
#include <amxmodx>
#include <cstrike>
#include <engine>
// Gloabal Variables
new g_Rail_Gun;
new beam;
public plugin_init()
{
register_plugin("Rail Gun","0.1","The Specialist");
g_Rail_Gun = register_cvar("rg_switch","1");
register_cvar("rg_rail_damage","1");
register_clcmd("amx_rail_arena","amx_rail_arena",ADMIN_CVAR,"Starts A Rail Gun Arena");
register_event("CurWeapon","weapon_event","be","1=1");
register_event("Damage","rail_damage","b");
}
public plugin_precache()
{
// precache the files needed for models and sounds
precache_model("models/v_gauss.mdl");
precache_model("models/p_gauss.mdl");
beam = precache_model("sprites/smoke.spr");
}
// current weapon event
public weapon_event(id)
{
// if cvar is off then end fucntion
if(get_pcvar_num(g_Rail_Gun)==0)
{
return PLUGIN_HANDLED;
}else{
// get weapon and ammo id's
new Weapon_ID = read_data(2);
// if weapon is awp and plugin is on and mode is 1 then set models
if( Weapon_ID == CSW_AWP)
{
// sets the players awp to the rail gun model
entity_set_string(id,EV_SZ_weaponmodel,"models/p_gauss.mdl");
// sets the players view model to the rail guns model
entity_set_string(id,EV_SZ_viewmodel,"models/v_gauss.mdl");
// add effects to bullets
rail_fire();
return PLUGIN_HANDLED;
}
}
return PLUGIN_HANDLED;
}
// damage event
public rail_damage(id)
{
// get user attackers , waepons and damage
new g_AWeapon;
new g_Damage = read_data(2);
get_user_attacker(id,g_AWeapon);
// if user was shot by AWP multiply damage by cvar
if(g_AWeapon == CSW_AWP )
{
// hit user with fake damage
fakedamage(id,"weapon_awp",float(g_Damage),DMG_BULLET && DMG_BLAST && DMG_ENERGYBEAM)
return PLUGIN_HANDLED;
}
return PLUGIN_HANDLED;
}
// sounds and messages for bullets
public rail_fire()
{
// effects that follwo the bulelts
message_begin(MSG_BROADCAST, SVC_TEMPENTITY);
write_byte(22);
write_short(beam);
write_byte(45);
write_byte(4);
write_byte(100);
write_byte(100);
write_byte(250);
write_byte(100);
}
public amx_rail_arena(id)
{
return PLUGIN_HANDLED;
}
thanks