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
|
local QBCore = exports['qb-core']:GetCoreObject()
|
||||||
Citizen.CreateThread(function()
|
local isTakingHostage = false
|
||||||
-- Warte auf QBCore
|
local hostagePed = nil
|
||||||
while not QBCore do
|
|
||||||
TriggerEvent('QBCore:GetObject', function(obj) QBCore = obj end)
|
|
||||||
Citizen.Wait(200)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Funktion: Überprüft, ob der Spieler Kabelbinder hat
|
-- Funktion zur Überprüfung von Kabelbindern
|
||||||
function HasCableTies()
|
local function HasCableTies()
|
||||||
local player = QBCore.Functions.GetPlayerData()
|
local Player = QBCore.Functions.GetPlayerData()
|
||||||
local hasTies = false
|
if not Player or not Player.items then return false end
|
||||||
|
|
||||||
if player and player.items then
|
for _, item in pairs(Player.items) do
|
||||||
for _, item in pairs(player.items) do
|
if item.name:lower() == 'cableties' and item.amount >= 1 then
|
||||||
if item.name == 'cableties' and item.amount >= 1 then
|
return true
|
||||||
hasTies = true
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return hasTies
|
end
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Hauptfunktion für Geiselnahme
|
||||||
|
local function TakeHostage()
|
||||||
|
local playerPed = PlayerPedId()
|
||||||
|
local closestPlayer, distance = QBCore.Functions.GetClosestPlayer()
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
-- 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
|
end
|
||||||
|
|
||||||
-- qb-target Integration
|
TriggerServerEvent('nordi_hostage:release')
|
||||||
|
end
|
||||||
|
|
||||||
|
-- QB-Target Integration
|
||||||
|
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
|
||||||
exports['qb-target']:AddTargetModel('prop_paper_bag_small', {
|
exports['qb-target']:AddTargetModel('prop_paper_bag_small', {
|
||||||
options = {
|
options = {
|
||||||
{
|
{
|
||||||
type = "client",
|
type = "client",
|
||||||
action = function()
|
action = TakeHostage,
|
||||||
-- Hier kommt deine Geiselnehmer-Logik
|
|
||||||
end,
|
|
||||||
icon = "fas fa-hands-bound",
|
icon = "fas fa-hands-bound",
|
||||||
label = "Person fesseln",
|
label = "Person fesseln",
|
||||||
canInteract = function()
|
canInteract = HasCableTies,
|
||||||
return HasCableTies()
|
|
||||||
end,
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
distance = 2.5
|
distance = 2.5
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue