• GMOD Swep Code Error
    5 replies, posted
Ok, so heres my issue- I was coding a SWEP and like always was working with the GDCW base, more specifically, the GDCW pistol base. When I was finished, I got the following error while I was testing it. This error just floods my console. [ERROR] addons/#cz75/lua/weapons/gdcw_base_pistol/shared.lua:230: attempt to perform arithmetic on field 'ConeDecrement' (a nil value) 1. unknown - addons/#cz75/lua/weapons/gdcw_base_pistol/shared.lua:230 When I went to inspect the code, I saw nothing wrong with it. Maybe you guys can help me out? Here is the code that is giving me errors. Line 230 is the specific line causing problems. function SWEP:Think() self:IronSight() if !self.Owner:IsNPC() then if self.Idle and CurTime() >= self.Idle then self.Idle = nil self:SendWeaponAnim(ACT_VM_IDLE) end end if (self.Primary.Cone>0.09) then self.Primary.Cone = self.Primary.Cone - self.Primary.ConeDecrement end end Here is a link to the entire base code- [url]http://pastebin.com/vJJyA0a7[/url] Thanks guys :)
wrong section, there's gmod dev for this I'll help you anyways though I guess if you look in the script, "self.Primary.ConeDecrement" isn't defined anywhere, and then on line 230, you just use it, breaking the script. "attempt to perform arithmetic on field 'ConeDecrement' (a nil value)" it cannot do maths on/with something that doesn't exist edit: also try to put code in code tags at least please like [code] function SWEP:Think() self:IronSight() if !self.Owner:IsNPC() then if self.Idle and CurTime() >= self.Idle then self.Idle = nil self:SendWeaponAnim(ACT_VM_IDLE) end end if (self.Primary.Cone>0.09) then self.Primary.Cone = self.Primary.Cone - self.Primary.ConeDecrement end end [/code] you did a good job by posting a paste to the whole code though, thank fuck
Hmm.. Im not sure what to do.. should I just remove the function completly? Function think.. I dont know what it is but its giving my pistols errors Thnx for helping... and sorry for wrong section, wont happen again.
[QUOTE=bosnian_cyco;46683085]Hmm.. Im not sure what to do.. should I just remove the function completly? Function think.. I dont know what it is but its giving my pistols errors Thnx for helping... and sorry for wrong section, wont happen again.[/QUOTE] No, just define ConeDecrement at the beginning of the file, and mess with values until you have the desired effect.
Ok.. Ill give it a shot thanks for the help, again. :)
See Developer Discussion, thanks!
Sorry, you need to Log In to post a reply to this thread.