forked from Simnation/Main
change Funktion GARAGE
This commit is contained in:
parent
eab3df34be
commit
a1dd0e2dd1
3 changed files with 74 additions and 41 deletions
|
@ -115,11 +115,17 @@ function AddTargetOptions()
|
||||||
icon = "fas fa-parking",
|
icon = "fas fa-parking",
|
||||||
label = "Fahrzeug einparken",
|
label = "Fahrzeug einparken",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
type = "client",
|
||||||
|
event = "mh_garage:retrieveOwnerVehicle",
|
||||||
|
icon = "fas fa-car",
|
||||||
|
label = "Eigene Fahrzeug ausparken",
|
||||||
|
},
|
||||||
{
|
{
|
||||||
type = "client",
|
type = "client",
|
||||||
event = "mh_garage:retrieveVehicle",
|
event = "mh_garage:retrieveVehicle",
|
||||||
icon = "fas fa-car",
|
icon = "fas fa-car",
|
||||||
label = "Fahrzeug ausparken",
|
label = "Schlüssel Fahrzeug ausparken",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,32 @@
|
||||||
|
RegisterNetEvent('mh_garage:retrieveOwnerVehicle')
|
||||||
|
AddEventHandler('mh_garage:retrieveOwnerVehicle', function()
|
||||||
|
local ped = PlayerPedId()
|
||||||
|
local coords = GetEntityCoords(ped)
|
||||||
|
local random = SelectName()
|
||||||
|
|
||||||
|
local opt = {}
|
||||||
|
|
||||||
|
QBCore.Functions.TriggerCallback('mh_garage:retrieveOwnerVehicle', function(cb)
|
||||||
|
if cb == false then
|
||||||
|
Notification("Es ist kein Fahrzeug hier!", "inform")
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
for i = 1, #cb, 1 do
|
||||||
|
local mods = json.decode(cb[i].mods)
|
||||||
|
table.insert(opt, {
|
||||||
|
title = cb[i].name,
|
||||||
|
description = "Kennzeichen: "..cb[i].plate, --[[ \nTankinhalt: "..math.round(mods.fuelLevel, 2).."%" ]]
|
||||||
|
icon = "car",
|
||||||
|
onSelect = function()
|
||||||
|
cb[i].mods = mods
|
||||||
|
SpawnThisVehicle(cb[i])
|
||||||
|
end
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
RegisterNetEvent('mh_garage:retrieveVehicle')
|
RegisterNetEvent('mh_garage:retrieveVehicle')
|
||||||
AddEventHandler('mh_garage:retrieveVehicle', function()
|
AddEventHandler('mh_garage:retrieveVehicle', function()
|
||||||
local ped = PlayerPedId()
|
local ped = PlayerPedId()
|
||||||
|
@ -6,7 +35,7 @@ AddEventHandler('mh_garage:retrieveVehicle', function()
|
||||||
|
|
||||||
local opt = {}
|
local opt = {}
|
||||||
|
|
||||||
QBCore.Functions.TriggerCallback('mh_garage:CallVehicles', function(cb)
|
QBCore.Functions.TriggerCallback('mh_garage:retrieveKeyVehicle', function(cb)
|
||||||
Debug(json.encode(cb))
|
Debug(json.encode(cb))
|
||||||
for i = 1, #cb, 1 do
|
for i = 1, #cb, 1 do
|
||||||
if cb[i].garage ~= "OUT" then
|
if cb[i].garage ~= "OUT" then
|
||||||
|
|
|
@ -4,7 +4,7 @@ local test_vari = {}
|
||||||
RegisterServerEvent('mh_garage:setMods')
|
RegisterServerEvent('mh_garage:setMods')
|
||||||
AddEventHandler('mh_garage:setMods', function(mods)
|
AddEventHandler('mh_garage:setMods', function(mods)
|
||||||
if test_vari[mods.plate] == true then
|
if test_vari[mods.plate] == true then
|
||||||
|
return
|
||||||
else
|
else
|
||||||
MySQL.query("SELECT mods FROM player_vehicles WHERE plate = ?", {mods.plate}, function(rs)
|
MySQL.query("SELECT mods FROM player_vehicles WHERE plate = ?", {mods.plate}, function(rs)
|
||||||
-- Prüfen ob rs überhaupt Daten enthält
|
-- Prüfen ob rs überhaupt Daten enthält
|
||||||
|
@ -77,54 +77,52 @@ function DelVehParking(plate)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
QBCore.Functions.CreateCallback('mh_garage:CallVehicles', function(source, cb, zone)
|
QBCore.Functions.CreateCallback('mh_garage:retrieveOwnerVehicle', function(source, cb, zone)
|
||||||
local _source = source
|
local _source = source
|
||||||
local Player = QBCore.Functions.GetPlayer(_source)
|
local Player = QBCore.Functions.GetPlayer(_source)
|
||||||
local vehicles = {}
|
local pedid = Player.PlayerData.citizenid
|
||||||
local vehicle_keys = {}
|
local veh = {}
|
||||||
|
|
||||||
if Config.CallKeyVehicles then
|
MySQL.query("SELECT * FROM player_vehicles WHERE owner = ? and garage = ?", {pedid, zone}, function(rs)
|
||||||
MySQL.query("SELECT plate FROM vehicle_keys WHERE owner = ?", {Player.PlayerData.citizenid}, function(rs)
|
if rs ~= nil and rs[1] ~= nil then
|
||||||
if rs and rs[1] then
|
|
||||||
for k, v in pairs (rs) do
|
for k, v in pairs (rs) do
|
||||||
table.insert(vehicle_keys, {plate = v.plate})
|
table.insert(veh, {
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
Wait(100)
|
|
||||||
if vehicle_keys[1] ~= nil then
|
|
||||||
print(json.encode(vehicle_keys))
|
|
||||||
for k, v in pairs(vehicle_keys) do
|
|
||||||
MySQL.query("SELECT vehicle, plate, mods, name FROM player_vehicles WHERE plate = ?", {v.plate}, function(rs)
|
|
||||||
if rs and rs[1] then
|
|
||||||
table.insert(vehicles, {
|
|
||||||
vehicle = rs[1].vehicle,
|
|
||||||
mods = rs[1].mods,
|
|
||||||
plate = rs[1].plate,
|
|
||||||
name = rs[1].name
|
|
||||||
})
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
MySQL.query("SELECT vehicle, plate, mods FROM player_vehicles WHERE citizenid = ? AND garage = ?", {Player.PlayerData.citizenid, zone}, function(rs)
|
|
||||||
if rs and rs[1] then
|
|
||||||
for k, v in pairs(rs) do
|
|
||||||
table.insert(vehicles, {
|
|
||||||
vehicle = v.vehicle,
|
vehicle = v.vehicle,
|
||||||
mods = v.mods,
|
mods = v.mods,
|
||||||
plate = v.plate,
|
plate = v.plate,
|
||||||
name = v.name
|
name = v.name
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
Wait(100)
|
||||||
|
cb(veh)
|
||||||
|
else
|
||||||
|
cb(false)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
end)
|
||||||
|
|
||||||
|
QBCore.Functions.CreateCallback('mh_garage:retrieveKeyVehicle', function(source, cb, zone)
|
||||||
|
local _source = source
|
||||||
|
local Player = QBCore.Functions.GetPlayer(_source)
|
||||||
|
local pedid = Player.PlayerData.citizenid
|
||||||
|
local veh = {}
|
||||||
|
|
||||||
|
MySQL.query("SELECT pv.* FROM player_vehicles pv JOIN vehicle_keys vk ON pv.plate = vk.plate WHERE vk.owner = ? AND vk.count > 0", {playerId}, function(vehicles)
|
||||||
|
if vehicles and #vehicles > 0 then
|
||||||
|
for _, vehicle in pairs(vehicles) do
|
||||||
|
table.insert(veh, {
|
||||||
|
vehicle = vehicle.vehicle,
|
||||||
|
mods = vehicle.mods,
|
||||||
|
plate = vehicle.plate,
|
||||||
|
name = vehicle.name
|
||||||
|
})
|
||||||
|
end
|
||||||
Wait(100)
|
Wait(100)
|
||||||
cb(vehicles)
|
cb(veh)
|
||||||
|
else
|
||||||
|
cb(false)
|
||||||
|
end
|
||||||
|
end)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
QBCore.Functions.CreateCallback('mh_garage:verwaltung', function(source, cb)
|
QBCore.Functions.CreateCallback('mh_garage:verwaltung', function(source, cb)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue