resources/[jobs]/[civ]/mh_jobgarage/client/client.lua aktualisiert
This commit is contained in:
		
							parent
							
								
									7d0628d8ef
								
							
						
					
					
						commit
						7d0410b025
					
				
					 1 changed files with 148 additions and 148 deletions
				
			
		| 
						 | 
				
			
			@ -1,148 +1,148 @@
 | 
			
		|||
QBCore = exports['qb-core']:GetCoreObject()
 | 
			
		||||
isInZone = false
 | 
			
		||||
Zone = nil
 | 
			
		||||
 | 
			
		||||
-- SetPosition
 | 
			
		||||
Citizen.CreateThread(function()
 | 
			
		||||
    while true do
 | 
			
		||||
        local sleep = 1000
 | 
			
		||||
        local ped = PlayerPedId()
 | 
			
		||||
        local coords = GetEntityCoords(ped)
 | 
			
		||||
        local isInMarker = false
 | 
			
		||||
        local Player = QBCore.Functions.GetPlayerData()
 | 
			
		||||
        
 | 
			
		||||
        
 | 
			
		||||
        if Player and Player.job then
 | 
			
		||||
            for k, v in pairs(Config.Zonen) do
 | 
			
		||||
                local dist = #(coords - v.Schluesselkasten)
 | 
			
		||||
                if dist < Config.DrawDistance and Player.job.name == v.Job then  
 | 
			
		||||
                    sleep = 0
 | 
			
		||||
                    DrawMarker(v.Marker.type, v.Schluesselkasten.x, v.Schluesselkasten.y, v.Schluesselkasten.z + 0.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, v.Marker.x, v.Marker.y, v.Marker.z, v.Marker.r, v.Marker.g, v.Marker.b, v.Marker.a, false, false, 2, v.Marker.rotate, nil, nil, false)
 | 
			
		||||
 | 
			
		||||
                    if dist < 2.0 then
 | 
			
		||||
                        if not isInZone then
 | 
			
		||||
                            Zone = v
 | 
			
		||||
                            isInZone = true
 | 
			
		||||
                            TextUI(true, "[E] - Schlüsselkasten öffnen.")
 | 
			
		||||
                        end
 | 
			
		||||
                        if IsControlJustReleased(0, 38) then
 | 
			
		||||
                            QBCore.Functions.TriggerCallback('mh_jobgarage:CallVehiclesInfo', function(cb)
 | 
			
		||||
                                OpenMenu(cb)
 | 
			
		||||
                            end, Player.job.name)
 | 
			
		||||
                        end
 | 
			
		||||
                    else
 | 
			
		||||
                        if isInZone then
 | 
			
		||||
                            Zone = nil
 | 
			
		||||
                            isInZone = false
 | 
			
		||||
                            TextUI(false)
 | 
			
		||||
                        end
 | 
			
		||||
                    end
 | 
			
		||||
                end
 | 
			
		||||
 | 
			
		||||
            end
 | 
			
		||||
        end
 | 
			
		||||
        Citizen.Wait(sleep)
 | 
			
		||||
    end
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
function OpenMenu(vehicles)
 | 
			
		||||
    local opt = {}
 | 
			
		||||
    local Player = QBCore.Functions.GetPlayerData()
 | 
			
		||||
 | 
			
		||||
    if Player.job.grade.level == Zone.Chiefrang then
 | 
			
		||||
        table.insert(opt, {
 | 
			
		||||
            title = "Fahrzeug Einstellungen",
 | 
			
		||||
            description = "Fahrzeuge verwalten",
 | 
			
		||||
            icon = "gears",
 | 
			
		||||
            onSelect = function()
 | 
			
		||||
                lib.hideContext("OpenMenu")
 | 
			
		||||
 | 
			
		||||
                OpenChiefMenu(vehicles)
 | 
			
		||||
            end
 | 
			
		||||
        })
 | 
			
		||||
        table.insert(opt, {
 | 
			
		||||
            title = "",
 | 
			
		||||
            disabled = true
 | 
			
		||||
        })
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    table.insert(opt, {
 | 
			
		||||
        title = "Alle Schlüssel zurück geben!",
 | 
			
		||||
        description = "Gibt alle vorhandenen Schlüssel zurück!",
 | 
			
		||||
        icon = "keys",
 | 
			
		||||
        onSelect = function()
 | 
			
		||||
            TriggerServerEvent('mh_jobgarage:GiveAllKeysBack', vehicles)
 | 
			
		||||
        end
 | 
			
		||||
    })
 | 
			
		||||
    table.insert(opt, {
 | 
			
		||||
        title = "",
 | 
			
		||||
        disabled = true
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    if vehicles then
 | 
			
		||||
        for k, v in pairs(vehicles) do
 | 
			
		||||
            table.insert(opt, {
 | 
			
		||||
                title = v.name,
 | 
			
		||||
                description = v.key_value.."x Schlüssel vorhanden.",
 | 
			
		||||
                icon = "car",
 | 
			
		||||
                onSelect = function()
 | 
			
		||||
                    OpenKeyMenu(v)
 | 
			
		||||
                end
 | 
			
		||||
            })
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    lib.registerContext({
 | 
			
		||||
        id = 'OpenMenu',
 | 
			
		||||
        title = "Schlüsselkasten",
 | 
			
		||||
        options = opt
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    lib.showContext('OpenMenu')
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function OpenKeyMenu(veh)
 | 
			
		||||
    local dis = false
 | 
			
		||||
    local closedVeh = "Nein"
 | 
			
		||||
    local meta = {{label = "Noch "..veh.key_value.." Schlüssel vorhanden!"}}
 | 
			
		||||
    if veh.closed == "true" then
 | 
			
		||||
        dis = true
 | 
			
		||||
        closedVeh = "Dieses Fahrzeug ist gesperrt!!!"
 | 
			
		||||
        meta = {{label = "Keine Schlüssel mehr im Kasten!"}}
 | 
			
		||||
    end
 | 
			
		||||
    lib.registerContext({
 | 
			
		||||
        id = 'OpenKeyMenu',
 | 
			
		||||
        title = "Schlüsselkasten",
 | 
			
		||||
        description = "Fahrzeug:"..veh.name.."\nKennzeichen:"..veh.plate.."\nSchlüsselanzahl:"..veh.key_value.."\nGesperrt:"..closedVeh,
 | 
			
		||||
        icon = "plus",
 | 
			
		||||
        options = {
 | 
			
		||||
            {
 | 
			
		||||
                title = "Schlüssel nehmen",
 | 
			
		||||
                description = "Gibt dir ein Schlüssel für den "..veh.name,
 | 
			
		||||
                disabled = dis,
 | 
			
		||||
                icon = "plus",
 | 
			
		||||
                onSelect = function()
 | 
			
		||||
                    print("Trigger ADDVEHICLE KEY")
 | 
			
		||||
                    TriggerServerEvent('mh_jobgarage:AddVehicleKey', veh)
 | 
			
		||||
                end,
 | 
			
		||||
                metadata = meta
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                title = "",
 | 
			
		||||
                disabled = true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                title = "Schlüssel geben",
 | 
			
		||||
                description = "Nimmt dir ein Schlüssel für den "..veh.name.." ab.",
 | 
			
		||||
                icon = "minus",
 | 
			
		||||
                onSelect = function()
 | 
			
		||||
                    print("Trigger DELVEHICLE KEY")
 | 
			
		||||
                    TriggerServerEvent('mh_jobgarage:DelVehicleKey', veh)
 | 
			
		||||
                end
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    lib.showContext('OpenKeyMenu')
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
QBCore = exports['qb-core']:GetCoreObject()
 | 
			
		||||
isInZone = false
 | 
			
		||||
Zone = nil
 | 
			
		||||
 | 
			
		||||
-- SetPosition
 | 
			
		||||
Citizen.CreateThread(function()
 | 
			
		||||
    while true do
 | 
			
		||||
        local sleep = 1000
 | 
			
		||||
        local ped = PlayerPedId()
 | 
			
		||||
        local coords = GetEntityCoords(ped)
 | 
			
		||||
        local isInMarker = false
 | 
			
		||||
        local Player = QBCore.Functions.GetPlayerData()
 | 
			
		||||
        
 | 
			
		||||
        
 | 
			
		||||
        if Player and Player.job then
 | 
			
		||||
            for k, v in pairs(Config.Zonen) do
 | 
			
		||||
                local dist = #(coords - v.Schluesselkasten)
 | 
			
		||||
                if dist < Config.DrawDistance and Player.job.name == v.Job then  
 | 
			
		||||
                    sleep = 0
 | 
			
		||||
                    DrawMarker(v.Marker.type, v.Schluesselkasten.x, v.Schluesselkasten.y, v.Schluesselkasten.z + 0.7, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, v.Marker.x, v.Marker.y, v.Marker.z, v.Marker.r, v.Marker.g, v.Marker.b, v.Marker.a, false, false, 2, v.Marker.rotate, nil, nil, false)
 | 
			
		||||
 | 
			
		||||
                    if dist < 2.0 then
 | 
			
		||||
                        if not isInZone then
 | 
			
		||||
                            Zone = v
 | 
			
		||||
                            isInZone = true
 | 
			
		||||
                            TextUI(true, "[E] - Schlüsselkasten öffnen.")
 | 
			
		||||
                        end
 | 
			
		||||
                        if IsControlJustReleased(0, 38) then
 | 
			
		||||
                            QBCore.Functions.TriggerCallback('mh_jobgarage:CallVehiclesInfo', function(cb)
 | 
			
		||||
                                OpenMenu(cb)
 | 
			
		||||
                            end, Player.job.name)
 | 
			
		||||
                        end
 | 
			
		||||
                    else
 | 
			
		||||
                        if isInZone then
 | 
			
		||||
                            Zone = nil
 | 
			
		||||
                            isInZone = false
 | 
			
		||||
                            TextUI(false)
 | 
			
		||||
                        end
 | 
			
		||||
                    end
 | 
			
		||||
                end
 | 
			
		||||
 | 
			
		||||
            end
 | 
			
		||||
        end
 | 
			
		||||
        Citizen.Wait(sleep)
 | 
			
		||||
    end
 | 
			
		||||
end)
 | 
			
		||||
 | 
			
		||||
function OpenMenu(vehicles)
 | 
			
		||||
    local opt = {}
 | 
			
		||||
    local Player = QBCore.Functions.GetPlayerData()
 | 
			
		||||
 | 
			
		||||
    if Player.job.grade.level >= Zone.Chiefrang then
 | 
			
		||||
        table.insert(opt, {
 | 
			
		||||
            title = "Fahrzeug Einstellungen",
 | 
			
		||||
            description = "Fahrzeuge verwalten",
 | 
			
		||||
            icon = "gears",
 | 
			
		||||
            onSelect = function()
 | 
			
		||||
                lib.hideContext("OpenMenu")
 | 
			
		||||
 | 
			
		||||
                OpenChiefMenu(vehicles)
 | 
			
		||||
            end
 | 
			
		||||
        })
 | 
			
		||||
        table.insert(opt, {
 | 
			
		||||
            title = "",
 | 
			
		||||
            disabled = true
 | 
			
		||||
        })
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    table.insert(opt, {
 | 
			
		||||
        title = "Alle Schlüssel zurück geben!",
 | 
			
		||||
        description = "Gibt alle vorhandenen Schlüssel zurück!",
 | 
			
		||||
        icon = "keys",
 | 
			
		||||
        onSelect = function()
 | 
			
		||||
            TriggerServerEvent('mh_jobgarage:GiveAllKeysBack', vehicles)
 | 
			
		||||
        end
 | 
			
		||||
    })
 | 
			
		||||
    table.insert(opt, {
 | 
			
		||||
        title = "",
 | 
			
		||||
        disabled = true
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    if vehicles then
 | 
			
		||||
        for k, v in pairs(vehicles) do
 | 
			
		||||
            table.insert(opt, {
 | 
			
		||||
                title = v.name,
 | 
			
		||||
                description = v.key_value.."x Schlüssel vorhanden.",
 | 
			
		||||
                icon = "car",
 | 
			
		||||
                onSelect = function()
 | 
			
		||||
                    OpenKeyMenu(v)
 | 
			
		||||
                end
 | 
			
		||||
            })
 | 
			
		||||
        end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    lib.registerContext({
 | 
			
		||||
        id = 'OpenMenu',
 | 
			
		||||
        title = "Schlüsselkasten",
 | 
			
		||||
        options = opt
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    lib.showContext('OpenMenu')
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
function OpenKeyMenu(veh)
 | 
			
		||||
    local dis = false
 | 
			
		||||
    local closedVeh = "Nein"
 | 
			
		||||
    local meta = {{label = "Noch "..veh.key_value.." Schlüssel vorhanden!"}}
 | 
			
		||||
    if veh.closed == "true" then
 | 
			
		||||
        dis = true
 | 
			
		||||
        closedVeh = "Dieses Fahrzeug ist gesperrt!!!"
 | 
			
		||||
        meta = {{label = "Keine Schlüssel mehr im Kasten!"}}
 | 
			
		||||
    end
 | 
			
		||||
    lib.registerContext({
 | 
			
		||||
        id = 'OpenKeyMenu',
 | 
			
		||||
        title = "Schlüsselkasten",
 | 
			
		||||
        description = "Fahrzeug:"..veh.name.."\nKennzeichen:"..veh.plate.."\nSchlüsselanzahl:"..veh.key_value.."\nGesperrt:"..closedVeh,
 | 
			
		||||
        icon = "plus",
 | 
			
		||||
        options = {
 | 
			
		||||
            {
 | 
			
		||||
                title = "Schlüssel nehmen",
 | 
			
		||||
                description = "Gibt dir ein Schlüssel für den "..veh.name,
 | 
			
		||||
                disabled = dis,
 | 
			
		||||
                icon = "plus",
 | 
			
		||||
                onSelect = function()
 | 
			
		||||
                    print("Trigger ADDVEHICLE KEY")
 | 
			
		||||
                    TriggerServerEvent('mh_jobgarage:AddVehicleKey', veh)
 | 
			
		||||
                end,
 | 
			
		||||
                metadata = meta
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                title = "",
 | 
			
		||||
                disabled = true
 | 
			
		||||
            },
 | 
			
		||||
            {
 | 
			
		||||
                title = "Schlüssel geben",
 | 
			
		||||
                description = "Nimmt dir ein Schlüssel für den "..veh.name.." ab.",
 | 
			
		||||
                icon = "minus",
 | 
			
		||||
                onSelect = function()
 | 
			
		||||
                    print("Trigger DELVEHICLE KEY")
 | 
			
		||||
                    TriggerServerEvent('mh_jobgarage:DelVehicleKey', veh)
 | 
			
		||||
                end
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    })
 | 
			
		||||
 | 
			
		||||
    lib.showContext('OpenKeyMenu')
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue