AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Compiler doesn't detect blatant assignment of variable (https://forums.alliedmods.net/showthread.php?t=56812)

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 }

Sylwester 06-21-2007 17:22

Re: Compiler doesn't detect blatant assignment of variable
 
I'm getting same warning for both plugins on g_wpnid
Code:

warning 204: symbol is assigned a value that is never used: "g_wpnid"
Next time attach .inc file. It would make things easier.
btw are you working on some unix system? I'm on windows and whole code has been pasted in one line in my editor...
Hopefully ms word saves the day lol

World Crafter 06-21-2007 17:30

Re: Compiler doesn't detect blatant assignment of variable
 
Wow, now I feel unbelievably stupid. I completely read the warning incorrectly every time I saw it. I kept thinking it said "symbol is never assigned a value: `g_wpnid`".
G_wpnid is, in fact, not used because the plugin isn't finished yet and I haven't used it outside of it's assignment.
Sorry to waste your time, I must be braindead from trying to code Pawn for the past 3 days, almost nonstop. It doesn't help that i'm learning everything as I get to it, either.
Someone can lock, close, or just ignore this thread.


All times are GMT -4. The time now is 21:28.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.