Okay I’ve tried figuring out the problem with the following code for hours, but I guess I’m just too stupid to get it?
ITEM.Name = "item_test"
ITEM.Price = 200
ITEM.Material = "none"
ITEM.WeaponClass = "none"
ITEM.SingleUse = false
function ITEM:OnBuy(ply)
-- ply:Give(self.WeaponClass)
-- ply:SelectWeapon(self.WeaponClass)
ply:PS_ToggleMenu()
end
local function buying(ply)
local has = "Sell"
local hasnot = "Buy"
if ply:PS_HasItem('item_test') then
return has
else
return hasnot
end
end
hook.Add( "ShouldDrawLocalPlayer", "item_buy", buying )
local boughtornot = buying()
ITEM.Category = boughtornot
The code is supposed to change the ITEM.Category when it is bought.
But it spits out this error:
[ERROR] lua/pointshop/items/buyable_weapons/item_test.lua:17: attempt to index local 'ply' (a nil value)
1. buying - lua/pointshop/items/buyable_weapons/item_test.lua:17
2. unknown - lua/pointshop/items/buyable_weapons/item_test.lua:25
3. include - [C]:-1
4. LoadItems - lua/pointshop/sh_init.lua:119
5. Initialize - lua/pointshop/sh_init.lua:55
6. unknown - lua/autorun/pointshop.lua:4
Apparently it has a problem with
local boughtornot = buying()
because if I comment it doesn’t give me a error.
Greeting, Santifocus