😇
vESX Framework
  • 👋Welcome to vESX
  • Use Cases
    • ðŸ–ĨïļInstallation
    • 👅Inventory
    • ⁉ïļFrequently Asked Questions
  • Converting Scripts
  • Dispatch
    • ðŸĪŠCreate new dispatch
Powered by GitBook
On this page

Converting Scripts

On this page you will learn anything that you need to adapt your old ESX or QBCore/PEPE scripts to vESX in full detail.

Remember to always include es_extended/imports.lua to your fxmanifest in order to remove all citizen threads considering an GetObject request to the core.

QBCore to vESX

RegisterNetEvent('QBCore:Client:OnPlayerLoaded')
AddEventHandler('QBCore:Client:OnPlayerLoaded',
    
RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded',

RegisterNetEvent('QBCore:Client:OnJobUptade')
AddEventHandler('QBCore:Client:OnJobUptade', 

RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob',


QBCore.Functions.DrawText3D(1, 1, 1, 'Text')

DrawText3D(1, 1, 1, 'Text')


QBCore.UI.Menu.Open
QBCore.UI.Menu.CloseAll()

ESX.UI.Menu.Open
ESX.UI.Menu.CloseAll()

OR
Use OX_LIB


QBCore.Functions.Notify('Test', 'error')
ESX.ShowNotification('Test', 'error')


xPlayer.Functions.GetItemByName 
xPlayer.getInventoryItem

xPlayer.Functions.RemoveItem 
xPlayer.removeInventoryItem 

xPlayer.Functions.AddItem
xPlayer.addInventoryItem


QBCore.Functions.GetPlayer(src)

ESX.GetPlayerFromId(src)



QBCore.Functions.SpawnVehicle()
QBCore.Functions.GetVehicleProperties()
QBCore.Functions.GetClosestVehicle()


ESX.Game.SpawnVehicle()
ESX.Game.GetVehicleProperties()
ESX.Game.GetClosestVehicle()
ESX.Game.VehicleInDirection()





QBCore.Functions.GetPlayerData()

ESX.GetPlayerData()


QBCore.Functions.CreateUseableItem()

ESX.RegisterUsableItem()


QBCore.Functions.CreateCallback()

ESX.RegisterServerCallback()
QBCore.Functions.TriggerCallback()

ESX.TriggerServerCallback()



QBCore.Functions.CreateCallback('skillsystem:fetchStatus', function(source, cb)
    local Player = QBCore.Functions.GetPlayer(source)

     if Player then
           exports.oxmysql:execute('SELECT skills FROM players WHERE citizenid = @citizenid', {
               ['@citizenid'] = Player.PlayerData.citizenid
          }, function(status)
              if status ~= nil then
                   cb(json.decode(status))
              else
                   cb(nil)
              end
          end)
     else
          cb()
     end
end)

ESX.RegisterServerCallback("gamz-skillsystem:fetchStatus", function(source, cb)
    local src = source
    local user = ESX.GetPlayerFromId(src)


    local fetch = [[
         SELECT
              skills
         FROM
              users
         WHERE
              identifier = @identifier
    ]]

    exports.oxmysql:execute(fetch, {
         ["@identifier"] = user.identifier -- This returns the user's rockstar license

    }, function(status)

         if status ~= nil then
              cb(json.decode(status))
         else
              cb(nil)
         end

    end)
end)


QBCore.Functions.ExecuteSql()

MySQL.Async.execute()
-- MySQL ORR:
exports.oxmysql:execute()


QBCore.Commands.Add()

RegisterCommand()
PreviousFrequently Asked QuestionsNextDispatch

Last updated 2 years ago