forked from Simnation/Main
Update client.lua
This commit is contained in:
parent
d11df2a252
commit
cc98b55498
1 changed files with 85 additions and 27 deletions
|
@ -1,40 +1,98 @@
|
|||
-- nordi_hostage/client.lua
|
||||
Citizen.CreateThread(function()
|
||||
-- Warte auf QBCore
|
||||
while not QBCore do
|
||||
TriggerEvent('QBCore:GetObject', function(obj) QBCore = obj end)
|
||||
Citizen.Wait(200)
|
||||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
local isTakingHostage = false
|
||||
local hostagePed = nil
|
||||
|
||||
-- Funktion zur Überprüfung von Kabelbindern
|
||||
local function HasCableTies()
|
||||
local Player = QBCore.Functions.GetPlayerData()
|
||||
if not Player or not Player.items then return false end
|
||||
|
||||
for _, item in pairs(Player.items) do
|
||||
if item.name:lower() == 'cableties' and item.amount >= 1 then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- Funktion: Überprüft, ob der Spieler Kabelbinder hat
|
||||
function HasCableTies()
|
||||
local player = QBCore.Functions.GetPlayerData()
|
||||
local hasTies = false
|
||||
-- Hauptfunktion für Geiselnahme
|
||||
local function TakeHostage()
|
||||
local playerPed = PlayerPedId()
|
||||
local closestPlayer, distance = QBCore.Functions.GetClosestPlayer()
|
||||
|
||||
if player and player.items then
|
||||
for _, item in pairs(player.items) do
|
||||
if item.name == 'cableties' and item.amount >= 1 then
|
||||
hasTies = true
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
return hasTies
|
||||
if closestPlayer ~= -1 and distance < 2.5 then
|
||||
local targetPed = GetPlayerPed(closestPlayer)
|
||||
|
||||
if not isTakingHostage then
|
||||
isTakingHostage = true
|
||||
hostagePed = targetPed
|
||||
|
||||
-- Animationen für beide Spieler
|
||||
RequestAnimDict("anim@gangops@hostage@")
|
||||
while not HasAnimDictLoaded("anim@gangops@hostage@") do
|
||||
Wait(100)
|
||||
end
|
||||
|
||||
-- qb-target Integration
|
||||
-- Täter Animation
|
||||
TaskPlayAnim(playerPed, "anim@gangops@hostage@", "perp_idle", 8.0, -8, -1, 49, 0, 0, 0, 0)
|
||||
|
||||
-- Geisel Animation
|
||||
TaskPlayAnim(hostagePed, "anim@gangops@hostage@", "victim_idle", 8.0, -8, -1, 49, 0, 0, 0, 0)
|
||||
|
||||
-- Sync für andere Spieler
|
||||
TriggerServerEvent('nordi_hostage:sync', GetPlayerServerId(closestPlayer))
|
||||
|
||||
-- Steuerung während Geiselnahme
|
||||
CreateThread(function()
|
||||
while isTakingHostage do
|
||||
DisableControlAction(0, 24, true) -- Angriff deaktivieren
|
||||
DisableControlAction(0, 25, true) -- Zielen deaktivieren
|
||||
DisableControlAction(0, 47, true) -- Waffe deaktivieren
|
||||
DisableControlAction(0, 58, true) -- Sprengen deaktivieren
|
||||
|
||||
if IsPedDeadOrDying(hostagePed, true) or IsPedDeadOrDying(playerPed, true) then
|
||||
ReleaseHostage()
|
||||
end
|
||||
|
||||
-- Freilassung mit E
|
||||
if IsControlPressed(0, 38) then
|
||||
ReleaseHostage()
|
||||
end
|
||||
|
||||
Wait(0)
|
||||
end
|
||||
end)
|
||||
end
|
||||
else
|
||||
QBCore.Functions.Notify('Kein Spieler in der Nähe', 'error')
|
||||
end
|
||||
end
|
||||
|
||||
-- Funktion zum Freilassen
|
||||
function ReleaseHostage()
|
||||
isTakingHostage = false
|
||||
|
||||
local playerPed = PlayerPedId()
|
||||
ClearPedTasks(playerPed)
|
||||
|
||||
if hostagePed then
|
||||
ClearPedTasks(hostagePed)
|
||||
hostagePed = nil
|
||||
end
|
||||
|
||||
TriggerServerEvent('nordi_hostage:release')
|
||||
end
|
||||
|
||||
-- QB-Target Integration
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
|
||||
exports['qb-target']:AddTargetModel('prop_paper_bag_small', {
|
||||
options = {
|
||||
{
|
||||
type = "client",
|
||||
action = function()
|
||||
-- Hier kommt deine Geiselnehmer-Logik
|
||||
end,
|
||||
action = TakeHostage,
|
||||
icon = "fas fa-hands-bound",
|
||||
label = "Person fesseln",
|
||||
canInteract = function()
|
||||
return HasCableTies()
|
||||
end,
|
||||
canInteract = HasCableTies,
|
||||
}
|
||||
},
|
||||
distance = 2.5
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue