• SWEP trouble
    2 replies, posted
Herro. Not sure where I am going wrong. I have a SWEP and for whatever reason, whenever I do SWEP:Owner on the second line, it gives me this error [IMG]https://i.gyazo.com/eee1aac7a67038c3a85fb187f64fe201.png[/IMG] (This happens both on client and server) (The error function is the function right after ply being defined) If I make SWEP:Owner to self.Owner, it just gives me this error. [IMG]https://i.gyazo.com/0f8518d8794bf19498b507e174ffb090.png[/IMG] (This also happens on client and serverside) [code] function SWEP:GetCuffSize(boneroo) local ply = SWEP:Owner local function lookupbone(lubone) -- Gets the bone id return ply:LookupBone(lubone) end local JSHBGroups = ply:GetHitBoxGroupCount() -- The amount of groups of hitboxes in the ent local JSHBXS = {} -- My little table to store the hitboxs I need JSHBXS.LeftHandHB = {} JSHBXS.RightHandHB = {} for k=0, JSHBGroups - 1 do -- Loops through all the hitbox groups with i = the hitbox group num local HBCount = ply:GetHitBoxCount(k) -- The amount of hitboxes in the hitbox group for v=0, HBCount do -- Loop through all the hitboxes in the group 'i' -- k now = the hitbox group and v = the hitbox in that group local mybone = ply:GetHitBoxBone(v,k) -- Gets a bone based on k,v if mybone == lookupbone(boneroo) then -- RBS.LHand is the bone id for Left hand JSHBXS.LeftHandHB["Group"] = k JSHBXS.LeftHandHB["HB"] = v elseif mybone == lookupbone(boneroo) then -- Same thing with right hand JSHBXS.RightHandHB["Group"] = k JSHBXS.RightHandHB["HB"] = v end end end -- Now we should have the hitboxes as needed. local function jsvecmath(boney) local JLH = JSHBXS.LeftHandHB -- So I don't have to type it all out local JRH = JSHBXS.RightHandHB local function jsquickr(hand) return ply:GetHitBoxBounds(hand["Group"], hand["HB"]) -- returns the vectors of hitbox end if boney == "ValveBiped.Bip01_L_Hand" then -- If we're dealing with the left hand local jvmin, jvmax = jsquickr(JLH) -- HB first, then group local x1,y1,z1 = jvmin local x2,y2,z2 = jvmax local x1 = math.abs(x1 - x2) -- get the distance between the two amirite? local z1 = math.abs(z1 - z2) -- get the distance between the two amirite? return Vector(x1,.1,z1) elseif boney == "ValveBiped.Bip01_R_Hand" then -- If we're dealing with the right hand local jvmin, jvmax = jsquickr(JRH) -- HB first, then group local x1,y1,z1 = jvmin local x2,y2,z2 = jvmax local x1 = math.abs(x1 - x2) -- get the distance between the two amirite? local z1 = math.abs(z1 - z2) -- get the distance between the two amirite? return Vector(x1,.1,z1) else return Vector(.17, .1, .17) end end return jsvecmath(boneroo) -- Gets the vector -- Edit x and z end [/code]
It should be ply = self:GetOwner(). Also, the way you're declaring sub-routines inside of the main routine is actually pretty cute, but it's going to be way more inefficient than just doing the work straight out since you are now adding an extra function call + having to create the function. [editline]13th August 2017[/editline] Also, the second error implies you aren't calling SWEP:GetCuffSize correctly.
[QUOTE=code_gs;52569734]It should be ply = self:GetOwner(). Also, the way you're declaring sub-routines inside of the main routine is actually pretty cute, but it's going to be way more inefficient than just doing the work straight out since you are now adding an extra function call + having to create the function. [editline]13th August 2017[/editline] Also, the second error implies you aren't calling SWEP:GetCuffSize correctly.[/QUOTE] I'm still testing the idea, I optimize it after I get it working. Thanks for the help. Still having the problem. [IMG]https://i.gyazo.com/a0924e0db91e4bb61d316621eb5f30c9.png[/IMG] This is how I call the function [code] SWEP:GetCuffSize("ValveBiped.Bip01_R_Hand") [/code] [editline]13th August 2017[/editline] NVM, Fixed it by doing a self.Owner check.
Sorry, you need to Log In to post a reply to this thread.