Skip to content

Commit

Permalink
Update 1.0.2 - Added a command for specific jobs to be able to sell i…
Browse files Browse the repository at this point in the history
…nsurances far from the NPC.
  • Loading branch information
Muhaddil committed Oct 15, 2024
1 parent d6e39e2 commit 2fba7fe
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 2 deletions.
47 changes: 46 additions & 1 deletion client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,51 @@ AddEventHandler('muhaddil_insurances:insurance:buy', function(data)
TriggerServerEvent('muhaddil_insurances:insurance:buy', data, accountType)
end)

RegisterCommand('checkInsurance', function()
local playerId = GetPlayerServerId(PlayerId())
local jobName = nil

local allowedJobs = Config.CheckInsuranceCommandJob

if Config.FrameWork == "esx" then
ESX.TriggerServerCallback('esx:getPlayerData', function(playerData)
jobName = playerData.job.name
local hasAccess = false

for _, job in ipairs(allowedJobs) do
if job == jobName then
hasAccess = true
break
end
end

if hasAccess then
TriggerEvent('muhaddil_insurances:checkInsurance')
else
Notify("Acceso denegado", "No tienes el trabajo adecuado para acceder a esta función.", 5000, "error")
end
end, playerId)
elseif Config.FrameWork == "qb" then
local PlayerData = QBCore.Functions.GetPlayerData()
jobName = PlayerData.job.name
local hasAccess = false

for _, job in ipairs(allowedJobs) do
if job == jobName then
hasAccess = true
break
end
end

if hasAccess then
TriggerEvent('muhaddil_insurances:checkInsurance')
else
Notify("Acceso denegado", "No tienes el trabajo adecuado para acceder a esta función.", 5000, "error")
end
end
end)


RegisterNetEvent('muhaddil_insurances:checkInsurance')
AddEventHandler('muhaddil_insurances:checkInsurance', function()
if CanAccessInsurance() then
Expand Down Expand Up @@ -201,7 +246,7 @@ function CanSellDiscountInsurance()
return true
end
end

return false
end
end
Expand Down
1 change: 1 addition & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Config.OnlyAllowedJobs = false -- Enable or disable restricted access to the ins
Config.AllowedJobs = {"ambulance", "police", "safd"} -- List of allowed jobs. Only these jobs can access the insurance menu when 'OnlyAllowedJobs' is set to true.
Config.DiscountJobs = { "ambulance" } -- List of jobs that are allowed to sell insurance at a discounted rate.
Config.UseDiscounts = true -- Setting this to true allows players (with specified jobs) to sell insurance at a discounted rate.
Config.CheckInsuranceCommandJob = {"ambulance" }

Config.BlipLabel = 'Seguros Médicos' -- The label displayed for the blip on the map, indicating the location of medical insurance services.
Config.ShowBlip = true -- Enable or disable the display of the blip on the map. If 'true', the blip will be shown; if 'false', it will be hidden.
Expand Down
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ lua54 'yes'

author 'Muhaddil'
description 'Simple Medical Insurance Script'
version 'v1.0.1'
version 'v1.0.2'

shared_script 'config.lua'
client_script 'client.lua'
Expand Down

0 comments on commit 2fba7fe

Please sign in to comment.