[Code Snippet] Spawn the faggio with the pizza box in back as prop

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 :smiley: by SuperCoolNinja.
Thanks to Antasurris for helping me to find the prop.

4 Likes

very nice

1 Like

very useful. keep up the good work.

1 Like

like always, ty boss !

So creative bro

1 Like

Thanks my G

Hi.

For me, the code doesn’t worked.

I fixed it, only with removing <const> things.

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 = GetHashKey("faggio");
    local propHash = "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)

King regards,

<const> is a feature of lua 5.4, by default fivem uses lua 5.3. To activate 5.4 add lua54 'yes' to your fxmanifest

Hi.

Thanks for this, but as i’m not a good developper (really not), it can’t really be useful for me.

Maybe others ppl.

King regards,