Untitled
unknown
lua
2 years ago
8.4 kB
10
Indexable
RegisterCommand(Config.commands.revivePoint.name, function(point)
local job = GetJob()
local isOwner = CurrentZone.job == job
local xPlayer = QBCore.Functions.GetPlayerData()
if not started then
local ped = PlayerPedId()
if PlayerData.dead or IsPedFatallyInjured(ped) then
if type(CurrentZone) == "table" then
if not lib.table.contains(CurrentZone.turfTypes, '1') then
return Notify(L('Notify.title_error'), L('revive_point.not_point'), 'error')
end
if CurrentZone and isOwner then
local pass, msg = lib.callback.await('hki_territories:canrevive', 100, CurrentZone.name)
if not pass then
return Notify(L('Notify.title_error'), msg, 'error')
end
if CurrentZone.job ~= job then
return Notify(L('Notify.title_error'), L('revive_point.no_own'), 'error')
end
local cb, duration, cap = lib.callback.await('hki_territories:checkRevivePointMoney', 100, CurrentZone.name)
if not cb then
return Notify(L('Notify.title_error'), L('revive_point.no_money'), 'error')
end
--[[if not cap then
return Notify(L('Notify.title_error'), L('revive_point.cantuse'), 'error')
end]]
started = true
if lib.progressCircle({
duration = duration,
label = L('revive_point.revive_progress'),
position = 'middle',
useWhileDead = true,
canCancel = false,
}) then
FreezeEntityPosition(cache.ped, true)
TriggerServerEvent('hki_territories:removeItem', CurrentZone.name)
TriggerServerEvent('hki_territories:reviveEvent')
local coords = vector3(CurrentZone.flag.x, CurrentZone.flag.y, CurrentZone.flag.z)
SetEntityCoords(ped, coords.x, coords.y, coords.z)
started = false
else FreezeEntityPosition(cache.ped, false) end
FreezeEntityPosition(cache.ped, false)
started = false
elseif CurrentZone and not isOwner and xPlayer.job.name == 'mafia1' then
local pass, msg = lib.callback.await('hki_territories:canrevive', 100, CurrentZone.name)
if not pass then
return Notify(L('Notify.title_error'), msg, 'error')
end
local cb, duration, cap = lib.callback.await('hki_territories:checkRevivePoint2Money', 100, CurrentZone.name)
if not cb then
return Notify(L('Notify.title_error'), L('revive_point.no_money'), 'error')
end
--[[if not cap then
return Notify(L('Notify.title_error'), L('revive_point.cantuse'), 'error')
end]]
started = true
if lib.progressCircle({
duration = Config.reviveBasic.time * 1000,
label = L('revive_point.revive_progress'),
position = 'middle',
useWhileDead = true,
canCancel = false,
}) then
FreezeEntityPosition(cache.ped, true)
TriggerServerEvent('hki_territories:reviveBasic', CurrentZone.name)
TriggerServerEvent('hki_territories:reviveEvent')
local coords = vector3(CurrentZone.flag2.x, CurrentZone.flag2.y, CurrentZone.flag2.z)
SetEntityCoords(ped, coords.x, coords.y, coords.z)
started = false
else FreezeEntityPosition(cache.ped, false) end
FreezeEntityPosition(cache.ped, false)
started = false
elseif CurrentZone and not isOwner and xPlayer.job.name == 'mafia3' then
local pass, msg = lib.callback.await('hki_territories:canrevive', 100, CurrentZone.name)
if not pass then
return Notify(L('Notify.title_error'), msg, 'error')
end
local cb, duration, cap = lib.callback.await('hki_territories:checkRevivePoint2Money', 100, CurrentZone.name)
if not cb then
return Notify(L('Notify.title_error'), L('revive_point.no_money'), 'error')
end
--[[if not cap then
return Notify(L('Notify.title_error'), L('revive_point.cantuse'), 'error')
end]]
started = true
if lib.progressCircle({
duration = Config.reviveBasic.time * 1000,
label = L('revive_point.revive_progress'),
position = 'middle',
useWhileDead = true,
canCancel = false,
}) then
FreezeEntityPosition(cache.ped, true)
TriggerServerEvent('hki_territories:reviveBasic', CurrentZone.name)
TriggerServerEvent('hki_territories:reviveEvent')
local coords = vector3(CurrentZone.flag3.x, CurrentZone.flag3.y, CurrentZone.flag3.z)
SetEntityCoords(ped, coords.x, coords.y, coords.z)
started = false
else FreezeEntityPosition(cache.ped, false) end
FreezeEntityPosition(cache.ped, false)
started = false
elseif CurrentZone and not isOwner and xPlayer.job.name == 'mafia4' then
local pass, msg = lib.callback.await('hki_territories:canrevive', 100, CurrentZone.name)
if not pass then
return Notify(L('Notify.title_error'), msg, 'error')
end
local cb, duration, cap = lib.callback.await('hki_territories:checkRevivePoint2Money', 100, CurrentZone.name)
if not cb then
return Notify(L('Notify.title_error'), L('revive_point.no_money'), 'error')
end
--[[if not cap then
return Notify(L('Notify.title_error'), L('revive_point.cantuse'), 'error')
end]]
started = true
if lib.progressCircle({
duration = Config.reviveBasic.time * 1000,
label = L('revive_point.revive_progress'),
position = 'middle',
useWhileDead = true,
canCancel = false,
}) then
FreezeEntityPosition(cache.ped, true)
TriggerServerEvent('hki_territories:reviveBasic', CurrentZone.name)
TriggerServerEvent('hki_territories:reviveEvent')
local coords = vector3(CurrentZone.flag4.x, CurrentZone.flag4.y, CurrentZone.flag4.z)
SetEntityCoords(ped, coords.x, coords.y, coords.z)
started = false
else FreezeEntityPosition(cache.ped, false) end
FreezeEntityPosition(cache.ped, false)
started = false
else
Notify(L('Notify.title_error'), L('revive_point.flag'), 'error')
end
else
Notify(L('Notify.title_error'), L('revive_point.no_inside'), 'error')
end
else
Notify(L('Notify.title_error'), L('revive_point.dead'), 'error')
end
else
Notify(L('Notify.title_inform'), L('revive_point.already'), 'inform')
end
end)Editor is loading...
Leave a Comment