Skip to content

Cases

Cases is a server side case tracking and opening system built into the bridge for creating case types that can be opened and their possible loots, it also includes all logic for handling cases being opened.

How it works

  1. You create a case type either by editing the ALL_CASES table or by using the exports provided below, with a unique ID and all items with their chances, min and max (you can also override an item image by using the image field).
  2. A player is given a case item with the metadata storing caseId as the cases unique ID.
  3. When the player uses a case, the server with look for available items from the case and pick one based on random weighted math, all item handling is done server side for maximum security.

item chances

All items must add up to the total chance of 100, if they don't, that case will not be usable.

Installation

Add the case item to your inventory resource using the format appropriate for your setup.

Add items listed below to your ox_inventory into data/items.lua.

lua
["case"] = {
    label = "Case",
    weight = 1000
},

Server Exports

CreateCase

Registers a new case type.

lua
exports["prp-bridge"]:CreateCase(caseId, payload)
ParameterTypeDescription
caseIdstringUnique identifier for this case.
payloadCaseDataPayloadConfig (see below).

Returns: boolean

  • true on success
  • false if the case item chances don't sum to 100

GetCase

Gets a case's data based on its unique identifier.

lua
exports["prp-bridge"]:GetCase(caseId)

GetAllCases

Gets all cases currently created.

lua
exports["prp-bridge"]:GetAllCases()

Returns: CaseDataPayload[] containing all registered case types and their items.

Payload

FieldTypeRequiredDescription
labelstringNoThe label of the case type.
itemsCaseItem[]YesAll the possible items in a case.

CaseItem

FieldTypeRequiredDescription
namestringYesThe name of the item in the case total items.
imagestringNoAn overridge image for the item in the case total items.
metadatastringNoAny custom metadata to apply to the item in the case total items.
chancenumberYesThe chance to get the item out of all the case total items.
minnumberNoThe minimum amount of said item you can get.
maxnumberNoThe maximum amount of said item you can get.

Examples

Simple test case example

lua
exports["prp-bridge"]:CreateCase("TEST_CASE", {
    items = {
        {
            name = "money",
            chance = 30,
            min = 300,
            max = 800,
        },
        {
            name = "lockpick",
            chance = 70
        }
    }
})