Place Any Object You Want With Item, Without Restarting The Server Or The Scripts. And no DB required
Preview
Preview
Feature
Place Any Object With Items Without Restarting The Scripts
Data Saved Without DB
0.0 Resmon When Idle / 0.2 While Placing Items
Only Player Who Place The Objects or Admin Can Remove The Objects
Dependencies
How to use
Open file server/items.lua
Register Useable Items With Your Framework And Call This Function
TriggerClientEvent('uus_object:client:placeObject', source, propName, itemName)
Example Using QBX
Credit
Big thanks to Joe Szymkowicz who have allowed the use of their code in Gunrack Scripts
1 Like
Linden
February 22, 2024, 1:37pm
2
Be careful with data being sent to your server events.
Check player permissions when saving data, validate the input.
for _, v in ipairs(UUS.ObjectList) do
formatted[#formatted + 1] = Model:format(v.obj, v.coords, v.rot, v.onGround, v.user, v.item)
end
local ret = ('return { \n%s}'):format(table.concat(formatted, '\n'))
GlobalState.uus_object_save_object = UUS.ObjectList
SaveResourceFile(cache.resource, 'data/objectlist.lua', ret, -1)
end)
RegisterNetEvent('uus_object:server:saveObject', function(data)
local mergedData = {}
for _, v in ipairs(UUS.ObjectList) do
mergedData[#mergedData + 1] = {
obj = v.obj,
coords = v.coords,
rot = v.rot,
onGround = v.onGround or false,
user = v.user,
item = v.item
}
Anybody can trigger the removeObject event to give themselves 1 of any item.
lib.addCommand('placeobject', {
help = 'Place an object (Admin Only)',
restricted = 'admin',
params = {
{ name = 'model', help = 'Object model', type = 'string' },
}
}, function(src, args, raw)
TriggerClientEvent('uus_object:client:placeObject', src, args.model)
end)
RegisterNetEvent('uus_object:server:removeObject', function(pos, item)
exports.ox_inventory:AddItem(source, item, 1)
table.remove(UUS.ObjectList, pos)
local Model = [[
{
obj = `%s`,
coords = %s,
rot = %s,
onGround = %s,
user = '%s',
item = '%s'
Thanks for your feedback, I’ll try to improve it later. But maybe I need a little help on how to do the validation, is there a script I can see as an example of validation? Or maybe you can show me a little bit about how to validate? I would be very grateful if you could give me a little idea about how to validate it.
Linden
February 22, 2024, 2:25pm
4
if not IsPlayerAceAllowed(playerId, 'command.placeobject') then return end
That’s enough to stop randoms from arbitrary event exceution.
alright il try to implement that, thankyou so much!
Can you share your ox_inventory?
Hey! Thank you for the release. Does it works with ox inv ? If so do you have a template for it ?