So I’ve worked on a code today to universally get all Info for a Pointshop Item based on just the Item Name/Item ID
Item ID= weapon_ttt_m16_ps
local entityname = string.gsub(ITEM.ID, "_ps", "")
ITEM.Name = ((weapons.GetStored(entityname)).PrintName)
ITEM.Price = 200
ITEM.Material = ((weapons.GetStored(entityname)).Icon)
ITEM.WeaponClass = entityname
ITEM.SingleUse = false
--(There is more Code to this Item but it is irrelevant)
(ERROR CODE BELOW)
But apparently
((weapons.GetStored(entityname)).PrintName)
Only works in a (?) Called function like this
concommand.Add( "testingcomand", function()
print((weapons.GetStored("weapon_ttt_m16")).PrintName)
end )
>>Outputs: M16
Or
function ITEM:OnBuy(ply)
print((weapons.GetStored("weapon_ttt_m16")).PrintName)
end
>>Outputs: M16
Why is that? And how can I fix that? I really am lost on this one, because I was and still am sure that it should work… But it doesnt ._.
Greetings, Santifocus
[ERROR] lua/pointshop/items/mg/weapon_ttt_m16_ps.lua:3: attempt to index a nil value
1. unknown - lua/pointshop/items/mg/weapon_ttt_m16_ps.lua:3
2. include - [C]:-1
3. LoadItems - lua/pointshop/sh_init.lua:119
4. Initialize - lua/pointshop/sh_init.lua:54
5. unknown - lua/autorun/pointshop.lua:3