Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion gamemodes/jazztronauts/entities/weapons/weapon_stan.lua
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ SWEP.TopSpeed = 2000


-- List this weapon in the store
local storeStan = jstore.Register(SWEP, 4000, { type = "tool" })
local storeStan = jstore.Register(SWEP, 4000, {
desc = jazzloc.Localize("jazz.weapon.stan.desc"), -- don't use the short one
type = "tool"
})

-- Create 3 items to be purchased one after the other that control range
local storeRange = jstore.RegisterSeries("stan_range", 2000, 10, {
Expand Down
31 changes: 25 additions & 6 deletions gamemodes/jazztronauts/gamemode/store/jstore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ function Register(unlockName, price, props)
props = props or {}
props.price = math.max(0, math.Round(price))
props.unlock = unlockName -- For completeness
props.icon = props.icon or "scripted/breen_fakemonitor_1"

if props.icon then
props.icon = Material(props.icon, "mips smooth")
end

-- Calc the # of requisite items needed
-- Later on we'll sort by this
Expand Down Expand Up @@ -205,6 +208,7 @@ if SERVER then
-- Purchase a single item, given its full unlock name
-- Ensure the item is available, the player has enough money, and that
-- they haven't already purchased it
local HasPurchased = {}
function PurchaseItem(ply, unlockName)
if not IsValid(ply) or not unlockName then return false end

Expand All @@ -215,13 +219,28 @@ if SERVER then
-- Check the player has enough money
if ply:GetNotes() < item.price then return false end

-- On successful unlock, decrement money
if unlocks.Unlock(list_name, ply, unlockName) then
ply:ChangeNotes(-item.price)
return true
-- Try to unlock, return if unsuccessful
if not unlocks.Unlock(list_name, ply, unlockName) then return false end

ply:ChangeNotes(-item.price)

-- Play a neat purchase sound for everyone to hear, varying in pitch after first purchase
local pitch = 100
if table.HasValue(HasPurchased, ply) then
pitch = math.random(90, 110) -- sounddata's supposed to randomize tables, but it just kinda doesn't
else
table.insert(HasPurchased, ply)
end
sound.Add( {
sound = "c25/buy.mp3",
name = "jazzbuysound",
channel = CHAN_STATIC,
level = 80,
pitch = pitch,
} )
ply:EmitSound("jazzbuysound")

return false
return true
end

net.Receive("jazz_store_purchase", function(len, ply)
Expand Down
6 changes: 3 additions & 3 deletions gamemodes/jazztronauts/gamemode/store/thirdparty.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ timer.Simple(0, function() -- Gross, but gives all weapons a chance to register
lookup[v.ClassName] = v
end
local function AddWeapon(name, price, options)
if not lookup[name] then
if not lookup[name] then
print("Can't add " .. name .. " to Jazztronauts store. Not registered yet!")
return
return
end

options = options or {}
Expand All @@ -17,4 +17,4 @@ timer.Simple(0, function() -- Gross, but gives all weapons a chance to register

-- Wowozela
AddWeapon("wowozela", 50000, { type = "tool" })
end )
end )
7 changes: 4 additions & 3 deletions gamemodes/jazztronauts/gamemode/ui/spawnmenu/creation.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
-- Register upgrade that allows them to buy back their spawn menu
jstore.Register("spawnmenu", 100000, {
cat = "tools",
name = jazzloc.Localize("jazz.weapon.gmodspawnmenu"),
desc = jazzloc.Localize("jazz.weapon.gmodspawnmenu.desc"),
name = jazzloc.Localize("jazz.gmodspawn"),
desc = jazzloc.Localize("jazz.gmodspawn.desc"),
icon = "ui/gman.jpg",
thirdparty = true
})

Expand Down Expand Up @@ -180,4 +181,4 @@ function PANEL:Populate()

end

vgui.Register( "JazzCreationMenu", PANEL, "DPropertySheet" )
vgui.Register( "JazzCreationMenu", PANEL, "DPropertySheet" )
Loading