forked from Simnation/Main
ed
This commit is contained in:
parent
57069485d5
commit
8d5055a73d
1412 changed files with 5583 additions and 0 deletions
78
resources/[Developer]/[Max]/Duck_Jobklingel-new/client.lua
Normal file
78
resources/[Developer]/[Max]/Duck_Jobklingel-new/client.lua
Normal 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)
|
Loading…
Add table
Add a link
Reference in a new issue