MaDHouSe79 / mh-cashasitem

The best cash/blackmoney/crypto item script for your qbcore server created by MaDHouSe79.
GNU General Public License v3.0
34 stars 6 forks source link

Inventory Issues #13

Closed KK7130 closed 7 months ago

KK7130 commented 7 months ago

Hello,

I am receiving a bug in the inventory client main.lua for the added in portion around line 727 (local isAllowed(curveh). It is preventing me from opening my inventory at the back of the trunk and bugging out my character and making me unable to get back into the vehicle. If you could help with this I would greatly appreciate it.

MaDHouSe79 commented 7 months ago

check if your vehicle has the right class, cause if you are not a police or albulance, you need to change the class of your vehicle if this is not a cop/ambu vehicle, maby your class is wrong...

KK7130 commented 7 months ago

Is there a way for me to change that all together with the jobs only being allowed to access vehicle storage or does it have to be this way for your mh script to run properly?

On Fri, Dec 8, 2023, 10:03 AM MaDHouSe @.***> wrote:

check if your vehicle has the right class, cause if you are not a police or albulance, you need to change the class of your vehicle if this is not a cop/ambu vehicle, maby your class is wrong...

— Reply to this email directly, view it on GitHub https://github.com/MaDHouSe79/mh-cashasitem/issues/13#issuecomment-1847335886, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEIRDL23OHJ5OLNZ5OSWOX3YIMT4DAVCNFSM6AAAAABAMUO746VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBXGMZTKOBYGY . You are receiving this because you authored the thread.Message ID: @.***>

MaDHouSe79 commented 7 months ago

Question, are you using gta dlc vehicles or modded vehicles?

KK7130 commented 7 months ago

I believe the vehicles I'm having the issue with are regular base gta vehicles and also modded vehicles that have been added into the server. Pretty much all vehicles are experiencing this. That's why I'm wondering if that function is capable of being taken out or if it is needed for the cashasitem script

On Fri, Dec 8, 2023, 10:38 AM MaDHouSe @.***> wrote:

Question, are you using gta dlc vehicles or modded vehicles?

— Reply to this email directly, view it on GitHub https://github.com/MaDHouSe79/mh-cashasitem/issues/13#issuecomment-1847399827, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEIRDLZZZKR433LNSJ27B2TYIMYAPAVCNFSM6AAAAABAMUO746VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBXGM4TSOBSG4 . You are receiving this because you authored the thread.Message ID: @.***>

MaDHouSe79 commented 7 months ago

But you are in the wrong script section asking your question about an inventory error on the wrong place.. This is cashasitem not an inventory, cause i don't know what you use, so beter ask your question on the script where you have issues with, it make it easyer for my to help people out.

KK7130 commented 7 months ago

Well this comes from your script with the cashasitem. In the directions under the qb inventory client main.lua it instructs you to change those specific lines and that is where my error is coming from.

On Fri, Dec 8, 2023, 11:08 AM MaDHouSe @.***> wrote:

But you are in the wrong script section asking your question about an inventory error on the wrong place.. This is cashasitem not an inventory, cause i don't know what you use, so beter ask your question on the script where you have issues with, it make it easyer for my to help people out.

— Reply to this email directly, view it on GitHub https://github.com/MaDHouSe79/mh-cashasitem/issues/13#issuecomment-1847455850, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEIRDL54UAHE7WC4HVGTFWLYIM3QDAVCNFSM6AAAAABAMUO746VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNBXGQ2TKOBVGA . You are receiving this because you authored the thread.Message ID: @.***>

KK7130 commented 7 months ago

inventory client main.lua for the added in portion around line 727 (local can open isAllowed(curveh) is where the error is coming from

RegisterCommand('inventory', function() if IsNuiFocused() then return end if not isCrafting and not inInventory then if not PlayerData.metadata['isdead'] and not PlayerData.metadata['inlaststand'] and not PlayerData.metadata['ishandcuffed'] and not IsPauseMenuActive() then local ped = PlayerPedId() local curVeh = nil local VendingMachine = nil if not Config.UseTarget then VendingMachine = GetClosestVending() end

        if IsPedInAnyVehicle(ped, false) then -- Is Player In Vehicle
            local vehicle = GetVehiclePedIsIn(ped, false)
            CurrentGlovebox = QBCore.Functions.GetPlate(vehicle)
            curVeh = vehicle
            CurrentVehicle = nil
        else
            local vehicle = QBCore.Functions.GetClosestVehicle()
            if vehicle ~= 0 and vehicle ~= nil then
                local pos = GetEntityCoords(ped)
                local dimensionMin, dimensionMax = GetModelDimensions(GetEntityModel(vehicle))
                local trunkpos = GetOffsetFromEntityInWorldCoords(vehicle, 0.0, (dimensionMin.y), 0.0)
                if (IsBackEngine(GetEntityModel(vehicle))) then
                    trunkpos = GetOffsetFromEntityInWorldCoords(vehicle, 0.0, (dimensionMax.y), 0.0)
                end
                if #(pos - trunkpos) < 1.5 and not IsPedInAnyVehicle(ped) then
                    if GetVehicleDoorLockStatus(vehicle) < 2 then
                        CurrentVehicle = QBCore.Functions.GetPlate(vehicle)
                        curVeh = vehicle
                        CurrentGlovebox = nil
                    else
                        QBCore.Functions.Notify(Lang:t('notify.vlocked'), 'error')
                        return
                    end
                else
                    CurrentVehicle = nil
                end
            else
                CurrentVehicle = nil
            end
        end

        if CurrentVehicle then -- Trunk
            local vehicleClass = GetVehicleClass(curVeh)
            local trunkConfig = Config.TrunkSpace[vehicleClass] or Config.TrunkSpace['default']
            if not trunkConfig then return print('Cannot get the vehicle trunk config') end
            local slots = trunkConfig.slots
            local maxweight = trunkConfig.maxWeight
            if not slots or not maxweight then return print('Cannot get the vehicle slots and maxweight') end

            local other = {
                maxweight = maxweight,
                slots = slots,
            }

            if Config.OnlyJobCanOpenJobVehicleTrucks then
                local canOpen = isAllowToOpen(curVeh)
                if canOpen then 
                    TriggerServerEvent("inventory:server:OpenInventory", "trunk", CurrentVehicle, other)
                    OpenTrunk()
                else
                    QBCore.Functions.Notify("No access", "error", 5000)
                end
            else
                TriggerServerEvent("inventory:server:OpenInventory", "trunk", CurrentVehicle, other)
                OpenTrunk()
            end

        elseif CurrentGlovebox then
            TriggerServerEvent('inventory:server:OpenInventory', 'glovebox', CurrentGlovebox)
        elseif CurrentDrop ~= 0 then
            TriggerServerEvent('inventory:server:OpenInventory', 'drop', CurrentDrop)
        elseif VendingMachine then
            local ShopItems = {}
            ShopItems.label = 'Vending Machine'
            ShopItems.items = Config.VendingItem
            ShopItems.slots = #Config.VendingItem
            TriggerServerEvent('inventory:server:OpenInventory', 'shop', 'Vendingshop_' .. math.random(1, 99), ShopItems)
        else
            openAnim()
            TriggerServerEvent('inventory:server:OpenInventory')
        end
    end
end

end, false)

MaDHouSe79 commented 7 months ago

Disable Config.OnlyJobCanOpenJobVehicleTrucks in the config.lua. But i'm going to close this topic, cause you are at the wrong script, i can't help if people ask question on the wrong place, go to the script where you need help.