Circle 3d zone

my goal was to create a red area visible both in the map and in the game and for more than 2 days I’ve been trying to care the fivem documentation but I can’t do it the only thing I’ve done but that doesn’t work and this:

Citizen.CreateThread(function()

    while true do

        local blip = AddBlipForRadius(1693.1, 6416.4, 32.59, 50.0)

        SetBlipDisplay(blip, 4)

        SetBlipScale  (blip, 0.9)

        SetBlipAsShortRange(blip, true)

end)
  1. You are running a forever loop without a required wait for atleast 1 tick.

  2. BUT DONT DO THIS FOR BLIPS. blips need to be created just once. Not once every tick which is around 60 times a second :stuck_out_tongue:

2 Likes

You’ve got a good start, however there are a few problems with your code.

  • When using while true do, you must close that with end like so:
while true do
    -- Your code here
end
  • Whenever you use while true do, make sure to have a Citizen.Wait(0) somewhere in there. It can be more than 0 if you need that, just make sure to have a wait function in there somewhere or else everyone on the server will crash.

  • When creating blips, you don’t need to loop the blip creation: Once is enough.

  • When creating a blip for a radius, you must set the sprite (type of the marker) to either 4, 9 or 10 as those are the only ones that work with radius blips.

  • When creating a marker in the 3D world, use “DrawMarker”. This will need to be done in a loop though.



Here’s an example:

Citizen.CreateThread(function()

    -- Creating and configuring the blip
    local blip = AddBlipForRadius(1693.1, 6416.4, 32.59, 50.0)
    SetBlipSprite(blip, 9)
    SetBlipAlpha(blip, 100)

    -- Starting the loop here to create the marker
    while true do
        DrawMarker(
            1,      -- Marker type
            1693.1, -- Position X
            6416.4, -- Position Y
            32.59,  -- Position Z
            0.0,    -- Direction X
            0.0,    -- Direction Y
            0.0,    -- Direction Z
            0.0,    -- Rotation X
            0.0,    -- Rotation Y
            0.0,    -- Rotation Z
            50.0,   -- Scale X
            50.0,   -- Scale Y
            5.0,    -- Scale Z
            255,    -- Color Red
            255,    -- Color Green
            255,    -- Color Blue
            255,    -- Alpha channel (transparency)
            false,  -- Bob up and down
            false,  -- Face the camera
            2,      -- Doesn't seem to matter, usually set to 2
            false,  -- Rotate
            nil,    -- Texture dictionary
            nil,    -- Texture name
            false   -- Draw on other entities
        )
        Citizen.Wait(0)
    end
end)



By the way, you don’t have to use a new line for each value in “DrawMarker” (or any function for that matter). I just like doing it this way because I can easily see what value does what. This is perfectly fine too:

DrawMarker(1, 1693.1, 6416.4, 32.59, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 50.0, 50.0, 5.0, 255, 255, 255, 255, false, false, 2, false, nil, nil, false)
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.