| World Crafter |
06-21-2007 16:21 |
Compiler doesn't detect blatant assignment of variable
This is regarding a plugin for WeaponMod and it makes no sense at all. I have two plugins: one that I am using as a base for code and another that I am actually writing. The plugin from scratch comes up with a compiler warning telling me that "g_wpnid" is never assigned, while the other base plugin is perfectly fine. Now here's the thing that's pissing me off: both plugins use, literally, the exact same code to assign the same variable. I don't understand how it is possible for one plugin to come up with this warning while the other doesn't.
Here is code from the warning plugin:
Code:
#include <amxmodx>
#include <fakemeta>
#include <weaponmod>
#define PLUGIN "Sawed-Off Shotgun"
#define VERSION "0.0.1"
#define AUTHOR "World Crafter"
// Weapon information
new WPN_NAME[] = "Sawed-Off Shotgun"
new WPN_SHORT[] = "sawedoff"
// Model information
new P_MODEL[] = "models/p_sawedoff.mdl"
new V_MODEL[] = "models/v_sawedoff.mdl"
new W_MODEL[] = "models/w_sawedoff.mdl"
new PELLET[] = "models/pellet.mdl"
// Sound information
new FIRE[] = "weapons/sawedoff_fire.wav"
// Weapon information
#define BULLET_SPEED 5000
// Sequences
enum
{
anim_idle,
anim_draw,
anim_reload,
anim_shoot1
}
// Variables
new g_wpnid
new g_trail
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_forward(FM_Touch,"fwd_Touch")
create_weapon()
}
create_weapon() {
new wpnid = wpn_register_weapon(WPN_NAME,WPN_SHORT)
if(wpnid == -1) return PLUGIN_CONTINUE
wpn_set_string(wpnid, wpn_viewmodel, V_MODEL)
wpn_set_string(wpnid, wpn_weaponmodel, P_MODEL)
wpn_set_string(wpnid, wpn_worldmodel, W_MODEL)
wpn_register_event(wpnid, event_attack1, "ev_attack1")
wpn_register_event(wpnid, event_draw, "ev_draw")
wpn_register_event(wpnid, event_reload, "ev_reload")
wpn_set_float(wpnid, wpn_refire_rate1, 0.1)
wpn_set_float(wpnid, wpn_reload_time, 2.2)
wpn_set_float(wpnid, wpn_recoil1, 5.0)
wpn_set_float(wpnid, wpn_run_speed, 230.0)
wpn_set_integer(wpnid, wpn_ammo1, 2)
wpn_set_integer(wpnid, wpn_ammo2, 30)
wpn_set_integer(wpnid, wpn_bullets_per_shot1, 1)
wpn_set_integer(wpnid, wpn_cost, 1400)
g_wpnid = wpnid
return PLUGIN_CONTINUE
}
And here is the identical code from the base:
Code:
#include <amxmodx>
#include <fakemeta>
#include <weaponmod>
new PLUGIN[] = "WPN Missile"
new VERSION[] = "0.2"
new AUTHOR[] = "DevconeS"
new WPN_NAME[] = "Missile"
new WPN_SHORT[] = "missile"
new P_MODEL[] = "models/p_egon.mdl"
new V_MODEL[] = "models/v_egon.mdl"
new W_MODEL[] = "models/w_egon.mdl"
new ROCKET_MDL[] = "models/rocket.mdl"
new FIRE[] = "weapons/rpg_fire.wav"
#define ROCKET_SPEED 2000
#define ROCKET_RADIUS 100.0
#define ROCKET_DAMAGE 10.0
// Sequences
enum
{
anim_idle,
anim_draw,
anim_reload,
anim_shoot1
}
new g_wpnid
new g_trail,g_explosion,g_flame
public plugin_init() {
register_plugin(PLUGIN,VERSION,AUTHOR)
register_forward(FM_Touch,"fwd_Touch")
create_weapon()
}
create_weapon() {
new wpnid = wpn_register_weapon(WPN_NAME,WPN_SHORT)
if(wpnid == -1) return PLUGIN_CONTINUE
wpn_set_string(wpnid,wpn_viewmodel,V_MODEL)
wpn_set_string(wpnid,wpn_weaponmodel,P_MODEL)
wpn_set_string(wpnid,wpn_worldmodel,W_MODEL)
wpn_register_event(wpnid,event_attack1,"ev_attack1")
wpn_register_event(wpnid,event_attack2,"ev_attack2")
wpn_register_event(wpnid,event_draw,"ev_draw")
wpn_register_event(wpnid,event_draw,"ev_reload")
wpn_set_float(wpnid,wpn_refire_rate1,0.1)
wpn_set_float(wpnid,wpn_refire_rate2,0.0)
wpn_set_float(wpnid,wpn_reload_time,2.1)
wpn_set_float(wpnid,wpn_recoil1,1.0)
wpn_set_float(wpnid,wpn_recoil2,3.0)
wpn_set_float(wpnid,wpn_run_speed,230.0)
wpn_set_integer(wpnid,wpn_ammo1,3)
wpn_set_integer(wpnid,wpn_ammo2,9)
wpn_set_integer(wpnid,wpn_bullets_per_shot1,1)
wpn_set_integer(wpnid,wpn_bullets_per_shot2,0)
wpn_set_integer(wpnid,wpn_cost,4000)
g_wpnid = wpnid
return PLUGIN_CONTINUE
}
|