DocumentationGuidesItem Use Effect

Goal

Add a coffee item that boosts player sprint speed for one minute.

Define the item

['coffee'] = {
  label = 'Coffee',
  weight = 200,
  stack = true,
  close = true,
  description = 'Keeps you awake'
}

Register use effect

local QBCore = exports['qb-core']:GetCoreObject()
 
QBCore.Functions.CreateUseableItem('coffee', function(source, item)
  TriggerClientEvent('tutorial:drinkCoffee', source)
end)
RegisterNetEvent('tutorial:drinkCoffee', function()
  local player = PlayerPedId()
  SetRunSprintMultiplierForPlayer(PlayerId(), 1.1)
  Wait(60000)
  SetRunSprintMultiplierForPlayer(PlayerId(), 1.0)
end)

Verification

  • Use coffee from inventory; sprint speed increases
  • After 60s, speed returns to normal

See also

Next steps

Combine with NUI forms or Permissions.