Skip to content

Commit

Permalink
Merge pull request #564 from bitpredator/dev
Browse files Browse the repository at this point in the history
chore: clean up the code
  • Loading branch information
bitpredator authored Nov 19, 2023
2 parents 2317708 + 8b4d8b4 commit 64396a2
Show file tree
Hide file tree
Showing 14 changed files with 49 additions and 78 deletions.
7 changes: 6 additions & 1 deletion .github/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,9 @@
25. [esx_status]: refactor: remove jquery + Remove some shitty lines @bitpredator
26. [esx_status/server]: fix: unused argument @bitpredator
27. [esx_addoninventory]: chore: check for nil society @bitpredator
28. [npwd]: chore: npwd update to version 1.8.6 @bitpredator
28. [npwd]: chore: npwd update to version 1.8.6 @bitpredator
29. [bpt_deliveries]: chore: clean up the code @bitpredator
30. [esx-radialmenu]: chore: fix lint error + clean up the code @bitpredator
31. [esx-qalle-jail]: fix: fix lint error @bitpredator
32. [esx_multicaracter]: fix: fix lint error @bitpredator
33. [esx_dmvschool]: fix: fix lint error @bitpredator
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
ESX = nil
local Status = {
DELIVERY_INACTIVE = 0,
PLAYER_STARTED_DELIVERY = 1,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
ESX = nil
ESX = exports["es_extended"]:getSharedObject()

-- Register events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ if ESX.GetConfig().Multichar then
end

function CharacterOptions(Characters, slots, SelectedCharacter)
local elements = {{title = _U('character', Characters[SelectedCharacter.value].firstname .. " ".. Characters[SelectedCharacter.value].lastname),icon = "fa-regular fa-user", unselectable = true},
local elements = {{title = _U('character', Characters[SelectedCharacter.value].firstname .. " ".. Characters[SelectedCharacter.value].lastname),icon = "fa-regular fa-user", unselectable = true},
{title = _U('return'), unselectable = false,icon = "fa-solid fa-arrow-left",description = _U('return_description'), action = "return"}}
if not Characters[SelectedCharacter.value].disabled then
if not Characters[SelectedCharacter.value].disabled then
elements[3] = {title = _U('char_play'), description = _U('char_play_description'), icon ="fa-solid fa-play",action = 'play', value = SelectedCharacter.value}
else
elements[3] = {title = _U('char_disabled'), value = SelectedCharacter.value, icon ="fa-solid fa-xmark", description = _U('char_disabled_description'),}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,9 @@ function OpenJailMenu()
},
function(data2, menu2)
local jailTime = tonumber(data2.value)
if jailTime == nil then
if jailTime == nil then
ESX.ShowNotification(_U('time_minutes'))
else
else
menu2.close()
local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer()

Expand All @@ -291,9 +291,7 @@ function OpenJailMenu()
title = "Jail Reason"
},
function(data3, menu3)

local reason = data3.value

local reason = data3.value
if reason == nil then
ESX.ShowNotification(_U('put_something'))
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ function TeleportPlayer(pos)
table.insert(elements, { label = v, value = v })
end

ESX.UI.Menu.Open(
'default', GetCurrentResourceName(), 'teleport_jail',
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'teleport_jail',
{
title = "Choose Position",
align = 'center',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ server_scripts {
client_scripts {
'@es_extended/locale.lua',
"config.lua",
"client/utils.lua",
"client/*.lua",
'locales/*.lua',
"client/client.lua"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ESX = exports["es_extended"]:getSharedObject()

RegisterCommand("jail", function(src, args, raw)
RegisterCommand("jail", function(src, args)
local xPlayer = ESX.GetPlayerFromId(src)

if xPlayer["job"]["name"] == "police" then
Expand All @@ -15,7 +15,7 @@ RegisterCommand("jail", function(src, args, raw)
JailPlayer(jailPlayer, jailTime)

TriggerClientEvent("esx:showNotification", src, GetPlayerName(jailPlayer) .. " Jailed for " .. jailTime .. " minutes!")

if args[3] ~= nil then
GetRPName(jailPlayer, function(Firstname, Lastname)
TriggerClientEvent('chat:addMessage', -1, { args = { "JUDGE", Firstname .. " " .. Lastname .. " Is now in jail for the reason: " .. args[3] }, color = { 249, 166, 0 } })
Expand Down Expand Up @@ -139,7 +139,7 @@ function GetRPName(playerId, data)
end)
end

ESX.RegisterServerCallback("esx-qalle-jail:retrieveJailedPlayers", function(source, cb)
ESX.RegisterServerCallback("esx-qalle-jail:retrieveJailedPlayers", function(_, cb)

local jailedPersons = {}

Expand Down
26 changes: 3 additions & 23 deletions server-data/resources/[esx_addons]/esx-radialmenu/client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ local function getNearestVeh()
local pos = GetEntityCoords(PlayerPedId())
local entityWorld = GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 20.0, 0.0)
local rayHandle = CastRayPointToPoint(pos.x, pos.y, pos.z, entityWorld.x, entityWorld.y, entityWorld.z, 10, PlayerPedId(), 0)
local _, _, _, _, vehicleHandle = GetRaycastResult(rayHandle)
local vehicleHandle = GetRaycastResult(rayHandle)
return vehicleHandle
end

Expand Down Expand Up @@ -250,7 +250,7 @@ RegisterKeyMapping('radialmenu', _U("command_description"), 'keyboard', Config.
-- Events

-- Sets the metadata when the player spawns
RegisterNetEvent('esx:playerLoaded', function(xPlayer, isNew)
RegisterNetEvent('esx:playerLoaded', function(xPlayer)
ESX.PlayerData = xPlayer
ESX.PlayerLoaded = true
end)
Expand Down Expand Up @@ -360,25 +360,7 @@ RegisterNetEvent('esx-radialmenu:client:ChangeSeat', function(data)
end
end)

RegisterNetEvent('esx-radialmenu:flipVehicle', function()
TriggerEvent('animations:client:EmoteCommandStart', {"mechanic"})
QBCore.Functions.Progressbar("pick_grape", _U("progress.flipping_car"), Config.Fliptime, false, true, {
disableMovement = true,
disableCarMovement = true,
disableMouse = false,
disableCombat = true,
}, {}, {}, {}, function() -- Done
local vehicle = getNearestVeh()
SetVehicleOnGroundProperly(vehicle)
TriggerEvent('animations:client:EmoteCommandStart', {"c"})
end, function() -- Cancel
ESX.ShowNotification( _U("task.cancel_task"), "error")
TriggerEvent('animations:client:EmoteCommandStart', {"c"})
end)
end)

-- NUI Callbacks

RegisterNUICallback('closeRadial', function(data, cb)
setRadialState(false, false, data.delay)
cb('ok')
Expand All @@ -396,12 +378,10 @@ RegisterNUICallback('selectItem', function(inData, cb)
TriggerServerEvent(data.event, data)
elseif data.type == 'command' then
ExecuteCommand(data.event)
-- elseif data.type == 'qbcommand' then
-- TriggerServerEvent('QBCore:CallCommand', data.event, data)
end
end
cb('ok')
end)

exports('AddOption', AddOption)
exports('RemoveOption', RemoveOption)
exports('RemoveOption', RemoveOption)
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ local disabledTrunk = {
}

-- Functions

local function DrawText3Ds(x, y, z, text)
SetTextScale(0.35, 0.35)
SetTextFont(4)
Expand All @@ -44,7 +43,7 @@ local function getNearestVeh()
local entityWorld = GetOffsetFromEntityInWorldCoords(PlayerPedId(), 0.0, 20.0, 0.0)

local rayHandle = CastRayPointToPoint(pos.x, pos.y, pos.z, entityWorld.x, entityWorld.y, entityWorld.z, 10, PlayerPedId(), 0)
local _, _, _, _, vehicleHandle = GetRaycastResult(rayHandle)
local vehicleHandle = GetRaycastResult(rayHandle)
return vehicleHandle
end

Expand All @@ -70,7 +69,6 @@ local function TrunkCam(bool)
end

-- Events

RegisterNetEvent('esx_kidnapping:client:SetKidnapping', function(bool)
isKidnapping = bool
end)
Expand Down Expand Up @@ -207,7 +205,6 @@ RegisterNetEvent('esx-trunk:client:GetIn', function()
end)

-- Threads

CreateThread(function()
while true do
local sleep = 1000
Expand Down
11 changes: 3 additions & 8 deletions server-data/resources/[esx_addons]/esx-radialmenu/fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,17 @@ shared_scripts {

client_scripts {
'locales/*.lua',
'client/main.lua',
'client/clothing.lua',
'client/trunk.lua',
'client/stretcher.lua'
'client/*.lua',
}

server_scripts {
'locales/*.lua',
'server/trunk.lua',
'server/stretcher.lua'
'server/*.lua',
}

files {
'html/index.html',
'html/css/main.css',
'html/js/main.js',
'html/js/RadialMenu.js',
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ RegisterNetEvent('esx-trunk:server:KidnapTrunk', function(targetId, closestVehic
TriggerClientEvent('esx-trunk:client:KidnapGetIn', targetId, closestVehicle)
end)

ESX.RegisterServerCallback('esx-trunk:server:getTrunkBusy', function(src, cb, plate)
ESX.RegisterServerCallback('esx-trunk:server:getTrunkBusy', function(_, cb, plate)
if trunkBusy[plate] then cb(true) return end
cb(false)
end)

ESX.RegisterCommand({"getintrunk"}, 'user', function(xPlayer, args, showError)
ESX.RegisterCommand({"getintrunk"}, 'user', function(xPlayer)
TriggerClientEvent('esx-trunk:client:GetIn', xPlayer.source)
end, false, {help = _U("getintrunk_command_desc")})

ESX.RegisterCommand({"putintrunk"}, 'user', function(xPlayer, args, showError)
ESX.RegisterCommand({"putintrunk"}, 'user', function(xPlayer, args)
TriggerClientEvent('esx-trunk:server:KidnapTrunk', xPlayer.source)
end, false, {help = _U("putintrunk_command_desc")})
14 changes: 7 additions & 7 deletions server-data/resources/[esx_addons]/esx_dmvschool/client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ function OpenDMVSchoolMenu()
end
end

ESX.OpenContext("right", elements, function(menu,element)
ESX.OpenContext("right", elements, function(_, element)
if element.value == "theory_test" then
ESX.TriggerServerCallback('esx_dmvschool:canYouPay', function(haveMoney)
if haveMoney then
Expand All @@ -151,26 +151,26 @@ function OpenDMVSchoolMenu()
end
end, element.type)
end
end, function(menu)
end, function()
CurrentAction = 'dmvschool_menu'
CurrentActionMsg = _U('press_open_menu')
CurrentActionData = {}
end)
end

RegisterNUICallback('question', function(data, cb)
RegisterNUICallback('question', function(_, cb)
SendNUIMessage({
openSection = 'question'
})
cb()
end)

RegisterNUICallback('close', function(data, cb)
RegisterNUICallback('close', function(_, cb)
StopTheoryTest(true)
cb()
end)

RegisterNUICallback('kick', function(data, cb)
RegisterNUICallback('kick', function(_, cb)
StopTheoryTest(false)
cb()
end)
Expand All @@ -183,7 +183,7 @@ AddEventHandler('esx_dmvschool:hasEnteredMarker', function(zone)
end
end)

AddEventHandler('esx_dmvschool:hasExitedMarker', function(zone)
AddEventHandler('esx_dmvschool:hasExitedMarker', function()
CurrentAction = nil
ESX.CloseContext()
end)
Expand Down Expand Up @@ -214,7 +214,7 @@ CreateThread(function()
local playerPed = PlayerPedId()
local coords = GetEntityCoords(playerPed)

for k,v in pairs(Config.Zones) do
for _, v in pairs(Config.Zones) do
local Pos = vector3(v.Pos.x, v.Pos.y, v.Pos.z)
if(v.Type ~= -1 and #(coords - Pos) < Config.DrawDistance) then
sleep = 0
Expand Down
Loading

0 comments on commit 64396a2

Please sign in to comment.