100 lines
3.5 KiB
Lua
100 lines
3.5 KiB
Lua
local PLUGIN = PLUGIN
|
|
|
|
-- Таблица для хранения кулдаунов
|
|
PLUGIN.disguiseCooldowns = PLUGIN.disguiseCooldowns or {}
|
|
|
|
-- Снятие маскировки
|
|
function PLUGIN:RemoveDisguise(client)
|
|
if not IsValid(client) then return end
|
|
|
|
local character = client:GetCharacter()
|
|
if not character then return end
|
|
|
|
-- Возвращаем оригинальную модель
|
|
local originalModel = character:GetModel()
|
|
client:SetModel(originalModel)
|
|
|
|
-- Удаляем флаг маскировки
|
|
character:SetData("disguised", false)
|
|
character:SetData("disguiseModel", nil)
|
|
|
|
-- Устанавливаем кулдаун
|
|
self.disguiseCooldowns[client:SteamID64()] = CurTime() + self.disguiseCooldown
|
|
|
|
client:Notify("Маскировка снята! Вы не сможете переодеться в течение 10 минут.")
|
|
end
|
|
|
|
-- Проверка кулдауна
|
|
function PLUGIN:CanUseDisguise(client)
|
|
local steamID = client:SteamID64()
|
|
local cooldown = self.disguiseCooldowns[steamID]
|
|
|
|
if cooldown and CurTime() < cooldown then
|
|
local remaining = math.ceil(cooldown - CurTime())
|
|
local minutes = math.floor(remaining / 60)
|
|
local seconds = remaining % 60
|
|
return false, string.format("Переодеться можно через %d:%02d", minutes, seconds)
|
|
end
|
|
|
|
return true
|
|
end
|
|
|
|
-- Хук на получение урона
|
|
function PLUGIN:EntityTakeDamage(target, dmg)
|
|
if not IsValid(target) or not target:IsPlayer() then return end
|
|
|
|
local character = target:GetCharacter()
|
|
if not character then return end
|
|
|
|
-- Проверяем, в маскировке ли игрок
|
|
if character:GetData("disguised") then
|
|
self:RemoveDisguise(target)
|
|
end
|
|
end
|
|
|
|
-- Хук на взятие оружия в руки
|
|
function PLUGIN:PlayerSwitchWeapon(client, oldWeapon, newWeapon)
|
|
if not IsValid(client) or not IsValid(newWeapon) then return end
|
|
|
|
local character = client:GetCharacter()
|
|
if not character then return end
|
|
|
|
-- Проверяем, в маскировке ли игрок
|
|
if character:GetData("disguised") then
|
|
self:RemoveDisguise(client)
|
|
end
|
|
end
|
|
|
|
-- Отправка данных украденного военного билета
|
|
net.Receive("ixDisguise_ShowStolenID", function(len, client)
|
|
local targetID = net.ReadUInt(16)
|
|
local itemID = net.ReadUInt(32)
|
|
|
|
local target = Player(targetID)
|
|
if not IsValid(target) or target:GetPos():Distance(client:GetPos()) > 200 then
|
|
client:Notify("Игрок слишком далеко!")
|
|
return
|
|
end
|
|
|
|
local item = ix.item.instances[itemID]
|
|
if not item or item.player ~= client then
|
|
return
|
|
end
|
|
|
|
-- Отправляем данные документа целевому игроку
|
|
local data = {
|
|
name = item:GetData("name", "Неизвестно"),
|
|
faction = item:GetData("faction", "Неизвестно"),
|
|
subdivision = item:GetData("subdivision", "Неизвестно"),
|
|
specialization = item:GetData("specialization", "Неизвестно"),
|
|
rank = item:GetData("rank", "Неизвестно")
|
|
}
|
|
|
|
net.Start("ixDisguise_ViewStolenID")
|
|
net.WriteTable(data)
|
|
net.Send(target)
|
|
|
|
client:Notify("Вы предъявили военный билет игроку " .. target:Name())
|
|
target:Notify(client:Name() .. " предъявил вам военный билет")
|
|
end)
|