Common Lua patterns for FiveM resources.
-- QBCore
local Player = QBCore.Functions.GetPlayer(source)
-- ESX
local xPlayer = ESX.GetPlayerFromId(source)-- QBCore
Player.Functions.AddMoney('cash', 100)
-- ESX
xPlayer.addMoney(100)-- Using ox_lib
lib.notify({
title = 'Server',
description = 'Message here',
type = 'success'
})CreateThread(function()
while true do
Wait(1000)
-- Do something
end
end)local lastTime = 0
RegisterNetEvent('myresource:action')
AddEventHandler('myresource:action', function()
local now = GetGameTimer()
if now - lastTime < 1000 then return end
lastTime = now
-- Do action
end)