HEX
JaksamInventorys

Installation

Here you will get the full Installation guide to setup our inventorys with Jaksams creators.

Search Player

To install our Search Player for Jaksams, follow these steps:

Create a folder

Create a folder named hex in your Jaksam resource folder at _modules/search_player

Create a file

Create a file named cl_search_player.lua and sv_search_player.lua inside the hex folder you just created.

Copy code

Copy the Client Search Player code and paste it into the cl_search_player.lua.

local moduleType = "search_player" -- Module category
local moduleName = "hex" -- THIS module name

-- Don't touch, required to appear in in-game settings
Integrations.modules = Integrations.modules or {}
Integrations.modules[moduleType] = Integrations.modules[moduleType] or {}
Integrations[moduleType] = Integrations[moduleType] or {}
Integrations[moduleType][moduleName] = {}
table.insert(Integrations.modules[moduleType], moduleName)

--[[
    You can edit below here
]] 
local function canOpenTarget(ped)
    return IsPedFatallyInjured(ped)
    or IsEntityPlayingAnim(ped, 'dead', 'dead_a', 3)
    or GetPedConfigFlag(ped, 120, true)
    or IsEntityPlayingAnim(ped, 'mp_arresting', 'idle', 3)
    or IsEntityPlayingAnim(ped, 'missminuteman_1ig_2', 'handsup_base', 3)
    or IsEntityPlayingAnim(ped, 'missminuteman_1ig_2', 'handsup_enter', 3)
    or IsEntityPlayingAnim(ped, 'random@mugging3', 'handsup_standing_base', 3)
end

Integrations[moduleType][moduleName].search = function(targetServerId)
    local targetPed = GetPlayerPed(GetPlayerFromServerId(targetServerId))

    if(not canOpenTarget(targetPed)) then
        notifyClient(getLocalizedText("actions:the_player_must_be_handcuffed"))
        return
    end
    
    TriggerServerEvent(Utils.eventsPrefix .. ":hex:searchPlayer", targetServerId)
end

Copy the Server Search Player code and paste it into the sv_search_player.lua.

RegisterNetEvent(Utils.eventsPrefix .. ':hex:searchPlayer', function(targetServerId)
    local playerId = source
    if playerId == targetServerId then return end
    
    local playerCoords = GetEntityCoords(GetPlayerPed(playerId))
    local targetPlayerCoords = GetEntityCoords(GetPlayerPed(targetServerId))
    local distance = #(playerCoords - targetPlayerCoords)
    if distance > 10.0 then return end

    local scriptName = ''

    if GetResourceState('hex_4_inventory') == 'started' then
        scriptName = 'hex_4_inventory'
    end

    if scriptName == '' then
        print("No inventory script found for search_player module.")
        return
    end

    exports[scriptName]:OpenInventory(playerId, {
        id = targetServerId,
        type = "player",
        title = ('Player: %s'):format(GetPlayerName(targetServerId))
    })
end)

Restart Resource

Restart your Jaksam resource to apply the changes.

Open Settings

Open the ingame creator settings go to Modules and change the Search Player to Hex.

Stash

To install our Stash for Jaksams, follow these steps:

Create a folder

Create a folder named hex in your Jaksam resource folder at _modules/stash

Create a file

Create a file named cl_stash.lua and sv_stash.lua inside the hex folder you just created.

Copy code

Copy the Client Stash code and paste it into the cl_stash.lua file.

local moduleType = "stash" -- Module category
local moduleName = "hex" -- THIS module name

-- Don't touch, required to appear in in-game settings
Integrations.modules = Integrations.modules or {}
Integrations.modules[moduleType] = Integrations.modules[moduleType] or {}
Integrations[moduleType] = Integrations[moduleType] or {}
Integrations[moduleType][moduleName] = {}
table.insert(Integrations.modules[moduleType], moduleName)

--[[ You can edit below here ]] 
Integrations[moduleType][moduleName].open = function(type, markerId)
    TriggerServerEvent(Utils.eventsPrefix .. ":hex:openStash", markerId)
end

Copy the Server Stash code and paste it into the sv_stash.lua file.

local hasConvered = {}

-- convert old identifier to new format if not already converted. This is to ensure that old stashes with the same identifier but different markerId's don't conflict with each other.
local function convertToId(identifier, markerId)
    if hasConvered[identifier] then return end

    local id = MySQL.Sync.fetchScalar('SELECT `id` FROM `hex_4_inventory` WHERE `identifier` = @identifier', {
        ['@identifier'] = identifier
    })

    hasConvered[identifier] = true

    if id then
        identifier = identifier .. '_' .. markerId

        MySQL.Sync.execute('UPDATE `hex_4_inventory` SET `identifier` = @newIdentifier WHERE `id` = @id', {
            ['@newIdentifier'] = identifier,
            ['@id'] = id
        })

        Citizen.Wait(500)
    end
end

RegisterNetEvent(Utils.eventsPrefix .. ":hex:openStash", function(markerId)
    local playerId = source
    
    local base = JobsCreator.Markers[markerId]
    if not base or (base.type ~= 'stash' and base.type ~= 'safe') then return end

    local playerJobName = Framework.getPlayerJobName(playerId)
    local jobName = base.jobName

    if jobName ~= playerJobName and jobName ~= 'public_marker' then return end

    convertToId(base.type .. '_' .. jobName, markerId)

    local stashCoords = vector3(tonumber(base.coords.x), tonumber(base.coords.y), tonumber(base.coords.z))
    local playerCoords = GetEntityCoords(GetPlayerPed(playerId))
    local distance = #(playerCoords - stashCoords)
    if distance > (base.scale.x + 0.5) * 2 then return end

    local scriptName = ''

    if GetResourceState('hex_4_inventory') == 'started' then
        scriptName = 'hex_4_inventory'
    end

    if scriptName == '' then
        print("No inventory script found for stash module.")
        return
    end

    local playerJobLabel = Framework.getJobLabel(jobName)

    if jobName == 'public_marker' then
        playerJobLabel = 'Public'
    end

    local label = base.type == 'stash' and 'Stash' or 'Safe'

    exports[scriptName]:OpenInventory(playerId, {
        id = ('%s_%s_%s'):format(base.type, jobName, markerId),
        type = base.type,
        title = ('%s: %s (ID: %s)'):format(label, playerJobLabel, markerId),
        weight = false
    })
end)

Restart Resource

Restart your Jaksam resource to apply the changes.

Open Settings

Open the ingame creator settings go to Modules and change the Stash to Hex.