This is a “poster” system designed to allow people to create their own posters and draw them on any vertically flat surface. There are already a few of these systems out there, but I wanted to share a version that is free, and only requires really one dependancy (ox_lib).
This has QBCore code with ox_inventory items, feel free to fork and make your own framework/inventory version, I will not do so for you!
This version does not require you to input any image size data, it is automatically captured by the images url. All you need is a valid image URL. Thats it. The DUI will be created based on the images actual size.
This system is great for “graffiti” tagging, advertising your player owned business, billboards etc.
Dependencies
ox_lib
QBCore
ox_inventory
As I stated above, feel free to rework this how you would like with your own systems. You can even make it framework free.
I was however wondering one thing after looking at the code. From what I saw (might have missed something), you load all DUIs at the same time. Isn’t there some sort of limit on how many can be loaded at the same time?
A few months ago I tried doing something with DUIs that would load them (create DUIs) only when the person was close to the object (using a grid system), but ended up it was lagging (lag spike / freezing and then returning) a lot when creating/destroying DUIs. Is this the reason you keep them all loaded?
Trying to figure out the best optimized way to deal with DUIs overall.
@Tugamars I havent experienced any issues with an exorbitant amount of DUI’s. Essentially I am using them the same as an NUI would. I think there are other factors involved. I do load and create the DUIs for any previously placed poster on player load, but I have not seen any issues with this.
The only crashes I have seen have been via the improper creation of a DUI, and the improper handle being given to a DestroyDUI call. As for FPS, I am using natives to draw them every tick when within radius, but as you can see in my video, FPS is not impacted. Resmon is obviously impacted, but as long as there isnt 50 posters next to each other, using this in a healthy way has not proved to have any downsides.
RegisterNetEvent("posters:addNewImage", function(data)
local Player = QBCore.Functions.GetPlayer(source)
RegisteredSprays[#RegisteredSprays+1] = data
TriggerClientEvent("posters:sendAddedImage", -1, data)
--exports.ox_inventory:RemoveItem(source, "poster", 1)
if not Player then return end
Player.Functions.RemoveItem("poster", 1)
end)
lib.callback.register('posters:getImages', function(source)
return RegisteredSprays
end)
RegisterNetEvent("posters:deleteImage", function(id, isOwner)
local Player = QBCore.Functions.GetPlayer(source)
for k,v in pairs(RegisteredSprays) do
if v.id == id then
table.remove(RegisteredSprays, k)
TriggerClientEvent("posters:deleteClientImage", -1, id)
end
end
if isOwner then
--exports.ox_inventory:AddItem(source, "poster", 1)
if not Player then return end
Player.Functions.AddItem("poster", 1)
end
end)
``` not tested
hi i have this error :C i want help Uncaught TypeError: Cannot read properties of undefined (reading ‘label’) (@qb-inventory/html/js/app.js:1821) i use qb inventory
please i’ve tried everything i know to install this, please could someone assist me with installation. i’m a noob! also thanks to the creator for the script