refactor: Switch to modern lang layout & use nw vars
This commit is contained in:
parent
58c6052d94
commit
e0d46d715c
2 changed files with 20 additions and 34 deletions
|
@ -3,55 +3,34 @@ if SERVER then
|
|||
|
||||
resource.AddFile("materials/vgui/ttt/icon_silentstep.vmt")
|
||||
resource.AddFile("materials/vgui/ttt/perks/hud_silentstep.png")
|
||||
|
||||
util.AddNetworkString("TTTSilentstepBought")
|
||||
end
|
||||
|
||||
ITEM.hud = Material("vgui/ttt/perks/hud_silentstep.png")
|
||||
ITEM.EquipMenuData = {
|
||||
type = "item_passive",
|
||||
name = "item_silentstep_name",
|
||||
desc = "item_silentstep_desc"
|
||||
desc = "item_silentstep_desc",
|
||||
}
|
||||
ITEM.material = "vgui/ttt/icon_silentstep"
|
||||
ITEM.CanBuy = { ROLE_TRAITOR, ROLE_DETECTIVE }
|
||||
|
||||
if SERVER then
|
||||
function ITEM:Bought(ply)
|
||||
net.Start("TTTSilentstepBought")
|
||||
net.WriteEntity(ply)
|
||||
net.Broadcast()
|
||||
---
|
||||
---@param ply Player
|
||||
function ITEM:Equip(ply)
|
||||
ply:SetNWBool("ttt_silent_step", true)
|
||||
end
|
||||
else
|
||||
hook.Add("TTT2Initialize", "TTTItemSilentStepLang", function()
|
||||
LANG.AddToLanguage("English", "item_silentstep_name", "Silent Step")
|
||||
LANG.AddToLanguage("English", "item_silentstep_desc", "Silent Step Perk.\nLets you walk like a ninja without any steps!")
|
||||
end)
|
||||
|
||||
net.Receive("TTTSilentstepBought", function()
|
||||
local ply = net.ReadEntity()
|
||||
|
||||
if ply == LocalPlayer() then return end
|
||||
|
||||
if not ply:HasEquipmentItem("item_ttt_silentstep") then
|
||||
ply.equipmentItems = ply.equipmentItems or {}
|
||||
ply.equipmentItems[#ply.equipmentItems + 1] = "item_ttt_silentstep"
|
||||
---
|
||||
---@param ply Player
|
||||
function ITEM:Reset(ply)
|
||||
ply:SetNWBool("ttt_silent_step", false)
|
||||
end
|
||||
end)
|
||||
|
||||
hook.Add("TTTEndRound", "TTTSilentStepCleanUp", function()
|
||||
local lcply = LocalPlayer()
|
||||
|
||||
for _, v in ipairs(player.GetAll()) do
|
||||
if v ~= lcply then
|
||||
v.equipmentItems = {}
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
hook.Add("PlayerFootstep", "TTTSilentStepNoSound", function(ply)
|
||||
if ply:HasEquipmentItem("item_ttt_silentstep") then
|
||||
---@cast ply Player
|
||||
if ply:GetNWBool("ttt_silent_step", false) then
|
||||
return true
|
||||
end
|
||||
end)
|
||||
|
|
7
lua/terrortown/lang/en/ttt_silentstep.lua
Normal file
7
lua/terrortown/lang/en/ttt_silentstep.lua
Normal file
|
@ -0,0 +1,7 @@
|
|||
local L = LANG.GetLanguageTableReference("en")
|
||||
|
||||
L["item_silentstep_name"] = "Silent Step"
|
||||
L["item_silentstep_desc"] = [[
|
||||
Silent Step Perk.
|
||||
Lets you walk like a ninja without any steps!
|
||||
]]
|
Loading…
Add table
Reference in a new issue