mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-08-29 01:08:57 +00:00
Initial Commit
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
|
||||
|
||||
description 'Qbus:Core'
|
||||
|
||||
server_scripts {
|
||||
"config.lua",
|
||||
"shared.lua",
|
||||
"server/main.lua",
|
||||
"server/functions.lua",
|
||||
"server/player.lua",
|
||||
--"server/loops.lua",
|
||||
"server/events.lua",
|
||||
"server/commands.lua",
|
||||
"server/debug.lua",
|
||||
}
|
||||
|
||||
client_scripts {
|
||||
"config.lua",
|
||||
"shared.lua",
|
||||
"client/main.lua",
|
||||
"client/functions.lua",
|
||||
"client/loops.lua",
|
||||
"client/events.lua",
|
||||
"client/debug.lua",
|
||||
}
|
||||
|
||||
ui_page {
|
||||
'html/ui.html'
|
||||
}
|
||||
|
||||
files {
|
||||
'html/ui.html',
|
||||
'html/css/main.css',
|
||||
'html/js/app.js',
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
QBCore.Debug = function(resource, obj, depth)
|
||||
TriggerServerEvent('QBCore:DebugSomething', resource, obj, depth)
|
||||
end
|
||||
@@ -0,0 +1,152 @@
|
||||
-- QBCore Command Events
|
||||
RegisterNetEvent('QBCore:Command:TeleportToPlayer')
|
||||
AddEventHandler('QBCore:Command:TeleportToPlayer', function(othersource)
|
||||
local coords = QBCore.Functions.GetCoords(GetPlayerPed(GetPlayerFromServerId(othersource)))
|
||||
local entity = GetPlayerPed(-1)
|
||||
if IsPedInAnyVehicle(Entity, false) then
|
||||
entity = GetVehiclePedIsUsing(entity)
|
||||
end
|
||||
SetEntityCoords(entity, coords.x, coords.y, coords.z)
|
||||
SetEntityHeading(entity, coords.a)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Command:TeleportToCoords')
|
||||
AddEventHandler('QBCore:Command:TeleportToCoords', function(x, y, z)
|
||||
local entity = GetPlayerPed(-1)
|
||||
if IsPedInAnyVehicle(Entity, false) then
|
||||
entity = GetVehiclePedIsUsing(entity)
|
||||
end
|
||||
SetEntityCoords(entity, x, y, z)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Command:SpawnVehicle')
|
||||
AddEventHandler('QBCore:Command:SpawnVehicle', function(model)
|
||||
QBCore.Functions.SpawnVehicle(model, function(vehicle)
|
||||
TaskWarpPedIntoVehicle(GetPlayerPed(-1), vehicle, -1)
|
||||
TriggerEvent("vehiclekeys:client:SetOwner", GetVehicleNumberPlateText(vehicle))
|
||||
end)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Command:DeleteVehicle')
|
||||
AddEventHandler('QBCore:Command:DeleteVehicle', function()
|
||||
local vehicle = QBCore.Functions.GetClosestVehicle()
|
||||
if IsPedInAnyVehicle(GetPlayerPed(-1)) then vehicle = GetVehiclePedIsIn(GetPlayerPed(-1), false) else vehicle = QBCore.Functions.GetClosestVehicle() end
|
||||
-- TriggerServerEvent('QBCore:Command:CheckOwnedVehicle', GetVehicleNumberPlateText(vehicle))
|
||||
QBCore.Functions.DeleteVehicle(vehicle)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Command:Revive')
|
||||
AddEventHandler('QBCore:Command:Revive', function()
|
||||
local coords = QBCore.Functions.GetCoords(GetPlayerPed(-1))
|
||||
NetworkResurrectLocalPlayer(coords.x, coords.y, coords.z+0.2, coords.a, true, false)
|
||||
SetPlayerInvincible(GetPlayerPed(-1), false)
|
||||
ClearPedBloodDamage(GetPlayerPed(-1))
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Command:GoToMarker')
|
||||
AddEventHandler('QBCore:Command:GoToMarker', function()
|
||||
Citizen.CreateThread(function()
|
||||
local entity = PlayerPedId()
|
||||
if IsPedInAnyVehicle(entity, false) then
|
||||
entity = GetVehiclePedIsUsing(entity)
|
||||
end
|
||||
local success = false
|
||||
local blipFound = false
|
||||
local blipIterator = GetBlipInfoIdIterator()
|
||||
local blip = GetFirstBlipInfoId(8)
|
||||
|
||||
while DoesBlipExist(blip) do
|
||||
if GetBlipInfoIdType(blip) == 4 then
|
||||
cx, cy, cz = table.unpack(Citizen.InvokeNative(0xFA7C7F0AADF25D09, blip, Citizen.ReturnResultAnyway(), Citizen.ResultAsVector())) --GetBlipInfoIdCoord(blip)
|
||||
blipFound = true
|
||||
break
|
||||
end
|
||||
blip = GetNextBlipInfoId(blipIterator)
|
||||
end
|
||||
|
||||
if blipFound then
|
||||
DoScreenFadeOut(250)
|
||||
while IsScreenFadedOut() do
|
||||
Citizen.Wait(250)
|
||||
end
|
||||
local groundFound = false
|
||||
local yaw = GetEntityHeading(entity)
|
||||
|
||||
for i = 0, 1000, 1 do
|
||||
SetEntityCoordsNoOffset(entity, cx, cy, ToFloat(i), false, false, false)
|
||||
SetEntityRotation(entity, 0, 0, 0, 0 ,0)
|
||||
SetEntityHeading(entity, yaw)
|
||||
SetGameplayCamRelativeHeading(0)
|
||||
Citizen.Wait(0)
|
||||
--groundFound = true
|
||||
if GetGroundZFor_3dCoord(cx, cy, ToFloat(i), cz, false) then --GetGroundZFor3dCoord(cx, cy, i, 0, 0) GetGroundZFor_3dCoord(cx, cy, i)
|
||||
cz = ToFloat(i)
|
||||
groundFound = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if not groundFound then
|
||||
cz = -300.0
|
||||
end
|
||||
success = true
|
||||
end
|
||||
|
||||
if success then
|
||||
SetEntityCoordsNoOffset(entity, cx, cy, cz, false, false, true)
|
||||
SetGameplayCamRelativeHeading(0)
|
||||
if IsPedSittingInAnyVehicle(PlayerPedId()) then
|
||||
if GetPedInVehicleSeat(GetVehiclePedIsUsing(PlayerPedId()), -1) == PlayerPedId() then
|
||||
SetVehicleOnGroundProperly(GetVehiclePedIsUsing(PlayerPedId()))
|
||||
end
|
||||
end
|
||||
--HideLoadingPromt()
|
||||
DoScreenFadeIn(250)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
-- Other stuff
|
||||
RegisterNetEvent('QBCore:Player:SetPlayerData')
|
||||
AddEventHandler('QBCore:Player:SetPlayerData', function(val)
|
||||
QBCore.PlayerData = val
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Player:UpdatePlayerData')
|
||||
AddEventHandler('QBCore:Player:UpdatePlayerData', function()
|
||||
local data = {}
|
||||
data.position = QBCore.Functions.GetCoords(GetPlayerPed(-1))
|
||||
TriggerServerEvent('QBCore:UpdatePlayer', data)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Player:UpdatePlayerPosition')
|
||||
AddEventHandler('QBCore:Player:UpdatePlayerPosition', function()
|
||||
local position = QBCore.Functions.GetCoords(GetPlayerPed(-1))
|
||||
TriggerServerEvent('QBCore:UpdatePlayerPosition', position)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Client:LocalOutOfCharacter')
|
||||
AddEventHandler('QBCore:Client:LocalOutOfCharacter', function(playerId, playerName, message)
|
||||
local sourcePos = GetEntityCoords(GetPlayerPed(GetPlayerFromServerId(playerId)), false)
|
||||
local pos = GetEntityCoords(GetPlayerPed(-1), false)
|
||||
if (GetDistanceBetweenCoords(pos.x, pos.y, pos.z, sourcePos.x, sourcePos.y, sourcePos.z, true) < 20.0) then
|
||||
TriggerEvent("chatMessage", "OOC " .. playerName, "normal", message)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Notify')
|
||||
AddEventHandler('QBCore:Notify', function(text, type, length)
|
||||
QBCore.Functions.Notify(text, type, length)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Client:TriggerCallback')
|
||||
AddEventHandler('QBCore:Client:TriggerCallback', function(name, ...)
|
||||
if QBCore.ServerCallbacks[name] ~= nil then
|
||||
QBCore.ServerCallbacks[name](...)
|
||||
QBCore.ServerCallbacks[name] = nil
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent("QBCore:Client:UseItem")
|
||||
AddEventHandler('QBCore:Client:UseItem', function(item)
|
||||
TriggerServerEvent("QBCore:Server:UseItem", item)
|
||||
end)
|
||||
@@ -0,0 +1,654 @@
|
||||
QBCore.Functions = {}
|
||||
QBCore.RequestId = 0
|
||||
|
||||
QBCore.Functions.GetPlayerData = function(cb)
|
||||
if cb ~= nil then
|
||||
cb(QBCore.PlayerData)
|
||||
else
|
||||
return QBCore.PlayerData
|
||||
end
|
||||
end
|
||||
|
||||
QBCore.Functions.DrawText = function(x, y, width, height, scale, r, g, b, a, text)
|
||||
SetTextFont(4)
|
||||
SetTextProportional(0)
|
||||
SetTextScale(scale, scale)
|
||||
SetTextColour(r, g, b, a)
|
||||
SetTextDropShadow(0, 0, 0, 0,255)
|
||||
SetTextEdge(2, 0, 0, 0, 255)
|
||||
SetTextDropShadow()
|
||||
SetTextOutline()
|
||||
SetTextEntry("STRING")
|
||||
AddTextComponentString(text)
|
||||
DrawText(x - width/2, y - height/2 + 0.005)
|
||||
end
|
||||
|
||||
QBCore.Functions.DrawText3D = function(x, y, z, text)
|
||||
SetTextScale(0.35, 0.35)
|
||||
SetTextFont(4)
|
||||
SetTextProportional(1)
|
||||
SetTextColour(255, 255, 255, 215)
|
||||
SetTextEntry("STRING")
|
||||
SetTextCentre(true)
|
||||
AddTextComponentString(text)
|
||||
SetDrawOrigin(x,y,z, 0)
|
||||
DrawText(0.0, 0.0)
|
||||
local factor = (string.len(text)) / 370
|
||||
DrawRect(0.0, 0.0+0.0125, 0.017+ factor, 0.03, 0, 0, 0, 75)
|
||||
ClearDrawOrigin()
|
||||
end
|
||||
|
||||
QBCore.Functions.GetCoords = function(entity)
|
||||
local coords = GetEntityCoords(entity, false)
|
||||
local heading = GetEntityHeading(entity)
|
||||
return {
|
||||
x = coords.x,
|
||||
y = coords.y,
|
||||
z = coords.z,
|
||||
a = heading
|
||||
}
|
||||
end
|
||||
|
||||
QBCore.Functions.SpawnVehicle = function(model, cb, coords, isnetworked)
|
||||
local model = (type(model)=="number" and model or GetHashKey(model))
|
||||
local coords = coords ~= nil and coords or QBCore.Functions.GetCoords(GetPlayerPed(-1))
|
||||
local isnetworked = isnetworked ~= nil and isnetworked or true
|
||||
|
||||
RequestModel(model)
|
||||
while not HasModelLoaded(model) do
|
||||
Citizen.Wait(10)
|
||||
end
|
||||
|
||||
local veh = CreateVehicle(model, coords.x, coords.y, coords.z, coords.a, isnetworked, false)
|
||||
local netid = NetworkGetNetworkIdFromEntity(veh)
|
||||
|
||||
SetVehicleHasBeenOwnedByPlayer(vehicle, true)
|
||||
SetNetworkIdCanMigrate(netid, true)
|
||||
--SetEntityAsMissionEntity(veh, true, true)
|
||||
SetVehicleNeedsToBeHotwired(veh, false)
|
||||
SetVehRadioStation(veh, "OFF")
|
||||
|
||||
SetModelAsNoLongerNeeded(model)
|
||||
|
||||
if cb ~= nil then
|
||||
cb(veh)
|
||||
end
|
||||
end
|
||||
|
||||
QBCore.Functions.DeleteVehicle = function(vehicle)
|
||||
SetEntityAsMissionEntity(vehicle, true, true)
|
||||
DeleteVehicle(vehicle)
|
||||
end
|
||||
|
||||
QBCore.Functions.Notify = function(text, textype, length) -- [text] = message, [type] = primary | error | success, [length] = time till fadeout.
|
||||
local ttype = textype ~= nil and textype or "primary"
|
||||
local length = length ~= nil and length or 5000
|
||||
SendNUIMessage({
|
||||
action = "show",
|
||||
type = ttype,
|
||||
length = length,
|
||||
text = text,
|
||||
})
|
||||
end
|
||||
|
||||
QBCore.Functions.TriggerCallback = function(name, cb, ...)
|
||||
QBCore.ServerCallbacks[name] = cb
|
||||
TriggerServerEvent("QBCore:Server:TriggerCallback", name, ...)
|
||||
end
|
||||
|
||||
QBCore.Functions.EnumerateEntities = function(initFunc, moveFunc, disposeFunc)
|
||||
return coroutine.wrap(function()
|
||||
local iter, id = initFunc()
|
||||
if not id or id == 0 then
|
||||
disposeFunc(iter)
|
||||
return
|
||||
end
|
||||
|
||||
local enum = {handle = iter, destructor = disposeFunc}
|
||||
setmetatable(enum, entityEnumerator)
|
||||
|
||||
local next = true
|
||||
repeat
|
||||
coroutine.yield(id)
|
||||
next, id = moveFunc(iter)
|
||||
until not next
|
||||
|
||||
enum.destructor, enum.handle = nil, nil
|
||||
disposeFunc(iter)
|
||||
end)
|
||||
end
|
||||
|
||||
QBCore.Functions.GetVehicles = function()
|
||||
local vehicles = {}
|
||||
for vehicle in QBCore.Functions.EnumerateEntities(FindFirstVehicle, FindNextVehicle, EndFindVehicle) do
|
||||
table.insert(vehicles, vehicle)
|
||||
end
|
||||
return vehicles
|
||||
end
|
||||
|
||||
QBCore.Functions.GetPeds = function(ignoreList)
|
||||
local ignoreList = ignoreList or {}
|
||||
local peds = {}
|
||||
for ped in QBCore.Functions.EnumerateEntities(FindFirstPed, FindNextPed, EndFindPed) do
|
||||
local found = false
|
||||
|
||||
for j=1, #ignoreList, 1 do
|
||||
if ignoreList[j] == ped then
|
||||
found = true
|
||||
end
|
||||
end
|
||||
|
||||
if not found then
|
||||
table.insert(peds, ped)
|
||||
end
|
||||
end
|
||||
|
||||
return peds
|
||||
end
|
||||
|
||||
QBCore.Functions.GetPlayers = function()
|
||||
local players = {}
|
||||
for _, player in ipairs(GetActivePlayers()) do
|
||||
local ped = GetPlayerPed(player)
|
||||
if DoesEntityExist(ped) then
|
||||
table.insert(players, player)
|
||||
end
|
||||
end
|
||||
return players
|
||||
end
|
||||
|
||||
QBCore.Functions.GetClosestVehicle = function(coords)
|
||||
--[[local coordFrom = coords
|
||||
local playerPed = GetPlayerPed(-1)
|
||||
|
||||
if coordFrom == nil then
|
||||
coordFrom = GetEntityCoords(playerPed)
|
||||
end
|
||||
local coordTo = GetOffsetFromEntityInWorldCoords(playerPed, 0.0, 255.0, 0.0)
|
||||
|
||||
local offset = 0
|
||||
local rayHandle
|
||||
local vehicle
|
||||
|
||||
for i = 0, 100 do
|
||||
rayHandle = CastRayPointToPoint(coordFrom.x, coordFrom.y, coordFrom.z, coordTo.x, coordTo.y, coordTo.z + offset, 10, GetPlayerPed(-1), 0)
|
||||
a, b, c, d, vehicle = GetRaycastResult(rayHandle)
|
||||
|
||||
offset = offset - 1
|
||||
|
||||
if vehicle ~= 0 then break end
|
||||
end
|
||||
|
||||
local distance = Vdist2(coordFrom, GetEntityCoords(vehicle))
|
||||
|
||||
if distance > 25 then vehicle = nil end
|
||||
|
||||
return vehicle ~= nil and vehicle or 0]]--
|
||||
|
||||
local vehicles = QBCore.Functions.GetVehicles()
|
||||
local closestDistance = -1
|
||||
local closestVehicle = -1
|
||||
local coords = coords
|
||||
|
||||
if coords == nil then
|
||||
local playerPed = PlayerPedId()
|
||||
coords = GetEntityCoords(playerPed)
|
||||
end
|
||||
for i=1, #vehicles, 1 do
|
||||
local vehicleCoords = GetEntityCoords(vehicles[i])
|
||||
local distance = GetDistanceBetweenCoords(vehicleCoords, coords.x, coords.y, coords.z, true)
|
||||
|
||||
if closestDistance == -1 or closestDistance > distance then
|
||||
closestVehicle = vehicles[i]
|
||||
closestDistance = distance
|
||||
end
|
||||
end
|
||||
return closestVehicle
|
||||
end
|
||||
|
||||
QBCore.Functions.GetClosestPed = function(coords, ignoreList)
|
||||
local ignoreList = ignoreList or {}
|
||||
local peds = QBCore.Functions.GetPeds(ignoreList)
|
||||
local closestDistance = -1
|
||||
local closestPed = -1
|
||||
|
||||
if coords == nil then
|
||||
coords = GetEntityCoords(GetPlayerPed(-1))
|
||||
end
|
||||
|
||||
for i=1, #peds, 1 do
|
||||
local pedCoords = GetEntityCoords(peds[i])
|
||||
local distance = GetDistanceBetweenCoords(pedCoords, coords.x, coords.y, coords.z, true)
|
||||
|
||||
if closestDistance == -1 or closestDistance > distance then
|
||||
closestPed = peds[i]
|
||||
closestDistance = distance
|
||||
end
|
||||
end
|
||||
|
||||
return closestPed, closestDistance
|
||||
end
|
||||
|
||||
|
||||
QBCore.Functions.GetClosestPlayer = function(coords)
|
||||
if coords == nil then
|
||||
coords = GetEntityCoords(GetPlayerPed(-1))
|
||||
end
|
||||
|
||||
local closestPlayers = QBCore.Functions.GetPlayersFromCoords(coords)
|
||||
local closestDistance = -1
|
||||
local closestPlayer = -1
|
||||
|
||||
for i=1, #closestPlayers, 1 do
|
||||
if closestPlayers[i] ~= PlayerId() and closestPlayers[i] ~= -1 then
|
||||
local pos = GetEntityCoords(GetPlayerPed(closestPlayers[i]))
|
||||
local distance = GetDistanceBetweenCoords(pos.x, pos.y, pos.z, coords.x, coords.y, coords.z, true)
|
||||
|
||||
if closestDistance == -1 or closestDistance > distance then
|
||||
closestPlayer = closestPlayers[i]
|
||||
closestDistance = distance
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return closestPlayer, closestDistance
|
||||
end
|
||||
|
||||
QBCore.Functions.GetPlayersFromCoords = function(coords, distance)
|
||||
local players = QBCore.Functions.GetPlayers()
|
||||
local closePlayers = {}
|
||||
|
||||
if coords == nil then
|
||||
coords = GetEntityCoords(GetPlayerPed(-1))
|
||||
end
|
||||
if distance == nil then
|
||||
distance = 5.0
|
||||
end
|
||||
for _, player in pairs(players) do
|
||||
local target = GetPlayerPed(player)
|
||||
local targetCoords = GetEntityCoords(target)
|
||||
local targetdistance = GetDistanceBetweenCoords(targetCoords, coords.x, coords.y, coords.z, true)
|
||||
if targetdistance <= distance then
|
||||
table.insert(closePlayers, player)
|
||||
end
|
||||
end
|
||||
|
||||
return closePlayers
|
||||
end
|
||||
|
||||
QBCore.Functions.HasItem = function(source, cb, item)
|
||||
local retval = false
|
||||
QBCore.Functions.TriggerCallback('QBCore:HasItem', function(result)
|
||||
if result then
|
||||
retval = true
|
||||
end
|
||||
return retval
|
||||
end, item)
|
||||
return retval
|
||||
end
|
||||
|
||||
QBCore.Functions.Progressbar = function(name, label, duration, useWhileDead, canCancel, disableControls, animation, prop, propTwo, onFinish, onCancel)
|
||||
exports['progressbar']:Progress({
|
||||
name = name:lower(),
|
||||
duration = duration,
|
||||
label = label,
|
||||
useWhileDead = useWhileDead,
|
||||
canCancel = canCancel,
|
||||
controlDisables = disableControls,
|
||||
animation = animation,
|
||||
prop = prop,
|
||||
propTwo = propTwo,
|
||||
}, function(cancelled)
|
||||
if not cancelled then
|
||||
if onFinish ~= nil then
|
||||
onFinish()
|
||||
end
|
||||
else
|
||||
if onCancel ~= nil then
|
||||
onCancel()
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
QBCore.Functions.GetVehicleProperties = function(vehicle)
|
||||
local color1, color2 = GetVehicleColours(vehicle)
|
||||
local pearlescentColor, wheelColor = GetVehicleExtraColours(vehicle)
|
||||
local livery = GetVehicleLivery(vehicle)
|
||||
if livery == 0 then
|
||||
livery = GetVehicleMod(vehicle, 48)
|
||||
end
|
||||
|
||||
|
||||
return {
|
||||
|
||||
model = GetEntityModel(vehicle),
|
||||
|
||||
plate = GetVehicleNumberPlateText(vehicle),
|
||||
plateIndex = GetVehicleNumberPlateTextIndex(vehicle),
|
||||
|
||||
health = GetEntityHealth(vehicle),
|
||||
dirtLevel = GetVehicleDirtLevel(vehicle),
|
||||
|
||||
color1 = color1,
|
||||
color2 = color2,
|
||||
|
||||
pearlescentColor = pearlescentColor,
|
||||
wheelColor = wheelColor,
|
||||
|
||||
wheels = GetVehicleWheelType(vehicle),
|
||||
windowTint = GetVehicleWindowTint(vehicle),
|
||||
|
||||
neonEnabled = {
|
||||
IsVehicleNeonLightEnabled(vehicle, 0),
|
||||
IsVehicleNeonLightEnabled(vehicle, 1),
|
||||
IsVehicleNeonLightEnabled(vehicle, 2),
|
||||
IsVehicleNeonLightEnabled(vehicle, 3)
|
||||
},
|
||||
|
||||
extras = {
|
||||
|
||||
},
|
||||
|
||||
neonColor = table.pack(GetVehicleNeonLightsColour(vehicle)),
|
||||
tyreSmokeColor = table.pack(GetVehicleTyreSmokeColor(vehicle)),
|
||||
|
||||
modSpoilers = GetVehicleMod(vehicle, 0),
|
||||
modFrontBumper = GetVehicleMod(vehicle, 1),
|
||||
modRearBumper = GetVehicleMod(vehicle, 2),
|
||||
modSideSkirt = GetVehicleMod(vehicle, 3),
|
||||
modExhaust = GetVehicleMod(vehicle, 4),
|
||||
modFrame = GetVehicleMod(vehicle, 5),
|
||||
modGrille = GetVehicleMod(vehicle, 6),
|
||||
modHood = GetVehicleMod(vehicle, 7),
|
||||
modFender = GetVehicleMod(vehicle, 8),
|
||||
modRightFender = GetVehicleMod(vehicle, 9),
|
||||
modRoof = GetVehicleMod(vehicle, 10),
|
||||
|
||||
modEngine = GetVehicleMod(vehicle, 11),
|
||||
modBrakes = GetVehicleMod(vehicle, 12),
|
||||
modTransmission = GetVehicleMod(vehicle, 13),
|
||||
modHorns = GetVehicleMod(vehicle, 14),
|
||||
modSuspension = GetVehicleMod(vehicle, 15),
|
||||
modArmor = GetVehicleMod(vehicle, 16),
|
||||
|
||||
modTurbo = IsToggleModOn(vehicle, 18),
|
||||
modSmokeEnabled = IsToggleModOn(vehicle, 20),
|
||||
modXenon = IsToggleModOn(vehicle, 22),
|
||||
|
||||
modFrontWheels = GetVehicleMod(vehicle, 23),
|
||||
modBackWheels = GetVehicleMod(vehicle, 24),
|
||||
|
||||
modPlateHolder = GetVehicleMod(vehicle, 25),
|
||||
modVanityPlate = GetVehicleMod(vehicle, 26),
|
||||
modTrimA = GetVehicleMod(vehicle, 27),
|
||||
modOrnaments = GetVehicleMod(vehicle, 28),
|
||||
modDashboard = GetVehicleMod(vehicle, 29),
|
||||
modDial = GetVehicleMod(vehicle, 30),
|
||||
modDoorSpeaker = GetVehicleMod(vehicle, 31),
|
||||
modSeats = GetVehicleMod(vehicle, 32),
|
||||
modSteeringWheel = GetVehicleMod(vehicle, 33),
|
||||
modShifterLeavers = GetVehicleMod(vehicle, 34),
|
||||
modAPlate = GetVehicleMod(vehicle, 35),
|
||||
modSpeakers = GetVehicleMod(vehicle, 36),
|
||||
modTrunk = GetVehicleMod(vehicle, 37),
|
||||
modHydrolic = GetVehicleMod(vehicle, 38),
|
||||
modEngineBlock = GetVehicleMod(vehicle, 39),
|
||||
modAirFilter = GetVehicleMod(vehicle, 40),
|
||||
modStruts = GetVehicleMod(vehicle, 41),
|
||||
modArchCover = GetVehicleMod(vehicle, 42),
|
||||
modAerials = GetVehicleMod(vehicle, 43),
|
||||
modTrimB = GetVehicleMod(vehicle, 44),
|
||||
modTank = GetVehicleMod(vehicle, 45),
|
||||
modWindows = GetVehicleMod(vehicle, 46),
|
||||
modLivery = livery,
|
||||
modCustomTyres = GetVehicleModVariation(vehicle, 23)
|
||||
}
|
||||
end
|
||||
|
||||
QBCore.Functions.SetVehicleProperties = function(vehicle, props)
|
||||
SetVehicleModKit(vehicle, 0)
|
||||
|
||||
if props.plate ~= nil then
|
||||
SetVehicleNumberPlateText(vehicle, props.plate)
|
||||
end
|
||||
|
||||
if props.plateIndex ~= nil then
|
||||
SetVehicleNumberPlateTextIndex(vehicle, props.plateIndex)
|
||||
end
|
||||
|
||||
if props.health ~= nil then
|
||||
SetEntityHealth(vehicle, props.health)
|
||||
end
|
||||
|
||||
if props.dirtLevel ~= nil then
|
||||
SetVehicleDirtLevel(vehicle, props.dirtLevel)
|
||||
end
|
||||
|
||||
if props.color1 ~= nil then
|
||||
local color1, color2 = GetVehicleColours(vehicle)
|
||||
SetVehicleColours(vehicle, props.color1, color2)
|
||||
end
|
||||
|
||||
if props.color2 ~= nil then
|
||||
local color1, color2 = GetVehicleColours(vehicle)
|
||||
SetVehicleColours(vehicle, color1, props.color2)
|
||||
end
|
||||
|
||||
if props.pearlescentColor ~= nil then
|
||||
local pearlescentColor, wheelColor = GetVehicleExtraColours(vehicle)
|
||||
SetVehicleExtraColours(vehicle, props.pearlescentColor, wheelColor)
|
||||
end
|
||||
|
||||
if props.wheelColor ~= nil then
|
||||
local pearlescentColor, wheelColor = GetVehicleExtraColours(vehicle)
|
||||
SetVehicleExtraColours(vehicle, pearlescentColor, props.wheelColor)
|
||||
end
|
||||
|
||||
if props.wheels ~= nil then
|
||||
SetVehicleWheelType(vehicle, props.wheels)
|
||||
end
|
||||
|
||||
if props.windowTint ~= nil then
|
||||
SetVehicleWindowTint(vehicle, props.windowTint)
|
||||
end
|
||||
|
||||
if props.neonEnabled ~= nil then
|
||||
SetVehicleNeonLightEnabled(vehicle, 0, props.neonEnabled[1])
|
||||
SetVehicleNeonLightEnabled(vehicle, 1, props.neonEnabled[2])
|
||||
SetVehicleNeonLightEnabled(vehicle, 2, props.neonEnabled[3])
|
||||
SetVehicleNeonLightEnabled(vehicle, 3, props.neonEnabled[4])
|
||||
end
|
||||
|
||||
if props.neonColor ~= nil then
|
||||
SetVehicleNeonLightsColour(vehicle, props.neonColor[1], props.neonColor[2], props.neonColor[3])
|
||||
end
|
||||
|
||||
if props.modSmokeEnabled ~= nil then
|
||||
ToggleVehicleMod(vehicle, 20, true)
|
||||
end
|
||||
|
||||
if props.tyreSmokeColor ~= nil then
|
||||
SetVehicleTyreSmokeColor(vehicle, props.tyreSmokeColor[1], props.tyreSmokeColor[2], props.tyreSmokeColor[3])
|
||||
end
|
||||
|
||||
if props.modSpoilers ~= nil then
|
||||
SetVehicleMod(vehicle, 0, props.modSpoilers, false)
|
||||
end
|
||||
|
||||
if props.modFrontBumper ~= nil then
|
||||
SetVehicleMod(vehicle, 1, props.modFrontBumper, false)
|
||||
end
|
||||
|
||||
if props.modRearBumper ~= nil then
|
||||
SetVehicleMod(vehicle, 2, props.modRearBumper, false)
|
||||
end
|
||||
|
||||
if props.modSideSkirt ~= nil then
|
||||
SetVehicleMod(vehicle, 3, props.modSideSkirt, false)
|
||||
end
|
||||
|
||||
if props.modExhaust ~= nil then
|
||||
SetVehicleMod(vehicle, 4, props.modExhaust, false)
|
||||
end
|
||||
|
||||
if props.modFrame ~= nil then
|
||||
SetVehicleMod(vehicle, 5, props.modFrame, false)
|
||||
end
|
||||
|
||||
if props.modGrille ~= nil then
|
||||
SetVehicleMod(vehicle, 6, props.modGrille, false)
|
||||
end
|
||||
|
||||
if props.modHood ~= nil then
|
||||
SetVehicleMod(vehicle, 7, props.modHood, false)
|
||||
end
|
||||
|
||||
if props.modFender ~= nil then
|
||||
SetVehicleMod(vehicle, 8, props.modFender, false)
|
||||
end
|
||||
|
||||
if props.modRightFender ~= nil then
|
||||
SetVehicleMod(vehicle, 9, props.modRightFender, false)
|
||||
end
|
||||
|
||||
if props.modRoof ~= nil then
|
||||
SetVehicleMod(vehicle, 10, props.modRoof, false)
|
||||
end
|
||||
|
||||
if props.modEngine ~= nil then
|
||||
SetVehicleMod(vehicle, 11, props.modEngine, false)
|
||||
end
|
||||
|
||||
if props.modBrakes ~= nil then
|
||||
SetVehicleMod(vehicle, 12, props.modBrakes, false)
|
||||
end
|
||||
|
||||
if props.modTransmission ~= nil then
|
||||
SetVehicleMod(vehicle, 13, props.modTransmission, false)
|
||||
end
|
||||
|
||||
if props.modHorns ~= nil then
|
||||
SetVehicleMod(vehicle, 14, props.modHorns, false)
|
||||
end
|
||||
|
||||
if props.modSuspension ~= nil then
|
||||
SetVehicleMod(vehicle, 15, props.modSuspension, false)
|
||||
end
|
||||
|
||||
if props.modArmor ~= nil then
|
||||
SetVehicleMod(vehicle, 16, props.modArmor, false)
|
||||
end
|
||||
|
||||
if props.modTurbo ~= nil then
|
||||
ToggleVehicleMod(vehicle, 18, props.modTurbo)
|
||||
end
|
||||
|
||||
if props.modXenon ~= nil then
|
||||
ToggleVehicleMod(vehicle, 22, props.modXenon)
|
||||
end
|
||||
|
||||
if props.modFrontWheels ~= nil then
|
||||
SetVehicleMod(vehicle, 23, props.modFrontWheels, false)
|
||||
end
|
||||
|
||||
if props.modBackWheels ~= nil then
|
||||
SetVehicleMod(vehicle, 24, props.modBackWheels, false)
|
||||
end
|
||||
|
||||
if props.modPlateHolder ~= nil then
|
||||
SetVehicleMod(vehicle, 25, props.modPlateHolder, false)
|
||||
end
|
||||
|
||||
if props.modVanityPlate ~= nil then
|
||||
SetVehicleMod(vehicle, 26, props.modVanityPlate, false)
|
||||
end
|
||||
|
||||
if props.modTrimA ~= nil then
|
||||
SetVehicleMod(vehicle, 27, props.modTrimA, false)
|
||||
end
|
||||
|
||||
if props.modOrnaments ~= nil then
|
||||
SetVehicleMod(vehicle, 28, props.modOrnaments, false)
|
||||
end
|
||||
|
||||
if props.modDashboard ~= nil then
|
||||
SetVehicleMod(vehicle, 29, props.modDashboard, false)
|
||||
end
|
||||
|
||||
if props.modDial ~= nil then
|
||||
SetVehicleMod(vehicle, 30, props.modDial, false)
|
||||
end
|
||||
|
||||
if props.modDoorSpeaker ~= nil then
|
||||
SetVehicleMod(vehicle, 31, props.modDoorSpeaker, false)
|
||||
end
|
||||
|
||||
if props.modSeats ~= nil then
|
||||
SetVehicleMod(vehicle, 32, props.modSeats, false)
|
||||
end
|
||||
|
||||
if props.modSteeringWheel ~= nil then
|
||||
SetVehicleMod(vehicle, 33, props.modSteeringWheel, false)
|
||||
end
|
||||
|
||||
if props.modShifterLeavers ~= nil then
|
||||
SetVehicleMod(vehicle, 34, props.modShifterLeavers, false)
|
||||
end
|
||||
|
||||
if props.modAPlate ~= nil then
|
||||
SetVehicleMod(vehicle, 35, props.modAPlate, false)
|
||||
end
|
||||
|
||||
if props.modSpeakers ~= nil then
|
||||
SetVehicleMod(vehicle, 36, props.modSpeakers, false)
|
||||
end
|
||||
|
||||
if props.modTrunk ~= nil then
|
||||
SetVehicleMod(vehicle, 37, props.modTrunk, false)
|
||||
end
|
||||
|
||||
if props.modHydrolic ~= nil then
|
||||
SetVehicleMod(vehicle, 38, props.modHydrolic, false)
|
||||
end
|
||||
|
||||
if props.modEngineBlock ~= nil then
|
||||
SetVehicleMod(vehicle, 39, props.modEngineBlock, false)
|
||||
end
|
||||
|
||||
if props.modAirFilter ~= nil then
|
||||
SetVehicleMod(vehicle, 40, props.modAirFilter, false)
|
||||
end
|
||||
|
||||
if props.modStruts ~= nil then
|
||||
SetVehicleMod(vehicle, 41, props.modStruts, false)
|
||||
end
|
||||
|
||||
if props.modArchCover ~= nil then
|
||||
SetVehicleMod(vehicle, 42, props.modArchCover, false)
|
||||
end
|
||||
|
||||
if props.modAerials ~= nil then
|
||||
SetVehicleMod(vehicle, 43, props.modAerials, false)
|
||||
end
|
||||
|
||||
if props.modTrimB ~= nil then
|
||||
SetVehicleMod(vehicle, 44, props.modTrimB, false)
|
||||
end
|
||||
|
||||
if props.modTank ~= nil then
|
||||
SetVehicleMod(vehicle, 45, props.modTank, false)
|
||||
end
|
||||
|
||||
if props.modWindows ~= nil then
|
||||
SetVehicleMod(vehicle, 46, props.modWindows, false)
|
||||
end
|
||||
|
||||
if props.modLivery ~= nil then
|
||||
SetVehicleMod(vehicle, 48, props.modLivery, false)
|
||||
SetVehicleLivery(vehicle, props.modLivery)
|
||||
end
|
||||
if props.modCustomTyres ~= nil and props.modCustomTyres then
|
||||
SetVehicleMod(vehicle, 23, props.modCustomTyres, true)
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,48 @@
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(7)
|
||||
if NetworkIsSessionStarted() then
|
||||
Citizen.Wait(10)
|
||||
TriggerServerEvent('QBCore:PlayerJoined')
|
||||
return
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(7)
|
||||
if isLoggedIn then
|
||||
Citizen.Wait((1000 * 60) * 10)
|
||||
TriggerEvent("QBCore:Player:UpdatePlayerData")
|
||||
else
|
||||
Citizen.Wait(5000)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(7)
|
||||
if isLoggedIn then
|
||||
Citizen.Wait(30000)
|
||||
TriggerEvent("QBCore:Player:UpdatePlayerPosition")
|
||||
else
|
||||
Citizen.Wait(5000)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(math.random(3000, 5000))
|
||||
if isLoggedIn then
|
||||
if QBCore.Functions.GetPlayerData().metadata["hunger"] <= 0 or QBCore.Functions.GetPlayerData().metadata["thirst"] <= 0 then
|
||||
local ped = GetPlayerPed(-1)
|
||||
local currentHealth = GetEntityHealth(ped)
|
||||
|
||||
SetEntityHealth(ped, currentHealth - math.random(5, 10))
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -0,0 +1,30 @@
|
||||
QBCore = {}
|
||||
QBCore.PlayerData = {}
|
||||
QBCore.Config = QBConfig
|
||||
QBCore.Shared = QBShared
|
||||
QBCore.ServerCallbacks = {}
|
||||
|
||||
isLoggedIn = false
|
||||
|
||||
function GetCoreObject()
|
||||
return QBCore
|
||||
end
|
||||
|
||||
RegisterNetEvent('QBCore:GetObject')
|
||||
AddEventHandler('QBCore:GetObject', function(cb)
|
||||
cb(GetCoreObject())
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerLoaded')
|
||||
AddEventHandler('QBCore:Client:OnPlayerLoaded', function()
|
||||
local ped = PlayerPedId()
|
||||
ShutdownLoadingScreenNui()
|
||||
isLoggedIn = true
|
||||
SetCanAttackFriendly(ped, true, true)
|
||||
NetworkSetFriendlyFireOption(true)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('QBCore:Client:OnPlayerUnload')
|
||||
AddEventHandler('QBCore:Client:OnPlayerUnload', function()
|
||||
isLoggedIn = false
|
||||
end)
|
||||
@@ -0,0 +1,31 @@
|
||||
QBConfig = {}
|
||||
|
||||
QBConfig.MaxPlayers = GetConvarInt('sv_maxclients', 64) -- Gets max players from config file, default 32
|
||||
QBConfig.IdentifierType = "steam" -- Set the identifier type (can be: steam, license)
|
||||
QBConfig.DefaultSpawn = {x=-1035.71,y=-2731.87,z=12.86,a=0.0}
|
||||
|
||||
QBConfig.Money = {}
|
||||
QBConfig.Money.MoneyTypes = {['cash'] = 500, ['bank'] = 5000, ['crypto'] = 0 } -- ['type']=startamount - Add or remove money types for your server (for ex. ['blackmoney']=0), remember once added it will not be removed from the database!
|
||||
QBConfig.Money.DontAllowMinus = {'cash', 'crypto'} -- Money that is not allowed going in minus
|
||||
|
||||
QBConfig.Player = {}
|
||||
QBConfig.Player.MaxWeight = 120000 -- Max weight a player can carry (currently 120kg, written in grams)
|
||||
QBConfig.Player.MaxInvSlots = 41 -- Max inventory slots for a player
|
||||
QBConfig.Player.Bloodtypes = {
|
||||
"A+",
|
||||
"A-",
|
||||
"B+",
|
||||
"B-",
|
||||
"AB+",
|
||||
"AB-",
|
||||
"O+",
|
||||
"O-",
|
||||
}
|
||||
|
||||
QBConfig.Server = {} -- General server config
|
||||
QBConfig.Server.closed = false -- Set server closed (no one can join except people with ace permission 'qbadmin.join')
|
||||
QBConfig.Server.closedReason = "We\'re still testing." -- Reason message to display when people can't join the server
|
||||
QBConfig.Server.uptime = 0 -- Time the server has been up.
|
||||
QBConfig.Server.whitelist = false -- Enable or disable whitelist on the server
|
||||
QBConfig.Server.discord = "https://discord.gg/Ttr6fY6" -- Discord invite link
|
||||
QBConfig.Server.PermissionList = {} -- permission list
|
||||
@@ -0,0 +1,44 @@
|
||||
body {
|
||||
background-color: transparent !important;
|
||||
}
|
||||
|
||||
.template, .notification {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.notif-container {
|
||||
width: 20vw;
|
||||
position: absolute;
|
||||
top: 4vh;
|
||||
right: 12vw;
|
||||
display: flex;
|
||||
flex-flow: row;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.notification {
|
||||
position: relative;
|
||||
padding: 1vh;
|
||||
width: fit-content;
|
||||
border-radius: .4vh;
|
||||
margin: 5px;
|
||||
font: caption;
|
||||
font-size: 1.2vh;
|
||||
font-weight: bold;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.success {
|
||||
background: #27ae60;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.primary {
|
||||
background-color: #2980b9;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.error {
|
||||
background: #c0392b;
|
||||
color: #fff;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
window.addEventListener('message', function (event) {
|
||||
switch(event.data.action) {
|
||||
case 'show':
|
||||
ShowNotif(event.data);
|
||||
break;
|
||||
default:
|
||||
ShowNotif(event.data);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
function ShowNotif(data) {
|
||||
var $notification = $('.notification.template').clone();
|
||||
$notification.removeClass('template');
|
||||
$notification.addClass(data.type);
|
||||
$notification.html(data.text);
|
||||
$notification.fadeIn();
|
||||
$('.notif-container').prepend($notification);
|
||||
setTimeout(function() {
|
||||
$.when($notification.fadeOut(1500)).done(function() {
|
||||
$notification.remove()
|
||||
});
|
||||
}, data.length != null ? data.length : 2500);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<html>
|
||||
<head>
|
||||
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
|
||||
<link href="css/main.css" rel="stylesheet" type="text/css"/>
|
||||
</head>
|
||||
<body>
|
||||
<div class="notif-container"></div>
|
||||
<div class="notification template"></div>
|
||||
</body>
|
||||
<script src="js/app.js" type="text/javascript"></script>
|
||||
</html>
|
||||
|
||||
<!-- ! -->
|
||||
@@ -0,0 +1,162 @@
|
||||
QBCore.Commands = {}
|
||||
QBCore.Commands.List = {}
|
||||
|
||||
QBCore.Commands.Add = function(name, help, arguments, argsrequired, callback, permission) -- [name] = command name (ex. /givemoney), [help] = help text, [arguments] = arguments that need to be passed (ex. {{name="id", help="ID of a player"}, {name="amount", help="amount of money"}}), [argsrequired] = set arguments required (true or false), [callback] = function(source, args) callback, [permission] = rank or job of a player
|
||||
QBCore.Commands.List[name:lower()] = {
|
||||
name = name:lower(),
|
||||
permission = permission ~= nil and permission:lower() or "user",
|
||||
help = help,
|
||||
arguments = arguments,
|
||||
argsrequired = argsrequired,
|
||||
callback = callback,
|
||||
}
|
||||
end
|
||||
|
||||
QBCore.Commands.Refresh = function(source)
|
||||
local Player = QBCore.Functions.GetPlayer(tonumber(source))
|
||||
if Player ~= nil then
|
||||
for command, info in pairs(QBCore.Commands.List) do
|
||||
if QBCore.Functions.HasPermission(source, "god") or QBCore.Functions.HasPermission(source, QBCore.Commands.List[command].permission) then
|
||||
TriggerClientEvent('chat:addSuggestion', source, "/"..command, info.help, info.arguments)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
QBCore.Commands.Add("tp", "Teleport to a player or location", {{name="id/x", help="ID of player or X position"}, {name="y", help="Y position"}, {name="z", help="Z position"}}, false, function(source, args)
|
||||
if (args[1] ~= nil and (args[2] == nil and args[3] == nil)) then
|
||||
-- tp to player
|
||||
local Player = QBCore.Functions.GetPlayer(tonumber(args[1]))
|
||||
if Player ~= nil then
|
||||
TriggerClientEvent('QBCore:Command:TeleportToPlayer', source, Player.PlayerData.source)
|
||||
else
|
||||
TriggerClientEvent('chatMessage', source, "SYSTEM", "error", "Player is not online!")
|
||||
end
|
||||
else
|
||||
-- tp to location
|
||||
if args[1] ~= nil and args[2] ~= nil and args[3] ~= nil then
|
||||
local x = tonumber(args[1])
|
||||
local y = tonumber(args[2])
|
||||
local z = tonumber(args[3])
|
||||
TriggerClientEvent('QBCore:Command:TeleportToCoords', source, x, y, z)
|
||||
else
|
||||
TriggerClientEvent('chatMessage', source, "SYSTEM", "error", "Not every argument has been entered (x, y, z)")
|
||||
end
|
||||
end
|
||||
end, "admin")
|
||||
|
||||
QBCore.Commands.Add("addpermission", "Grant permissions to someone (god/admin)", {{name="id", help="ID of player"}, {name="permission", help="Permission level"}}, true, function(source, args)
|
||||
local Player = QBCore.Functions.GetPlayer(tonumber(args[1]))
|
||||
local permission = tostring(args[2]):lower()
|
||||
if Player ~= nil then
|
||||
QBCore.Functions.AddPermission(Player.PlayerData.source, permission)
|
||||
else
|
||||
TriggerClientEvent('chatMessage', source, "SYSTEM", "error", "Player is not online!")
|
||||
end
|
||||
end, "god")
|
||||
|
||||
QBCore.Commands.Add("removepermission", "Remove permissions from someone", {{name="id", help="ID of player"}}, true, function(source, args)
|
||||
local Player = QBCore.Functions.GetPlayer(tonumber(args[1]))
|
||||
if Player ~= nil then
|
||||
QBCore.Functions.RemovePermission(Player.PlayerData.source)
|
||||
else
|
||||
TriggerClientEvent('chatMessage', source, "SYSTEM", "error", "Player is not online!")
|
||||
end
|
||||
end, "god")
|
||||
|
||||
QBCore.Commands.Add("sv", "Spawn a vehicle", {{name="model", help="Model name of the vehicle"}}, true, function(source, args)
|
||||
TriggerClientEvent('QBCore:Command:SpawnVehicle', source, args[1])
|
||||
end, "admin")
|
||||
|
||||
QBCore.Commands.Add("debug", "Turn debug mode on / off", {}, false, function(source, args)
|
||||
TriggerClientEvent('koil-debug:toggle', source)
|
||||
end, "admin")
|
||||
|
||||
QBCore.Commands.Add("dv", "Despawn a vehicle", {}, false, function(source, args)
|
||||
TriggerClientEvent('QBCore:Command:DeleteVehicle', source)
|
||||
end, "admin")
|
||||
|
||||
QBCore.Commands.Add("tpm", "Teleport to your waypoint", {}, false, function(source, args)
|
||||
TriggerClientEvent('QBCore:Command:GoToMarker', source)
|
||||
end, "admin")
|
||||
|
||||
QBCore.Commands.Add("givemoney", "Give money to a player", {{name="id", help="Player ID"},{name="moneytype", help="Type of money (cash, bank, crypto)"}, {name="amount", help="Amount of money"}}, true, function(source, args)
|
||||
local Player = QBCore.Functions.GetPlayer(tonumber(args[1]))
|
||||
if Player ~= nil then
|
||||
Player.Functions.AddMoney(tostring(args[2]), tonumber(args[3]))
|
||||
else
|
||||
TriggerClientEvent('chatMessage', source, "SYSTEM", "error", "Player is not online!")
|
||||
end
|
||||
end, "admin")
|
||||
|
||||
QBCore.Commands.Add("setmoney", "set a players money amount", {{name="id", help="Player ID"},{name="moneytype", help="Type of money (cash, bank, crypto)"}, {name="amount", help="Amount of money"}}, true, function(source, args)
|
||||
local Player = QBCore.Functions.GetPlayer(tonumber(args[1]))
|
||||
if Player ~= nil then
|
||||
Player.Functions.SetMoney(tostring(args[2]), tonumber(args[3]))
|
||||
else
|
||||
TriggerClientEvent('chatMessage', source, "SYSTEM", "error", "Player is not online!")
|
||||
end
|
||||
end, "admin")
|
||||
|
||||
QBCore.Commands.Add("setjob", "Assign a job to a player", {{name="id", help="Speler ID"}, {name="job", help="Job name"}}, true, function(source, args)
|
||||
local Player = QBCore.Functions.GetPlayer(tonumber(args[1]))
|
||||
if Player ~= nil then
|
||||
Player.Functions.SetJob(tostring(args[2]))
|
||||
else
|
||||
TriggerClientEvent('chatMessage', source, "SYSTEM", "error", "Player is not online!")
|
||||
end
|
||||
end, "admin")
|
||||
|
||||
QBCore.Commands.Add("job", "See what job you have", {}, false, function(source, args)
|
||||
local Player = QBCore.Functions.GetPlayer(source)
|
||||
TriggerClientEvent('chatMessage', source, "SYSTEM", "warning", "Job: "..Player.PlayerData.job.label)
|
||||
end)
|
||||
|
||||
QBCore.Commands.Add("setgang", "Assign a player to a gang", {{name="id", help="Player ID"}, {name="job", help="Name of a gang"}}, true, function(source, args)
|
||||
local Player = QBCore.Functions.GetPlayer(tonumber(args[1]))
|
||||
if Player ~= nil then
|
||||
Player.Functions.SetGang(tostring(args[2]))
|
||||
else
|
||||
TriggerClientEvent('chatMessage', source, "SYSTEM", "error", "Player is not online!")
|
||||
end
|
||||
end, "admin")
|
||||
|
||||
QBCore.Commands.Add("gang", "See what gang you're in", {}, false, function(source, args)
|
||||
local Player = QBCore.Functions.GetPlayer(source)
|
||||
|
||||
if Player.PlayerData.gang.name ~= "geen" then
|
||||
TriggerClientEvent('chatMessage', source, "SYSTEM", "warning", "Gang: "..Player.PlayerData.gang.label)
|
||||
else
|
||||
TriggerClientEvent('QBCore:Notify', source, "You're not in a gang!", "error")
|
||||
end
|
||||
end)
|
||||
|
||||
QBCore.Commands.Add("testnotify", "test notify", {{name="text", help="Tekst enzo"}}, true, function(source, args)
|
||||
TriggerClientEvent('QBCore:Notify', source, table.concat(args, " "), "success")
|
||||
end, "god")
|
||||
|
||||
QBCore.Commands.Add("clearinv", "Clear the inventory of a player", {{name="id", help="Player ID"}}, false, function(source, args)
|
||||
local playerId = args[1] ~= nil and args[1] or source
|
||||
local Player = QBCore.Functions.GetPlayer(tonumber(playerId))
|
||||
if Player ~= nil then
|
||||
Player.Functions.ClearInventory()
|
||||
else
|
||||
TriggerClientEvent('chatMessage', source, "SYSTEM", "error", "Player is not online!")
|
||||
end
|
||||
end, "admin")
|
||||
|
||||
QBCore.Commands.Add("ooc", "Out of Character message", {}, false, function(source, args)
|
||||
local message = table.concat(args, " ")
|
||||
TriggerClientEvent("QBCore:Client:LocalOutOfCharacter", -1, source, GetPlayerName(source), message)
|
||||
local Players = QBCore.Functions.GetPlayers()
|
||||
local Player = QBCore.Functions.GetPlayer(source)
|
||||
|
||||
for k, v in pairs(QBCore.Functions.GetPlayers()) do
|
||||
if QBCore.Functions.HasPermission(v, "admin") then
|
||||
if QBCore.Functions.IsOptin(v) then
|
||||
TriggerClientEvent('chatMessage', v, "OOC " .. GetPlayerName(source), "normal", message)
|
||||
TriggerEvent("qb-log:server:CreateLog", "ooc", "OOC", "white", "**"..GetPlayerName(source).."** (CitizenID: "..Player.PlayerData.citizenid.." | ID: "..source..") **Message:** " ..message, false)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -0,0 +1,36 @@
|
||||
RegisterServerEvent('QBCore:DebugSomething')
|
||||
AddEventHandler('QBCore:DebugSomething', function(resource, obj, depth)
|
||||
print("\x1b[4m\x1b[36m["..resource..":DEBUG]\x1b[0m")
|
||||
if type(obj) == "string" then
|
||||
print(string.format("%q", obj))
|
||||
elseif type(obj) == "table" then
|
||||
local str = "{"
|
||||
for k, v in pairs(obj) do
|
||||
if type(v) == "table" then
|
||||
for ik, iv in pairs(v) do
|
||||
str = str.."\n["..k.."] -> ["..ik.."] -> "..tostring(iv)
|
||||
end
|
||||
else
|
||||
str = str.."\n["..k.."] -> "..tostring(v)
|
||||
end
|
||||
end
|
||||
|
||||
print(str.."\n}")
|
||||
else
|
||||
local success, value = pcall(function() return tostring(obj) end)
|
||||
print((success and value or "<!!error in __tostring metamethod!!>"))
|
||||
end
|
||||
print("\x1b[4m\x1b[36mEND OF DEBUG\x1b[0m")
|
||||
end)
|
||||
|
||||
QBCore.Debug = function(resource, obj, depth)
|
||||
TriggerEvent('QBCore:DebugSomething', resource, obj, depth)
|
||||
end
|
||||
|
||||
QBCore.ShowError = function(resource, msg)
|
||||
print("\x1b[31m["..resource..":ERROR]\x1b[0m "..msg)
|
||||
end
|
||||
|
||||
QBCore.ShowSuccess = function(resource, msg)
|
||||
print("\x1b[32m["..resource..":LOG]\x1b[0m "..msg)
|
||||
end
|
||||
@@ -0,0 +1,290 @@
|
||||
-- Player joined
|
||||
RegisterServerEvent("QBCore:PlayerJoined")
|
||||
AddEventHandler('QBCore:PlayerJoined', function()
|
||||
local src = source
|
||||
end)
|
||||
|
||||
AddEventHandler('playerDropped', function(reason)
|
||||
local src = source
|
||||
print("Dropped: "..GetPlayerName(src))
|
||||
TriggerEvent("qb-log:server:CreateLog", "joinleave", "Dropped", "red", "**".. GetPlayerName(src) .. "** ("..GetPlayerIdentifiers(src)[1]..") left..")
|
||||
TriggerEvent("qb-log:server:sendLog", GetPlayerIdentifiers(src)[1], "joined", {})
|
||||
if reason ~= "Reconnecting" and src > 60000 then return false end
|
||||
if(src==nil or (QBCore.Players[src] == nil)) then return false end
|
||||
QBCore.Players[src].Functions.Save()
|
||||
QBCore.Players[src] = nil
|
||||
end)
|
||||
|
||||
-- Checking everything before joining
|
||||
AddEventHandler('playerConnecting', function(playerName, setKickReason, deferrals)
|
||||
deferrals.defer()
|
||||
local src = source
|
||||
deferrals.update("\nChecking name...")
|
||||
local name = GetPlayerName(src)
|
||||
if name == nil then
|
||||
QBCore.Functions.Kick(src, 'Please don\'t use a blank Steam username.', setKickReason, deferrals)
|
||||
CancelEvent()
|
||||
return false
|
||||
end
|
||||
if(string.match(name, "[*%%'=`\"]")) then
|
||||
QBCore.Functions.Kick(src, 'You have a character in your username ('..string.match(name, "[*%%'=`\"]")..') that is not allowed.\nPlease remove this out of your Steam username.', setKickReason, deferrals)
|
||||
CancelEvent()
|
||||
return false
|
||||
end
|
||||
if (string.match(name, "drop") or string.match(name, "table") or string.match(name, "database")) then
|
||||
QBCore.Functions.Kick(src, 'Your username contains a word (drop/table/database) that is not allowed.\nPlease change your Steam username.', setKickReason, deferrals)
|
||||
CancelEvent()
|
||||
return false
|
||||
end
|
||||
deferrals.update("\nChecking identifiers...")
|
||||
local identifiers = GetPlayerIdentifiers(src)
|
||||
local steamid = identifiers[1]
|
||||
local license = identifiers[2]
|
||||
if (QBConfig.IdentifierType == "steam" and (steamid:sub(1,6) == "steam:") == false) then
|
||||
QBCore.Functions.Kick(src, 'You need to open Steam to play.', setKickReason, deferrals)
|
||||
CancelEvent()
|
||||
return false
|
||||
elseif (QBConfig.IdentifierType == "license" and (steamid:sub(1,6) == "license:") == false) then
|
||||
QBCore.Functions.Kick(src, 'No Social Club license found.', setKickReason, deferrals)
|
||||
CancelEvent()
|
||||
return false
|
||||
end
|
||||
deferrals.update("\nChecking ban status...")
|
||||
local isBanned, Reason = QBCore.Functions.IsPlayerBanned(src)
|
||||
if(isBanned) then
|
||||
QBCore.Functions.Kick(src, Reason, setKickReason, deferrals)
|
||||
CancelEvent()
|
||||
return false
|
||||
end
|
||||
deferrals.update("\nChecking whitelist status...")
|
||||
if(not QBCore.Functions.IsWhitelisted(src)) then
|
||||
QBCore.Functions.Kick(src, 'You aren\'t whitelisted.', setKickReason, deferrals)
|
||||
CancelEvent()
|
||||
return false
|
||||
end
|
||||
deferrals.update("\nChecking server status...")
|
||||
if(QBCore.Config.Server.closed and not IsPlayerAceAllowed(src, "qbadmin.join")) then
|
||||
QBCore.Functions.Kick(_source, 'the server is closed:\n'..QBCore.Config.Server.closedReason, setKickReason, deferrals)
|
||||
CancelEvent()
|
||||
return false
|
||||
end
|
||||
TriggerEvent("qb-log:server:CreateLog", "joinleave", "Queue", "orange", "**"..name .. "** ("..json.encode(GetPlayerIdentifiers(src))..") in queue..")
|
||||
TriggerEvent("qb-log:server:sendLog", GetPlayerIdentifiers(src)[1], "left", {})
|
||||
TriggerEvent("connectqueue:playerConnect", src, setKickReason, deferrals)
|
||||
end)
|
||||
|
||||
RegisterServerEvent("QBCore:server:CloseServer")
|
||||
AddEventHandler('QBCore:server:CloseServer', function(reason)
|
||||
local src = source
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
|
||||
if QBCore.Functions.HasPermission(source, "admin") or QBCore.Functions.HasPermission(source, "god") then
|
||||
local reason = reason ~= nil and reason or "No reason specified..."
|
||||
QBCore.Config.Server.closed = true
|
||||
QBCore.Config.Server.closedReason = reason
|
||||
TriggerClientEvent("qbadmin:client:SetServerStatus", -1, true)
|
||||
else
|
||||
QBCore.Functions.Kick(src, "You don't have permissions for this..", nil, nil)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent("QBCore:server:OpenServer")
|
||||
AddEventHandler('QBCore:server:OpenServer', function()
|
||||
local src = source
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
if QBCore.Functions.HasPermission(source, "admin") or QBCore.Functions.HasPermission(source, "god") then
|
||||
QBCore.Config.Server.closed = false
|
||||
TriggerClientEvent("qbadmin:client:SetServerStatus", -1, false)
|
||||
else
|
||||
QBCore.Functions.Kick(src, "You don't have permissions for this..", nil, nil)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent("QBCore:UpdatePlayer")
|
||||
AddEventHandler('QBCore:UpdatePlayer', function(data)
|
||||
local src = source
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
|
||||
if Player ~= nil then
|
||||
Player.PlayerData.position = data.position
|
||||
|
||||
local newHunger = Player.PlayerData.metadata["hunger"] - 4.2
|
||||
local newThirst = Player.PlayerData.metadata["thirst"] - 3.8
|
||||
if newHunger <= 0 then newHunger = 0 end
|
||||
if newThirst <= 0 then newThirst = 0 end
|
||||
Player.Functions.SetMetaData("thirst", newThirst)
|
||||
Player.Functions.SetMetaData("hunger", newHunger)
|
||||
|
||||
Player.Functions.AddMoney("bank", Player.PlayerData.job.payment)
|
||||
TriggerClientEvent('QBCore:Notify', src, "You received your paycheck of €"..Player.PlayerData.job.payment)
|
||||
TriggerClientEvent("hud:client:UpdateNeeds", src, newHunger, newThirst)
|
||||
|
||||
Player.Functions.Save()
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent("QBCore:UpdatePlayerPosition")
|
||||
AddEventHandler("QBCore:UpdatePlayerPosition", function(position)
|
||||
local src = source
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
if Player ~= nil then
|
||||
Player.PlayerData.position = position
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent("QBCore:Server:TriggerCallback")
|
||||
AddEventHandler('QBCore:Server:TriggerCallback', function(name, ...)
|
||||
local src = source
|
||||
QBCore.Functions.TriggerCallback(name, src, function(...)
|
||||
TriggerClientEvent("QBCore:Client:TriggerCallback", src, name, ...)
|
||||
end, ...)
|
||||
end)
|
||||
|
||||
RegisterServerEvent("QBCore:Server:UseItem")
|
||||
AddEventHandler('QBCore:Server:UseItem', function(item)
|
||||
local src = source
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
if item ~= nil and item.amount > 0 then
|
||||
if QBCore.Functions.CanUseItem(item.name) then
|
||||
QBCore.Functions.UseItem(src, item)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent("QBCore:Server:RemoveItem")
|
||||
AddEventHandler('QBCore:Server:RemoveItem', function(itemName, amount, slot)
|
||||
local src = source
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
Player.Functions.RemoveItem(itemName, amount, slot)
|
||||
end)
|
||||
|
||||
RegisterServerEvent("QBCore:Server:AddItem")
|
||||
AddEventHandler('QBCore:Server:AddItem', function(itemName, amount, slot, info)
|
||||
local src = source
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
Player.Functions.AddItem(itemName, amount, slot, info)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('QBCore:Server:SetMetaData')
|
||||
AddEventHandler('QBCore:Server:SetMetaData', function(meta, data)
|
||||
local src = source
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
if meta == "hunger" or meta == "thirst" then
|
||||
if data > 100 then
|
||||
data = 100
|
||||
end
|
||||
end
|
||||
if Player ~= nil then
|
||||
Player.Functions.SetMetaData(meta, data)
|
||||
end
|
||||
TriggerClientEvent("hud:client:UpdateNeeds", src, Player.PlayerData.metadata["hunger"], Player.PlayerData.metadata["thirst"])
|
||||
end)
|
||||
|
||||
AddEventHandler('chatMessage', function(source, n, message)
|
||||
if string.sub(message, 1, 1) == "/" then
|
||||
local args = QBCore.Shared.SplitStr(message, " ")
|
||||
local command = string.gsub(args[1]:lower(), "/", "")
|
||||
CancelEvent()
|
||||
if QBCore.Commands.List[command] ~= nil then
|
||||
local Player = QBCore.Functions.GetPlayer(tonumber(source))
|
||||
if Player ~= nil then
|
||||
table.remove(args, 1)
|
||||
if (QBCore.Functions.HasPermission(source, "god") or QBCore.Functions.HasPermission(source, QBCore.Commands.List[command].permission)) then
|
||||
if (QBCore.Commands.List[command].argsrequired and #QBCore.Commands.List[command].arguments ~= 0 and args[#QBCore.Commands.List[command].arguments] == nil) then
|
||||
TriggerClientEvent('chatMessage', source, "SYSTEM", "error", "All arguments must be filled out!")
|
||||
local agus = ""
|
||||
for name, help in pairs(QBCore.Commands.List[command].arguments) do
|
||||
agus = agus .. " ["..help.name.."]"
|
||||
end
|
||||
TriggerClientEvent('chatMessage', source, "/"..command, false, agus)
|
||||
else
|
||||
QBCore.Commands.List[command].callback(source, args)
|
||||
end
|
||||
else
|
||||
TriggerClientEvent('chatMessage', source, "SYSTEM", "error", "No access to this command!")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent('QBCore:CallCommand')
|
||||
AddEventHandler('QBCore:CallCommand', function(command, args)
|
||||
if QBCore.Commands.List[command] ~= nil then
|
||||
local Player = QBCore.Functions.GetPlayer(tonumber(source))
|
||||
if Player ~= nil then
|
||||
if (QBCore.Functions.HasPermission(source, "god")) or (QBCore.Functions.HasPermission(source, QBCore.Commands.List[command].permission)) or (QBCore.Commands.List[command].permission == Player.PlayerData.job.name) then
|
||||
if (QBCore.Commands.List[command].argsrequired and #QBCore.Commands.List[command].arguments ~= 0 and args[#QBCore.Commands.List[command].arguments] == nil) then
|
||||
TriggerClientEvent('chatMessage', source, "SYSTEM", "error", "All arguments must be filled out!")
|
||||
local agus = ""
|
||||
for name, help in pairs(QBCore.Commands.List[command].arguments) do
|
||||
agus = agus .. " ["..help.name.."]"
|
||||
end
|
||||
TriggerClientEvent('chatMessage', source, "/"..command, false, agus)
|
||||
else
|
||||
QBCore.Commands.List[command].callback(source, args)
|
||||
end
|
||||
else
|
||||
TriggerClientEvent('chatMessage', source, "SYSTEM", "error", "No access to this command!")
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterServerEvent("QBCore:AddCommand")
|
||||
AddEventHandler('QBCore:AddCommand', function(name, help, arguments, argsrequired, callback, persmission)
|
||||
QBCore.Commands.Add(name, help, arguments, argsrequired, callback, persmission)
|
||||
end)
|
||||
|
||||
RegisterServerEvent("QBCore:ToggleDuty")
|
||||
AddEventHandler('QBCore:ToggleDuty', function()
|
||||
local src = source
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
if Player.PlayerData.job.onduty then
|
||||
Player.Functions.SetJobDuty(false)
|
||||
TriggerClientEvent('QBCore:Notify', src, "You are now off duty!")
|
||||
else
|
||||
Player.Functions.SetJobDuty(true)
|
||||
TriggerClientEvent('QBCore:Notify', src, "You are now on duty!")
|
||||
end
|
||||
TriggerClientEvent("QBCore:Client:SetDuty", src, Player.PlayerData.job.onduty)
|
||||
end)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
QBCore.Functions.ExecuteSql(true, "SELECT * FROM `permissions`", function(result)
|
||||
if result[1] ~= nil then
|
||||
for k, v in pairs(result) do
|
||||
QBCore.Config.Server.PermissionList[v.steam] = {
|
||||
steam = v.steam,
|
||||
license = v.license,
|
||||
permission = v.permission,
|
||||
optin = true,
|
||||
}
|
||||
end
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
QBCore.Functions.CreateCallback('QBCore:HasItem', function(source, cb, itemName)
|
||||
local retval = false
|
||||
local Player = QBCore.Functions.GetPlayer(source)
|
||||
if Player ~= nil then
|
||||
if Player.Functions.GetItemByName(itemName) ~= nil then
|
||||
retval = true
|
||||
end
|
||||
end
|
||||
|
||||
cb(retval)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('QBCore:Command:CheckOwnedVehicle')
|
||||
AddEventHandler('QBCore:Command:CheckOwnedVehicle', function(VehiclePlate)
|
||||
if VehiclePlate ~= nil then
|
||||
QBCore.Functions.ExecuteSql(false, "SELECT * FROM `player_vehicles` WHERE `plate` = '"..VehiclePlate.."'", function(result)
|
||||
if result[1] ~= nil then
|
||||
QBCore.Functions.ExecuteSql(false, "UPDATE `player_vehicles` SET `state` = '1' WHERE `citizenid` = '"..result[1].citizenid.."'")
|
||||
TriggerEvent('qb-garages:server:RemoveVehicle', result[1].citizenid, VehiclePlate)
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
@@ -0,0 +1,247 @@
|
||||
QBCore.Functions = {}
|
||||
|
||||
QBCore.Functions.ExecuteSql = function(wait, query, cb)
|
||||
local rtndata = {}
|
||||
local waiting = true
|
||||
exports['ghmattimysql']:execute(query, {}, function(data)
|
||||
if cb ~= nil and wait == false then
|
||||
cb(data)
|
||||
end
|
||||
rtndata = data
|
||||
waiting = false
|
||||
end)
|
||||
if wait then
|
||||
while waiting do
|
||||
Citizen.Wait(5)
|
||||
end
|
||||
if cb ~= nil and wait == true then
|
||||
cb(rtndata)
|
||||
end
|
||||
end
|
||||
return rtndata
|
||||
end
|
||||
|
||||
QBCore.Functions.GetIdentifier = function(source, idtype)
|
||||
local idtype = idtype ~=nil and idtype or QBConfig.IdentifierType
|
||||
for _, identifier in pairs(GetPlayerIdentifiers(source)) do
|
||||
if string.find(identifier, idtype) then
|
||||
return identifier
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
QBCore.Functions.GetSource = function(identifier)
|
||||
for src, player in pairs(QBCore.Players) do
|
||||
local idens = GetPlayerIdentifiers(src)
|
||||
for _, id in pairs(idens) do
|
||||
if identifier == id then
|
||||
return src
|
||||
end
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
QBCore.Functions.GetPlayer = function(source)
|
||||
if type(source) == "number" then
|
||||
return QBCore.Players[source]
|
||||
else
|
||||
return QBCore.Players[QBCore.Functions.GetSource(source)]
|
||||
end
|
||||
end
|
||||
|
||||
QBCore.Functions.GetPlayerByCitizenId = function(citizenid)
|
||||
for src, player in pairs(QBCore.Players) do
|
||||
local cid = citizenid
|
||||
if QBCore.Players[src].PlayerData.citizenid == cid then
|
||||
return QBCore.Players[src]
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
QBCore.Functions.GetPlayerByPhone = function(number)
|
||||
for src, player in pairs(QBCore.Players) do
|
||||
local cid = citizenid
|
||||
if QBCore.Players[src].PlayerData.charinfo.phone == number then
|
||||
return QBCore.Players[src]
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
QBCore.Functions.GetPlayers = function()
|
||||
local sources = {}
|
||||
for k, v in pairs(QBCore.Players) do
|
||||
table.insert(sources, k)
|
||||
end
|
||||
return sources
|
||||
end
|
||||
|
||||
QBCore.Functions.CreateCallback = function(name, cb)
|
||||
QBCore.ServerCallbacks[name] = cb
|
||||
end
|
||||
|
||||
QBCore.Functions.TriggerCallback = function(name, source, cb, ...)
|
||||
if QBCore.ServerCallbacks[name] ~= nil then
|
||||
QBCore.ServerCallbacks[name](source, cb, ...)
|
||||
end
|
||||
end
|
||||
|
||||
QBCore.Functions.CreateUseableItem = function(item, cb)
|
||||
QBCore.UseableItems[item] = cb
|
||||
end
|
||||
|
||||
QBCore.Functions.CanUseItem = function(item)
|
||||
return QBCore.UseableItems[item] ~= nil
|
||||
end
|
||||
|
||||
QBCore.Functions.UseItem = function(source, item)
|
||||
QBCore.UseableItems[item.name](source, item)
|
||||
end
|
||||
|
||||
QBCore.Functions.Kick = function(source, reason, setKickReason, deferrals)
|
||||
local src = source
|
||||
reason = "\n"..reason.."\n🔸 Check our Discord for further information: "..QBCore.Config.Server.discord
|
||||
if(setKickReason ~=nil) then
|
||||
setKickReason(reason)
|
||||
end
|
||||
Citizen.CreateThread(function()
|
||||
if(deferrals ~= nil)then
|
||||
deferrals.update(reason)
|
||||
Citizen.Wait(2500)
|
||||
end
|
||||
if src ~= nil then
|
||||
DropPlayer(src, reason)
|
||||
end
|
||||
local i = 0
|
||||
while (i <= 4) do
|
||||
i = i + 1
|
||||
while true do
|
||||
if src ~= nil then
|
||||
if(GetPlayerPing(src) >= 0) then
|
||||
break
|
||||
end
|
||||
Citizen.Wait(100)
|
||||
Citizen.CreateThread(function()
|
||||
DropPlayer(src, reason)
|
||||
end)
|
||||
end
|
||||
end
|
||||
Citizen.Wait(5000)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
QBCore.Functions.IsWhitelisted = function(source)
|
||||
local identifiers = GetPlayerIdentifiers(source)
|
||||
local rtn = false
|
||||
if (QBCore.Config.Server.whitelist) then
|
||||
QBCore.Functions.ExecuteSql(true, "SELECT * FROM `whitelist` WHERE `"..QBCore.Config.IdentifierType.."` = '".. QBCore.Functions.GetIdentifier(source).."'", function(result)
|
||||
local data = result[1]
|
||||
if data ~= nil then
|
||||
for _, id in pairs(identifiers) do
|
||||
if data.steam == id or data.license == id then
|
||||
rtn = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
else
|
||||
rtn = true
|
||||
end
|
||||
return rtn
|
||||
end
|
||||
|
||||
QBCore.Functions.AddPermission = function(source, permission)
|
||||
local Player = QBCore.Functions.GetPlayer(source)
|
||||
if Player ~= nil then
|
||||
QBCore.Config.Server.PermissionList[GetPlayerIdentifiers(source)[1]] = {
|
||||
steam = GetPlayerIdentifiers(source)[1],
|
||||
license = GetPlayerIdentifiers(source)[2],
|
||||
permission = permission:lower(),
|
||||
}
|
||||
QBCore.Functions.ExecuteSql(true, "DELETE FROM `permissions` WHERE `steam` = '"..GetPlayerIdentifiers(source)[1].."'")
|
||||
QBCore.Functions.ExecuteSql(true, "INSERT INTO `permissions` (`name`, `steam`, `license`, `permission`) VALUES ('"..GetPlayerName(source).."', '"..GetPlayerIdentifiers(source)[1].."', '"..GetPlayerIdentifiers(source)[2].."', '"..permission:lower().."')")
|
||||
Player.Functions.UpdatePlayerData()
|
||||
TriggerClientEvent('QBCore:Client:OnPermissionUpdate', source, permission)
|
||||
end
|
||||
end
|
||||
|
||||
QBCore.Functions.RemovePermission = function(source)
|
||||
local Player = QBCore.Functions.GetPlayer(source)
|
||||
if Player ~= nil then
|
||||
QBCore.Config.Server.PermissionList[GetPlayerIdentifiers(source)[1]] = nil
|
||||
QBCore.Functions.ExecuteSql(true, "DELETE FROM `permissions` WHERE `steam` = '"..GetPlayerIdentifiers(source)[1].."'")
|
||||
Player.Functions.UpdatePlayerData()
|
||||
end
|
||||
end
|
||||
|
||||
QBCore.Functions.HasPermission = function(source, permission)
|
||||
local retval = false
|
||||
local steamid = GetPlayerIdentifiers(source)[1]
|
||||
local licenseid = GetPlayerIdentifiers(source)[2]
|
||||
local permission = tostring(permission:lower())
|
||||
if permission == "user" then
|
||||
retval = true
|
||||
else
|
||||
if QBCore.Config.Server.PermissionList[steamid] ~= nil then
|
||||
if QBCore.Config.Server.PermissionList[steamid].steam == steamid and QBCore.Config.Server.PermissionList[steamid].license == licenseid then
|
||||
if QBCore.Config.Server.PermissionList[steamid].permission == permission or QBCore.Config.Server.PermissionList[steamid].permission == "god" then
|
||||
retval = true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return retval
|
||||
end
|
||||
|
||||
QBCore.Functions.GetPermission = function(source)
|
||||
local retval = "user"
|
||||
Player = QBCore.Functions.GetPlayer(source)
|
||||
local steamid = GetPlayerIdentifiers(source)[1]
|
||||
local licenseid = GetPlayerIdentifiers(source)[2]
|
||||
if Player ~= nil then
|
||||
if QBCore.Config.Server.PermissionList[Player.PlayerData.steam] ~= nil then
|
||||
if QBCore.Config.Server.PermissionList[Player.PlayerData.steam].steam == steamid and QBCore.Config.Server.PermissionList[Player.PlayerData.steam].license == licenseid then
|
||||
retval = QBCore.Config.Server.PermissionList[Player.PlayerData.steam].permission
|
||||
end
|
||||
end
|
||||
end
|
||||
return retval
|
||||
end
|
||||
|
||||
QBCore.Functions.IsOptin = function(source)
|
||||
local retval = false
|
||||
local steamid = GetPlayerIdentifiers(source)[1]
|
||||
if QBCore.Functions.HasPermission(source, "admin") then
|
||||
retval = QBCore.Config.Server.PermissionList[steamid].optin
|
||||
end
|
||||
return retval
|
||||
end
|
||||
|
||||
QBCore.Functions.ToggleOptin = function(source)
|
||||
local steamid = GetPlayerIdentifiers(source)[1]
|
||||
if QBCore.Functions.HasPermission(source, "admin") then
|
||||
QBCore.Config.Server.PermissionList[steamid].optin = not QBCore.Config.Server.PermissionList[steamid].optin
|
||||
end
|
||||
end
|
||||
|
||||
QBCore.Functions.IsPlayerBanned = function (source)
|
||||
local retval = false
|
||||
local message = ""
|
||||
QBCore.Functions.ExecuteSql(true, "SELECT * FROM `bans` WHERE `steam` = '"..GetPlayerIdentifiers(source)[1].."' OR `license` = '"..GetPlayerIdentifiers(source)[2].."' OR `ip` = '"..GetPlayerIdentifiers(source)[3].."'", function(result)
|
||||
if result[1] ~= nil then
|
||||
if os.time() < result[1].expire then
|
||||
retval = true
|
||||
local timeTable = os.date("*t", tonumber(result[1].expire))
|
||||
message = "You have been banned from the server:\n"..result[1].reason.."\nJe ban verloopt "..timeTable.day.. "/" .. timeTable.month .. "/" .. timeTable.year .. " " .. timeTable.hour.. ":" .. timeTable.min .. "\n"
|
||||
else
|
||||
QBCore.Functions.ExecuteSql(true, "DELETE FROM `bans` WHERE `id` = "..result[1].id)
|
||||
end
|
||||
end
|
||||
end)
|
||||
return retval, message
|
||||
end
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
QBCore = {}
|
||||
QBCore.Config = QBConfig
|
||||
QBCore.Shared = QBShared
|
||||
QBCore.ServerCallbacks = {}
|
||||
QBCore.UseableItems = {}
|
||||
|
||||
function GetCoreObject()
|
||||
return QBCore
|
||||
end
|
||||
|
||||
RegisterServerEvent('QBCore:GetObject')
|
||||
AddEventHandler('QBCore:GetObject', function(cb)
|
||||
cb(GetCoreObject())
|
||||
end)
|
||||
@@ -0,0 +1,561 @@
|
||||
QBCore.Players = {}
|
||||
QBCore.Player = {}
|
||||
|
||||
QBCore.Player.Login = function(source, citizenid, newData)
|
||||
if source ~= nil then
|
||||
if citizenid then
|
||||
QBCore.Functions.ExecuteSql(true, "SELECT * FROM `players` WHERE `citizenid` = '"..citizenid.."'", function(result)
|
||||
local PlayerData = result[1]
|
||||
if PlayerData ~= nil then
|
||||
PlayerData.money = json.decode(PlayerData.money)
|
||||
PlayerData.job = json.decode(PlayerData.job)
|
||||
PlayerData.position = json.decode(PlayerData.position)
|
||||
PlayerData.metadata = json.decode(PlayerData.metadata)
|
||||
PlayerData.charinfo = json.decode(PlayerData.charinfo)
|
||||
if PlayerData.gang ~= nil then
|
||||
PlayerData.gang = json.decode(PlayerData.gang)
|
||||
else
|
||||
PlayerData.gang = {}
|
||||
end
|
||||
end
|
||||
QBCore.Player.CheckPlayerData(source, PlayerData)
|
||||
end)
|
||||
else
|
||||
QBCore.Player.CheckPlayerData(source, newData)
|
||||
end
|
||||
return true
|
||||
else
|
||||
QBCore.ShowError(GetCurrentResourceName(), "ERROR QBCORE.PLAYER.LOGIN - NO SOURCE GIVEN!")
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
QBCore.Player.CheckPlayerData = function(source, PlayerData)
|
||||
PlayerData = PlayerData ~= nil and PlayerData or {}
|
||||
|
||||
PlayerData.source = source
|
||||
PlayerData.citizenid = PlayerData.citizenid ~= nil and PlayerData.citizenid or QBCore.Player.CreateCitizenId()
|
||||
PlayerData.steam = PlayerData.steam ~= nil and PlayerData.steam or QBCore.Functions.GetIdentifier(source, "steam")
|
||||
PlayerData.license = PlayerData.license ~= nil and PlayerData.license or QBCore.Functions.GetIdentifier(source, "license")
|
||||
PlayerData.name = GetPlayerName(source)
|
||||
PlayerData.cid = PlayerData.cid ~= nil and PlayerData.cid or 1
|
||||
|
||||
PlayerData.money = PlayerData.money ~= nil and PlayerData.money or {}
|
||||
for moneytype, startamount in pairs(QBCore.Config.Money.MoneyTypes) do
|
||||
PlayerData.money[moneytype] = PlayerData.money[moneytype] ~= nil and PlayerData.money[moneytype] or startamount
|
||||
end
|
||||
|
||||
PlayerData.charinfo = PlayerData.charinfo ~= nil and PlayerData.charinfo or {}
|
||||
PlayerData.charinfo.firstname = PlayerData.charinfo.firstname ~= nil and PlayerData.charinfo.firstname or "Firstname"
|
||||
PlayerData.charinfo.lastname = PlayerData.charinfo.lastname ~= nil and PlayerData.charinfo.lastname or "Lastname"
|
||||
PlayerData.charinfo.birthdate = PlayerData.charinfo.birthdate ~= nil and PlayerData.charinfo.birthdate or "00-00-0000"
|
||||
PlayerData.charinfo.gender = PlayerData.charinfo.gender ~= nil and PlayerData.charinfo.gender or 0
|
||||
PlayerData.charinfo.backstory = PlayerData.charinfo.backstory ~= nil and PlayerData.charinfo.backstory or "placeholder backstory"
|
||||
PlayerData.charinfo.nationality = PlayerData.charinfo.nationality ~= nil and PlayerData.charinfo.nationality or "Dutch"
|
||||
PlayerData.charinfo.phone = PlayerData.charinfo.phone ~= nil and PlayerData.charinfo.phone or "06"..math.random(11111111, 99999999)
|
||||
PlayerData.charinfo.account = PlayerData.charinfo.account ~= nil and PlayerData.charinfo.account or "NL0"..math.random(1,9).."QBUS"..math.random(1111,9999)..math.random(1111,9999)..math.random(11,99)
|
||||
|
||||
PlayerData.metadata = PlayerData.metadata ~= nil and PlayerData.metadata or {}
|
||||
PlayerData.metadata["hunger"] = PlayerData.metadata["hunger"] ~= nil and PlayerData.metadata["hunger"] or 100
|
||||
PlayerData.metadata["thirst"] = PlayerData.metadata["thirst"] ~= nil and PlayerData.metadata["thirst"] or 100
|
||||
PlayerData.metadata["stress"] = PlayerData.metadata["stress"] ~= nil and PlayerData.metadata["stress"] or 0
|
||||
PlayerData.metadata["isdead"] = PlayerData.metadata["isdead"] ~= nil and PlayerData.metadata["isdead"] or false
|
||||
PlayerData.metadata["inlaststand"] = PlayerData.metadata["inlaststand"] ~= nil and PlayerData.metadata["inlaststand"] or false
|
||||
PlayerData.metadata["armor"] = PlayerData.metadata["armor"] ~= nil and PlayerData.metadata["armor"] or 0
|
||||
PlayerData.metadata["ishandcuffed"] = PlayerData.metadata["ishandcuffed"] ~= nil and PlayerData.metadata["ishandcuffed"] or false
|
||||
PlayerData.metadata["tracker"] = PlayerData.metadata["tracker"] ~= nil and PlayerData.metadata["tracker"] or false
|
||||
PlayerData.metadata["injail"] = PlayerData.metadata["injail"] ~= nil and PlayerData.metadata["injail"] or 0
|
||||
PlayerData.metadata["jailitems"] = PlayerData.metadata["jailitems"] ~= nil and PlayerData.metadata["jailitems"] or {}
|
||||
PlayerData.metadata["status"] = PlayerData.metadata["status"] ~= nil and PlayerData.metadata["status"] or {}
|
||||
PlayerData.metadata["phone"] = PlayerData.metadata["phone"] ~= nil and PlayerData.metadata["phone"] or {}
|
||||
PlayerData.metadata["fitbit"] = PlayerData.metadata["fitbit"] ~= nil and PlayerData.metadata["fitbit"] or {}
|
||||
PlayerData.metadata["commandbinds"] = PlayerData.metadata["commandbinds"] ~= nil and PlayerData.metadata["commandbinds"] or {}
|
||||
PlayerData.metadata["bloodtype"] = PlayerData.metadata["bloodtype"] ~= nil and PlayerData.metadata["bloodtype"] or QBCore.Config.Player.Bloodtypes[math.random(1, #QBCore.Config.Player.Bloodtypes)]
|
||||
PlayerData.metadata["dealerrep"] = PlayerData.metadata["dealerrep"] ~= nil and PlayerData.metadata["dealerrep"] or 0
|
||||
PlayerData.metadata["craftingrep"] = PlayerData.metadata["craftingrep"] ~= nil and PlayerData.metadata["craftingrep"] or 0
|
||||
PlayerData.metadata["attachmentcraftingrep"] = PlayerData.metadata["attachmentcraftingrep"] ~= nil and PlayerData.metadata["attachmentcraftingrep"] or 0
|
||||
PlayerData.metadata["currentapartment"] = PlayerData.metadata["currentapartment"] ~= nil and PlayerData.metadata["currentapartment"] or nil
|
||||
PlayerData.metadata["jobrep"] = PlayerData.metadata["jobrep"] ~= nil and PlayerData.metadata["jobrep"] or {
|
||||
["tow"] = 0,
|
||||
["trucker"] = 0,
|
||||
["taxi"] = 0,
|
||||
["hotdog"] = 0,
|
||||
}
|
||||
PlayerData.metadata["callsign"] = PlayerData.metadata["callsign"] ~= nil and PlayerData.metadata["callsign"] or "NO CALLSIGN"
|
||||
PlayerData.metadata["fingerprint"] = PlayerData.metadata["fingerprint"] ~= nil and PlayerData.metadata["fingerprint"] or QBCore.Player.CreateFingerId()
|
||||
PlayerData.metadata["walletid"] = PlayerData.metadata["walletid"] ~= nil and PlayerData.metadata["walletid"] or QBCore.Player.CreateWalletId()
|
||||
PlayerData.metadata["criminalrecord"] = PlayerData.metadata["criminalrecord"] ~= nil and PlayerData.metadata["criminalrecord"] or {
|
||||
["hasRecord"] = false,
|
||||
["date"] = nil
|
||||
}
|
||||
PlayerData.metadata["licences"] = PlayerData.metadata["licences"] ~= nil and PlayerData.metadata["licences"] or {
|
||||
["driver"] = true,
|
||||
["business"] = false
|
||||
}
|
||||
PlayerData.metadata["inside"] = PlayerData.metadata["inside"] ~= nil and PlayerData.metadata["inside"] or {
|
||||
house = nil,
|
||||
apartment = {
|
||||
apartmentType = nil,
|
||||
apartmentId = nil,
|
||||
}
|
||||
}
|
||||
PlayerData.metadata["phonedata"] = PlayerData.metadata["phonedata"] ~= nil and PlayerData.metadata["phonedata"] or {
|
||||
SerialNumber = QBCore.Player.CreateSerialNumber(),
|
||||
InstalledApps = {},
|
||||
}
|
||||
|
||||
PlayerData.job = PlayerData.job ~= nil and PlayerData.job or {}
|
||||
PlayerData.job.name = PlayerData.job.name ~= nil and PlayerData.job.name or "unemployed"
|
||||
PlayerData.job.label = PlayerData.job.label ~= nil and PlayerData.job.label or "unemployed"
|
||||
PlayerData.job.payment = PlayerData.job.payment ~= nil and PlayerData.job.payment or 10
|
||||
PlayerData.job.onduty = PlayerData.job.onduty ~= nil and PlayerData.job.onduty or true
|
||||
|
||||
PlayerData.gang = PlayerData.gang ~= nil and PlayerData.gang or {}
|
||||
PlayerData.gang.name = PlayerData.gang.name ~= nil and PlayerData.gang.name or "geen"
|
||||
PlayerData.gang.label = PlayerData.gang.label ~= nil and PlayerData.gang.label or "Geen Gang"
|
||||
|
||||
PlayerData.position = PlayerData.position ~= nil and PlayerData.position or QBConfig.DefaultSpawn
|
||||
PlayerData.LoggedIn = true
|
||||
|
||||
PlayerData = QBCore.Player.LoadInventory(PlayerData)
|
||||
QBCore.Player.CreatePlayer(PlayerData)
|
||||
end
|
||||
|
||||
QBCore.Player.CreatePlayer = function(PlayerData)
|
||||
local self = {}
|
||||
self.Functions = {}
|
||||
self.PlayerData = PlayerData
|
||||
|
||||
self.Functions.UpdatePlayerData = function()
|
||||
TriggerClientEvent("QBCore:Player:SetPlayerData", self.PlayerData.source, self.PlayerData)
|
||||
QBCore.Commands.Refresh(self.PlayerData.source)
|
||||
end
|
||||
|
||||
self.Functions.SetJob = function(job)
|
||||
local job = job:lower()
|
||||
local grade = tonumber(grade)
|
||||
if QBCore.Shared.Jobs[job] ~= nil then
|
||||
self.PlayerData.job.name = job
|
||||
self.PlayerData.job.label = QBCore.Shared.Jobs[job].label
|
||||
self.PlayerData.job.payment = QBCore.Shared.Jobs[job].payment
|
||||
self.PlayerData.job.onduty = QBCore.Shared.Jobs[job].defaultDuty
|
||||
self.Functions.UpdatePlayerData()
|
||||
TriggerClientEvent("QBCore:Client:OnJobUpdate", self.PlayerData.source, self.PlayerData.job)
|
||||
end
|
||||
end
|
||||
|
||||
self.Functions.SetGang = function(gang)
|
||||
local gang = gang:lower()
|
||||
if QBCore.Shared.Gangs[gang] ~= nil then
|
||||
self.PlayerData.gang.name = gang
|
||||
self.PlayerData.gang.label = QBCore.Shared.Gangs[gang].label
|
||||
self.Functions.UpdatePlayerData()
|
||||
TriggerClientEvent("QBCore:Client:OnGangUpdate", self.PlayerData.source, self.PlayerData.gang)
|
||||
end
|
||||
end
|
||||
|
||||
self.Functions.SetJobDuty = function(onDuty)
|
||||
self.PlayerData.job.onduty = onDuty
|
||||
self.Functions.UpdatePlayerData()
|
||||
end
|
||||
|
||||
self.Functions.SetMetaData = function(meta, val)
|
||||
local meta = meta:lower()
|
||||
if val ~= nil then
|
||||
self.PlayerData.metadata[meta] = val
|
||||
self.Functions.UpdatePlayerData()
|
||||
end
|
||||
end
|
||||
|
||||
self.Functions.AddJobReputation = function(amount)
|
||||
local amount = tonumber(amount)
|
||||
self.PlayerData.metadata["jobrep"][self.PlayerData.job.name] = self.PlayerData.metadata["jobrep"][self.PlayerData.job.name] + amount
|
||||
self.Functions.UpdatePlayerData()
|
||||
end
|
||||
|
||||
self.Functions.AddMoney = function(moneytype, amount, reason)
|
||||
reason = reason ~= nil and reason or "unkown"
|
||||
local moneytype = moneytype:lower()
|
||||
local amount = tonumber(amount)
|
||||
if amount < 0 then return end
|
||||
if self.PlayerData.money[moneytype] ~= nil then
|
||||
self.PlayerData.money[moneytype] = self.PlayerData.money[moneytype]+amount
|
||||
self.Functions.UpdatePlayerData()
|
||||
TriggerEvent("qb-log:server:sendLog", self.PlayerData.citizenid, "moneyadded", {amount=amount, moneytype=moneytype, newbalance=self.PlayerData.money[moneytype], reason=reason})
|
||||
if amount > 100000 then
|
||||
TriggerEvent("qb-log:server:CreateLog", "playermoney", "AddMoney", "lightgreen", "**"..GetPlayerName(self.PlayerData.source) .. " (citizenid: "..self.PlayerData.citizenid.." | id: "..self.PlayerData.source..")** €"..amount .. " ("..moneytype..") added, new "..moneytype.." balance: "..self.PlayerData.money[moneytype], true)
|
||||
else
|
||||
TriggerEvent("qb-log:server:CreateLog", "playermoney", "AddMoney", "lightgreen", "**"..GetPlayerName(self.PlayerData.source) .. " (citizenid: "..self.PlayerData.citizenid.." | id: "..self.PlayerData.source..")** €"..amount .. " ("..moneytype..") added, new "..moneytype.." balance: "..self.PlayerData.money[moneytype])
|
||||
end
|
||||
TriggerClientEvent("hud:client:OnMoneyChange", self.PlayerData.source, moneytype, amount, false)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
self.Functions.RemoveMoney = function(moneytype, amount, reason)
|
||||
reason = reason ~= nil and reason or "unkown"
|
||||
local moneytype = moneytype:lower()
|
||||
local amount = tonumber(amount)
|
||||
if amount < 0 then return end
|
||||
if self.PlayerData.money[moneytype] ~= nil then
|
||||
for _, mtype in pairs(QBCore.Config.Money.DontAllowMinus) do
|
||||
if mtype == moneytype then
|
||||
if self.PlayerData.money[moneytype] - amount < 0 then return false end
|
||||
end
|
||||
end
|
||||
self.PlayerData.money[moneytype] = self.PlayerData.money[moneytype] - amount
|
||||
self.Functions.UpdatePlayerData()
|
||||
TriggerEvent("qb-log:server:sendLog", self.PlayerData.citizenid, "moneyremoved", {amount=amount, moneytype=moneytype, newbalance=self.PlayerData.money[moneytype], reason=reason})
|
||||
if amount > 100000 then
|
||||
TriggerEvent("qb-log:server:CreateLog", "playermoney", "RemoveMoney", "red", "**"..GetPlayerName(self.PlayerData.source) .. " (citizenid: "..self.PlayerData.citizenid.." | id: "..self.PlayerData.source..")** €"..amount .. " ("..moneytype..") removed, new "..moneytype.." balance: "..self.PlayerData.money[moneytype], true)
|
||||
else
|
||||
TriggerEvent("qb-log:server:CreateLog", "playermoney", "RemoveMoney", "red", "**"..GetPlayerName(self.PlayerData.source) .. " (citizenid: "..self.PlayerData.citizenid.." | id: "..self.PlayerData.source..")** €"..amount .. " ("..moneytype..") removed, new "..moneytype.." balance: "..self.PlayerData.money[moneytype])
|
||||
end
|
||||
TriggerClientEvent("hud:client:OnMoneyChange", self.PlayerData.source, moneytype, amount, true)
|
||||
TriggerClientEvent('qb-phone_new:client:RemoveBankMoney', self.PlayerData.source, amount)
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
self.Functions.SetMoney = function(moneytype, amount, reason)
|
||||
reason = reason ~= nil and reason or "unkown"
|
||||
local moneytype = moneytype:lower()
|
||||
local amount = tonumber(amount)
|
||||
if amount < 0 then return end
|
||||
if self.PlayerData.money[moneytype] ~= nil then
|
||||
self.PlayerData.money[moneytype] = amount
|
||||
self.Functions.UpdatePlayerData()
|
||||
TriggerEvent("qb-log:server:sendLog", self.PlayerData.citizenid, "moneyset", {amount=amount, moneytype=moneytype, newbalance=self.PlayerData.money[moneytype], reason=reason})
|
||||
TriggerEvent("qb-log:server:CreateLog", "playermoney", "SetMoney", "green", "**"..GetPlayerName(self.PlayerData.source) .. " (citizenid: "..self.PlayerData.citizenid.." | id: "..self.PlayerData.source..")** €"..amount .. " ("..moneytype..") gezet, nieuw "..moneytype.." balans: "..self.PlayerData.money[moneytype])
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
self.Functions.AddItem = function(item, amount, slot, info)
|
||||
local totalWeight = QBCore.Player.GetTotalWeight(self.PlayerData.items)
|
||||
local itemInfo = QBCore.Shared.Items[item:lower()]
|
||||
if itemInfo == nil then TriggerClientEvent('chatMessage', -1, "SYSTEM", "warning", "No item found??") return end
|
||||
local amount = tonumber(amount)
|
||||
local slot = tonumber(slot) ~= nil and tonumber(slot) or QBCore.Player.GetFirstSlotByItem(self.PlayerData.items, item)
|
||||
if itemInfo["type"] == "weapon" and info == nil then
|
||||
info = {
|
||||
serie = tostring(QBCore.Shared.RandomInt(2) .. QBCore.Shared.RandomStr(3) .. QBCore.Shared.RandomInt(1) .. QBCore.Shared.RandomStr(2) .. QBCore.Shared.RandomInt(3) .. QBCore.Shared.RandomStr(4)),
|
||||
}
|
||||
end
|
||||
if (totalWeight + (itemInfo["weight"] * amount)) <= QBCore.Config.Player.MaxWeight then
|
||||
if (slot ~= nil and self.PlayerData.items[slot] ~= nil) and (self.PlayerData.items[slot].name:lower() == item:lower()) and (itemInfo["type"] == "item" and not itemInfo["unique"]) then
|
||||
self.PlayerData.items[slot].amount = self.PlayerData.items[slot].amount + amount
|
||||
self.Functions.UpdatePlayerData()
|
||||
TriggerEvent("qb-log:server:sendLog", self.PlayerData.citizenid, "itemadded", {name=self.PlayerData.items[slot].name, amount=amount, slot=slot, newamount=self.PlayerData.items[slot].amount, reason="unkown"})
|
||||
TriggerEvent("qb-log:server:CreateLog", "playerinventory", "AddItem", "green", "**"..GetPlayerName(self.PlayerData.source) .. " (citizenid: "..self.PlayerData.citizenid.." | id: "..self.PlayerData.source..")** got item: [slot:" ..slot.."], itemname: " .. self.PlayerData.items[slot].name .. ", added amount: " .. amount ..", new total amount: ".. self.PlayerData.items[slot].amount)
|
||||
--TriggerClientEvent('QBCore:Notify', self.PlayerData.source, itemInfo["label"].. " toegevoegd!", "success")
|
||||
return true
|
||||
elseif (not itemInfo["unique"] and slot or slot ~= nil and self.PlayerData.items[slot] == nil) then
|
||||
self.PlayerData.items[slot] = {name = itemInfo["name"], amount = amount, info = info ~= nil and info or "", label = itemInfo["label"], description = itemInfo["description"] ~= nil and itemInfo["description"] or "", weight = itemInfo["weight"], type = itemInfo["type"], unique = itemInfo["unique"], useable = itemInfo["useable"], image = itemInfo["image"], shouldClose = itemInfo["shouldClose"], slot = slot, combinable = itemInfo["combinable"]}
|
||||
self.Functions.UpdatePlayerData()
|
||||
TriggerEvent("qb-log:server:sendLog", self.PlayerData.citizenid, "itemadded", {name=self.PlayerData.items[slot].name, amount=amount, slot=slot, newamount=self.PlayerData.items[slot].amount, reason="unkown"})
|
||||
TriggerEvent("qb-log:server:CreateLog", "playerinventory", "AddItem", "green", "**"..GetPlayerName(self.PlayerData.source) .. " (citizenid: "..self.PlayerData.citizenid.." | id: "..self.PlayerData.source..")** got item: [slot:" ..slot.."], itemname: " .. self.PlayerData.items[slot].name .. ", added amount: " .. amount ..", new total amount: ".. self.PlayerData.items[slot].amount)
|
||||
--TriggerClientEvent('QBCore:Notify', self.PlayerData.source, itemInfo["label"].. " toegevoegd!", "success")
|
||||
return true
|
||||
elseif (itemInfo["unique"]) or (not slot or slot == nil) or (itemInfo["type"] == "weapon") then
|
||||
for i = 1, QBConfig.Player.MaxInvSlots, 1 do
|
||||
if self.PlayerData.items[i] == nil then
|
||||
self.PlayerData.items[i] = {name = itemInfo["name"], amount = amount, info = info ~= nil and info or "", label = itemInfo["label"], description = itemInfo["description"] ~= nil and itemInfo["description"] or "", weight = itemInfo["weight"], type = itemInfo["type"], unique = itemInfo["unique"], useable = itemInfo["useable"], image = itemInfo["image"], shouldClose = itemInfo["shouldClose"], slot = i, combinable = itemInfo["combinable"]}
|
||||
self.Functions.UpdatePlayerData()
|
||||
TriggerEvent("qb-log:server:sendLog", self.PlayerData.citizenid, "itemadded", {name=self.PlayerData.items[i].name, amount=amount, slot=i, newamount=self.PlayerData.items[i].amount, reason="unkown"})
|
||||
TriggerEvent("qb-log:server:CreateLog", "playerinventory", "AddItem", "green", "**"..GetPlayerName(self.PlayerData.source) .. " (citizenid: "..self.PlayerData.citizenid.." | id: "..self.PlayerData.source..")** got item: [slot:" ..i.."], itemname: " .. self.PlayerData.items[i].name .. ", added amount: " .. amount ..", new total amount: ".. self.PlayerData.items[i].amount)
|
||||
--TriggerClientEvent('QBCore:Notify', self.PlayerData.source, itemInfo["label"].. " toegevoegd!", "success")
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
self.Functions.RemoveItem = function(item, amount, slot)
|
||||
local itemInfo = QBCore.Shared.Items[item:lower()]
|
||||
local amount = tonumber(amount)
|
||||
local slot = tonumber(slot)
|
||||
if slot ~= nil then
|
||||
if self.PlayerData.items[slot].amount > amount then
|
||||
self.PlayerData.items[slot].amount = self.PlayerData.items[slot].amount - amount
|
||||
self.Functions.UpdatePlayerData()
|
||||
TriggerEvent("qb-log:server:sendLog", self.PlayerData.citizenid, "itemremoved", {name=self.PlayerData.items[slot].name, amount=amount, slot=slot, newamount=self.PlayerData.items[slot].amount, reason="unkown"})
|
||||
TriggerEvent("qb-log:server:CreateLog", "playerinventory", "RemoveItem", "red", "**"..GetPlayerName(self.PlayerData.source) .. " (citizenid: "..self.PlayerData.citizenid.." | id: "..self.PlayerData.source..")** lost item: [slot:" ..slot.."], itemname: " .. self.PlayerData.items[slot].name .. ", removed amount: " .. amount ..", new total amount: ".. self.PlayerData.items[slot].amount)
|
||||
--TriggerClientEvent('QBCore:Notify', self.PlayerData.source, itemInfo["label"].. " verwijderd!", "error")
|
||||
return true
|
||||
else
|
||||
self.PlayerData.items[slot] = nil
|
||||
self.Functions.UpdatePlayerData()
|
||||
TriggerEvent("qb-log:server:sendLog", self.PlayerData.citizenid, "itemremoved", {name=item, amount=amount, slot=slot, newamount=0, reason="unkown"})
|
||||
TriggerEvent("qb-log:server:CreateLog", "playerinventory", "RemoveItem", "red", "**"..GetPlayerName(self.PlayerData.source) .. " (citizenid: "..self.PlayerData.citizenid.." | id: "..self.PlayerData.source..")** lost item: [slot:" ..slot.."], itemname: " .. item .. ", removed amount: " .. amount ..", item removed")
|
||||
--TriggerClientEvent('QBCore:Notify', self.PlayerData.source, itemInfo["label"].. " verwijderd!", "error")
|
||||
return true
|
||||
end
|
||||
else
|
||||
local slots = QBCore.Player.GetSlotsByItem(self.PlayerData.items, item)
|
||||
local amountToRemove = amount
|
||||
if slots ~= nil then
|
||||
for _, slot in pairs(slots) do
|
||||
if self.PlayerData.items[slot].amount > amountToRemove then
|
||||
self.PlayerData.items[slot].amount = self.PlayerData.items[slot].amount - amountToRemove
|
||||
self.Functions.UpdatePlayerData()
|
||||
TriggerEvent("qb-log:server:sendLog", self.PlayerData.citizenid, "itemremoved", {name=self.PlayerData.items[slot].name, amount=amount, slot=slot, newamount=self.PlayerData.items[slot].amount, reason="unkown"})
|
||||
TriggerEvent("qb-log:server:CreateLog", "playerinventory", "RemoveItem", "red", "**"..GetPlayerName(self.PlayerData.source) .. " (citizenid: "..self.PlayerData.citizenid.." | id: "..self.PlayerData.source..")** lost item: [slot:" ..slot.."], itemname: " .. self.PlayerData.items[slot].name .. ", removed amount: " .. amount ..", new total amount: ".. self.PlayerData.items[slot].amount)
|
||||
--TriggerClientEvent('QBCore:Notify', self.PlayerData.source, itemInfo["label"].. " verwijderd!", "error")
|
||||
return true
|
||||
elseif self.PlayerData.items[slot].amount == amountToRemove then
|
||||
self.PlayerData.items[slot] = nil
|
||||
self.Functions.UpdatePlayerData()
|
||||
TriggerEvent("qb-log:server:sendLog", self.PlayerData.citizenid, "itemremoved", {name=item, amount=amount, slot=slot, newamount=0, reason="unkown"})
|
||||
TriggerEvent("qb-log:server:CreateLog", "playerinventory", "RemoveItem", "red", "**"..GetPlayerName(self.PlayerData.source) .. " (citizenid: "..self.PlayerData.citizenid.." | id: "..self.PlayerData.source..")** lost item: [slot:" ..slot.."], itemname: " .. item .. ", removed amount: " .. amount ..", item removed")
|
||||
--TriggerClientEvent('QBCore:Notify', self.PlayerData.source, itemInfo["label"].. " verwijderd!", "error")
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
self.Functions.SetInventory = function(items)
|
||||
self.PlayerData.items = items
|
||||
self.Functions.UpdatePlayerData()
|
||||
TriggerEvent("qb-log:server:sendLog", self.PlayerData.citizenid, "setinventory", {items=json.encode(items)})
|
||||
TriggerEvent("qb-log:server:CreateLog", "playerinventory", "SetInventory", "blue", "**"..GetPlayerName(self.PlayerData.source) .. " (citizenid: "..self.PlayerData.citizenid.." | id: "..self.PlayerData.source..")** items set: " .. json.encode(items))
|
||||
end
|
||||
|
||||
self.Functions.ClearInventory = function()
|
||||
self.PlayerData.items = {}
|
||||
self.Functions.UpdatePlayerData()
|
||||
TriggerEvent("qb-log:server:sendLog", self.PlayerData.citizenid, "clearinventory", {})
|
||||
TriggerEvent("qb-log:server:CreateLog", "playerinventory", "ClearInventory", "red", "**"..GetPlayerName(self.PlayerData.source) .. " (citizenid: "..self.PlayerData.citizenid.." | id: "..self.PlayerData.source..")** inventory cleared")
|
||||
end
|
||||
|
||||
self.Functions.GetItemByName = function(item)
|
||||
local item = tostring(item):lower()
|
||||
local slot = QBCore.Player.GetFirstSlotByItem(self.PlayerData.items, item)
|
||||
if slot ~= nil then
|
||||
return self.PlayerData.items[slot]
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
self.Functions.GetItemBySlot = function(slot)
|
||||
local slot = tonumber(slot)
|
||||
if self.PlayerData.items[slot] ~= nil then
|
||||
return self.PlayerData.items[slot]
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
self.Functions.Save = function()
|
||||
QBCore.Player.Save(self.PlayerData.source)
|
||||
end
|
||||
|
||||
QBCore.Players[self.PlayerData.source] = self
|
||||
QBCore.Player.Save(self.PlayerData.source)
|
||||
self.Functions.UpdatePlayerData()
|
||||
end
|
||||
|
||||
QBCore.Player.Save = function(source)
|
||||
local PlayerData = QBCore.Players[source].PlayerData
|
||||
if PlayerData ~= nil then
|
||||
QBCore.Functions.ExecuteSql(true, "SELECT * FROM `players` WHERE `citizenid` = '"..PlayerData.citizenid.."'", function(result)
|
||||
if result[1] == nil then
|
||||
QBCore.Functions.ExecuteSql(true, "INSERT INTO `players` (`citizenid`, `cid`, `steam`, `license`, `name`, `money`, `charinfo`, `job`, `gang`, `position`, `metadata`) VALUES ('"..PlayerData.citizenid.."', '"..tonumber(PlayerData.cid).."', '"..PlayerData.steam.."', '"..PlayerData.license.."', '"..PlayerData.name.."', '"..json.encode(PlayerData.money).."', '"..QBCore.EscapeSqli(json.encode(PlayerData.charinfo)).."', '"..json.encode(PlayerData.job).."', '"..json.encode(PlayerData.gang).."', '"..json.encode(PlayerData.position).."', '"..json.encode(PlayerData.metadata).."')")
|
||||
else
|
||||
QBCore.Functions.ExecuteSql(true, "UPDATE `players` SET steam='"..PlayerData.steam.."',license='"..PlayerData.license.."',name='"..PlayerData.name.."',money='"..json.encode(PlayerData.money).."',charinfo='"..QBCore.EscapeSqli(json.encode(PlayerData.charinfo)).."',job='"..json.encode(PlayerData.job).."',gang='"..json.encode(PlayerData.gang).."', position='"..json.encode(PlayerData.position).."',metadata='"..json.encode(PlayerData.metadata).."' WHERE `citizenid` = '"..PlayerData.citizenid.."'")
|
||||
end
|
||||
QBCore.Player.SaveInventory(source)
|
||||
end)
|
||||
QBCore.ShowSuccess(GetCurrentResourceName(), PlayerData.name .." PLAYER SAVED!")
|
||||
else
|
||||
QBCore.ShowError(GetCurrentResourceName(), "ERROR QBCORE.PLAYER.SAVE - PLAYERDATA IS EMPTY!")
|
||||
end
|
||||
end
|
||||
|
||||
QBCore.Player.Logout = function(source)
|
||||
TriggerClientEvent('QBCore:Client:OnPlayerUnload', source)
|
||||
TriggerClientEvent("QBCore:Player:UpdatePlayerData", source)
|
||||
Citizen.Wait(200)
|
||||
-- TriggerEvent('QBCore:Server:OnPlayerUnload')
|
||||
-- QBCore.Players[source].Functions.Save()
|
||||
QBCore.Players[source] = nil
|
||||
end
|
||||
|
||||
QBCore.Player.DeleteCharacter = function(source, citizenid)
|
||||
QBCore.Functions.ExecuteSql(true, "DELETE FROM `players` WHERE `citizenid` = '"..citizenid.."'")
|
||||
TriggerEvent("qb-log:server:sendLog", citizenid, "characterdeleted", {})
|
||||
TriggerEvent("qb-log:server:CreateLog", "joinleave", "Character Deleted", "red", "**".. GetPlayerName(source) .. "** ("..GetPlayerIdentifiers(source)[1]..") deleted **"..citizenid.."**..")
|
||||
end
|
||||
|
||||
QBCore.Player.LoadInventory = function(PlayerData)
|
||||
PlayerData.items = {}
|
||||
QBCore.Functions.ExecuteSql(true, "SELECT * FROM `playeritems` WHERE `citizenid` = '"..PlayerData.citizenid.."'", function(oldInventory)
|
||||
if oldInventory[1] ~= nil then
|
||||
for _, item in pairs(oldInventory) do
|
||||
if item ~= nil then
|
||||
local itemInfo = QBCore.Shared.Items[item.name:lower()]
|
||||
PlayerData.items[item.slot] = {name = itemInfo["name"], amount = item.amount, info = json.decode(item.info) ~= nil and json.decode(item.info) or "", label = itemInfo["label"], description = itemInfo["description"] ~= nil and itemInfo["description"] or "", weight = itemInfo["weight"], type = itemInfo["type"], unique = itemInfo["unique"], useable = itemInfo["useable"], image = itemInfo["image"], shouldClose = itemInfo["shouldClose"], slot = item.slot, combinable = itemInfo["combinable"]}
|
||||
end
|
||||
Citizen.Wait(1)
|
||||
end
|
||||
QBCore.Functions.ExecuteSql(true, "DELETE FROM `playeritems` WHERE `citizenid` = '"..PlayerData.citizenid.."'")
|
||||
else
|
||||
QBCore.Functions.ExecuteSql(true, "SELECT * FROM `players` WHERE `citizenid` = '"..PlayerData.citizenid.."'", function(result)
|
||||
if result[1] ~= nil then
|
||||
if result[1].inventory ~= nil then
|
||||
plyInventory = json.decode(result[1].inventory)
|
||||
if next(plyInventory) ~= nil then
|
||||
for _, item in pairs(plyInventory) do
|
||||
if item ~= nil then
|
||||
local itemInfo = QBCore.Shared.Items[item.name:lower()]
|
||||
PlayerData.items[item.slot] = {
|
||||
name = itemInfo["name"],
|
||||
amount = item.amount,
|
||||
info = item.info ~= nil and item.info or "",
|
||||
label = itemInfo["label"],
|
||||
description = itemInfo["description"] ~= nil and itemInfo["description"] or "",
|
||||
weight = itemInfo["weight"],
|
||||
type = itemInfo["type"],
|
||||
unique = itemInfo["unique"],
|
||||
useable = itemInfo["useable"],
|
||||
image = itemInfo["image"],
|
||||
shouldClose = itemInfo["shouldClose"],
|
||||
slot = item.slot,
|
||||
combinable = itemInfo["combinable"]
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
end)
|
||||
return PlayerData
|
||||
end
|
||||
|
||||
QBCore.Player.SaveInventory = function(source)
|
||||
if QBCore.Players[source] ~= nil then
|
||||
local PlayerData = QBCore.Players[source].PlayerData
|
||||
local items = PlayerData.items
|
||||
local ItemsJson = {}
|
||||
if items ~= nil and next(items) ~= nil then
|
||||
for slot, item in pairs(items) do
|
||||
if items[slot] ~= nil then
|
||||
table.insert(ItemsJson, {
|
||||
name = item.name,
|
||||
amount = item.amount,
|
||||
info = item.info,
|
||||
type = item.type,
|
||||
slot = slot,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
QBCore.Functions.ExecuteSql(true, "UPDATE `players` SET `inventory` = '"..QBCore.EscapeSqli(json.encode(ItemsJson)).."' WHERE `citizenid` = '"..PlayerData.citizenid.."'")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
QBCore.Player.GetTotalWeight = function(items)
|
||||
local weight = 0
|
||||
if items ~= nil then
|
||||
for slot, item in pairs(items) do
|
||||
weight = weight + (item.weight * item.amount)
|
||||
end
|
||||
end
|
||||
return tonumber(weight)
|
||||
end
|
||||
|
||||
QBCore.Player.GetSlotsByItem = function(items, itemName)
|
||||
local slotsFound = {}
|
||||
if items ~= nil then
|
||||
for slot, item in pairs(items) do
|
||||
if item.name:lower() == itemName:lower() then
|
||||
table.insert(slotsFound, slot)
|
||||
end
|
||||
end
|
||||
end
|
||||
return slotsFound
|
||||
end
|
||||
|
||||
QBCore.Player.GetFirstSlotByItem = function(items, itemName)
|
||||
if items ~= nil then
|
||||
for slot, item in pairs(items) do
|
||||
if item.name:lower() == itemName:lower() then
|
||||
return tonumber(slot)
|
||||
end
|
||||
end
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
QBCore.Player.CreateCitizenId = function()
|
||||
local UniqueFound = false
|
||||
local CitizenId = nil
|
||||
|
||||
while not UniqueFound do
|
||||
CitizenId = tostring(QBCore.Shared.RandomStr(3) .. QBCore.Shared.RandomInt(5)):upper()
|
||||
QBCore.Functions.ExecuteSql(true, "SELECT COUNT(*) as count FROM `players` WHERE `citizenid` = '"..CitizenId.."'", function(result)
|
||||
if result[1].count == 0 then
|
||||
UniqueFound = true
|
||||
end
|
||||
end)
|
||||
end
|
||||
return CitizenId
|
||||
end
|
||||
|
||||
QBCore.Player.CreateFingerId = function()
|
||||
local UniqueFound = false
|
||||
local FingerId = nil
|
||||
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))
|
||||
QBCore.Functions.ExecuteSql(true, "SELECT COUNT(*) as count FROM `players` WHERE `metadata` LIKE '%"..FingerId.."%'", function(result)
|
||||
if result[1].count == 0 then
|
||||
UniqueFound = true
|
||||
end
|
||||
end)
|
||||
end
|
||||
return FingerId
|
||||
end
|
||||
|
||||
QBCore.Player.CreateWalletId = function()
|
||||
local UniqueFound = false
|
||||
local WalletId = nil
|
||||
while not UniqueFound do
|
||||
WalletId = "QB-"..math.random(11111111, 99999999)
|
||||
QBCore.Functions.ExecuteSql(true, "SELECT COUNT(*) as count FROM `players` WHERE `metadata` LIKE '%"..WalletId.."%'", function(result)
|
||||
if result[1].count == 0 then
|
||||
UniqueFound = true
|
||||
end
|
||||
end)
|
||||
end
|
||||
return WalletId
|
||||
end
|
||||
|
||||
QBCore.Player.CreateSerialNumber = function()
|
||||
local UniqueFound = false
|
||||
local SerialNumber = nil
|
||||
|
||||
while not UniqueFound do
|
||||
SerialNumber = math.random(11111111, 99999999)
|
||||
QBCore.Functions.ExecuteSql(true, "SELECT COUNT(*) as count FROM players WHERE metadata LIKE '%"..SerialNumber.."%'", function(result)
|
||||
if result[1].count == 0 then
|
||||
UniqueFound = true
|
||||
end
|
||||
end)
|
||||
end
|
||||
return SerialNumber
|
||||
end
|
||||
|
||||
QBCore.EscapeSqli = function(str)
|
||||
local replacements = { ['"'] = '\\"', ["'"] = "\\'" }
|
||||
return str:gsub( "['\"]", replacements ) -- or string.gsub( source, "['\"]", replacements )
|
||||
end
|
||||
+6273
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user