[Pointshop] Problem with getting Values from Tables (And use them for the Item Properties)

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)


But apparently


Only works in a (?) Called function like this

concommand.Add( "testingcomand", function()
end )

>>Outputs: M16


function ITEM:OnBuy(ply)

>>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

The Pointshop file is being loaded before the M16 weapon file, so “weapon_ttt_m16” doesn’t exist yet.

Oh wow I did not know that, that makes quite a lote sense then ^^

Imma try something… brb

[editline]30th October 2017[/editline]

Okay puttin timer.Simple(5, infront of function PS:LoadItems()

timer.Simple(5,function PS:LoadItems()

Just causes way more erros, figures.
Is there a way to delay the loading of the pointshop?


timer.Simple is wrong


Yeah probably but that does not work either :confused:

Alrigth, found a solution myself …