forked from Simnation/Main
ed
This commit is contained in:
parent
57069485d5
commit
8d5055a73d
1412 changed files with 5583 additions and 0 deletions
59
resources/[Developer]/[Max]/Duck_Jobklingel-new/server.lua
Normal file
59
resources/[Developer]/[Max]/Duck_Jobklingel-new/server.lua
Normal file
|
@ -0,0 +1,59 @@
|
|||
local QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
-- Klingel Event Handler
|
||||
RegisterNetEvent('qb-doorbell:server:ringDoorbell', function(doorbellData)
|
||||
local src = source
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
|
||||
if not Player then return end
|
||||
|
||||
local senderName = Player.PlayerData.charinfo.firstname .. " " .. Player.PlayerData.charinfo.lastname
|
||||
|
||||
-- Alle Spieler durchgehen
|
||||
local players = QBCore.Functions.GetPlayers()
|
||||
local notificationsSent = 0
|
||||
|
||||
for _, playerId in pairs(players) do
|
||||
local targetPlayer = QBCore.Functions.GetPlayer(playerId)
|
||||
if targetPlayer then
|
||||
local targetCoords = GetEntityCoords(GetPlayerPed(playerId))
|
||||
local distance = #(targetCoords - doorbellData.notification.coords)
|
||||
|
||||
-- Prüfen ob Spieler im Radius ist
|
||||
if distance <= doorbellData.notification.radius then
|
||||
local canReceive = false
|
||||
|
||||
-- Job-Prüfung
|
||||
if doorbellData.notification.requireJob then
|
||||
-- Prüfen ob Spieler einen der erlaubten Jobs hat
|
||||
for _, allowedJob in pairs(doorbellData.notification.allowedJobs) do
|
||||
if targetPlayer.PlayerData.job.name == allowedJob then
|
||||
canReceive = true
|
||||
break
|
||||
end
|
||||
end
|
||||
else
|
||||
-- Keine Job-Anforderung, jeder kann Benachrichtigung erhalten
|
||||
canReceive = true
|
||||
end
|
||||
|
||||
-- Benachrichtigung senden
|
||||
if canReceive then
|
||||
TriggerClientEvent('qb-doorbell:client:receiveNotification', playerId,
|
||||
doorbellData.notification.message, senderName)
|
||||
notificationsSent = notificationsSent + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Feedback an den Klingelnden wenn niemand erreicht wurde
|
||||
if notificationsSent == 0 then
|
||||
TriggerClientEvent('ox_lib:notify', src, {
|
||||
title = 'Klingel',
|
||||
description = 'Niemand scheint in der Nähe zu sein...',
|
||||
type = 'error',
|
||||
duration = 4000
|
||||
})
|
||||
end
|
||||
end)
|
Loading…
Add table
Add a link
Reference in a new issue