[DISCONTINUED] esx-kr-bag-inventory


Results nothing happening just uses the item

now you have to press F5

Yeah, forgot to say that maybe i should put it in the readme :joy:

1 Like

set key for exemple F4 in client and test

Yea lmao 100% Should its also my fault I should of read the script itself lmao, but hey I’ma add a notification when its used to notify them of pressing the specified key to open the bag.

Alright!

everything is good with the new version, thanks a lot !!!

No problem, enjoy man.

Is there a way to make it so everyone can pick up a dropped bag and look into it? I feel it may be useful when sending someone to jail for cops to search the bag.

Have you even tried the script??

How to limit items in the bag?

Add another Trigger for a button press and add a button to search the box in the 3dtext for example Press F9 to search then when F9 is pressed do the exact same thing as the take out trigger does.

You’ll have to make a new column which says “itemcount” etc. And when you put a item the itemcount is being added with 1. Also have to check the value of “itemcount” like if result[1].itemcount <= 5 then

to be honest i know what do you mean, but im to newbie to do something like this…

:warning:This Code has been implemented in the official release of this resource now:warning:
Done some testing

Issues & Some Additions

Issues:

  • Duplicating Bags When you have a bag and drop it then restart the resource it duplicates the bag and spawns another one on the ground and gives you one back. (Not sure how you’d fix it)

Addition:

  • Searching Bags Without picking them up
  • Added Notification on how to acces your bag when you use the bag.
    Just add
    TriggerClientEvent('esx:showNotification', source, 'Press ~b~[KEY]~w~ to access your bag.')
    on line 8 in server.lua

How to set up searching the bags
Change line 321-356 to this in your client.lua

Citizen.CreateThread(function()
    while true do

        local wait = 500

            for i=1, #Bags, 1 do

                local playercoords = GetEntityCoords(PlayerPedId())

                if GetDistanceBetweenCoords(playercoords, Bags[i].id.coords.x, Bags[i].id.coords.y, Bags[i].id.coords.z, true) <= 1.5 and not HasBag then

                    wait = 5
                    Draw3DText(Bags[i].id.coords.x, Bags[i].id.coords.y, Bags[i].id.coords.z + 0.45, '~g~[E]~w~ to pick up the bag')
                    Draw3DText(Bags[i].id.coords.x, Bags[i].id.coords.y, Bags[i].id.coords.z + 0.35, '~o~[N]~w~ to Search bag')
             
                        if IsControlJustReleased(0, Keys['E']) then
                            HasBag = true
                            BagId = Bags[i].id.id
                            local Bag = GetClosestObjectOfType(Bags[i].id.coords.x, Bags[i].id.coords.y, Bags[i].id.coords.z, 1.5, 1626933972, false, false, false)
    
                                NetworkFadeOutEntity(Bag, false, false)
                                DeleteObject(Bag)
                         
                                TriggerServerEvent('esx-kr-bag:PickUpBag', Bags[i].id.id)
                        end
                    if IsControlJustReleased(0, Keys['N']) then
                            HasBag = false
                            BagId = Bags[i].id.id
                            TakeItem()

                        end
                    end
                end
            Citizen.Wait(wait)
        end
    end)

Its seriously so easy to implement but hey incase your lazy
Did This Help you? And are you going to use this? (Drop a like show some love :wink: :heart: )

  • Yes
  • No

0 voters

5 Likes

amazing script…

Thanks you my friend for all the great ideas. I have now implemented all the code snippets.

If anyone else have any other idea to make the script better, feel free to write it here.

And for the duplication part, i only this it’s the model, am i right? Because you can’t really pick it up again. And it’s not really made to restart mid-game. Anyways there are some simple solutions for it ex, storing all the bags in a variable which can on resouce stop delete all the entites with the variable. I could also load in all the positons from Bag = {} and find all the objects there though and then delete them all.