AKL DOCUMENTATION
  • 👋Introduction
  • GUSTI RESOURCES
    • ⛏️gusti-minerjob
      • Setup
      • Update
    • 🚙gusti-membershipvehicle
    • 🍗gusti-butcherjob
    • 📣gusti-iosnotify
      • Setup
      • Usage
    • 🌐gusti-status server web
      • Setup
    • ⏳gusti-loadscreen
      • Setup
      • Building
    • 💎gusti-vipmenu
      • Setup
    • 🛠️gusti-welderloot
      • Common Issues
      • Setup
    • 🏃‍♂️gusti-boostsprint
      • Setup
    • 🚀gusti-boostfps
    • 📹gusti-cctv
      • Setup
    • 📅gusti-datetime
      • Setup
    • ☢️gusti-radzone
      • Setup
    • 🔫gusti-hidereticle
    • 🚗gusti-givevehicle
      • Setup
      • Usage
    • 💥gusti-duarmemek
      • Setup
      • Usage
  • 🛡️gusti-vipsystem
    • Setup
    • Usage
  • CODE SNIPPETS
    • Fix Animasi
    • Fix Spam Punch
    • Boost Fps
    • Disable Ambient
    • Send Webhook Messages
    • Spawns GTA V Online Train On Fivem
    • Removing / Adding Limit Map
    • Blacklist Name
    • Item Probability
    • Anti Duplicate Vehicle
    • How To Unbind Keys
Powered by GitBook
On this page
  1. CODE SNIPPETS

Item Probability

How to make a probability item system

RegisterNetEvent('gusti-lootcrate:openCrate')
AddEventHandler('gusti-lootcrate:openCrate', function()
    ESX.TriggerServerCallback('gusti-lootcrate:openCrate', function(success)
        if success then
            ESX.ShowNotification('You received an item!')
        else
            ESX.ShowNotification('You cannot carry more items.')
        end
    end)
end)
ESX.RegisterServerCallback('gusti-lootcrate:openCrate', function(source, cb)
    local xPlayer = ESX.GetPlayerFromId(source)
    local item

    local chance = math.random(100)

    if chance <= 50 then
        item = 'legendary_item'
    elseif chance <= 80 then
        item = 'special_item'
    else
        item = 'epic_item'
    end

    if xPlayer.canCarryItem(item, 1) then
        xPlayer.addInventoryItem(item, 1)
        cb(true)
    else
        cb(false)
    end
end)
PreviousBlacklist NameNextAnti Duplicate Vehicle

Last updated 1 year ago