1
0
Fork 0
forked from Simnation/Main
This commit is contained in:
Nordi98 2025-08-12 20:30:24 +02:00
parent 57069485d5
commit 8d5055a73d
1412 changed files with 5583 additions and 0 deletions

View file

@ -0,0 +1,78 @@
local QBCore = exports['qb-core']:GetCoreObject()
local doorbellCooldowns = {}
-- Benachrichtigung empfangen
RegisterNetEvent('qb-doorbell:client:receiveNotification', function(message, senderName)
lib.notify({
title = 'Klingel',
description = message .. '\nVon: ' .. senderName,
type = 'inform',
duration = 8000,
position = 'top'
})
end)
-- Klingel-Funktion
local function RingDoorbell(doorbellData)
local currentTime = GetGameTimer()
-- Cooldown Check
if doorbellCooldowns[doorbellData.id] and
(currentTime - doorbellCooldowns[doorbellData.id]) < Config.CooldownTime then
local remainingTime = math.ceil((Config.CooldownTime - (currentTime - doorbellCooldowns[doorbellData.id])) / 1000)
lib.notify({
title = 'Klingel',
description = 'Du musst noch ' .. remainingTime .. ' Sekunden warten!',
type = 'error',
duration = 3000
})
return
end
-- Cooldown setzen
doorbellCooldowns[doorbellData.id] = currentTime
-- Server Event triggern
TriggerServerEvent('qb-doorbell:server:ringDoorbell', doorbellData)
lib.notify({
title = 'Klingel',
description = 'Du hast geklingelt!',
type = 'success',
duration = 3000
})
end
-- Klingel-Interaktionen erstellen
local function CreateDoorbellInteractions()
for _, doorbell in pairs(Config.Doorbells) do
local point = lib.points.new({
coords = doorbell.bellCoords,
distance = Config.InteractionDistance,
doorbell = doorbell
})
function point:onEnter()
lib.showTextUI('[E] ' .. self.doorbell.label, {
position = "left-center",
icon = 'bell'
})
end
function point:onExit()
lib.hideTextUI()
end
function point:nearby()
if IsControlJustPressed(0, 38) then -- E Key
RingDoorbell(self.doorbell)
end
end
end
end
-- Initialisierung
CreateThread(function()
Wait(1000)
CreateDoorbellInteractions()
end)

View file

@ -0,0 +1,65 @@
Config = {}
Config.InteractionDistance = 2.0 -- Distanz zum Klingeln
Config.CooldownTime = 5000 -- Cooldown in ms zwischen Klingeln
-- Klingel-Konfigurationen
Config.Doorbells = {
-- Beispiel 1: Polizeistation
{
id = 1,
label = "Polizeistation Klingel",
-- Koordinate wo man klingeln kann
bellCoords = vector3(441.0, -981.0, 30.7),
-- Benachrichtigungs-Einstellungen
notification = {
coords = vector3(441.0, -975.0, 30.7), -- Wo die Benachrichtigung empfangen wird
radius = 50.0, -- Umkreis in dem man die Benachrichtigung bekommt
requireJob = true, -- Job erforderlich?
allowedJobs = {"police", "sheriff"}, -- Erlaubte Jobs
message = "Jemand klingelt an der Polizeistation!"
}
},
-- Beispiel 2: Krankenhaus
{
id = 2,
label = "Krankenhaus Empfang",
bellCoords = vector3(-449.0, -340.0, 34.5),
notification = {
coords = vector3(-440.0, -340.0, 34.5),
radius = 30.0,
requireJob = true,
allowedJobs = {"ambulance", "doctor"},
message = "Patient wartet am Empfang!"
}
},
-- Beispiel 3: Öffentliche Klingel (ohne Job-Anforderung)
{
id = 3,
label = "Rathaus Klingel",
bellCoords = vector3(-544.0, -204.0, 38.2),
notification = {
coords = vector3(-540.0, -200.0, 38.2),
radius = 25.0,
requireJob = false, -- Keine Job-Anforderung
allowedJobs = {}, -- Leer da keine Jobs erforderlich
message = "Jemand benötigt Hilfe am Rathaus!"
}
},
-- Beispiel 4: Mechaniker
{
id = 4,
label = "Werkstatt Klingel",
bellCoords = vector3(-347.0, -133.0, 39.0),
notification = {
coords = vector3(-350.0, -130.0, 39.0),
radius = 40.0,
requireJob = true,
allowedJobs = {"mechanic", "tuner"},
message = "Kunde wartet in der Werkstatt!"
}
}
}

View file

@ -0,0 +1,24 @@
fx_version 'cerulean'
game 'gta5'
author 'Duck'
description 'Job Klingel'
version '1.0.0'
shared_scripts {
'@ox_lib/init.lua',
'config.lua'
}
client_scripts {
'client.lua'
}
server_scripts {
'server.lua'
}
dependencies {
'qb-core',
'ox_lib'
}

View file

@ -0,0 +1,16 @@
##############################
####################################
##### # # ##### # #
# ## # # # # #
# ## # # # ### ---DUCK SCRIPTS
# ## # # # # #
##### ### ##### # #
####################################
##############################
## Dieses Script ist NUR für Private Zwecke erstellt wurden & darf NUR auf SimNation RP verwendet werden!
## Es handelt sich hierbei um ein QB Script!

View 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)