forked from Simnation/Main
Update server.lua
This commit is contained in:
parent
5273090baf
commit
3667e4358b
1 changed files with 18 additions and 11 deletions
|
@ -151,28 +151,35 @@ QBCore.Functions.CreateCallback('vehiclerental:server:getRentalInfo', function(s
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- Befehl für Mietzeit
|
-- Befehl für Mietzeit (KORRIGIERT)
|
||||||
QBCore.Commands.Add('mietzeit', 'Zeige deine aktuelle Mietzeit an', {}, false, function(source, args)
|
QBCore.Commands.Add('mietzeit', 'Zeige deine aktuelle Mietzeit an', {}, false, function(source, args)
|
||||||
QBCore.Functions.TriggerCallback('vehiclerental:server:getRentalInfo', source, function(rentals)
|
local Player = QBCore.Functions.GetPlayer(source)
|
||||||
if not rentals or #rentals == 0 then
|
if not Player then return end
|
||||||
|
|
||||||
|
MySQL.Async.fetchAll('SELECT * FROM vehicle_rentals WHERE citizenid = ? AND returned = FALSE', {
|
||||||
|
Player.PlayerData.citizenid
|
||||||
|
}, function(result)
|
||||||
|
if not result or #result == 0 then
|
||||||
TriggerClientEvent('QBCore:Notify', source, 'Du hast keine aktiven Mietverhältnisse!', 'error')
|
TriggerClientEvent('QBCore:Notify', source, 'Du hast keine aktiven Mietverhältnisse!', 'error')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
for i = 1, #rentals do
|
for i = 1, #result do
|
||||||
local rental = rentals[i]
|
local rental = result[i]
|
||||||
|
local currentTime = os.time()
|
||||||
|
local timeLeft = rental.end_time - currentTime
|
||||||
local timeText = ""
|
local timeText = ""
|
||||||
|
|
||||||
if rental.isOverdue then
|
if timeLeft < 0 then
|
||||||
local hoursOverdue = math.ceil(math.abs(rental.timeLeft) / 3600)
|
local hoursOverdue = math.ceil(math.abs(timeLeft) / 3600)
|
||||||
timeText = "Überfällig um " .. hoursOverdue .. " Stunden"
|
timeText = "Überfällig um " .. hoursOverdue .. " Stunden"
|
||||||
|
TriggerClientEvent('QBCore:Notify', source, rental.vehicle_model .. " (" .. rental.vehicle_plate .. "): " .. timeText, 'error')
|
||||||
else
|
else
|
||||||
local hoursLeft = math.floor(rental.timeLeft / 3600)
|
local hoursLeft = math.floor(timeLeft / 3600)
|
||||||
local minutesLeft = math.floor((rental.timeLeft % 3600) / 60)
|
local minutesLeft = math.floor((timeLeft % 3600) / 60)
|
||||||
timeText = hoursLeft .. "h " .. minutesLeft .. "m verbleibend"
|
timeText = hoursLeft .. "h " .. minutesLeft .. "m verbleibend"
|
||||||
|
TriggerClientEvent('QBCore:Notify', source, rental.vehicle_model .. " (" .. rental.vehicle_plate .. "): " .. timeText, 'primary')
|
||||||
end
|
end
|
||||||
|
|
||||||
TriggerClientEvent('QBCore:Notify', source, rental.vehicleModel .. " (" .. rental.plate .. "): " .. timeText, rental.isOverdue and 'error' or 'primary')
|
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue