I'm using SWEP:CustomAmmoDisplay() to make a custom ammo display :downs: but when I try to use a bunch of functions they error out.
Even using self.Owner results in indexing a nil value.
Can anyone verify this for me or am I doing something wrong?
[lua]if CLIENT then
function SWEP:DrawHUD()
MsgN("HUD "..tostring(IsEntity(self))) -- HUD true
MsgN("HUD "..self.Owner:GetAmmoCount(self.Primary.Ammo)) -- HUD 100
end
function SWEP:CustomAmmoDisplay()
MsgN("Ammo "..tostring(IsEntity(self))) -- Ammo false
MsgN("Ammo "..self.Owner:GetAmmoCount(self.Primary.Ammo))
-- [ERROR] addons/ut2k4_weapons/lua/weapons/ut2k4_mine_layer/shared.lua:251: attempt to index field 'Owner' (a nil value)
-- 1. unknown - addons/ut2k4_weapons/lua/weapons/ut2k4_mine_layer/shared.lua:251
end
end[/lua]
Are you sure the owner exists?
[del]Try using self:GetOwner() instead in that single case, if that still doesn't work report it on [URL="https://github.com/garrynewman/garrysmod/issues"]gmod's github[/URL] as an issue.[/del]
If it goes as far as to say that its own self is invalid then [URL="https://github.com/garrynewman/garrysmod/issues"]report it[/URL].
The owner exists in the DrawHUD function so I'm sure it does
[editline]26th April 2013[/editline]
[QUOTE=Jvs;40435385]Try using self:GetOwner() instead in that single case, if that still doesn't work report it on [URL="https://github.com/garrynewman/garrysmod/issues"]gmod's github[/URL] as an issue.[/QUOTE]
[code]
[ERROR] addons/ut2k4_weapons/lua/weapons/ut2k4_mine_layer/shared.lua:239: attempt to call method 'GetOwner' (a nil value)
1. unknown - addons/ut2k4_weapons/lua/weapons/ut2k4_mine_layer/shared.lua:239
[/code]
I'll post it on github then
Sorry, you need to Log In to post a reply to this thread.