πConfigurables
Config
Config = {}
-- OXTarget = 'ox_target'
-- QBTarget = 'qb-target'
Config.pedmodel = 's_m_y_cop_01'
Config.locales = {
start_exam_text = 'Do you want to start the weapon license exam?',
exam_started_text = 'The weapon license exam has started. Follow the instructions provided.',
good_day_text = 'Okay, have a good day!',
insufficient_funds_text = 'Sorry, you do not have enough money to take the exam.',
yes_button = 'Yes',
no_button = 'No',
continue_button = 'Continue',
close_button = 'Close',
end_button = 'End conversation',
job_title = 'Weapon License Examiner',
officer_name = 'Officer',
blip_title = 'Weapon license',
cheater = 'Nt filthy cheater (; Greetings from samurai',
recived_weapon_license = 'You have received a weapon license!',
}
Config.framework = "esx" -- or "qbcore" -- if using qbox then still leave at qbcore (;
Config.requiredMoney = 500
Config.moneytype = 'money' -- money type
Config.distance = 10 -- the cheater distance check if a player isnt in this distance and executes a event he gets kicked (;
Config.blip = true
Config.blipsprite = 110
Config.blipcolour = 1
Config.locations = {
vector4(14.4966, -1106.5750, 28.7970, 332.7171),
}
Opensource
RegisterNetEvent('smr:success', function()
local src = source
local playerPed = GetPlayerPed(src)
local playerCoords = GetEntityCoords(playerPed)
if not isPlayerNearAnyLocation(playerCoords) then
DropPlayer(src, Config.locales.cheater) -- Kick the player
return
end
if Config.framework == "qbcore" then
QBCore = exports['qb-core']:GetCoreObject()
local targetPlayer = QBCore.Functions.GetPlayer(src)
if targetPlayer then
local licences = targetPlayer.PlayerData.metadata["licences"]
if licences["weapon"] == false then
licences["weapon"] = true
targetPlayer.Functions.SetMetaData("licences", licences)
TriggerClientEvent('QBCore:Notify', src, Config.locales.recived_weapon_license, 'success')
end
else
TriggerClientEvent('QBCore:Notify', src, "Player not found", 'error')
end
elseif Config.framework == "esx" then
ESX = exports["es_extended"]:getSharedObject()
local xPlayer = ESX.GetPlayerFromId(src)
local identifier = xPlayer.identifier
local licenseType = 'weapon'
MySQL.query('SELECT * FROM user_licenses WHERE owner = ? AND type = ?', {identifier, licenseType}, function(result)
if result[1] then
print('Player already has a weapon license.')
else
MySQL.update('INSERT INTO user_licenses (owner, type) VALUES (?, ?)', {identifier, licenseType}, function(affectedRows)
if affectedRows > 0 then
TriggerClientEvent('esx:showNotification', src, Config.locales.recived_weapon_license)
else
print('Failed to give weapon license.')
end
end)
end
end)
end
end)
RegisterNetEvent('smr:startit', function()
local src = source
local playerPed = GetPlayerPed(src)
local playerCoords = GetEntityCoords(playerPed)
if not isPlayerNearAnyLocation(playerCoords) then
DropPlayer(src, Config.locales.cheater)
return
end
local requiredMoney = Config.requiredMoney
local moneyType = Config.moneytype
if Config.framework == "esx" then
ESX = exports["es_extended"]:getSharedObject()
local xPlayer = ESX.GetPlayerFromId(src)
local money = 0
if moneyType == 'money' then
money = xPlayer.getMoney()
elseif moneyType == 'bank' then
money = xPlayer.getAccount('bank').money
elseif moneyType == 'black_money' then
money = xPlayer.getAccount('black_money').money
end
if money >= requiredMoney then
xPlayer.removeAccountMoney(moneyType, requiredMoney)
TriggerClientEvent('smr:moneyRemoved', src, true)
else
TriggerClientEvent('smr:moneyRemoved', src, false)
end
elseif Config.framework == "qbcore" then
QBCore = exports['qb-core']:GetCoreObject()
local Player = QBCore.Functions.GetPlayer(src)
local money = 0
if moneyType == 'cash' then
money = Player.PlayerData.money['cash']
elseif moneyType == 'bank' then
money = Player.PlayerData.money['bank']
elseif moneyType == 'crypto' then
money = Player.PlayerData.money['crypto']
end
if money >= requiredMoney then
Player.Functions.RemoveMoney(moneyType, requiredMoney)
TriggerClientEvent('smr:moneyRemoved', src, true)
else
TriggerClientEvent('smr:moneyRemoved', src, false)
end
end
end)
Last updated