Merge branch 'dev' into csoki-core-refactor

This commit is contained in:
Csoki
2023-01-24 18:58:38 +01:00
committed by GitHub
7 changed files with 179 additions and 47 deletions
+2 -1
View File
@@ -402,7 +402,8 @@ CREATE TABLE `users` (
`disabled` TINYINT(1) NULL DEFAULT '0',
`last_property` varchar(255) DEFAULT NULL,
`created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
`last_seen` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP
`last_seen` timestamp NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP,
`phone_number` VARCHAR(20) DEFAULT NULL
) ENGINE=InnoDB;
-- --------------------------------------------------------
@@ -0,0 +1,55 @@
local npwd = GetResourceState('npwd'):find('start') and exports.npwd or nil
local function checkPhone()
if not npwd then
return
end
npwd:setPhoneDisabled((ESX.SearchInventory('phone').count or 0) <= 0)
end
RegisterNetEvent('esx:playerLoaded', checkPhone)
AddEventHandler('onClientResourceStart', function(resource)
if resource ~= 'npwd' then
return
end
npwd = GetResourceState('npwd'):find('start') and exports.npwd or nil
if ESX.PlayerLoaded then
checkPhone()
end
end)
AddEventHandler('onClientResourceStop', function(resource)
if resource == 'npwd' then
npwd = nil
end
end)
RegisterNetEvent('esx:onPlayerLogout', function()
if not npwd then
return
end
npwd:setPhoneVisible(false)
npwd:setPhoneDisabled(true)
end)
RegisterNetEvent('esx:removeInventoryItem', function(item, count)
if not npwd then
return
end
if item == 'phone' and count == 0 then
npwd:setPhoneDisabled(true)
end
end)
RegisterNetEvent('esx:addInventoryItem', function(item)
if not npwd or item ~= 'phone' then
return
end
npwd:setPhoneDisabled(false)
end)
+1 -1
View File
@@ -60,7 +60,7 @@ Config.RemoveHudCommonents = {
[22] = false, --HUD_WEAPONS
}
Config.MaxAdminVehicles = false -- admin vehicles spawn with max vehcle settings
Config.SpawnVehMaxUpgrades = true -- admin vehicles spawn with max vehcle settings
Config.CustomAIPlates = 'ESX.A111' -- Custom plates for AI vehicles
-- Pattern string format
--1 will lead to a random number from 0-9.
+6 -6
View File
@@ -28,7 +28,8 @@ server_scripts {
'server/commands.lua',
'common/modules/*.lua',
'common/functions.lua'
'common/functions.lua',
'server/modules/*.lua'
}
client_scripts {
@@ -36,13 +37,12 @@ client_scripts {
'client/functions.lua',
'client/wrapper.lua',
'client/main.lua',
'client/modules/death.lua',
'client/modules/scaleform.lua',
'client/modules/streaming.lua',
'common/modules/*.lua',
'common/functions.lua',
'common/functions.lua'
'client/modules/*.lua'
}
ui_page {
+45 -18
View File
@@ -23,29 +23,56 @@ end, true, {help = TranslateCap('command_setjob'), validate = true, arguments =
{name = 'grade', help = TranslateCap('command_setjob_grade'), type = 'number'}
}})
local upgrades = Config.SpawnVehMaxUpgrades and
{
plate = "ADMINCAR",
modEngine = 3,
modBrakes = 2,
modTransmission = 2,
modSuspension = 3,
modArmor = true,
windowTint = 1
} or {}
ESX.RegisterCommand('car', 'admin', function(xPlayer, args, showError)
local GameBuild = tonumber(GetConvar("sv_enforceGameBuild", 1604))
if not args.car then args.car = GameBuild >= 2699 and "draugur" or "prototipo" end
if not xPlayer then
return print('[^1ERROR^7] The xPlayer value is nil')
end
local playerPed = GetPlayerPed(xPlayer.source)
local playerCoords = GetEntityCoords(playerPed)
local playerHeading = GetEntityHeading(playerPed)
local playerVehicle = GetVehiclePedIsIn(playerPed)
if not args.car or type(args.car) ~= 'string' then
args.car = 'adder'
end
if playerVehicle then
DeleteEntity(playerVehicle)
end
ESX.DiscordLogFields("UserActions", "/car Triggered", "pink", {
{name = "Player", value = xPlayer.name, inline = true},
{name = "ID", value = xPlayer.source, inline = true},
{name = "Vehicle", value = args.car, inline = true}
{name = "Vehicle", value = args.car, inline = true}
})
local upgrades = Config.MaxAdminVehicles and {
plate = "ADMINCAR",
modEngine = 3,
modBrakes = 2,
modTransmission = 2,
modSuspension = 3,
modArmor = true,
windowTint = 1,
} or {}
local coords = xPlayer.getCoords(true)
local PlayerPed = GetPlayerPed(xPlayer.source)
ESX.OneSync.SpawnVehicle(args.car, coords - vector3(0,0, 0.9), GetEntityHeading(PlayerPed), upgrades, function(networkId)
local vehicle = NetworkGetEntityFromNetworkId(networkId)
Wait(250)
TaskWarpPedIntoVehicle(PlayerPed, vehicle, -1)
ESX.OneSync.SpawnVehicle(args.car, playerCoords, playerHeading, upgrades, function(networkId)
if networkId then
local vehicle = NetworkGetEntityFromNetworkId(networkId)
for i = 1, 20 do
Wait(0)
SetPedIntoVehicle(playerPed, vehicle, -1)
if GetVehiclePedIsIn(playerPed, false) == vehicle then
break
end
end
if GetVehiclePedIsIn(playerPed, false) ~= vehicle then
print('[^1ERROR^7] The player could not be seated in the vehicle')
end
end
end)
end, false, {help = TranslateCap('command_car'), validate = false, arguments = {
{name = 'car',validate = false, help = TranslateCap('command_car_car'), type = 'string'}
@@ -0,0 +1,49 @@
local npwd = GetResourceState('npwd'):find('start') and exports.npwd or nil
AddEventHandler('onServerResourceStart', function(resource)
if resource ~= 'npwd' then
return
end
npwd = GetResourceState('npwd'):find('start') and exports.npwd or nil
for _, xPlayer in pairs(ESX.Players) do
npwd:newPlayer({
source = xPlayer.source,
identifier = xPlayer.identifier,
firstname = xPlayer.get('firstName'),
lastname = xPlayer.get('lastName')
})
end
end)
AddEventHandler('onServerResourceStop', function(resource)
if resource == 'npwd' then
npwd = nil
end
end)
AddEventHandler('esx:playerLoaded', function(playerId, xPlayer)
if not npwd then
return
end
if not xPlayer then
xPlayer = ESX.GetPlayerFromId(playerId)
end
npwd:newPlayer({
source = playerId,
identifier = xPlayer.identifier,
firstname = xPlayer.get('firstName'),
lastname = xPlayer.get('lastName')
})
end)
AddEventHandler('esx:playerLogout', function(playerId)
if not npwd then
return
end
npwd:unloadPlayer(playerId)
end)
+21 -21
View File
@@ -61,29 +61,29 @@ end
---@param heading number
---@param Properties table
---@param cb function
function ESX.OneSync.SpawnVehicle(model, coords, heading, Properties, cb)
local veh_model = type(model) == 'string' and joaat(model) or model
Properties = Properties or {}
local vector = type(coords) == "vector3" and coords or vec(coords.x, coords.y, coords.z)
TriggerClientEvent("esx:requestModel", -1, model)
CreateThread(function()
local xPlayer = ESX.OneSync.GetClosestPlayer(vector, 300)
ESX.GetVehicleType(veh_model, xPlayer.id, function(Type)
if Type then
local SpawnedEntity = CreateVehicleServerSetter(veh_model, Type, vector, heading)
local NetworkId = NetworkGetNetworkIdFromEntity(SpawnedEntity)
while not DoesEntityExist(SpawnedEntity) do
Wait(100)
end
Properties.NetId = NetworkId
Entity(SpawnedEntity).state:set('VehicleProperties', Properties, true)
cb(NetworkId)
else
print(('[^1ERROR^7] Tried to spawn invalid vehicle - ^5%s^7!'):format(model))
function ESX.OneSync.SpawnVehicle(model, coords, heading, properties, cb)
local vehicleModel = joaat(model)
local vehicleProperties = properties
CreateThread(function()
local xPlayer = ESX.OneSync.GetClosestPlayer(coords, 300)
ESX.GetVehicleType(vehicleModel, xPlayer.id, function(vehicleType)
if vehicleType then
local createdVehicle = CreateVehicleServerSetter(vehicleModel, vehicleType, coords, heading)
if DoesEntityExist(createdVehicle) then
local networkId = NetworkGetNetworkIdFromEntity(createdVehicle)
vehicleProperties.NetId = networkId
Entity(createdVehicle).state:set('VehicleProperties', vehicleProperties, true)
cb(networkId)
else
print('[^1ERROR^7] Unfortunately, this vehicle has not spawned')
end
end)
else
print(('[^1ERROR^7] Tried to spawn invalid vehicle - ^5%s^7!'):format(model))
end
end)
end
end)
end
---@param model number|string