Hi,
I have a mistake, could you help me!
Captura de pantalla (882)|690x67
v1.2.0 Released
Fixes
- Wait for player to spawn before initialising resource
- Fix leaderboard if no players found
- Fix UI not hiding after timeout
Changes
- Added
esx_xp:ready
event to allow user to wait for resource to be ready for use
AddEventHandler("esx_xp:ready", function(data)
local currentXP = data.xp
local currentRank = data.rank
local xPlayer = data.player
-- esx_xp is ready for use
end)
Links
Can you post line 34
of client/main.lua
so I can see what’s going on?
Add print(jobXP, playerXP)
line before line 34
then restart the resource with ensure esx_joblisting
then access the joblisting and check the console for the printed statement to see which one is nil
.
If jobXP
is nil
, there’s a problem with the Config.LockedJobs
table, if it’s playerXP
then there’s a problem with getting the player’s XP.
OK bro and how can I put so that the required rank is seen and not the required experience in the job table?
For example in the job table it appears: You need 5000XP
I want to put: You need Level 5
Add this to config.lua
Config.LockedJobs = {
airlines = 100, -- rank 100
banker = 10, -- rank 10
banksecurity = 5, -- rank 5
cardealer = 10 -- rank 10
}
Overwrite ShowJobListingMenu()
function in client/main.lua
with this:
function ShowJobListingMenu()
ESX.TriggerServerCallback('esx_joblisting:getJobsList', function(jobs)
local elements = {}
for i=1, #jobs, 1 do
local element = {
label = jobs[i].label,
job = jobs[i].job
}
-- Job requires rank
if Config.LockedJobs[jobs[i].job] ~= nil then
local jobRank = Config.LockedJobs[jobs[i].job]
local playerRank = ESX.GetPlayerData().rank
-- Player doesn't have required rank
if playerRank < jobRank then
element.locked = true
element.rank = jobRank
element.label = jobs[i].label .. ": <span style='color:red;'>You need Level " .. jobRank .. "</span>"
end
end
table.insert(elements, element)
end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'joblisting', {
title = _U('job_center'),
align = 'top-left',
elements = elements
}, function(data, menu)
-- Check if job is rank locked
if data.current.locked then
-- Player doesn't have required rank
ESX.ShowNotification("~r~ERROR: ~w~You require ~b~Level " .. data.current.rank .. " ~w~to get this job!")
else
-- Player has required rank
TriggerServerEvent('esx_joblisting:setJob', data.current.job)
ESX.ShowNotification(_U('new_job'))
menu.close()
end
end, function(data, menu)
menu.close()
end)
end)
end
Thanks bro and sorry for my bad english
Glad I could help. Don’t apologise if it’s not your first language.
Sorry for so much trouble, but I would like to know how to configure a job so that for each delivery you will have experience
You’d need to check each job to see where the delivery is flagged as a success and trigger the event to add XP. You’ll need to check the server-side file for the xPlayer.addMoney()
line and add the event trigger after it:
xPlayer.addMoney(total)
TriggerClientEvent('esx_xp:Add', source, 10000)
Nothing on this?
“How would I go about making this so I can get xp for killing peds? Not just cops but peds overall?”
You’d need to loop through peds and check if they’re dead and if so, see if the cause of death was the player.
So far I’ve been eyeing this script I found here
My draft is looking something like this, I’m calling this .lua as a client script in my esx_xp fxmanifest.lua
If I get this working, it’ll unfortunately only work if they’re shot by me aiming at them but it’s a start.
function deleteEntity(entity)
Citizen.InvokeNative(0xAE3CBE5BF394C9C9, Citizen.PointerValueIntInitialized(entity))
end
function rewards()
aiming, ent = GetEntityPlayerIsFreeAimingAt(PlayerId(), Citizen.ReturnResultAnyway())
local playerPed = PlayerPedId()
if HasEntityBeenDamagedByEntity(targetPed, playerPed, 1) then
if IsEntityAPed(ent) then
if IsEntityDead(ent) then
deleteEntity(ent)
local cash
cash = GetPedMoney(GetPlayerPed(-1))
if type(cash) == "boolean" then
cash = 0
end
Wait(1)
--SetPedMoney(GetPlayerPed(-1), cash + 10)
TriggerClientEvent('esx_xp:Add', source, 100)
PlaySound(-1, "LOCAL_PLYR_CASH_COUNTER_INCREASE", "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS", 0, 0, 1)
end
end
end
Citizen.CreateThread(function()
while true do
Wait(1)
rewards()
end
end)
end
I’m aware this is pretty far off, my actual coding knowledge is incredibly basic
Hi! I posted some issues on Github, along with some things that can solve them.
v1.2.2 Released
Fixes
- Fixed paging error on removing players
- Fixed performance issue when removing players
- Fixed error retrieving current player
- Fixed leaderboard page numbers remaining if pagination isn’t required
Links
Hey bro what is wrong here? im trying to make a passive xp add, it works but console says
SCRIPT ERROR: @esx_xp/client/main.lua:117: attempt to index a nil value (global ‘ESX’)
EDIT: Forget it, i think your script doesnt like restarts
if someone want to do this just add a client lua,
add it on the fxmanifest and put this code on it
– EXP PASIVA –
RegisterNetEvent("esx_xp:updateUI") AddEventHandler("esx_xp:updateUI", function(_xp) CurrentXP = tonumber(_xp) SendNUIMessage({ xpm_set = true, xp = CurrentXP })
end)
PlayerOnlineTime = 0
Citizen.CreateThread(function()
while true do Wait(10000) -- EDIT THIS, DEFAULT IS 10 SECONDS IN MS PlayerOnlineTime = PlayerOnlineTime + 1 if PlayerOnlineTime == 1 then exports('ESXP_Add', ESXP_Add) exports['mythic_notify']:SendAlert('success', '+100 XP') TriggerEvent('esx_xp:Add', 100) PlayerOnlineTime = 0 end end
end)
The easiest way is to require a licence for esx_weaponshop
and check the player’s rank in the license menu.
config.lua
Config.LicenseEnable = true -- enable this
Config.LicensePrice = 5000
Config.LicenseRank = 50 -- add this line
esx_weaponshop/client/main.lua
Find this line:
OpenBuyLicenseMenu(CurrentActionData.zone)
and replace it with this:
if ESX.GetPlayerData().rank >= Config.LicenseRank then
OpenBuyLicenseMenu(CurrentActionData.zone)
else
ESX.ShowNotification("~r~ERROR: ~w~A rank of ~g~".. Config.LicenseRank .. " ~w~is required to purchase a weapon license!")
end
Make sure you’re using esx_license
.
Hello,
maybe my english is bad, hope it can be understood
I have a weaponshop with inventoryhud. how to make several open weapons according to rank.
Config : config.lua (5.6 KB)
Client : main.lua (19.9 KB) shop.lua (10.8 KB).
Server : main.lua (19.6 KB)
Please help, Thank you for taking your time