• Swep problem
    8 replies, posted
Ok, making this swep.. pGrenade:GetPhysicsObject():SetVelocity( vecThrow ); gets this error weapons/weapon_football/shared.lua:103: Tried to use invalid object (type IPhysicsObject) (Object was NULL or not of the right type) anyone know how to fix it? thnx.
pGrenade:GetPhysicsObject() is not valid. Do something like [code]local phys = pGrenade:GetPhysicsObject() if not IsValid(phys) then return end[/code] Before your whatever you're doing.
weapons/weapon_football/shared.lua:93: attempt to index global 'pGrenade' (a nil value) [QUOTE] local phys = pGrenade:GetPhysicsObject() if not IsValid(phys) then return end local ent = ents.Create("blah") [/QUOTE] That code u gave me is the error =/ [editline]09:04PM[/editline] Ok, I fixed all the errors. BUT. now when i left click it just looses ammo. doesn't throw anything. add me on steam D:
We'd need to see more code, say the rest of your primary attack function, before we can really find out where the problem is.
-removed pastebin link.. dont want noobs copying.- ill pm it to you guys.
Entoros' lines quit out of the function if it's not a valid physics object. Since you're calling them before the entity is fully initialised, it makes sense that its physics object isn't fully initialised either. Try moving the lines to after your ent:Activate() or taking them out, and seeing what happens (tell us which one you did). Also you're not at risk of your SWEP being copied - I Googled its base (swep_frag) and what you're making is pretty much an edit of that. Without wanting to sound blunt you're the one copying code and altering it.
By the way, the pastebin can be found on google [url]http://pastebin.com/Ji2r61tV[/url] :whatup:
Please use more descriptive thread titles.
Yessir [editline]04:06PM[/editline] Ok , when I shoot like i said up top it just looses ammo. heres the pastebin's. SWEP: [url]http://pastebin.com/6XkTfci6[/url] SENT: [url]http://pastebin.com/D894Kd8N[/url]
Sorry, you need to Log In to post a reply to this thread.