Qubit Studios
StoreSupport
  • Hello
  • Support
  • FIVEM SCRIPTS
    • ⚒️Car Crafting
      • Installation & Configuration
    • 🖲️3D Printer
      • Installation & Configuration
    • 💎Honor System
      • Installation & Configuration
      • Usage & Integration
  • REDM SCRIPTS
    • 🚨Native Alert
      • Installation & Configuration
Powered by GitBook
On this page
  • Decrease/Increase Honor Export
  • GetHonorLevel Honor Export

Was this helpful?

  1. FIVEM SCRIPTS
  2. Honor System

Usage & Integration

You can easily integrate the Qubit Honor system into any desired job using the client-side and server-side exports. You can find the exports below.

Client Side Usage
exports['qubit-honorsystem']:IncreaseHonor(amount, reason)
exports['qubit-honorsystem']:DecreaseHonor(amount, reason)
exports['qubit-honorsystem']:GetHonor()
exports['qubit-honorsystem']:GetHonorPercentage()
exports['qubit-honorsystem']:GetHonorLevel()
Server Side Usage
exports['qubit-honorsystem']:IncreaseHonor(source, amount, reason)
exports['qubit-honorsystem']:DecreaseHonor(source, amount, reason)
exports['qubit-honorsystem']:GetHonor(source)
exports['qubit-honorsystem']:GetHonorPercentage(source)
exports['qubit-honorsystem']:GetHonorLevel(source)

Decrease/Increase Honor Export

The "Increase Honor" export is used in both server and client Lua files to increase a user's honor value. Here are a few real usage examples:

Example Script snippet qbx_truckrobbery/client/main.lua

local function lootTruck()
    local looting = true
	CreateThread(function()
        if lib.progressBar({
            duration = config.lootDuration,
            label = locale('info.looting_truck'),
            useWhileDead = false,
            canCancel = true,
            disable = {
                move = true,
                car = true,
                combat = true,
                mouse = false,
            },
            anim = {
                dict = 'anim@heists@ornate_bank@grab_cash_heels',
                clip = 'grab',
                flag = 1,
            },
            prop = {
                model = `prop_cs_heist_bag_02`,
                bone = 57005,
                pos = vec3(0.0, 0.0, -0.16),
                rot = vec3(250.0, -30.0, 0.0),
            }
        }) then
            local success = lib.callback.await('qbx_truckrobbery:server:giveReward')
            -- WE ARE DECREASE HONOR FOR TRUCK ROBBERY ON CLIENT SIDE
            exports['qubit-honorsystem']:DecreaseHonor(500, "BANK TRUCK ROBBED")
            -- exports['qubit-honorsystem']:IncreaseHonor(500, "BANK TRUCK ROBBED")
            if not success then return end
            SetPedComponentVariation(cache.ped, 5, 45, 0, 2)
            resetMission()
        end
        looting = false
    end)
    while looting do
        if #(GetEntityCoords(cache.ped) - GetEntityCoords(truck)) > 6 and lib.progressActive() then
            lib.cancelProgress()
        end
        Wait(1000)
    end
end

Let's do the same example for the server side:

Example Script snippet qbx_truckrobbery/server/main.lua

lib.callback.register('qbx_truckrobbery:server:giveReward', function(source)
    if Entity(truck).state.truckstate ~= TruckState.LOOTABLE then return end
    Entity(truck).state:set('truckstate', TruckState.LOOTED, true)
    local cantCarryRewards = {}
    local cantCarryRewardsSize = 0
    for i = 1, #config.rewards do
        local reward = config.rewards[i]
        if not reward.probability or math.random() <= reward.probability then
            local amount = math.random(reward.minAmount or 1, reward.maxAmount or 1)
            if exports.ox_inventory:CanCarryItem(source, reward.item, amount) then
                exports.ox_inventory:AddItem(source, reward.item, amount)
            else
                cantCarryRewardsSize += 1
                cantCarryRewards[cantCarryRewardsSize] = {reward.item, amount}
            end
        end
    end
    -- WE ARE DECREASE HONOR FOR TRUCK ROBBERY ON SERVER SIDE
    exports['qubit-honorsystem']:DecreaseHonor(source, 500, "BANK TRUCK ROBBED")
    -- exports['qubit-honorsystem']:IncreaseHonor(source, 500, "BANK TRUCK ROBBED")
    if cantCarryRewardsSize > 0 then
        exports.ox_inventory:CustomDrop('Loot', cantCarryRewards, GetEntityCoords(GetPlayerPed(source)))
    end
	exports.qbx_core:Notify(source, locale('success.looted'), 'success')
	return true
end)

GetHonorLevel Honor Export

In this way, we can grant or reduce honor for the user within any profession. Now, for example, we want to adjust the user's earnings based on their honor level. To do this, we will use the GetHonorLevel export and, depending on the level, define what they will receive using the desired variable.

Example Script snippet qbx_truckrobbery/server/main.lua

lib.callback.register('qbx_truckrobbery:server:giveReward', function(source)
    if Entity(truck).state.truckstate ~= TruckState.LOOTABLE then return end
    Entity(truck).state:set('truckstate', TruckState.LOOTED, true)
    local cantCarryRewards = {}
    local cantCarryRewardsSize = 0
    for i = 1, #config.rewards do
        local reward = config.rewards[i]
        if not reward.probability or math.random() <= reward.probability then
            local amount = math.random(reward.minAmount or 1, reward.maxAmount or 1)

	    -- Start Honor Decrease & Change Reward Amount
	    ---- We are maked amount multiplie by the honor level
	    ---- This is to make it so the lower your honor level, the more you get because this job is illegal
	    local currentLevel = exports['qubit-honorsystem']:GetHonorLevel(source)
	    amount = amount * currentLevel.levelData['qbx_truckrobbery:rewardMultiplier']
	    -- End Honor Decrease & Change Reward Amount

            if exports.ox_inventory:CanCarryItem(source, reward.item, amount) then
                exports.ox_inventory:AddItem(source, reward.item, amount)
            else
                cantCarryRewardsSize += 1
                cantCarryRewards[cantCarryRewardsSize] = {reward.item, amount}
            end
        end
    end

    if cantCarryRewardsSize > 0 then
        exports.ox_inventory:CustomDrop('Loot', cantCarryRewards, GetEntityCoords(GetPlayerPed(source)))
    end
	exports.qbx_core:Notify(source, locale('success.looted'), 'success')
	return true
end)

In the example above, I used the GetHonorLevel export to retrieve the user's current level data. This level data includes the following values, which come from config.lua

GetHonorLevel Export Response;

min = 15,
max = 30,
icon = "bad50.png",
title = "NOTORIOUS OUTLAW",
subtitle = "THREAT TO SOCIETY",
levelSoundtrack = "bad50",
levelSoundtrackVolume = 0.2,
levelData = {
    ['qbx_truckrobbery:rewardMultiplier'] = 1.4
}
level = "SlightlyBad"

Here, I created a custom variable inside the levelData variable in config.lua by using the script's name, and I named it rewardMultiplier. You can define anything you want—this value doesn't have to be a number; it can also be an array or a string, depending on what you want to store for a specific job. Then, I set this value to 1.4 in config.lua so that players with the SlightlyBad level will receive 1.4 times more items from this heist. The current config.lua looks like the following:

Config.HonorLevels = { -- based on percentage 0% means - Honor Pool Value like (-10000) - 100% means - Honor Pool Value like (10000)
    VeryBad = {
        min = 0, -- min honor for the honor level
        max = 5, -- min and max honor for the honor level
        icon = "bad100.png", -- icon for the honor level
        title = "THE SCARFACE", -- title for the honor level
        subtitle = "THE WORLD IS YOURS", -- subtitle for the honor level
        levelSoundtrack = "bad100", -- soundtrack for the honor level
        levelSoundtrackVolume = 0.6, -- volume for the honor level
        levelData = {
          -- EXAMPLE: 
          -- ['script_name:variable_name'] = 'value',
        } -- You can add more variables for specific job or script integration
    },
    Bad = {
        min = 5,
        max = 15,
        icon = "bad75.png",
        title = "MOST WANTED",
        subtitle = "MOST DANGEROUS CRIMINAL",
        levelSoundtrack = "bad75",
        levelSoundtrackVolume = 0.2,
        levelData = {
            ['qbx_truckrobbery:rewardMultiplier'] = 1.8
        }
    },
    SlightlyBad = {
        min = 15,
        max = 30,
        icon = "bad50.png",
        title = "NOTORIOUS OUTLAW",
        subtitle = "THREAT TO SOCIETY",
        levelSoundtrack = "bad50",
        levelSoundtrackVolume = 0.2,
        levelData = {
            ['qbx_truckrobbery:rewardMultiplier'] = 1.4
        }
    },
    AlmostNeutral = {
        min = 30,
        max = 50,
        icon = "bad25.png",
        title = "STREET THUG",
        subtitle = "CRIMINAL ACTIVITIES",
        levelSoundtrack = "bad25",
        levelSoundtrackVolume = 0.2,
        levelData = {
            ['qbx_truckrobbery:rewardMultiplier'] = 1.2
        }
    },
    Neutral = {
        min = 50,
        max = 50,
        icon = "zero.png",
        title = "NEUTRAL CITIZEN",
        subtitle = "UNKNOWN REPUTATION",
        levelSoundtrack = nil,
        levelSoundtrackVolume = 0.2,
        levelData = {
            ['qbx_truckrobbery:rewardMultiplier'] = 1.0
        }
    },
    SlightlyGood = {
        min = 50,
        max = 70,
        icon = "good25.png",
        title = "TRUSTED FRIEND",
        subtitle = "GAINING RESPECT",
        levelSoundtrack = "good25",
        levelSoundtrackVolume = 0.3,
        levelData = {
            ['qbx_truckrobbery:rewardMultiplier'] = 0.8
        }
    },
    Good = {
        min = 70,
        max = 85,
        icon = "good50.png",
        title = "RESPECTED CITIZEN",
        subtitle = "VALUED MEMBER OF SOCIETY",
        levelSoundtrack = "good50",
        levelSoundtrackVolume = 0.2,
        levelData = {
            ['qbx_truckrobbery:rewardMultiplier'] = 0.6
        }
    },
    VeryGood = {
        min = 85,
        max = 95,
        icon = "good75.png",
        title = "FAMOUS PERSON",
        subtitle = "WELL-KNOWN IN THE COMMUNITY",
        levelSoundtrack = "good75",
        levelSoundtrackVolume = 0.2,
        levelData = {
            ['qbx_truckrobbery:rewardMultiplier'] = 0.4
        }
    },
    Legendary = {
        min = 95,
        max = 100,
        icon = "good100.png",
        title = "SAINT OF THE CITY",
        subtitle = "YOU ARE A LEGENDARY HERO",
        levelSoundtrack = "good100",
        levelSoundtrackVolume = 0.2,
        levelData = {
            ['qbx_truckrobbery:rewardMultiplier'] = 0.2
        }
    }
}

PreviousInstallation & ConfigurationNextNative Alert

Last updated 2 days ago

Was this helpful?

💎