mirror of
https://github.com/lifestorm/wnsrc.git
synced 2025-12-17 13:53:45 +03:00
59 lines
1.5 KiB
Lua
59 lines
1.5 KiB
Lua
--[[
|
|
| This file was obtained through the combined efforts
|
|
| of Madbluntz & Plymouth Antiquarian Society.
|
|
|
|
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
|
|
| Maloy, DrPepper10 @ RIP, Atle!
|
|
|
|
|
| Visit for more: https://plymouth.thetwilightzone.ru/
|
|
--]]
|
|
|
|
|
|
ITEM.name = "Ammo Base"
|
|
ITEM.model = "models/Items/BoxSRounds.mdl"
|
|
ITEM.width = 1
|
|
ITEM.height = 1
|
|
ITEM.ammo = "pistol" -- type of the ammo
|
|
ITEM.ammoAmount = 30 -- amount of the ammo
|
|
ITEM.description = "A Box that contains %s of Pistol Ammo"
|
|
ITEM.category = "Ammunition"
|
|
ITEM.useSound = "items/ammo_pickup.wav"
|
|
|
|
function ITEM:GetDescription()
|
|
local rounds = self:GetData("rounds", self.ammoAmount)
|
|
return L(self.description, rounds)
|
|
end
|
|
|
|
if (CLIENT) then
|
|
function ITEM:PaintOver(item, w, h)
|
|
draw.SimpleText(
|
|
item:GetData("rounds", item.ammoAmount), "DermaDefault", w - 5, h - 5,
|
|
color_white, TEXT_ALIGN_RIGHT, TEXT_ALIGN_BOTTOM, 1, color_black
|
|
)
|
|
end
|
|
end
|
|
|
|
-- On player uneqipped the item, Removes a weapon from the player and keep the ammo in the item.
|
|
ITEM.functions.use = {
|
|
name = "Load",
|
|
tip = "useTip",
|
|
icon = "icon16/add.png",
|
|
OnRun = function(item)
|
|
local rounds = item:GetData("rounds", item.ammoAmount)
|
|
|
|
item.player:GiveAmmo(rounds, item.ammo)
|
|
if (ix.config.Get("equipSoundEnabled")) then
|
|
item.player:EmitSound(item.useSound, ix.config.Get("equipSoundLevel", 60))
|
|
end
|
|
|
|
return true
|
|
end,
|
|
}
|
|
|
|
-- Called after the item is registered into the item tables.
|
|
function ITEM:OnRegistered()
|
|
if (ix.ammo) then
|
|
ix.ammo.Register(self.ammo)
|
|
end
|
|
end
|