forked from Simnation/Main
Merge branch 'master' of https://git.evolution-state-life.de/Evolution-State-Life/Main
This commit is contained in:
commit
23e76064a9
2 changed files with 60 additions and 57 deletions
|
@ -36,6 +36,26 @@ function OpenChiefMenu(vehicles)
|
|||
lib.showContext("ChiefSettingsMenu")
|
||||
end
|
||||
|
||||
|
||||
function IsVehicleSpawned(plate)
|
||||
|
||||
local vehicles = GetGamePool('CVehicle')
|
||||
|
||||
for _, vehicle in ipairs(vehicles) do
|
||||
if DoesEntityExist(vehicle) then
|
||||
local mods = QBCore.Functions.GetVehicleProperties(vehicle)
|
||||
local vehiclePlate = mods.plate
|
||||
|
||||
if vehiclePlate == plate then
|
||||
print("Function: "..mods)
|
||||
return true, mods
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return false, nil -- Vehicle not found
|
||||
end
|
||||
|
||||
function OpenChiefAddVehicleMenu()
|
||||
local Player = QBCore.Functions.GetPlayerData()
|
||||
local opt = {}
|
||||
|
@ -47,48 +67,50 @@ function OpenChiefAddVehicleMenu()
|
|||
local opt = {}
|
||||
|
||||
for i = 1, #vehicles, 1 do
|
||||
local isSpawned, mods = IsVehicleSpawned(plate)
|
||||
while not isSpawned do
|
||||
Wait(100)
|
||||
end
|
||||
print("Chiefsettings: "..mods)
|
||||
local isSpawned, mods = IsVehicleSpawned(vehicles[i].plate)
|
||||
|
||||
if isSpawned then
|
||||
print("Chiefsettings: "..mods)
|
||||
|
||||
table.insert(opt, {
|
||||
title = "Kennzeichen: "..mods.plate,
|
||||
description = "Deine Ersatzschlüssel: "..vehicles[i].keys,
|
||||
icon = 'car',
|
||||
onSelect = function()
|
||||
local value = lib.inputDialog("Schlüsselkasten", {
|
||||
{type = "input", label = "Anzeigename", description = "Anzeigename wie die anderen den sehen!"},
|
||||
{type = "number", label = "Schlüsselanzahl", description = "Anzahl der Ersatzschlüssel.", min = 1, max = vehicles[i].keys},
|
||||
{type = "number", label = "Rang", description = "Ab welchen Rang darf man das Fahrzeug Fahren?"}
|
||||
})
|
||||
table.insert(opt, {
|
||||
title = "Kennzeichen: "..mods.plate,
|
||||
description = "Deine Ersatzschlüssel: "..vehicles[i].keys,
|
||||
icon = 'car',
|
||||
onSelect = function()
|
||||
local value = lib.inputDialog("Schlüsselkasten", {
|
||||
{type = "input", label = "Anzeigename", description = "Anzeigename wie die anderen den sehen!"},
|
||||
{type = "number", label = "Schlüsselanzahl", description = "Anzahl der Ersatzschlüssel.", min = 1, max = vehicles[i].keys},
|
||||
{type = "number", label = "Rang", description = "Ab welchen Rang darf man das Fahrzeug Fahren?"}
|
||||
})
|
||||
|
||||
QBCore.Functions.TriggerCallback('mh_jobgarage:AddVehicleToJob', function(cb)
|
||||
if cb.status then
|
||||
Notification("Schlüsselkasten", cb.text, cb.type)
|
||||
lib.hideContext('ChiefAddVehicleMenu')
|
||||
QBCore.Functions.TriggerCallback('mh_jobgarage:CallVehiclesInfo', function(cb)
|
||||
OpenMenu(cb)
|
||||
end, Player.job.name)
|
||||
else
|
||||
Notification("Schlüsselkasten", cb.text, cb.type)
|
||||
if cb.key then
|
||||
SetNewWaypoint(Config.KeyMaker.x, Config.KeyMaker.y)
|
||||
QBCore.Functions.TriggerCallback('mh_jobgarage:AddVehicleToJob', function(cb)
|
||||
if cb.status then
|
||||
Notification("Schlüsselkasten", cb.text, cb.type)
|
||||
lib.hideContext('ChiefAddVehicleMenu')
|
||||
QBCore.Functions.TriggerCallback('mh_jobgarage:CallVehiclesInfo', function(cb)
|
||||
OpenMenu(cb)
|
||||
end, Player.job.name)
|
||||
else
|
||||
Notification("Schlüsselkasten", cb.text, cb.type)
|
||||
if cb.key then
|
||||
SetNewWaypoint(Config.KeyMaker.x, Config.KeyMaker.y)
|
||||
end
|
||||
end
|
||||
end
|
||||
end, mods.plate, value)
|
||||
end
|
||||
})
|
||||
end, mods.plate, value)
|
||||
end
|
||||
})
|
||||
|
||||
lib.registerContext({
|
||||
id = "ChiefAddVehicleMenu",
|
||||
title = "Schlüsselkasten",
|
||||
description = "Füge ein Fahrzeug hinzu.",
|
||||
options = opt
|
||||
})
|
||||
lib.registerContext({
|
||||
id = "ChiefAddVehicleMenu",
|
||||
title = "Schlüsselkasten",
|
||||
description = "Füge ein Fahrzeug hinzu.",
|
||||
options = opt
|
||||
})
|
||||
|
||||
lib.showContext("ChiefAddVehicleMenu")
|
||||
lib.showContext("ChiefAddVehicleMenu")
|
||||
else
|
||||
Notification("Schlüsselkasten", "Kein Fahrzeug gefunden!", "warning")
|
||||
end
|
||||
end
|
||||
else
|
||||
Notification("Schlüsselkasten", "Keine Fahrzeuge von dir Gefunden!", "error")
|
||||
|
|
|
@ -27,23 +27,4 @@ end
|
|||
RegisterNetEvent('mh_jobgarage:notify')
|
||||
AddEventHandler('mh_jobgarage:notify', function(title, text, type)
|
||||
Notification(title, text, type)
|
||||
end)
|
||||
|
||||
function IsVehicleSpawned(plate)
|
||||
|
||||
local vehicles = GetGamePool('CVehicle')
|
||||
|
||||
for _, vehicle in ipairs(vehicles) do
|
||||
if DoesEntityExist(vehicle) then
|
||||
local mods = QBCore.Functions.GetVehicleProperties(vehicle)
|
||||
local vehiclePlate = mods.plate
|
||||
|
||||
if vehiclePlate == plate then
|
||||
print("Function: "..mods)
|
||||
return true, mods
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return false, nil -- Vehicle not found
|
||||
end
|
||||
end)
|
Loading…
Add table
Add a link
Reference in a new issue