attempt to call method 'RemoveCallback' (a nil value) ?
4 replies, posted
Hi,
I'm trying to remove a callback both from serverside and clientside it works clientside but server throw a
attempt to call method 'RemoveCallback' (a nil value)
full code if needed :
function SWEP:PrimaryAttack()
if not IsFirstTimePredicted() then return end
self:Initialize()
end
function SWEP:SecondaryAttack()
if not IsFirstTimePredicted() then return end
self:RemoveCallbackZ('bbpcbid')
end
function SWEP:RemoveCallbackZ( varIndex )
if CLIENT then
self.Owner:RemoveCallback("BuildBonePositions", self.Owner:GetTable()[varIndex])
self.Owner:SetVar(varIndex, nil )
end
if SERVER then
print(self.Owner)
print(varIndex)
self.Owner:RemoveCallback("BuildBonePositions", self.Owner:GetTable()[varIndex])
end
end
function SWEP:DrawWorldModel()
return false
end
function SWEP:Deploy()
self.Owner:DrawViewModel(false)
end
function SWEP:Initialize()
self:SetHoldType(self.HoldType)
if not self.Owner:GetTable()['bbpcbid'] then
print("no bbpcbid in player table, adding one")
local callbackId = self.Owner:AddCallback("BuildBonePositions", function(entTarget)
if not entTarget:IsValid() then self:RemoveCallbackZ(entTarget:GetTable()[('bbpcbid')]) return end
local rightFoot = entTarget:LookupBone("ValveBiped.Bip01_R_Foot")
local head = entTarget:LookupBone("ValveBiped.Bip01_Head1")
local rShoulder = entTarget:LookupBone("ValveBiped.Bip01_R_Shoulder")
local lShoulder = entTarget:LookupBone("ValveBiped.Bip01_L_Shoulder")
local headPos,headAng = entTarget:GetBonePosition(head)
local lShoulderPos,lShoulderAng = entTarget:GetBonePosition(lShoulder)
local rShoulderPos,rShoulderAng = entTarget:GetBonePosition(rShoulder)
entTarget:SetBonePosition(head, headPos + Vector(0,0,10), headAng)
end )
self.Owner:SetVar("bbpcbid", callbackId )
end
end
SERVER OUTPUT :
Player [1][Z.]
bbpcbid
[ERROR] addons/rickysweapons/lua/weapons/weapon_footkick/shared.lua:41: attempt to call method 'RemoveCallback' (a nil value)
1. RemoveCallbackZ - addons/rickysweapons/lua/weapons/weapon_footkick/shared.lua:41
2. unknown - addons/rickysweapons/lua/weapons/weapon_footkick/shared.lua:27
Thanks in advance.
'RemoveCallback' (a nil value)
Your server is not up to date.
My server is not up to date ? What do you mean ? RemoveCallback doesnt exist serverside but exist clientside ?
What should i do then, ask my provider ? (im hosted by gmchosting)
Update your server through your provider's method, or make a ticket with them. RemoveCallback was added in the July update.
Sorry, you need to Log In to post a reply to this thread.