Skip to content

Commit

Permalink
Fixes, Grades
Browse files Browse the repository at this point in the history
[+] Config.Company.allowedGrades
[/] Check fixes
  • Loading branch information
zRxnx committed Jul 8, 2023
1 parent 45e354b commit 16d8fc5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 18 deletions.
35 changes: 22 additions & 13 deletions client/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ OpenMainMenu = function()
end

if Config.Menu.vehicle then
if GetVehiclePedIsIn(cache.ped, false) ~= 0 then
if (DoesEntityExist(cache.vehicle)) and GetPedInVehicleSeat(cache.vehicle, -1) == cache.ped then
MENU[#MENU + 1] = {
title = Strings.veh_title,
description = Strings.veh_desc,
Expand All @@ -60,7 +60,7 @@ OpenMainMenu = function()
end

if Config.Menu.company then
if ESX.PlayerData.job.grade_name == 'boss' then
if IsGradeAllowed() then
MENU[#MENU + 1] = {
title = Strings.company_title,
description = Strings.company_desc,
Expand Down Expand Up @@ -121,7 +121,7 @@ OpenInfoMenu = function()

MENU[#MENU + 1] = {
title = Strings.player_title,
description = (Strings.player_desc):format(SID, GetPlayerName(PlayerId()), PLAYER_DATA.ping),
description = (Strings.player_desc):format(SID, GetPlayerName(cache.playerId), PLAYER_DATA.ping),
arrow = false,
}

Expand Down Expand Up @@ -312,7 +312,7 @@ end

DATA_ENGINE = true
OpenVehicleMenu = function()
if GetVehiclePedIsIn(cache.ped, false) == 0 then
if not (DoesEntityExist(cache.vehicle)) or GetPedInVehicleSeat(cache.vehicle, -1) ~= cache.ped then
OpenMainMenu()
return
end
Expand All @@ -333,13 +333,18 @@ OpenVehicleMenu = function()
arrow = false,
onSelect = function()
if DATA_ENGINE then
SetVehicleEngineOn(vehicle, false, false, false)
SetVehicleUndriveable(vehicle, true)
DATA_ENGINE = false

while not DATA_ENGINE and DoesEntityExist(vehicle) and GetPedInVehicleSeat(vehicle, -1) == cache.ped do
SetVehicleEngineOn(vehicle, false, false, false)
SetVehicleUndriveable(vehicle, true)
Wait()
end
else
DATA_ENGINE = true

SetVehicleEngineOn(vehicle, true, false, false)
SetVehicleUndriveable(vehicle, false)
DATA_ENGINE = true
end
end
}
Expand Down Expand Up @@ -399,7 +404,7 @@ OpenVehicleMenu = function()
end

OpenVehicleExtrasMenu = function()
if GetVehiclePedIsIn(cache.ped, false) == 0 then
if not (DoesEntityExist(cache.vehicle)) or GetPedInVehicleSeat(cache.vehicle, -1) ~= cache.ped then
OpenMainMenu()
return
elseif not Config.CanOpenExtras() then
Expand Down Expand Up @@ -448,7 +453,7 @@ OpenVehicleExtrasMenu = function()
end

OpenVehicleLiveryMenu = function()
if GetVehiclePedIsIn(cache.ped, false) == 0 then
if not (DoesEntityExist(cache.vehicle)) or GetPedInVehicleSeat(cache.vehicle, -1) ~= cache.ped then
OpenMainMenu()
return
end
Expand Down Expand Up @@ -492,7 +497,7 @@ DATA_LIGHTS = {
neon = true
}
OpenVehicleLightsMenu = function()
if GetVehiclePedIsIn(cache.ped, false) == 0 then
if not (DoesEntityExist(cache.vehicle)) or GetPedInVehicleSeat(cache.vehicle, -1) ~= cache.ped then
OpenMainMenu()
return
end
Expand Down Expand Up @@ -568,7 +573,7 @@ DATA_WINDOWS = {
back_right = false
}
OpenVehicleWindowMenu = function()
if GetVehiclePedIsIn(cache.ped, false) == 0 then
if not (DoesEntityExist(cache.vehicle)) or GetPedInVehicleSeat(cache.vehicle, -1) ~= cache.ped then
OpenMainMenu()
return
end
Expand Down Expand Up @@ -689,7 +694,7 @@ DATA_DOORS = {
trunk = false
}
OpenVehicleDoorsMenu = function()
if GetVehiclePedIsIn(cache.ped, false) == 0 then
if not (DoesEntityExist(cache.vehicle)) or GetPedInVehicleSeat(cache.vehicle, -1) ~= cache.ped then
OpenMainMenu()
return
end
Expand Down Expand Up @@ -983,7 +988,7 @@ OpenCompanyMenu = function()
end
StartCooldown()

if ESX.PlayerData.job.grade_name ~= 'boss' then
if not IsGradeAllowed() then
OpenMainMenu()
return
end
Expand Down Expand Up @@ -1134,4 +1139,8 @@ StartCooldown = function()
SetTimeout(Config.Cooldown, function()
COOLDOWN = false
end)
end

IsGradeAllowed = function()
return Config.Company.allowedGrades[ESX.PlayerData.job.grade_name] or false
end
7 changes: 6 additions & 1 deletion configuration/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Config = {}

--| Discord Webhook in 'server/server.lua'
Config.Command = 'personalmenu' --| Command
Config.Key = 'F5' --| Note: its a keyMapping
Config.Key = 'F5' --| Note: Its a keymapping
Config.Cooldown = 3 * seconds --| Note: Only for client > server or server > client | To disable set to 0
Config.Menu = {
informations = true,
Expand All @@ -20,6 +20,11 @@ Config.Company = {
default = {
job = 'unemployed', --| Job when you get fired
grade = 0 --| Job grade when you get fired
},

allowedGrades = { --| grade names for company feature
['boss'] = true,
['co_boss'] = true,
}
}

Expand Down
12 changes: 8 additions & 4 deletions server/functions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Player = {
local xJob = xPlayer.getJob()
local yJob = yTarget.getJob()

if xJob.grade_name ~= 'boss' then
if IsGradeAllowed(xJob) then
return
elseif xJob.name == yJob.name then
Config.Notification(xPlayer.source, (Strings.company_hire_already):format(yTarget.getName()))
Expand All @@ -21,7 +21,7 @@ Player = {
local xJob = xPlayer.getJob()
local yJob = yTarget.getJob()

if xJob.grade_name ~= 'boss' then
if IsGradeAllowed(xJob) then
return
elseif xJob.name == yJob.name then
if ESX.DoesJobExist(Config.Company.default.job, Config.Company.default.grade) then
Expand All @@ -40,7 +40,7 @@ Player = {
local xJob = xPlayer.getJob()
local yJob = yTarget.getJob()

if xJob.grade_name ~= 'boss' then
if IsGradeAllowed(xJob) then
return
elseif xJob.name == yJob.name then
local grade = yJob.grade + 1
Expand All @@ -61,7 +61,7 @@ Player = {
local xJob = xPlayer.getJob()
local yJob = yTarget.getJob()

if xJob.grade_name ~= 'boss' then
if IsGradeAllowed(xJob) then
return
elseif xJob.name == yJob.name then
local grade = yJob.grade - 1
Expand Down Expand Up @@ -156,4 +156,8 @@ end
PunishPlayer = function(player, reason)
DiscordLog(player, 'PUNISH', reason)
DropPlayer(player, reason)
end

IsGradeAllowed = function(job)
return Config.Company.allowedGrades[job.grade_name] or false
end

0 comments on commit 16d8fc5

Please sign in to comment.