Skip to content

Commit

Permalink
Update 1.0.3 - Introduced a broad set of new configuration options to…
Browse files Browse the repository at this point in the history
… enhance user experience and provide greater customization
  • Loading branch information
Muhaddil committed Oct 19, 2024
1 parent 2fba7fe commit 786d4f8
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 23 deletions.
39 changes: 19 additions & 20 deletions client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ end

CreateThread(function()
for k, v in pairs(Config.Locations["insurances"]) do
TargetingBoxZone("insurances" .. k, v, 3.5, 2, 2,
TargetingBoxZone("insurances" .. k, v, Config.ZoneSize, Config.ZoneHeight, Config.ZoneDepth,
{
type = "client",
icon = "fa fa-clipboard",
icon = Config.TargetIcon,
event = "muhaddil_insurances:checkInsurance",
label = 'Seguros Médicos',
label = Config.ZoneLabel or 'Seguros Médicos',
}
)
end
Expand All @@ -99,22 +99,22 @@ Citizen.CreateThread(function()
return
end

RequestModel("s_m_m_doctor_01")
while not HasModelLoaded("s_m_m_doctor_01") do
RequestModel(Config.PedModel)
while not HasModelLoaded(Config.PedModel) do
Wait(0)
end

for _, spawnPosition in ipairs(Config.Locations["insurances"]) do
local heading = spawnPosition.w

local insurancePed = CreatePed(4, GetHashKey("s_m_m_doctor_01"), spawnPosition.x, spawnPosition.y,
local insurancePed = CreatePed(4, GetHashKey(Config.PedModel), spawnPosition.x, spawnPosition.y,
spawnPosition.z - 1.0,
heading, false, true)
SetEntityAsMissionEntity(insurancePed, true, true)
SetBlockingOfNonTemporaryEvents(insurancePed, true)
SetEntityInvincible(insurancePed, true)
FreezeEntityPosition(insurancePed, true)
SetModelAsNoLongerNeeded("s_m_m_doctor_01")
SetModelAsNoLongerNeeded(Config.PedModel)

table.insert(insurancePeds, insurancePed)
end
Expand All @@ -123,7 +123,7 @@ Citizen.CreateThread(function()
end

while true do
Citizen.Wait(5000)
Citizen.Wait(Config.PedSpawnCheckInterval)

if not insurancePedsSpawned then
SpawnInsurancePeds()
Expand All @@ -133,7 +133,7 @@ Citizen.CreateThread(function()
for _, insurancePed in ipairs(insurancePeds) do
local insurancePedCoords = GetEntityCoords(insurancePed)
local distance = #(playerCoords - insurancePedCoords)
if distance < 2.0 then
if distance < Config.PedInteractionDistance then
isNearInsurancePed = true
end
end
Expand All @@ -145,10 +145,10 @@ CreateThread(function()
for _, location in ipairs(Config.Locations["insurances"]) do
local x, y, z = table.unpack(location)
local blip = AddBlipForCoord(x, y, z)
SetBlipSprite(blip, 408)
SetBlipSprite(blip, Config.BlipSprite)
SetBlipAsShortRange(blip, true)
SetBlipScale(blip, 0.8)
SetBlipColour(blip, 0)
SetBlipScale(blip, Config.BlipScale)
SetBlipColour(blip, Config.BlipColour)
BeginTextCommandSetBlipName("STRING")
AddTextComponentString(Config.BlipLabel)
EndTextCommandSetBlipName(blip)
Expand Down Expand Up @@ -183,7 +183,7 @@ RegisterCommand('checkInsurance', function()
if hasAccess then
TriggerEvent('muhaddil_insurances:checkInsurance')
else
Notify("Acceso denegado", "No tienes el trabajo adecuado para acceder a esta función.", 5000, "error")
Notify(Config.AccessDeniedTitle, Config.AccessDeniedMessage, Config.NotificationDuration, "error")
end
end, playerId)
elseif Config.FrameWork == "qb" then
Expand All @@ -201,12 +201,11 @@ RegisterCommand('checkInsurance', function()
if hasAccess then
TriggerEvent('muhaddil_insurances:checkInsurance')
else
Notify("Acceso denegado", "No tienes el trabajo adecuado para acceder a esta función.", 5000, "error")
Notify(Config.AccessDeniedTitle, Config.AccessDeniedMessage, Config.NotificationDuration, "error")
end
end
end)


RegisterNetEvent('muhaddil_insurances:checkInsurance')
AddEventHandler('muhaddil_insurances:checkInsurance', function()
if CanAccessInsurance() then
Expand All @@ -222,7 +221,7 @@ AddEventHandler('muhaddil_insurances:checkInsurance', function()
end, playerId)
end
else
Notify("Acceso denegado", "No tienes el trabajo adecuado para acceder a esta función.", 5000, "error")
Notify(Config.AccessDeniedTitle, Config.AccessDeniedMessage, Config.NotificationDuration, "error")
end
end)

Expand Down Expand Up @@ -279,17 +278,17 @@ AddEventHandler('muhaddil_insurances:insurance:buyDiscount', function(data)
if not hasUsedDiscount then
local closestPlayer, closestDistance = GetClosestPlayer()

if closestPlayer ~= -1 and closestDistance <= 3.0 then
if closestPlayer ~= -1 and closestDistance <= Config.DiscountInteractionDistance then
local targetPlayerId = GetPlayerServerId(closestPlayer)
local accountType = Config.Account

TriggerServerEvent('muhaddil_insurances:insurance:buy', data, accountType, targetPlayerId)
hasUsedDiscount = true
Notify("Descuento aplicado", "Has vendido un seguro con descuento al jugador más cercano.", 5000, "success")
Notify(Config.DiscountAppliedTitle, Config.DiscountAppliedMessage, Config.NotificationDuration, "success")
else
Notify("Error", "No hay ningún jugador cerca para aplicar el descuento.", 5000, "error")
Notify(Config.ErrorTitle, Config.NoPlayerNearbyMessage, Config.NotificationDuration, "error")
end
else
Notify("Descuento ya utilizado", "Ya has usado el descuento para esta sesión.", 5000, "error")
Notify(Config.DiscountAlreadyUsedTitle, Config.DiscountAlreadyUsedMessage, Config.NotificationDuration, "error")
end
end)
28 changes: 27 additions & 1 deletion config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,36 @@ 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.CheckInsuranceCommandJob = { "ambulance" } -- List of jobs allowed to use the command to check insurance status.
Config.DiscountInteractionDistance = '3.0' -- The maximum distance at which players can interact with another player to apply discounts.

Config.PeriodicallyDeleteInsurance = '3600000' -- The interval (in milliseconds) at which expired insurances will be cleaned from the database.

Config.TargetIcon = 'fa fa-clipboard' -- The icon used for the targeting box when interacting with insurance locations.
Config.ZoneLabel = 'Seguros Médicos' -- The label displayed for the insurance interaction zone.
Config.ZoneSize = '3.5' -- The size of the interaction zone for ox_target.
Config.ZoneHeight = '2' -- The height of the interaction zone for ox_target.
Config.ZoneDepth = '2' -- The depth of the interaction zone for ox_target.

Config.PedModel = 's_m_m_doctor_01' -- The model used for the insurance NPCs.
Config.PedSpawnCheckInterval = '5000' -- The interval (in milliseconds) at which the script checks if insurance NPCs need to be spawned.
Config.PedInteractionDistance = '2.0' -- The distance at which players can interact with the insurance NPCs.

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.
Config.BlipSprite = '408' -- The sprite ID for the blip, determining its appearance on the map.
Config.BlipScale = '0.8' -- The scale of the blip on the map.
Config.BlipColour = '0' -- The color of the blip on the map.

Config.AccessDeniedTitle = 'Acceso Denegado' -- The title displayed in notifications when access to a feature is denied.
Config.AccessDeniedMessage = 'No tienes el trabajo adecuado para acceder a esta función.' -- The message displayed in notifications when access to a feature is denied.
Config.NotificationDuration = '5000' -- The duration (in milliseconds) for which notifications are displayed.
Config.DiscountAppliedTitle = 'Descuento aplicado' -- The title displayed in notifications when a discount is successfully applied.
Config.DiscountAppliedMessage = 'Has vendido un seguro con descuento al jugador más cercano.' -- The message displayed in notifications when a discount is successfully applied.
Config.ErrorTitle = 'Error' -- The title displayed in error notifications.
Config.NoPlayerNearbyMessage = 'No hay ningún jugador cerca para aplicar el descuento.' -- The message displayed when there are no players nearby to apply a discount.
Config.DiscountAlreadyUsedTitle = 'Descuento ya utilizado' -- The title displayed when a player tries to use a discount they have already used.
Config.DiscountAlreadyUsedMessage = 'Ya has usado el descuento para esta sesión.' -- The message displayed when a player tries to use a discount they have already used.

Config.AutoRunSQL = true -- Enable or disable automatic integration of the SQL table needed for this script.
Config.AutoVersionChecker = true -- Enable or disable the automatic version checker. If 'true', it will check for updates and warn you if the script isn't up to date.
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.2'
version 'v1.0.3'

shared_script 'config.lua'
client_script 'client.lua'
Expand Down
2 changes: 1 addition & 1 deletion server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ end

Citizen.CreateThread(function()
while true do
Wait(3600000)
Wait(Config.PeriodicallyDeleteInsurance)
cleanExpiredInsurances()
end
end)
Expand Down

0 comments on commit 786d4f8

Please sign in to comment.