add sborka

This commit is contained in:
2026-03-31 10:27:04 +03:00
commit f5e5f56c84
2345 changed files with 382127 additions and 0 deletions

View File

@@ -0,0 +1,263 @@
local PLUGIN = PLUGIN
-- Обработка отправки опроса
net.Receive("ixMilitaryID_SubmitQuiz", function(len, client)
local answers = net.ReadTable()
local character = client:GetCharacter()
if not character then return end
-- Проверка правильности ответов (опционально)
local score = 0
for i, answer in ipairs(answers) do
local question = PLUGIN.quizQuestions[i]
if question.correctAnswer and answer == question.correctAnswer then
score = score + 1
end
end
-- Если есть минимальный балл
if PLUGIN.minimumScore and score < PLUGIN.minimumScore then
client:Notify("Вы не прошли опрос. Попробуйте снова.")
return
end
-- Создание военного билета
local inventory = character:GetInventory()
if not inventory or isnumber(inventory) then
client:Notify("Инвентарь еще не загрузился, подождите немного...")
return
end
-- Проверяем, есть ли уже военный билет
for _, item in pairs(inventory:GetItems()) do
if item.uniqueID == "military_id" then
client:Notify("У вас уже есть военный билет!")
return
end
end
-- Выдаем пустой военный билет (данные заполнятся при первом просмотре)
inventory:Add("military_id")
client:Notify("Вы получили военный билет!")
end)
-- Показать документ другому игроку
net.Receive("ixMilitaryID_ShowToPlayer", function(len, client)
local targetIndex = net.ReadUInt(16)
local itemID = net.ReadUInt(32)
print("Received ShowToPlayer request: targetIndex=" .. targetIndex .. ", itemID=" .. itemID)
local target = Entity(targetIndex)
if not IsValid(target) or not target:IsPlayer() or target:GetPos():Distance(client:GetPos()) > 200 then
client:Notify("Игрок слишком далеко!")
return
end
if (client.ixNextIDShow or 0) > CurTime() then
client:Notify("Подождите " .. math.ceil(client.ixNextIDShow - CurTime()) .. " сек. перед повторным показом")
return
end
if target.ixIsViewingID then
client:Notify("Этот человек уже изучает другой документ")
return
end
local item = ix.item.instances[itemID]
if not item or item.player ~= client then
return
end
-- Берем актуальные данные персонажа
local character = client:GetCharacter()
if not character then return end
local factionTable = ix.faction.Get(character:GetFaction())
local podrData = factionTable and factionTable.Podr and factionTable.Podr[character:GetPodr()]
local specData = factionTable and factionTable.Spec and factionTable.Spec[character:GetSpec()]
local data = {
name = character:GetName(),
faction = factionTable and factionTable.name or "Неизвестно",
subdivision = podrData and podrData.name or "Неизвестно",
specialization = specData and specData.name or "Неизвестно",
rank = client.GetRankName and client:GetRankName() or "Неизвестно",
wanted = character:GetData("wanted", false)
}
-- Устанавливаем статус просмотра для цели
target.ixIsViewingID = true
-- Ставим кулдаун отправителю
client.ixNextIDShow = CurTime() + 5
-- Отправляем данные документа целевому игроку
net.Start("ixMilitaryID_ViewDocument")
net.WriteTable(data)
net.Send(target)
client:Notify("Вы предъявили военный билет игроку " .. target:Name())
target:Notify(client:Name() .. " предъявил вам военный билет")
end)
-- Сохранение отредактированного документа
net.Receive("ixMilitaryID_SaveEdit", function(len, client)
if not client:IsAdmin() then
client:Notify("У вас нет прав для редактирования!")
return
end
local itemID = net.ReadUInt(32)
local newData = net.ReadTable()
local item = ix.item.instances[itemID]
if not item or item.uniqueID ~= "military_id" then
return
end
-- Обновляем данные
for key, value in pairs(newData) do
item:SetData(key, value)
end
client:Notify("Военный билет успешно отредактирован!")
-- Если владелец онлайн, уведомляем его
if IsValid(item.player) and item.player ~= client then
item.player:Notify("Ваш военный билет был отредактирован администратором")
end
end)
-- Сброс состояния просмотра документа
net.Receive("ixMilitaryID_StopView", function(len, client)
client.ixIsViewingID = nil
end)
function PLUGIN:PlayerDisconnected(client)
client.ixIsViewingID = nil
end
function PLUGIN:OnCharacterLoaded(character)
local ply = character:GetPlayer()
if IsValid(ply) then
ply:SetNWBool("ix_wanted", character:GetData("wanted", false))
end
end
-- Консольная команда для предъявления военного билета другому игроку
concommand.Add("show_military_id_to_player", function(ply)
local character = ply:GetCharacter()
if not character then
ply:Notify("У вас нет активного персонажа!")
return
end
-- Проверяем наличие военного билета в инвентаре
local inventory = character:GetInventory()
local hasItem = false
if inventory then
for _, item in pairs(inventory:GetItems()) do
if item.uniqueID == "military_id" then
hasItem = true
break
end
end
end
if not hasItem then
ply:Notify("У вас нет военного билета! Вам нужно его получить.")
return
end
-- Трассировка взгляда от лица игрока
local trace = ply:GetEyeTrace()
local target = trace.Entity
-- Проверяем что смотрим на игрока и он близко
if IsValid(target) and target:IsPlayer() and target ~= ply and target:GetPos():Distance(ply:GetPos()) <= 200 then
if (ply.ixNextIDShow or 0) > CurTime() then
ply:Notify("Подождите " .. math.ceil(ply.ixNextIDShow - CurTime()) .. " сек. перед повторным показом")
return
end
if target.ixIsViewingID then
ply:Notify("Этот человек уже изучает другой документ")
return
end
local factionTable = ix.faction.Get(character:GetFaction())
local podrData = factionTable and factionTable.Podr and factionTable.Podr[character:GetPodr()]
local specData = factionTable and factionTable.Spec and factionTable.Spec[character:GetSpec()]
local data = {
name = character:GetName(),
faction = factionTable and factionTable.name or "Неизвестно",
subdivision = podrData and podrData.name or "Неизвестно",
specialization = specData and specData.name or "Неизвестно",
rank = ply.GetRankName and ply:GetRankName() or "Неизвестно",
wanted = character:GetData("wanted", false),
wanted_fsb = character:GetData("wanted_fsb", false),
wanted_sbu = character:GetData("wanted_sbu", false)
}
-- Устанавливаем статус просмотра для цели
target.ixIsViewingID = true
-- Ставим кулдаун отправителю
ply.ixNextIDShow = CurTime() + 5
-- Отправляем данные документа целевому игроку
net.Start("ixMilitaryID_ViewDocument")
net.WriteTable(data)
net.Send(target)
ply:Notify("Вы показали военный билет игроку " .. target:GetName())
else
ply:Notify("Посмотрите на игрока поблизости")
end
end)
-- Консольная команда для показа военного билета себе
concommand.Add("show_military_id", function(ply)
local character = ply:GetCharacter()
if not character then
ply:Notify("У вас нет активного персонажа!")
return
end
-- Проверяем наличие военного билета в инвентаре
local inventory = character:GetInventory()
local hasItem = false
if inventory then
for _, item in pairs(inventory:GetItems()) do
if item.uniqueID == "military_id" then
hasItem = true
break
end
end
end
if not hasItem then
ply:Notify("У вас нет военного билета! Вам нужно его получить.")
return
end
local factionTable = ix.faction.Get(character:GetFaction())
local podrData = factionTable and factionTable.Podr and factionTable.Podr[character:GetPodr()]
local specData = factionTable and factionTable.Spec and factionTable.Spec[character:GetSpec()]
local data = {
name = character:GetName(),
faction = factionTable and factionTable.name or "Неизвестно",
subdivision = podrData and podrData.name or "Неизвестно",
specialization = specData and specData.name or "Неизвестно",
rank = ply.GetRankName and ply:GetRankName() or "Неизвестно",
wanted = character:GetData("wanted", false),
wanted_fsb = character:GetData("wanted_fsb", false),
wanted_sbu = character:GetData("wanted_sbu", false)
}
net.Start("ixMilitaryID_ViewDocument")
net.WriteTable(data)
net.Send(ply)
end)