structura foldere
mutat kq- folders in un singur folder [kq]
This commit is contained in:
@@ -0,0 +1,167 @@
|
||||
if Config.Framework ~= 'esx' then
|
||||
return
|
||||
end
|
||||
|
||||
ESX = exports['es_extended']:getSharedObject()
|
||||
|
||||
userTable = 'users'
|
||||
identifierColumn = 'identifier'
|
||||
garageTable = 'owned_vehicles'
|
||||
garageIdentifierColumn = 'owner'
|
||||
garagePropsColumn = 'vehicle'
|
||||
storedColumn = 'stored'
|
||||
|
||||
Query = {
|
||||
SELECT_PLAYER_VEHICLES = [[
|
||||
SELECT id, owner, tag, plate, vehicle, type, garage, impound_data, favorite, stored, jobVehicle, jobGarage FROM owned_vehicles WHERE garage = ? AND owner = ?
|
||||
]]
|
||||
}
|
||||
|
||||
RegisterNetEvent('esx:playerLoaded')
|
||||
AddEventHandler('esx:playerLoaded', function(id)
|
||||
savePlayer(id)
|
||||
CreateQuests(id)
|
||||
end)
|
||||
|
||||
CreateThread(function()
|
||||
for k, v in pairs(ESX.Players) do
|
||||
if v and v.source then
|
||||
Debug('Loaded player:', v.source)
|
||||
CreateQuests(v.source)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
function InitInsideShellGarage(source)
|
||||
local xPlayer = GetPlayerFromId(source)
|
||||
if not xPlayer then return end
|
||||
local str = [[
|
||||
SELECT shell_garage FROM users WHERE identifier = ?
|
||||
]]
|
||||
local result = MySQL.Sync.fetchAll(str, { xPlayer.identifier })
|
||||
if not result[1] or not result[1].shell_garage then return end
|
||||
local data = json.decode(result[1].shell_garage)
|
||||
if not data then return end
|
||||
TriggerClientEvent('advancedgarages:enterShellGarage', source, data.garage, data.defaultCoords, data.customGarageId)
|
||||
end
|
||||
|
||||
RegisterNetEvent('esx:playerLoaded')
|
||||
AddEventHandler('esx:playerLoaded', function(id, xPlayer)
|
||||
TriggerClientEvent('advancedgarages:SetShellData', id, shellPlayers)
|
||||
InitInsideShellGarage(id)
|
||||
end)
|
||||
|
||||
function RegisterServerCallback(name, cb)
|
||||
ESX.RegisterServerCallback(name, cb)
|
||||
end
|
||||
|
||||
function RegisterUsableItem(name, cb)
|
||||
ESX.RegisterUsableItem(name, cb)
|
||||
end
|
||||
|
||||
function GetPlayerFromId(source)
|
||||
return ESX.GetPlayerFromId(source)
|
||||
end
|
||||
|
||||
function GetPlayerFromIdentifier(identifier)
|
||||
return ESX.GetPlayerFromIdentifier(identifier)
|
||||
end
|
||||
|
||||
function GetPlayerIdentifier(source)
|
||||
local player = GetPlayerFromId(source)
|
||||
return player?.identifier
|
||||
end
|
||||
|
||||
function GetJobName(source)
|
||||
local player = GetPlayerFromId(source)
|
||||
return player.getJob().name
|
||||
end
|
||||
|
||||
function GetJobGrade(source)
|
||||
local player = GetPlayerFromId(source)
|
||||
return player.getJob().grade or 0
|
||||
end
|
||||
|
||||
function GetJobsData()
|
||||
local jobs = ESX.GetJobs()
|
||||
local data = {}
|
||||
for k, v in pairs(jobs) do
|
||||
data[#data + 1] = {
|
||||
name = v.name,
|
||||
label = v.label,
|
||||
grades = table.map(v.grades, function(grade)
|
||||
return {
|
||||
id = grade.id,
|
||||
name = grade.name,
|
||||
label = grade.label,
|
||||
grade = grade.grade
|
||||
}
|
||||
end)
|
||||
}
|
||||
end
|
||||
return data
|
||||
end
|
||||
|
||||
function GetPlayerSource(player)
|
||||
return player?.source
|
||||
end
|
||||
|
||||
function GetAccountMoney(source, account)
|
||||
local player = GetPlayerFromId(source)
|
||||
return player.getAccount(account).money
|
||||
end
|
||||
|
||||
function RemoveAccountMoney(source, account, amount)
|
||||
if amount <= 0 then
|
||||
return true
|
||||
end
|
||||
local player = GetPlayerFromId(source)
|
||||
player.removeAccountMoney(account, amount)
|
||||
return true
|
||||
end
|
||||
|
||||
function AddAccountMoney(source, account, amount)
|
||||
local player = GetPlayerFromId(source)
|
||||
player.addAccountMoney(account, amount)
|
||||
end
|
||||
|
||||
function RemoveItem(source, item, count)
|
||||
local player = GetPlayerFromId(source)
|
||||
player.removeInventoryItem(item, count)
|
||||
end
|
||||
|
||||
function PlayerIsAdmin(source)
|
||||
local player = GetPlayerFromId(source)
|
||||
return player.getGroup() == 'admin' or player.getGroup() == 'superadmin'
|
||||
end
|
||||
|
||||
RegisterServerEvent('advancedgarages:server:setVehicle')
|
||||
AddEventHandler('advancedgarages:server:setVehicle', function(vehicleProps, model, playerID, vehicleType, addcommand)
|
||||
local src = source
|
||||
local Player = GetPlayerFromId(src)
|
||||
local plate = vehicleProps.plate
|
||||
local garage
|
||||
if Player ~= nil then
|
||||
if addcommand then
|
||||
garage = 'OUT'
|
||||
else
|
||||
garage = GetImpoundOfType(vehicleType, vehicleProps.coords)
|
||||
if not garage then
|
||||
Notification(src, i18n.t('missing_type', { type = vehicleType }), 'error')
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
MySQL.Async.execute('INSERT INTO ' .. garageTable .. ' (' .. garageIdentifierColumn .. ', plate, ' .. garagePropsColumn .. ', garage, type) VALUES (?, ?, ?, ?, ?)', {
|
||||
GetPlayerIdentifier(playerID),
|
||||
plate,
|
||||
json.encode(vehicleProps),
|
||||
garage,
|
||||
vehicleType
|
||||
}, function(rowsAffected)
|
||||
if rowsAffected > 0 then
|
||||
Notification(playerID, i18n.t('give_vehicle.give_info', { model = model, plate = plate, player = GetPlayerName(playerID) }), 'success')
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
@@ -0,0 +1,167 @@
|
||||
if Config.Framework ~= 'qb' then
|
||||
return
|
||||
end
|
||||
|
||||
QBCore = exports['qb-core']:GetCoreObject()
|
||||
|
||||
userTable = 'players'
|
||||
identifierColumn = 'citizenid'
|
||||
garageTable = 'player_vehicles'
|
||||
garageIdentifierColumn = 'citizenid'
|
||||
garagePropsColumn = 'mods'
|
||||
storedColumn = 'state'
|
||||
|
||||
Query = {
|
||||
SELECT_PLAYER_VEHICLES = [[
|
||||
SELECT `id`, `citizenid`, `mods`, `plate`, `garage`, `tag`, `impound_data`, `favorite`, `type`, `jobVehicle`, `jobGarage` FROM player_vehicles WHERE garage = ? AND citizenid = ?
|
||||
]],
|
||||
}
|
||||
|
||||
function InitInsideShellGarage(source)
|
||||
local identifier = GetPlayerIdentifier(source)
|
||||
if not identifier then return end
|
||||
local str = [[
|
||||
SELECT shell_garage FROM players WHERE citizenid = ?
|
||||
]]
|
||||
local result = MySQL.Sync.fetchAll(str, { identifier })
|
||||
if not result[1] or not result[1].shell_garage then return end
|
||||
local data = json.decode(result[1].shell_garage)
|
||||
if not data then return end
|
||||
TriggerClientEvent('advancedgarages:enterShellGarage', source, data.garage, data.defaultCoords, data.customGarageId)
|
||||
end
|
||||
|
||||
RegisterNetEvent('QBCore:Server:OnPlayerLoaded', function()
|
||||
local src = source
|
||||
Wait(1250)
|
||||
local Player = GetPlayerFromId(src)
|
||||
local identifier = Player.PlayerData.citizenid
|
||||
savePlayer(src)
|
||||
CreateQuests(src)
|
||||
TriggerClientEvent('advancedgarages:SetShellData', src, shellPlayers)
|
||||
InitInsideShellGarage(src)
|
||||
end)
|
||||
|
||||
CreateThread(function()
|
||||
for k, v in pairs(QBCore.Functions.GetPlayers()) do
|
||||
if v then
|
||||
Debug('Loaded player:', v)
|
||||
CreateQuests(v)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
function RegisterServerCallback(name, cb)
|
||||
QBCore.Functions.CreateCallback(name, cb)
|
||||
end
|
||||
|
||||
function RegisterUsableItem(name, cb)
|
||||
QBCore.Functions.CreateUseableItem(name, cb)
|
||||
end
|
||||
|
||||
function GetPlayerFromId(source)
|
||||
return QBCore.Functions.GetPlayer(source)
|
||||
end
|
||||
|
||||
function GetPlayerFromIdentifier(identifier)
|
||||
return QBCore.Functions.GetPlayerByCitizenId(identifier)
|
||||
end
|
||||
|
||||
function GetPlayerIdentifier(source)
|
||||
local player = GetPlayerFromId(source)
|
||||
return player?.PlayerData?.citizenid
|
||||
end
|
||||
|
||||
function GetJobName(source)
|
||||
local player = GetPlayerFromId(source)
|
||||
return player.PlayerData.job.name
|
||||
end
|
||||
|
||||
function GetJobGrade(source)
|
||||
local player = GetPlayerFromId(source)
|
||||
return player.PlayerData.job.grade.level or 0
|
||||
end
|
||||
|
||||
function GetJobsData()
|
||||
local data = {}
|
||||
for k, v in pairs(QBCore.Shared.Jobs) do
|
||||
data[#data + 1] = {
|
||||
name = k,
|
||||
label = v.label,
|
||||
grades = table.map(v.grades, function(grade, index)
|
||||
return {
|
||||
label = grade.name,
|
||||
grade = tonumber(index)
|
||||
}
|
||||
end)
|
||||
}
|
||||
end
|
||||
return data
|
||||
end
|
||||
|
||||
function GetPlayerSource(player)
|
||||
return player?.PlayerData?.source
|
||||
end
|
||||
|
||||
function GetAccountMoney(source, account)
|
||||
local player = GetPlayerFromId(source)
|
||||
if account == 'money' then account = 'cash' end
|
||||
return player.PlayerData.money[account]
|
||||
end
|
||||
|
||||
function RemoveAccountMoney(source, account, amount)
|
||||
local player = GetPlayerFromId(source)
|
||||
if account == 'money' then account = 'cash' end
|
||||
player.Functions.RemoveMoney(account, amount)
|
||||
return true
|
||||
end
|
||||
|
||||
function AddAccountMoney(source, account, amount)
|
||||
local player = GetPlayerFromId(source)
|
||||
if account == 'money' then account = 'cash' end
|
||||
player.Functions.AddMoney(account, amount)
|
||||
end
|
||||
|
||||
function RemoveItem(source, item, count)
|
||||
local player = GetPlayerFromId(source, true)
|
||||
player.Functions.RemoveItem(item, count)
|
||||
end
|
||||
|
||||
function PlayerIsAdmin(source)
|
||||
if source == 0 then
|
||||
return true
|
||||
end
|
||||
return QBCore.Functions.HasPermission(source, 'god') or IsPlayerAceAllowed(source, 'command') or QBCore.Functions.HasPermission(source, 'admin')
|
||||
end
|
||||
|
||||
RegisterServerEvent('advancedgarages:server:setVehicle')
|
||||
AddEventHandler('advancedgarages:server:setVehicle', function(vehicleProps, model, playerID, vehicleType, addcommand)
|
||||
local src = source
|
||||
local Player = GetPlayerFromId(src)
|
||||
local playerID = tonumber(playerID)
|
||||
|
||||
if Player ~= nil and playerID ~= nil then
|
||||
local Target = QBCore.Functions.GetPlayer(playerID)
|
||||
local plate = vehicleProps.plate
|
||||
|
||||
local garage = GetImpoundOfType(vehicleType, vehicleProps.coords)
|
||||
if not garage then
|
||||
Notification(src, i18n.t('missing_type', { type = vehicleType }), 'error')
|
||||
return
|
||||
end
|
||||
|
||||
MySQL.Async.execute('INSERT INTO ' .. garageTable .. ' (license, ' .. garageIdentifierColumn .. ', vehicle, hash, plate, ' .. garagePropsColumn .. ', garage, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?)', {
|
||||
Target.PlayerData.license,
|
||||
Target.PlayerData.citizenid,
|
||||
model,
|
||||
vehicleProps.model,
|
||||
plate,
|
||||
json.encode(vehicleProps),
|
||||
garage,
|
||||
vehicleType
|
||||
}, function(rowsAffected)
|
||||
if rowsAffected > 0 then
|
||||
Notification(playerID, i18n.t('give_vehicle.give_info', { model = model, plate = plate, player = GetPlayerName(playerID) }), 'success')
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
@@ -0,0 +1,25 @@
|
||||
function CheckSpawnCoordsIsFree(coords)
|
||||
local vehicles = GetAllVehicles()
|
||||
for k, v in pairs(vehicles) do
|
||||
local vehicleCoords = GetEntityCoords(v)
|
||||
local distance = #(coords - vec3(vehicleCoords.x, vehicleCoords.y, vehicleCoords.z))
|
||||
local plate = MathTrim(GetVehicleNumberPlateText(v))
|
||||
if distance < 3 then
|
||||
local existVehicle = GetVehicleFromPlate(plate)
|
||||
if not existVehicle then
|
||||
if DoesEntityExist(v) then
|
||||
DeleteEntity(v)
|
||||
end
|
||||
goto continue
|
||||
end
|
||||
local existDriver = GetPedInVehicleSeat(v, -1)
|
||||
if existDriver == 0 then
|
||||
DeleteSpawnedVehicle(plate)
|
||||
goto continue
|
||||
end
|
||||
return false
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
return true
|
||||
end
|
||||
@@ -0,0 +1,15 @@
|
||||
--[[
|
||||
Welcome webhooks setup!
|
||||
Here you will have the link to configure the admin webhooks,
|
||||
you can modify them from server/custom/misc/SetInventoryData.lua.
|
||||
]]
|
||||
|
||||
Webhooks = Webhooks or {}
|
||||
|
||||
Webhooks = {
|
||||
['take_vehicle'] = '',
|
||||
['save_vehicle'] = '',
|
||||
['recovery_vehicle'] = '',
|
||||
['impound_vehicle'] = '',
|
||||
['give_vehicle'] = '',
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
function CreateQuests(source)
|
||||
if GetResourceState('qs-inventory') ~= 'started' then
|
||||
Debug('qs-inventory not started, skipping garage quest creation.')
|
||||
return
|
||||
end
|
||||
|
||||
local quest1 = exports['qs-inventory']:createQuest(source, {
|
||||
name = 'deposit_vehicle_garage',
|
||||
title = 'Safe Parking',
|
||||
description = 'Deposit a vehicle into a garage.',
|
||||
reward = 150,
|
||||
requiredLevel = 0
|
||||
})
|
||||
|
||||
local quest2 = exports['qs-inventory']:createQuest(source, {
|
||||
name = 'add_custom_plate',
|
||||
title = 'Personal Tag',
|
||||
description = 'Add a custom tag or plate to one of your vehicles.',
|
||||
reward = 200,
|
||||
requiredLevel = 1
|
||||
})
|
||||
|
||||
local quest3 = exports['qs-inventory']:createQuest(source, {
|
||||
name = 'mark_favorite_vehicle',
|
||||
title = 'Favorite Ride',
|
||||
description = 'Mark a vehicle as your favorite.',
|
||||
reward = 150,
|
||||
requiredLevel = 0
|
||||
})
|
||||
|
||||
local quest4 = exports['qs-inventory']:createQuest(source, {
|
||||
name = 'enter_garage_interior',
|
||||
title = 'Garage Explorer',
|
||||
description = 'Enter the interior of a garage.',
|
||||
reward = 100,
|
||||
requiredLevel = 0
|
||||
})
|
||||
|
||||
Debug('Garage quests assigned to player:', source, {
|
||||
deposit_vehicle_garage = quest1,
|
||||
add_custom_plate = quest2,
|
||||
mark_favorite_vehicle = quest3,
|
||||
enter_garage_interior = quest4
|
||||
})
|
||||
end
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user