Scenes

Select Scene as player

  • To select a different scene as player, you can use command /multicharacter

  • This will promp a menu where players can select the scene they want to use and a favorite vehicle to spawn in scene (if available).

How to create a scene

Before we start, we need to install this resource: https://github.com/DemiAutomatic/object_gizmo

To create a new scene you need to teleport to the location where you want to create it, for this example we are gonna be using MRPD parking lot.

  • Go to your av_multicharacter/scenes/ and duplicate any existing file, rename it and start editing its content, it should look something like this:

  • Once the file is duplicated and renamed, we need to modify the following fields:

    • Index key: This should be an unique index key, for this example I change it to Scenes['mrpd']

    • playerSpawn: This is a table with coords that will be used to spawn your ped during the character selection, this coords needs to be close but hidden from the scene. If you are creating the scene in an interior is important that you spawn the ped inside that interior.

  • Go back to Fivem, run the admin command to open the editor (check _config.lua), you should be able to interact with a menu to your right side of the screen:

  • Using this menu you can spawn entities like peds, vehicles or objects by using their model name and be able to set their position.

  • Once you have placed an entity it will be listed here, you can copy the entity coords, edit the position or delete it.

  • Place the ped and set the position and heading

  • Once we have our first vehicle (optional) and our first character positioned we can click the Toggle Cam to position the camera

  • Once we have our first character slot ready we need to start copying the coords

    • Camera: While in free mode press G to copy coords

    • Character/Vehicle: Click the copy button for every entity.

  • Paste the coords in the scene file:

  • When coords are added to clipboard they have the following format:

-- format for peds
{ x = 444.95, y = -1025.17, z = 28.55, heading = 0.0, model = "s_m_y_cop_01" },
-- format for vehicles
{ x = 446.22, y = -1026.85, z = 28.27, heading = 0.0, model = "police" },
-- format for cameras
{ x = 445.49, y = -1020.83, z = 28.97, rotX = -2.9, rotY = 0.0, rotZ = -172.85, fov = 42.0 },
  • Always be careful to not delete the part that says ped = or vehicle = or camera = because you will break everything.

  • Once you have all your characters, vehicles and cameras setup for every slot, go to config/_scenes.lua and add the scene in Config.Scenes table:

{ -- MRPD
    value = "mrpd", -- needs to match the scene key index
    label = "MRPD", -- used for multicharacter menu
    canUse = function() -- false it will hide this scene from player
        return true
    end
},

function CanUse()

This function allows you to show or hide a specific scene from players, by default you have the following scenes enabled only if the Gabz map script is started:

{ -- Paid map by Gabz https://fivem.gabzv.com/
    value = "gabz_bennys",
    label = "Bennys Motorworks",
    canUse = function()
        return GetResourceState('cfx-gabz-bennys') == "started"
    end
},
{ -- Paid map by Gabz https://fivem.gabzv.com/
    value = "gabz_prison",
    label = "Prison",
    canUse = function()
        return GetResourceState('cfx-gabz-prison') == "started"
    end
},
{ -- Paid map by Gabz https://fivem.gabzv.com/
    value = "gabz_tuning",  
    label = "Tunershop", 
    canUse = function()
        return GetResourceState('cfx-gabz-tuners') == "started"
    end
},
  • If the map resource is not started it will return false, you can use this to (for example) show a specific scene to certain group of players, example of a gang scene where only gang members (using av_gangs) have access:

{
    value = "ballas_scene",
    label = "Ballas",
    canUse = function()
        local gang = exports['av_gangs']:getGang()
        if not gang then return false end -- If player isn't a gang member block it
        if gang and gang['name'] == "ballas" then
            return true -- player is Ballas member, show this scene in his menu
        else
            return false -- player is not a Ballas member
        end 
    end
},
  • Remember that this function is client side only.

Run Custom Code

You can run custom code every time a new slot is created in the scene, this code can be executed in client/editable/_custom.lua

Last updated