Skip to content

Latest commit

 

History

History
380 lines (309 loc) · 12.7 KB

File metadata and controls

380 lines (309 loc) · 12.7 KB

https://youtu.be/e1ANBG0ktWU YOUTUBE SETUP VIDEO

https://youtu.be/e1ANBG0ktWU YOUTUBE SETUP VIDEO

https://youtu.be/e1ANBG0ktWU YOUTUBE SETUP VIDEO

https://youtu.be/e1ANBG0ktWU YOUTUBE SETUP VIDEO

ox_inventory redesign

Number 1

QBOX

go to ox_inventory\modules\bridge\qbx\server.lua

and add this functions.

local SteamApiKey = ''
local DiscordBotToken = 'MTQyNzY0NjY5MzgxNzU4MTYxOA.G-kMDT.TyRMbCpdmOCKvSqRsj0f-_8sKkYoOHC2E7T5L0'
local ProfilePhotos = 'discord' -- steam / discord (we recommend discord)

function GetPhoto(src)
    if ProfilePhotos == "discord" then 
        local discord = nil
        local avatar = nil
        for i = 0, GetNumPlayerIdentifiers(src) - 1 do
            local license = GetPlayerIdentifier(src, i)
            if string.sub(license, 1, string.len("discord:")) == "discord:" then
                discord = license
            end
        end
        if discord then
            discord = string.sub(discord, 9, string.len(discord))
            local p = promise.new()
            PerformHttpRequest("https://discordapp.com/api/users/" .. discord, function(statusCode, data)
                if statusCode == 200 then
                    data = json.decode(data or "{}")
                    if data.avatar then
                        local animated = data.avatar:gsub(1, 2) == "a_"

                        avatar = "https://cdn.discordapp.com/avatars/" ..
                            discord .. "/" .. data.avatar .. (animated and ".gif" or ".png")
                    end
                end
                p:resolve()
            end, "GET", "", {
                Authorization = "Bot " .. DiscordBotToken
            })
            Citizen.Await(p)
        end
        local resultAvatar = avatar or nil
        return resultAvatar
    elseif ProfilePhotos == "steam" then
        local hex = tonumber(string.gsub(GetPlayerIdentifier(src, 0), 'steam:', ''), 16)
        local avatar = nil
        if hex then
            local p = promise.new()
            PerformHttpRequest('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=' .. SteamApiKey .. '&steamids=' .. hex, function(error, result)
                local result = json.decode(result)
                avatar = result.response.players[1].avatarfull
                p:resolve()
            end)
            Citizen.Await(p)
        end
        local resultAvatar = avatar or nil
        return resultAvatar
    else
        return nil
    end     
end

lib.callback.register('ox_inventory:getPlayerServerDatas', function(source)
    local src = source
    local player = QBX:GetPlayer(src)
    local photo = GetPhoto(src)

    local cash = player.Functions.GetMoney('cash')
    local bank = player.Functions.GetMoney('bank')

    local returnData = {
        name = ('%s %s.'):format(player.PlayerData.charinfo.firstname, string.sub(player.PlayerData.charinfo.lastname, 1, 1)),
        source = src,
        photo = photo,
        bank = bank,
        cash = cash,
    }

    return returnData
end)

ESX

go to ox_inventory\modules\bridge\esx\server.lua

and add this functions.

local SteamApiKey = ''
local DiscordBotToken = 'MTQyNzY0NjY5MzgxNzU4MTYxOA.G-kMDT.TyRMbCpdmOCKvSqRsj0f-_8sKkYoOHC2E7T5L0'
local ProfilePhotos = 'discord' -- steam / discord (we recommend discord)

function GetPhoto(src)
    if ProfilePhotos == "discord" then 
        local discord = nil
        local avatar = nil
        for i = 0, GetNumPlayerIdentifiers(src) - 1 do
            local license = GetPlayerIdentifier(src, i)
            if string.sub(license, 1, string.len("discord:")) == "discord:" then
                discord = license
            end
        end
        if discord then
            discord = string.sub(discord, 9, string.len(discord))
            local p = promise.new()
            PerformHttpRequest("https://discordapp.com/api/users/" .. discord, function(statusCode, data)
                if statusCode == 200 then
                    data = json.decode(data or "{}")
                    if data.avatar then
                        local animated = data.avatar:gsub(1, 2) == "a_"

                        avatar = "https://cdn.discordapp.com/avatars/" ..
                            discord .. "/" .. data.avatar .. (animated and ".gif" or ".png")
                    end
                end
                p:resolve()
            end, "GET", "", {
                Authorization = "Bot " .. DiscordBotToken
            })
            Citizen.Await(p)
        end
        local resultAvatar = avatar or nil
        return resultAvatar
    elseif ProfilePhotos == "steam" then
        local hex = tonumber(string.gsub(GetPlayerIdentifier(src, 0), 'steam:', ''), 16)
        local avatar = nil
        if hex then
            local p = promise.new()
            PerformHttpRequest('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=' .. SteamApiKey .. '&steamids=' .. hex, function(error, result)
                local result = json.decode(result)
                avatar = result.response.players[1].avatarfull
                p:resolve()
            end)
            Citizen.Await(p)
        end
        local resultAvatar = avatar or nil
        return resultAvatar
    else
        return nil
    end     
end

lib.callback.register('ox_inventory:getPlayerServerDatas', function(source)
    local src = source
    local player = ESX.GetPlayerFromId(src)
    local photo = GetPhoto(src)

    local cash = player.getAccount("money").money
    local bank = player.getAccount("bank").money

    local returnData = {
        name = player.getName(),
        source = src,
        photo = photo,
        bank = bank,
        cash = cash,
    }

    return returnData
end)

QBCore

go to ox_inventory\modules\bridge\qb\server.lua

and add this functions.

local SteamApiKey = ''
local DiscordBotToken = 'MTQyNzY0NjY5MzgxNzU4MTYxOA.G-kMDT.TyRMbCpdmOCKvSqRsj0f-_8sKkYoOHC2E7T5L0'
local ProfilePhotos = 'discord' -- steam / discord (we recommend discord)

function GetPhoto(src)
    if ProfilePhotos == "discord" then 
        local discord = nil
        local avatar = nil
        for i = 0, GetNumPlayerIdentifiers(src) - 1 do
            local license = GetPlayerIdentifier(src, i)
            if string.sub(license, 1, string.len("discord:")) == "discord:" then
                discord = license
            end
        end
        if discord then
            discord = string.sub(discord, 9, string.len(discord))
            local p = promise.new()
            PerformHttpRequest("https://discordapp.com/api/users/" .. discord, function(statusCode, data)
                if statusCode == 200 then
                    data = json.decode(data or "{}")
                    if data.avatar then
                        local animated = data.avatar:gsub(1, 2) == "a_"

                        avatar = "https://cdn.discordapp.com/avatars/" ..
                            discord .. "/" .. data.avatar .. (animated and ".gif" or ".png")
                    end
                end
                p:resolve()
            end, "GET", "", {
                Authorization = "Bot " .. DiscordBotToken
            })
            Citizen.Await(p)
        end
        local resultAvatar = avatar or nil
        return resultAvatar
    elseif ProfilePhotos == "steam" then
        local hex = tonumber(string.gsub(GetPlayerIdentifier(src, 0), 'steam:', ''), 16)
        local avatar = nil
        if hex then
            local p = promise.new()
            PerformHttpRequest('http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=' .. SteamApiKey .. '&steamids=' .. hex, function(error, result)
                local result = json.decode(result)
                avatar = result.response.players[1].avatarfull
                p:resolve()
            end)
            Citizen.Await(p)
        end
        local resultAvatar = avatar or nil
        return resultAvatar
    else
        return nil
    end     
end

lib.callback.register('ox_inventory:getPlayerServerDatas', function(source)
    local src = source
    local player = QBCore.Functions.GetPlayer(src)

    local cash = player.Functions.GetMoney('cash')
    local bank = player.Functions.GetMoney('bank')

    local returnData = {
        name = ('%s %s'):format(player.PlayerData.charinfo.firstname, player.PlayerData.charinfo.lastname),
        source = src,
        photo = GetPhoto(src),
        bank = bank,
        cash = cash,
    }

    return returnData
end)

Number 2

go to ox_inventory\client.lua

add functions under this local playerPed = cache.ped ;

local preView = nil 

local function DrawPedToScreen(ped, draw)
    if draw == nil then draw = 0 end
    CreateThread(function()
        SetFrontendActive(true)

        ActivateFrontendMenu(GetHashKey("FE_MENU_VERSION_EMPTY_NO_BACKGROUND"), false, -1)
        Wait(100)
        SetMouseCursorVisibleInMenus(false)

        local Male = GetHashKey("mp_m_freemode_01") local Female = GetHashKey("mp_f_freemode_01")
        local modelFinal
        if GetEntityModel(ped) == Male then modelFinal = "mp_m_freemode_01" elseif GetEntityModel(ped) == Female then modelFinal = "mp_f_freemode_01" else return false end

        PlayerPedPreview = CreatePed(2, modelFinal, 0, 0, 0, 0, false, true)
        ClonePedToTarget( ped, PlayerPedPreview)

        FreezeEntityPosition(PlayerPedPreview, true)
        SetEntityVisible(PlayerPedPreview, false, false)
        NetworkSetEntityInvisibleToNetwork(PlayerPedPreview, false)

        Wait(200)
        SetPedAsNoLongerNeeded(PlayerPedPreview)
        GivePedToPauseMenu(PlayerPedPreview, draw)
        SetPauseMenuPedLighting(true)
        SetPauseMenuPedSleepState(true)
        ReplaceHudColourWithRgba(117, 0, 0, 0, 0)
        preView = PlayerPedPreview
    end)
end

local function DeleteDrawedPed()
    SetFrontendActive(false)
    DeleteEntity(preView)
end

local function RefreshPedScreen()
    Citizen.CreateThread(function()
        if DoesEntityExist(preView) then
            Wait(3000)
            DeleteDrawedPed()
            Wait(50)
            if inInventory then
                DrawPedToScreen(PlayerPedId(), 0)
            end
        end
    end)
end

and search;

function client.openInventory(inv, data)

under this add;

lib.callback('ox_inventory:getPlayerServerDatas', false, function(plyData)
	SendNUIMessage({
		action = 'updatePlayerDatas',
		data = plyData
	})
end)

and search;

function client.closeInventory(server)

and add this;

DeleteDrawedPed()

and search;

if not currentInventory.coords and not inv == 'container' then

and add this;

DrawPedToScreen(PlayerPedId(), 0)

Number 3

delete your build folder from ox_inventory\web and go to ox_inv_redesign\web and add our build file at ox_inv_redesign\web

for configuration and translate you can edit build\config.json

Number 4 (Last)

go to fxmanifest.lua and

change this;

client_script 'init.lua'

to this:

client_scripts {
    'init.lua',
    'modules/clothing/functions.lua',
    'modules/clothing/variations.lua',
    'modules/clothing/data.lua',
    'modules/clothing/**.lua'
}

and change "files" to this:

files {
    'client.lua',
    'server.lua',
    'locales/*.json',
    'web/build/index.html',
    'web/build/assets/*.js',
    'web/build/assets/*.css',
    'web/build/assets/*.png',
    'web/images/*.png',
    'web/build/config.json',
    'modules/**/shared.lua',
    'modules/**/client.lua',
    'modules/bridge/**/client.lua',
    'data/*.lua',
}

also add this to your server.cfg for qb-core

setr inventory:framework "qb"