First you need to be sure that you run your server with the cayo perico version minimum to be able to spawn the prop.
this idea of making this script doesn’t come from me but from a good friend “ridesim” who told me to do that so here we go.
We know that people can just stream it and use, but yeah here is another way of doing it.
Preview with 2 instance :
RegisterCommand('faggio', function(source, args, rawCommand)
local player = PlayerPedId();
local x,y,z = table.unpack(GetOffsetFromEntityInWorldCoords(player, 0.0, 8.0, 0.5));
local vehiclehash <const> = GetHashKey("faggio");
local propHash <const> = "h4_prop_h4_box_delivery_01a";
RequestModel(vehiclehash)
Citizen.CreateThread(function()
local waiting = 0
while not HasModelLoaded(vehiclehash) do
waiting = waiting + 100
Citizen.Wait(100)
if waiting > 3000 then
print("Vehicle not found")
break
end
end
local vehicule = CreateVehicle(vehiclehash, x, y, z, GetEntityHeading(player)+90, 1, 0)
local prop = CreateObject(GetHashKey(propHash), x, y, z, true, true, true)
SetVehicleNumberPlateText(vehicule, "XXXXX")
SetPedIntoVehicle(player, vehicule, -1)
AttachEntityToEntity(prop, vehicule, 21, 0.0, 0.4, -0.2, 0, 0, -89.9999924, false, false, false, false, 2, true)
end)
end)
If you still want the source code to contribute to it here it is :
Enjoy it by SuperCoolNinja.
Thanks to Antasurris for helping me to find the prop.