[FREE] [STANDALONE] Case Opening

Hi!

I created a highly customizable case opening resource.

How to use
The resource can be triggered using a server-event
Server Script example

TriggerEvent("case_opening:server:openCase","caseID",playerID)
RegisterNetEvent("case_opening:server:getReward",function(reward)
    print("Yay! I won",reward)
end)

Video

Screenshot > Config

Github
If you want to work around with it, I uploaded it to github.

1 Like

cant wait to fuel gambling addictions :laughing:

1 Like

How do I make this so it can be used as an item?

i would download this 100% if you make it has an item to trigger instead of a command
btw looks rly good

I updated the repo on github, so please make sure to download the latest one.

This specific code is for ESX. But you can modify it for your framework.
All you have to do is put this code into any server script.

ESX.RegisterUsableItem("item - change it",function(source)
    local source = source 
    local xPlayer = ESX.GetPlayerFromId(source)

    xPlayer.removeInventoryItem("item - change it",1)

    TriggerEvent("case_opening:server:openCase","caseId - change it",source)
end)

RegisterNetEvent("case_opening:server:getReward",function(reward, playerId)
    -- reward is the prizeID, in the example config it's the 15k_cash, 50k_cash etc..
    -- playerId is the ID of the player, you can use it to give out the reward
end)

The command part in the video was used for debugging. It’s not in the published code.

1 Like

Check the reply below your message.

Can you also do it as a QB item?

Yes! All you have to do is modify the ESX example a little, this snippet below should do the trick.

QBCore.Functions.CreateUseableItem("ITEM - CHANGE IT", function(source)
    local src = source
    local Player = QBCore.Functions.GetPlayer(src)

    Player.Functions.RemoveItem("ITEM - CHANGE IT", 1)

    TriggerEvent("case_opening:server:openCase","caseId - CHANGE IT",src)
end)