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/icon_silentstep.vmt")
|
||||||
resource.AddFile("materials/vgui/ttt/perks/hud_silentstep.png")
|
resource.AddFile("materials/vgui/ttt/perks/hud_silentstep.png")
|
||||||
|
|
||||||
util.AddNetworkString("TTTSilentstepBought")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
ITEM.hud = Material("vgui/ttt/perks/hud_silentstep.png")
|
ITEM.hud = Material("vgui/ttt/perks/hud_silentstep.png")
|
||||||
ITEM.EquipMenuData = {
|
ITEM.EquipMenuData = {
|
||||||
type = "item_passive",
|
type = "item_passive",
|
||||||
name = "item_silentstep_name",
|
name = "item_silentstep_name",
|
||||||
desc = "item_silentstep_desc"
|
desc = "item_silentstep_desc",
|
||||||
}
|
}
|
||||||
ITEM.material = "vgui/ttt/icon_silentstep"
|
ITEM.material = "vgui/ttt/icon_silentstep"
|
||||||
ITEM.CanBuy = { ROLE_TRAITOR, ROLE_DETECTIVE }
|
ITEM.CanBuy = { ROLE_TRAITOR, ROLE_DETECTIVE }
|
||||||
|
|
||||||
if SERVER then
|
if SERVER then
|
||||||
function ITEM:Bought(ply)
|
---
|
||||||
net.Start("TTTSilentstepBought")
|
---@param ply Player
|
||||||
net.WriteEntity(ply)
|
function ITEM:Equip(ply)
|
||||||
net.Broadcast()
|
ply:SetNWBool("ttt_silent_step", true)
|
||||||
end
|
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()
|
---@param ply Player
|
||||||
|
function ITEM:Reset(ply)
|
||||||
if ply == LocalPlayer() then return end
|
ply:SetNWBool("ttt_silent_step", false)
|
||||||
|
|
||||||
if not ply:HasEquipmentItem("item_ttt_silentstep") then
|
|
||||||
ply.equipmentItems = ply.equipmentItems or {}
|
|
||||||
ply.equipmentItems[#ply.equipmentItems + 1] = "item_ttt_silentstep"
|
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
hook.Add("PlayerFootstep", "TTTSilentStepNoSound", function(ply)
|
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
|
return true
|
||||||
end
|
end
|
||||||
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