Pointshop Help

I need help with pointshop, what I am trying to do is make it so that you need to buy and own boost 1 before you can buy boost 2 and if you sell boost 1 after buying boost 2 it wont work anymore.
Thanks in advance.

This is my attempt at it:


ITEM.Name = 'Health Boost 2'
ITEM.Price = 2
ITEM.Material = '/DGN/health2.png'
ITEM.NoPreview = true

function ITEM:OnBuy(ply)
	if not ply:HasItem(hp1) then
	ply:SendLua([[chat.AddText(Color(0,0,200), "You need Health Boost 1 to purchase this item!")]])
	else return true end
end

function ITEM:OnEquip(ply)
	if ply:HasItem(hp1) then
		ply:SetHealth(175)
	else
		ply:SendLua([[chat.AddText(Color(0,0,200), "You need Health Boost 1 to Equip this item!")]])
		ply:SetHealth(100)
	end
end

function ITEM:OnHolster(ply)
	ply:SetHealth(100)
end

it would help if you explained what isn’t working

you can’t expect us to test your own code for you

hp1 is nil?

This is the error I get when I try to buy health boost 2, hp1 is the name of the lua file for health boost 1


[ERROR] addons/pointshop-master/lua/items/powerups/hp2.lua:7: attempt to call method 'HasItem' (a nil value)
  1. OnBuy - addons/pointshop-master/lua/items/powerups/hp2.lua:7
   2. PS_BuyItem - addons/pointshop-master/lua/sv_player_extension.lua:234
    3. func - addons/pointshop-master/lua/sv_pointshop.lua:4
     4. unknown - lua/includes/modules/net.lua:31



Ah, it’s Player.PS_HasItem not Player.HasItem.

does it make a difference whether I have ply:PS_Has… or ply.PS_Has…??

snip

ply.PS_HasItem(ply, item) is the same as ply:PS_HasItem(item)

Okay so here is my code now, there are no longer any errors it just sets my hp to 100 when I equip it whether I have health boost 1 or not and I can still buy it whether I have health boost 1 or not:


ITEM.Name = 'Health Boost 2'
ITEM.Price = 1
ITEM.Material = '/DGN/health2.png'
ITEM.NoPreview = true

function ITEM:OnBuy(ply)
	if not ply:PS_HasItem(hp1) then
	ply:SendLua([[chat.AddText(Color(0,0,200), "You need Health Boost 1 to purchase this item!")]])
	else return false end
end

function ITEM:OnEquip(ply)
	if ply:PS_HasItem(hp1) then
		ply:SetHealth(150)
	else
		ply:SendLua([[chat.AddText(Color(0,0,200), "You need Health Boost 1 to Equip this item!")]])
		ply:SetHealth(100)
	end
end

function ITEM:OnHolster(ply)
	ply:SetHealth(100)
end

What is hp1 set to? I don’t see you defining it anywhere in your code.

Replace hp1 with “hp1”.