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:
[CODE]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[/CODE]
it would help if you explained what isn't working
you can't expect us to test your own code for you
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
[CODE][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
[/CODE]
does it make a difference whether I have ply:PS_Has.... or ply.PS_Has....??
[QUOTE=Blackout338;41491969]does it make a difference whether I have ply:PS_Has.... or ply.PS_Has....??[/QUOTE]
snip
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:
[CODE]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[/CODE]
[QUOTE]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[/QUOTE]
Sorry, you need to Log In to post a reply to this thread.