add sborka
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
local PLUGIN = PLUGIN
|
||||
|
||||
-- Просмотр украденного документа
|
||||
net.Receive("ixDisguise_ViewStolenID", function()
|
||||
local data = net.ReadTable()
|
||||
|
||||
local plugin = ix.plugin.Get("military_id")
|
||||
if plugin then
|
||||
plugin:ShowDocument(data)
|
||||
end
|
||||
end)
|
||||
@@ -0,0 +1,83 @@
|
||||
ITEM.name = "Украденный военный билет"
|
||||
ITEM.description = "Военный билет, снятый с убитого противника. Содержит его данные."
|
||||
ITEM.model = "models/props_c17/paper01.mdl"
|
||||
ITEM.width = 1
|
||||
ITEM.height = 1
|
||||
ITEM.category = "Маскировка"
|
||||
ITEM.noDrop = false
|
||||
|
||||
-- Функция предъявления документа
|
||||
ITEM.functions.Show = {
|
||||
name = "Предъявить",
|
||||
tip = "Показать военный билет ближайшему игроку",
|
||||
icon = "icon16/eye.png",
|
||||
OnRun = function(item)
|
||||
local client = item.player
|
||||
|
||||
if CLIENT then
|
||||
-- Создаем меню выбора игрока
|
||||
local menu = DermaMenu()
|
||||
|
||||
for _, ply in ipairs(player.GetAll()) do
|
||||
if ply ~= client and ply:GetPos():Distance(client:GetPos()) <= 200 then
|
||||
menu:AddOption(ply:Name(), function()
|
||||
net.Start("ixDisguise_ShowStolenID")
|
||||
net.WriteUInt(ply:UserID(), 16)
|
||||
net.WriteUInt(item:GetID(), 32)
|
||||
net.SendToServer()
|
||||
end)
|
||||
end
|
||||
end
|
||||
|
||||
if menu:ChildCount() == 0 then
|
||||
menu:AddOption("Нет игроков поблизости", function() end):SetDisabled(true)
|
||||
end
|
||||
|
||||
menu:Open()
|
||||
end
|
||||
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
return !IsValid(item.entity)
|
||||
end
|
||||
}
|
||||
|
||||
-- Функция просмотра своего документа
|
||||
ITEM.functions.View = {
|
||||
name = "Просмотреть",
|
||||
tip = "Посмотреть содержимое военного билета",
|
||||
icon = "icon16/page_white_text.png",
|
||||
OnRun = function(item)
|
||||
local client = item.player
|
||||
|
||||
if SERVER then
|
||||
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(client)
|
||||
end
|
||||
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
return !IsValid(item.entity)
|
||||
end
|
||||
}
|
||||
|
||||
-- Кастомное отображение в инвентаре
|
||||
if CLIENT then
|
||||
function ITEM:PaintOver(item, w, h)
|
||||
local victimName = self:GetData("name")
|
||||
if victimName then
|
||||
draw.SimpleText(victimName, "DermaDefault", w/2, h - 5, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_BOTTOM)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,101 @@
|
||||
ITEM.name = "Украденная форма"
|
||||
ITEM.description = "Военная форма, снятая с убитого противника. Позволяет замаскироваться под врага."
|
||||
ITEM.model = "models/props_c17/suitcase001a.mdl"
|
||||
ITEM.width = 2
|
||||
ITEM.height = 2
|
||||
ITEM.category = "Маскировка"
|
||||
ITEM.noDrop = false
|
||||
|
||||
-- Функция надевания формы
|
||||
ITEM.functions.Wear = {
|
||||
name = "Надеть",
|
||||
tip = "Надеть украденную форму для маскировки",
|
||||
icon = "icon16/user_suit.png",
|
||||
OnRun = function(item)
|
||||
local client = item.player
|
||||
local character = client:GetCharacter()
|
||||
|
||||
if SERVER then
|
||||
-- Проверяем кулдаун
|
||||
local plugin = ix.plugin.Get("disguise")
|
||||
local canUse, msg = plugin:CanUseDisguise(client)
|
||||
|
||||
if not canUse then
|
||||
client:Notify(msg)
|
||||
return false
|
||||
end
|
||||
|
||||
-- Проверяем, не в маскировке ли уже
|
||||
if character:GetData("disguised") then
|
||||
client:Notify("Вы уже в маскировке!")
|
||||
return false
|
||||
end
|
||||
|
||||
-- Получаем украденную модель
|
||||
local stolenModel = item:GetData("stolenModel")
|
||||
if not stolenModel then
|
||||
client:Notify("Форма повреждена!")
|
||||
return false
|
||||
end
|
||||
|
||||
-- Сохраняем оригинальную модель и надеваем украденную
|
||||
local originalModel = client:GetModel()
|
||||
character:SetData("originalModel", originalModel)
|
||||
character:SetData("disguiseModel", stolenModel)
|
||||
character:SetData("disguised", true)
|
||||
|
||||
client:SetModel(stolenModel)
|
||||
|
||||
local victimName = item:GetData("victimName", "неизвестного")
|
||||
client:Notify("Вы надели форму " .. victimName .. ". Будьте осторожны!")
|
||||
|
||||
-- Удаляем предмет после использования
|
||||
item:Remove()
|
||||
end
|
||||
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
return !IsValid(item.entity)
|
||||
end
|
||||
}
|
||||
|
||||
-- Функция снятия формы
|
||||
ITEM.functions.Remove = {
|
||||
name = "Снять",
|
||||
tip = "Снять маскировку",
|
||||
icon = "icon16/user_delete.png",
|
||||
OnRun = function(item)
|
||||
local client = item.player
|
||||
local character = client:GetCharacter()
|
||||
|
||||
if SERVER then
|
||||
if not character:GetData("disguised") then
|
||||
client:Notify("Вы не в маскировке!")
|
||||
return false
|
||||
end
|
||||
|
||||
local plugin = ix.plugin.Get("disguise")
|
||||
if plugin then
|
||||
plugin:RemoveDisguise(client)
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end,
|
||||
OnCanRun = function(item)
|
||||
local client = item.player
|
||||
local character = client and client:GetCharacter()
|
||||
return !IsValid(item.entity) and character and character:GetData("disguised")
|
||||
end
|
||||
}
|
||||
|
||||
-- Кастомное отображение в инвентаре
|
||||
if CLIENT then
|
||||
function ITEM:PaintOver(item, w, h)
|
||||
local victimName = self:GetData("victimName")
|
||||
if victimName then
|
||||
draw.SimpleText("Форма: " .. victimName, "DermaDefault", w/2, h - 5, color_white, TEXT_ALIGN_CENTER, TEXT_ALIGN_BOTTOM)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
PLUGIN.name = "Disguise System"
|
||||
PLUGIN.author = "Your Name"
|
||||
PLUGIN.description = "Система маскировки с украденной формой и документами"
|
||||
|
||||
ix.util.Include("sv_plugin.lua")
|
||||
ix.util.Include("cl_plugin.lua")
|
||||
|
||||
if SERVER then
|
||||
util.AddNetworkString("ixDisguise_ViewStolenID")
|
||||
util.AddNetworkString("ixDisguise_ShowStolenID")
|
||||
end
|
||||
|
||||
-- Конфигурация
|
||||
PLUGIN.dropChance = 0.3 -- 30% шанс выпадения предметов
|
||||
PLUGIN.disguiseCooldown = 600 -- 10 минут в секундах
|
||||
@@ -0,0 +1,99 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user