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:
[code]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 [/code]
150 HP boost:
[code]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 [/code]
[B]Note: The example code is incomplete and wont work on its own.[/B]
[QUOTE=DJMullaney;51563038]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:
[code]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 [/code]
150 HP boost:
[code]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 [/code]
[B]Note: The example code is incomplete and wont work on its own.[/B][/QUOTE]
Why would that code not work on it's own?
[QUOTE=Brendon;51563551]Why would that code not work on it's own?[/QUOTE]
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 :)
[QUOTE=DJMullaney;51563634]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 :)[/QUOTE]
Oh okay cool :)
So is this all correct so far:
125 HP Boost
[code]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
[/code]
150 HP Boost
[code]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
[/code]
175 HP Boost
[code]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
[/code]
[QUOTE=Brendon;51563833]Oh okay cool :)
So is this all correct so far:
125 HP Boost
[code]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
[/code]
150 HP Boost
[code]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
[/code]
175 HP Boost
[code]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
[/code][/QUOTE]
I've looked into this a little bit more. [URL="http://pointshop.burt0n.net/items/functions"]Here is a really useful page for pointshop coding.[/URL]
file1 should be called "125hpboost.lua"
[code]
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
[/code]
file2 should be called "150hpboost.lua"
[code]
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
[/code]
file3 should be called "175hpboost.lua"
[code]
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
[/code]
file4 should be called "200hpboost.lua"
[code]
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
[/code]
[QUOTE=DJMullaney;51563976]I've looked into this a little bit more. [URL="http://pointshop.burt0n.net/items/functions"]Here is a really useful page for pointshop coding.[/URL]
-snip-[/QUOTE]
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.
[QUOTE=Brendon;51564222]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.[/QUOTE]
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:
[code]
function ITEM:OnEquip(ply, modifcations)
ply:SetHealth(200)
end
[/code]
to
[code]
function ITEM:OnEquip(ply, modifcations)
ply:SetHealth(ply:Health() + 200)
end
[/code]
Sorry, you need to Log In to post a reply to this thread.