mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-08-29 01:08:57 +00:00
⚠️⚠️ ghmatti ditch ⚠️⚠️
This commit is contained in:
+2
-2
@@ -43,5 +43,5 @@ files {
|
||||
dependencies {
|
||||
'progressbar',
|
||||
'connectqueue',
|
||||
'ghmattimysql'
|
||||
}
|
||||
'oxmysql'
|
||||
}
|
||||
+3
-3
@@ -232,7 +232,7 @@ AddEventHandler('QBCore:ToggleDuty', function()
|
||||
end)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
local result = exports['ghmattimysql']:executeSync('SELECT * FROM permissions')
|
||||
local result = exports.oxmysql:fetchSync('SELECT * FROM permissions', {})
|
||||
if result[1] ~= nil then
|
||||
for k, v in pairs(result) do
|
||||
QBCore.Config.Server.PermissionList[v.license] = {
|
||||
@@ -306,9 +306,9 @@ end)
|
||||
RegisterServerEvent('QBCore:Command:CheckOwnedVehicle')
|
||||
AddEventHandler('QBCore:Command:CheckOwnedVehicle', function(VehiclePlate)
|
||||
if VehiclePlate ~= nil then
|
||||
local result = exports['ghmattimysql']:executeSync('SELECT * FROM player_vehicles WHERE plate=@plate', {['@plate'] = VehiclePlate})
|
||||
local result = exports.oxmysql:fetchSync('SELECT * FROM player_vehicles WHERE plate=@plate', {['@plate'] = VehiclePlate})
|
||||
if result[1] ~= nil then
|
||||
exports.ghmattimysql:execute('UPDATE player_vehicles SET state=@state WHERE citizenid=@citizenid', {['@state'] = 1, ['@citizenid'] = result[1].citizenid})
|
||||
exports.oxmysql:execute('UPDATE player_vehicles SET state=@state WHERE citizenid=@citizenid', {['@state'] = 1, ['@citizenid'] = result[1].citizenid})
|
||||
TriggerEvent('qb-garages:server:RemoveVehicle', result[1].citizenid, VehiclePlate)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -128,7 +128,7 @@ QBCore.Functions.IsWhitelisted = function(source)
|
||||
local identifiers = GetPlayerIdentifiers(source)
|
||||
local rtn = false
|
||||
if (QBCore.Config.Server.whitelist) then
|
||||
local result = exports['ghmattimysql']:executeSync('SELECT * FROM whitelist WHERE license=@license', {['@license'] = QBCore.Functions.GetIdentifier(source, 'license')})
|
||||
local result = exports.oxmysql:fetchSync('SELECT * FROM whitelist WHERE license=@license', {['@license'] = QBCore.Functions.GetIdentifier(source, 'license')})
|
||||
local data = result[1]
|
||||
if data ~= nil then
|
||||
for _, id in pairs(identifiers) do
|
||||
@@ -150,9 +150,9 @@ QBCore.Functions.AddPermission = function(source, permission)
|
||||
license = QBCore.Functions.GetIdentifier(source, 'license'),
|
||||
permission = permission:lower(),
|
||||
}
|
||||
exports['ghmattimysql']:execute('DELETE FROM permissions WHERE license=@license', {['@license'] = QBCore.Functions.GetIdentifier(source, 'license')})
|
||||
exports.oxmysql:execute('DELETE FROM permissions WHERE license=@license', {['@license'] = QBCore.Functions.GetIdentifier(source, 'license')})
|
||||
|
||||
exports['ghmattimysql']:execute('INSERT INTO permissions (name, license, permission) VALUES (@name, @license, @permission)', {
|
||||
exports.oxmysql:insert('INSERT INTO permissions (name, license, permission) VALUES (@name, @license, @permission)', {
|
||||
['@name'] = GetPlayerName(source),
|
||||
['@license'] = QBCore.Functions.GetIdentifier(source, 'license'),
|
||||
['@permission'] = permission:lower()
|
||||
@@ -167,7 +167,7 @@ QBCore.Functions.RemovePermission = function(source)
|
||||
local Player = QBCore.Functions.GetPlayer(source)
|
||||
if Player ~= nil then
|
||||
QBCore.Config.Server.PermissionList[QBCore.Functions.GetIdentifier(source, 'license')] = nil
|
||||
exports['ghmattimysql']:execute('DELETE FROM permissions WHERE license=@license', {['@license'] = QBCore.Functions.GetIdentifier(source, 'license')})
|
||||
exports.oxmysql:execute('DELETE FROM permissions WHERE license=@license', {['@license'] = QBCore.Functions.GetIdentifier(source, 'license')})
|
||||
Player.Functions.UpdatePlayerData()
|
||||
end
|
||||
end
|
||||
@@ -223,14 +223,14 @@ end
|
||||
QBCore.Functions.IsPlayerBanned = function (source)
|
||||
local retval = false
|
||||
local message = ""
|
||||
local result = exports.ghmattimysql:executeSync('SELECT * FROM bans WHERE license=@license', {['@license'] = QBCore.Functions.GetIdentifier(source, 'license')})
|
||||
local result = exports.oxmysql:fetchSync('SELECT * FROM bans WHERE license=@license', {['@license'] = QBCore.Functions.GetIdentifier(source, 'license')})
|
||||
if result[1] ~= nil then
|
||||
if os.time() < result[1].expire then
|
||||
retval = true
|
||||
local timeTable = os.date("*t", tonumber(result.expire))
|
||||
message = "You have been banned from the server:\n"..result[1].reason.."\nYour ban expires "..timeTable.day.. "/" .. timeTable.month .. "/" .. timeTable.year .. " " .. timeTable.hour.. ":" .. timeTable.min .. "\n"
|
||||
else
|
||||
exports['ghmattimysql']:execute('DELETE FROM bans WHERE id=@id', {['@id'] = result[1].id})
|
||||
exports.oxmysql:execute('DELETE FROM bans WHERE id=@id', {['@id'] = result[1].id})
|
||||
end
|
||||
end
|
||||
return retval, message
|
||||
|
||||
+13
-13
@@ -4,7 +4,7 @@ QBCore.Player = {}
|
||||
QBCore.Player.Login = function(source, citizenid, newData)
|
||||
if source ~= nil then
|
||||
if citizenid then
|
||||
local result = exports['ghmattimysql']:executeSync('SELECT * FROM players WHERE citizenid=@citizenid', {['@citizenid'] = citizenid})
|
||||
local result = exports.oxmysql:fetchSync('SELECT * FROM players WHERE citizenid=@citizenid', {['@citizenid'] = citizenid})
|
||||
local PlayerData = result[1]
|
||||
if PlayerData ~= nil then
|
||||
PlayerData.money = json.decode(PlayerData.money)
|
||||
@@ -439,9 +439,9 @@ end
|
||||
QBCore.Player.Save = function(source)
|
||||
local PlayerData = QBCore.Players[source].PlayerData
|
||||
if PlayerData ~= nil then
|
||||
local result = exports.ghmattimysql:executeSync('SELECT * FROM players WHERE citizenid=@citizenid', {['@citizenid'] = PlayerData.citizenid})
|
||||
local result = exports.oxmysql:fetchSync('SELECT * FROM players WHERE citizenid=@citizenid', {['@citizenid'] = PlayerData.citizenid})
|
||||
if result[1] == nil then
|
||||
exports.ghmattimysql:execute('INSERT INTO players (citizenid, cid, license, name, money, charinfo, job, gang, position, metadata) VALUES (@citizenid, @cid, @license, @name, @money, @charinfo, @job, @gang, @position, @metadata)', {
|
||||
exports.oxmysql:insert('INSERT INTO players (citizenid, cid, license, name, money, charinfo, job, gang, position, metadata) VALUES (@citizenid, @cid, @license, @name, @money, @charinfo, @job, @gang, @position, @metadata)', {
|
||||
['@citizenid'] = PlayerData.citizenid,
|
||||
['@cid'] = tonumber(PlayerData.cid),
|
||||
['@license'] = PlayerData.license,
|
||||
@@ -454,7 +454,7 @@ QBCore.Player.Save = function(source)
|
||||
['@metadata'] = json.encode(PlayerData.metadata)
|
||||
})
|
||||
else
|
||||
exports.ghmattimysql:execute('UPDATE players SET license=@license, name=@name, money=@money, charinfo=@charinfo, job=@job, gang=@gang, position=@position, metadata=@metadata WHERE citizenid=@citizenid', {
|
||||
exports.oxmysql:execute('UPDATE players SET license=@license, name=@name, money=@money, charinfo=@charinfo, job=@job, gang=@gang, position=@position, metadata=@metadata WHERE citizenid=@citizenid', {
|
||||
['@citizenid'] = PlayerData.citizenid,
|
||||
['@license'] = PlayerData.license,
|
||||
['@name'] = PlayerData.name,
|
||||
@@ -498,10 +498,10 @@ local playertables = {
|
||||
|
||||
QBCore.Player.DeleteCharacter = function(source, citizenid)
|
||||
local license = QBCore.Functions.GetIdentifier(source, 'license')
|
||||
local result = exports.ghmattimysql:scalarSync('SELECT license FROM players where citizenid = ?', {citizenid})
|
||||
local result = exports.oxmysql:scalarSync('SELECT license FROM players where citizenid = ?', {citizenid})
|
||||
if license == result then
|
||||
for k,v in pairs(playertables) do
|
||||
exports.ghmattimysql:execute('DELETE FROM '..v.table..' WHERE citizenid = ?', {citizenid})
|
||||
exports.oxmysql:execute('DELETE FROM '..v.table..' WHERE citizenid = ?', {citizenid})
|
||||
end
|
||||
TriggerEvent("qb-log:server:CreateLog", "joinleave", "Character Deleted", "red", "**".. GetPlayerName(source) .. "** ("..QBCore.Functions.GetIdentifier(source, 'license')..") deleted **"..citizenid.."**..")
|
||||
else
|
||||
@@ -512,7 +512,7 @@ end
|
||||
|
||||
QBCore.Player.LoadInventory = function(PlayerData)
|
||||
PlayerData.items = {}
|
||||
local result = exports['ghmattimysql']:executeSync('SELECT * FROM players WHERE citizenid=@citizenid', {['@citizenid'] = PlayerData.citizenid})
|
||||
local result = exports.oxmysql:fetchSync('SELECT * FROM players WHERE citizenid=@citizenid', {['@citizenid'] = PlayerData.citizenid})
|
||||
if result[1] ~= nil then
|
||||
if result[1].inventory ~= nil then
|
||||
plyInventory = json.decode(result[1].inventory)
|
||||
@@ -562,9 +562,9 @@ QBCore.Player.SaveInventory = function(source)
|
||||
})
|
||||
end
|
||||
end
|
||||
exports.ghmattimysql:execute('UPDATE players SET inventory=@inventory WHERE citizenid=@citizenid', {['@inventory'] = json.encode(ItemsJson), ['@citizenid'] = PlayerData.citizenid})
|
||||
exports.oxmysql:execute('UPDATE players SET inventory=@inventory WHERE citizenid=@citizenid', {['@inventory'] = json.encode(ItemsJson), ['@citizenid'] = PlayerData.citizenid})
|
||||
else
|
||||
exports.ghmattimysql:execute('UPDATE players SET inventory=@inventory WHERE citizenid=@citizenid', {['@inventory'] = '[]', ['@citizenid'] = PlayerData.citizenid})
|
||||
exports.oxmysql:execute('UPDATE players SET inventory=@inventory WHERE citizenid=@citizenid', {['@inventory'] = '[]', ['@citizenid'] = PlayerData.citizenid})
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -608,7 +608,7 @@ QBCore.Player.CreateCitizenId = function()
|
||||
|
||||
while not UniqueFound do
|
||||
CitizenId = tostring(QBCore.Shared.RandomStr(3) .. QBCore.Shared.RandomInt(5)):upper()
|
||||
local result = exports.ghmattimysql:executeSync('SELECT COUNT(*) as count FROM players WHERE citizenid=@citizenid', {['@citizenid'] = CitizenId})
|
||||
local result = exports.oxmysql:fetchSync('SELECT COUNT(*) as count FROM players WHERE citizenid=@citizenid', {['@citizenid'] = CitizenId})
|
||||
if result[1].count == 0 then
|
||||
UniqueFound = true
|
||||
end
|
||||
@@ -622,7 +622,7 @@ QBCore.Player.CreateFingerId = function()
|
||||
while not UniqueFound do
|
||||
FingerId = tostring(QBCore.Shared.RandomStr(2) .. QBCore.Shared.RandomInt(3) .. QBCore.Shared.RandomStr(1) .. QBCore.Shared.RandomInt(2) .. QBCore.Shared.RandomStr(3) .. QBCore.Shared.RandomInt(4))
|
||||
local query = '%'..FingerId..'%'
|
||||
local result = exports.ghmattimysql:executeSync('SELECT COUNT(*) as count FROM `players` WHERE `metadata` LIKE @query', {['@query'] = query})
|
||||
local result = exports.oxmysql:fetchSync('SELECT COUNT(*) as count FROM `players` WHERE `metadata` LIKE @query', {['@query'] = query})
|
||||
if result[1].count == 0 then
|
||||
UniqueFound = true
|
||||
end
|
||||
@@ -636,7 +636,7 @@ QBCore.Player.CreateWalletId = function()
|
||||
while not UniqueFound do
|
||||
WalletId = "QB-"..math.random(11111111, 99999999)
|
||||
local query = '%'..WalletId..'%'
|
||||
local result = exports.ghmattimysql:executeSync('SELECT COUNT(*) as count FROM players WHERE metadata LIKE @query', {['@query'] = query})
|
||||
local result = exports.oxmysql:fetchSync('SELECT COUNT(*) as count FROM players WHERE metadata LIKE @query', {['@query'] = query})
|
||||
if result[1].count == 0 then
|
||||
UniqueFound = true
|
||||
end
|
||||
@@ -651,7 +651,7 @@ QBCore.Player.CreateSerialNumber = function()
|
||||
while not UniqueFound do
|
||||
SerialNumber = math.random(11111111, 99999999)
|
||||
local query = '%'..SerialNumber..'%'
|
||||
local result = exports.ghmattimysql:executeSync('SELECT COUNT(*) as count FROM players WHERE metadata LIKE @query', {['@query'] = query})
|
||||
local result = exports.oxmysql:fetchSync('SELECT COUNT(*) as count FROM players WHERE metadata LIKE @query', {['@query'] = query})
|
||||
if result[1].count == 0 then
|
||||
UniqueFound = true
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user