• SWEP Registering - Userdata not present
    3 replies, posted
This problem is something I could not figure out, I tried researching, searching the forums - nothing. The issue lies in my shared function that creates a weapon with enhanced stats based off of pre-existing SWEPs, using weapons.register() instead of copying, pasting and editing each file. It uses weapons.Get(), and does not properly copy the FULL table. Yes, I do know that weapons.Get() does NOT copy over userdata (weapons.Get() uses table.Copy), which is the issue; the client-side of each SWEP includes multiple vectors and angles which MUST be present, otherwise the animations and other details will not be drawn correctly, producing errors. I know for a fact that weapons.GetStored() actually accomplishes the goal of creating a new SWEP with increased stats, but it also alters the original as well (obviously). So, how am I to retrieve a proper copy of the table WITH everything included? (I tried getting a new table with sanitising and desanitising the table returned from weapons.GetStored(), same result as previously mentioned). function CreateRefinedWeapon(class) local SWEP = weapons.Get(class) if not SWEP or not SWEP.Damage or not SWEP.ReloadSpeed then return end SWEP.Damage = SWEP.Damage + (SWEP.Damage * 0.15) --SWEP.Damage_Orig = SWEP.Damage_Orig + (SWEP.Damage_Orig * 0.15) SWEP.ReloadSpeed = SWEP.ReloadSpeed - (SWEP.ReloadSpeed * 0.25) --SWEP.ReloadSpeed_Orig = SWEP.ReloadSpeed_Orig - (SWEP.ReloadSpeed_Orig * 0.25) SWEP.Spawnable = false local newClass = class .. "_refined" local ID = (QM.GetIDByClass(class) and QM.GetIDByClass(class) .. "_refined") or (newClass) weapons.Register(SWEP, newClass) local SWEP = {id = ID, class = newClass, cost = 999, slot = "primary", hiddenFromStore = true} table.insert(RefinedWeapons, SWEP) end
Are you trying to change SWEP table after creating it?
No. Like I said, weapons.GetStored() returns the true table which is what I need. weapon.Get is not acceptable in this situation because it uses table.Copy.
Ok. So you need not-a-copy of previous weapon and you found that weapons.GetStored can help you, right?
Sorry, you need to Log In to post a reply to this thread.