Pointshop Boost Help

I am looking for help with pointshop boosts for deathrun.

For example I want 4 HP boosts, 125, 150, 175, 200. I want you to have to purchase the first to be able to get the second, how would I go about that?

Have you got any written code yet? I would say you need to make a variable once the first is purchased and add that same variable to the next boost.

For example:

125 HP boost:


ITEM.Name = '125 HP Boost'
ITEM.Price = 1000
ITEM.Model = 'models/props_junk/GlassBottle01a.mdl'
ITEM.NoPreview = true

local boostnumber = 0

function ITEM:OnEquip(ply, modifications)
	ply:SetHealth(125)
	boostnumber = 1
end

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

150 HP boost:


ITEM.Name = '150 HP Boost'
ITEM.Price = 1000
ITEM.Model = 'models/props_junk/GlassBottle01a.mdl'
ITEM.NoPreview = true

include("125hpboost.lua") -- This should be the file name of the previous boost.

function ITEM:OnEquip(ply, modifications)
	if boostnumber == 1 then
		ply:SetHealth(150)
	else
		chat.AddText( Color( 255, 0, 0 ), "You must purchase the 100 HP Boost first!")
	end
end

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

Note: The example code is incomplete and wont work on its own.

Why would that code not work on it’s own?

Sorry, that note was supposed to be deleted after I decided to write the code myself, that should work. If not then let me know on this thread and I’ll get back to you asap :slight_smile:

Oh okay cool :slight_smile:

So is this all correct so far:
125 HP Boost


ITEM.Name = '125 HP Boost'
ITEM.Price = 1000
ITEM.Model = 'models/props_junk/GlassBottle01a.mdl'
ITEM.NoPreview = true

local boostnumber = 0

function ITEM:OnEquip(ply, modifications)
	ply:SetHealth(125)
	boostnumber = 1
end

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


150 HP Boost


ITEM.Name = '150 HP Boost'
ITEM.Price = 1000
ITEM.Model = 'models/props_junk/GlassBottle01a.mdl'
ITEM.NoPreview = true

include("125hpboost.lua") -- This should be the file name of the previous boost.

local boostnumber = 1

function ITEM:OnEquip(ply, modifications)
	if boostnumber == 2 then
		ply:SetHealth(150)
	else
		chat.AddText( Color( 255, 0, 0 ), "You must purchase the 100 HP Boost first!")
	end
end

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


175 HP Boost


ITEM.Name = '150 HP Boost'
ITEM.Price = 1000
ITEM.Model = 'models/props_junk/GlassBottle01a.mdl'
ITEM.NoPreview = true

include("150hpboost.lua") -- This should be the file name of the previous boost.

function ITEM:OnEquip(ply, modifications)
	if boostnumber == 2 then
		ply:SetHealth(175)
	else
		chat.AddText( Color( 255, 0, 0 ), "You must purchase the 100 HP Boost first!")
	end
end

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


I’ve looked into this a little bit more. Here is a really useful page for pointshop coding.

file1 should be called “125hpboost.lua”



ITEM.Name = '125 HP Boost'
ITEM.Price = 1000
ITEM.Model = 'models/props_junk/GlassBottle01a.mdl'
ITEM.NoPreview = true

local boostnumber = 0

function ITEM:OnBuy(ply)
	local boostnumber = 1
end

function ITEM:OnEquip(ply, modifications)
	ply:SetHealth(125)
end

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


file2 should be called “150hpboost.lua”



ITEM.Name = '150 HP Boost'
ITEM.Price = 1000
ITEM.Model = 'models/props_junk/GlassBottle01a.mdl'
ITEM.NoPreview = true

include("125hpboost.lua") -- This should be the file name of the previous boost.


function ITEM:CanPlayerBuy(ply)
	if boostnumber == 1 then
		return true
	else
		chat.AddText( Color( 255, 0, 0 ), "You must purchase the 125 HP Boost first!")
	end
end

function ITEM:OnBuy(ply)
	local boostnumber = 2
end

function ITEM:OnEquip(ply, modifcations)
	ply:SetHealth(150)
end

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


file3 should be called “175hpboost.lua”



ITEM.Name = '175 HP Boost'
ITEM.Price = 1000
ITEM.Model = 'models/props_junk/GlassBottle01a.mdl'
ITEM.NoPreview = true

include("150hpboost.lua") -- This should be the file name of the previous boost.


function ITEM:CanPlayerBuy(ply)
	if boostnumber == 2 then
		return true
	else
		chat.AddText( Color( 255, 0, 0 ), "You must purchase the 150 HP Boost first!")
	end
end

function ITEM:OnBuy(ply)
	local boostnumber = 3
end

function ITEM:OnEquip(ply, modifcations)
	ply:SetHealth(175)
end

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


file4 should be called “200hpboost.lua”



ITEM.Name = '200 HP Boost'
ITEM.Price = 1000
ITEM.Model = 'models/props_junk/GlassBottle01a.mdl'
ITEM.NoPreview = true

include("175hpboost.lua") -- This should be the file name of the previous boost.


function ITEM:CanPlayerBuy(ply)
	if boostnumber == 3 then
		return true
	else
		chat.AddText( Color( 255, 0, 0 ), "You must purchase the 175 HP Boost first!")
	end
end

function ITEM:OnEquip(ply, modifcations)
	ply:SetHealth(200)
end

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


Thanks for the help!

I had one about two years ago that I didn’t save, I’m pretty sure I did it a different way, I got the amount of health the person had and then added on to that.

All you have to do to make it add to the player’s current health rather than set the player’s health is change the line that says:



function ITEM:OnEquip(ply, modifcations)
	ply:SetHealth(200)
end


to



function ITEM:OnEquip(ply, modifcations)
	ply:SetHealth(ply:Health() + 200)
end