1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-08-11 16:10:18 +02:00
parent 23e3e52966
commit 68151e44fe
11 changed files with 594 additions and 0 deletions

View file

@ -0,0 +1,107 @@
local QBCore = exports['qb-core']:GetCoreObject()
local bac = nil
local display = false
function SetDisplay(bool)
display = bool
SetNuiFocus(bool, bool)
SendNUIMessage({
type = "ui",
status = bool,
})
end
RegisterNUICallback("exit", function(data)
SetDisplay(false)
SendNUIMessage({
type = "data",
bac = '0.00',
textColor = '--color-black'
})
end)
RegisterNUICallback("startBac", function(data)
local target = GetClosestPlayerRadius(2.0)
if target == nil then
QBCore.Functions.Notify("Keine Person in der Nähe gefunden!", "error")
return
end
TriggerServerEvent('qb-alcoholtest:server:doBacTest', GetPlayerServerId(target))
QBCore.Functions.Notify('Anfrage wurde an ' .. GetPlayerName(target) .. ' gesendet')
end)
-- Kontrollen deaktivieren, wenn UI geöffnet ist
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if display then
DisableControlAction(0, 1, display) -- LookLeftRight
DisableControlAction(0, 2, display) -- LookUpDown
DisableControlAction(0, 142, display) -- MeleeAttackAlternate
DisableControlAction(0, 18, display) -- Enter
DisableControlAction(0, 322, display) -- ESC
DisableControlAction(0, 106, display) -- VehicleMouseControlOverride
else
Citizen.Wait(500)
end
end
end)
-- Alkoholtester Item verwenden
RegisterNetEvent('qb-alcoholtest:client:useBreathalyzer')
AddEventHandler('qb-alcoholtest:client:useBreathalyzer', function()
SetDisplay(true)
end)
-- BAC-Test Anfrage erhalten
RegisterNetEvent('qb-alcoholtest:client:requestBac')
AddEventHandler('qb-alcoholtest:client:requestBac', function(leo, target)
local accepted = nil
QBCore.Functions.Notify(GetPlayerName(GetPlayerFromServerId(leo)) .. " möchte deinen Alkoholwert testen.")
QBCore.Functions.Notify("Akzeptieren [Y] Ablehnen [N]")
Citizen.CreateThread(function()
while accepted == nil do
Citizen.Wait(0)
if IsControlJustReleased(1, 246) then -- Y Taste
accepted = true
TriggerServerEvent('qb-alcoholtest:server:acceptedBac', leo, target)
-- Tatsächlichen BAC-Wert vom System abrufen
TriggerServerEvent('qb-alcoholtest:server:getActualBAC', leo, target)
end
if IsControlJustReleased(1, 249) then -- N Taste
accepted = false
TriggerServerEvent('qb-alcoholtest:server:refusedBac', leo, target)
end
end
end)
end)
-- BAC-Wert anzeigen
RegisterNetEvent('qb-alcoholtest:client:displayBac')
AddEventHandler('qb-alcoholtest:client:displayBac', function(bac, color)
SendNUIMessage({
type = "data",
bac = bac,
textColor = color
})
end)
-- BAC-Test abgelehnt
RegisterNetEvent('qb-alcoholtest:client:bacRefused')
AddEventHandler('qb-alcoholtest:client:bacRefused', function(target)
SetDisplay(false)
SendNUIMessage({
type = "data",
bac = '0.00',
textColor = '--color-black'
})
QBCore.Functions.Notify(GetPlayerName(GetPlayerFromServerId(target)) .. " hat den Alkoholtest abgelehnt!", "error")
end)
-- BAC-Test akzeptiert
RegisterNetEvent('qb-alcoholtest:client:acceptedBac')
AddEventHandler('qb-alcoholtest:client:acceptedBac', function(target)
QBCore.Functions.Notify("Teste " .. GetPlayerName(GetPlayerFromServerId(target)) .. "'s Blutalkoholwert...")
end)