Marker - pitermcflebor/fivem-classes-lua GitHub Wiki

Client-side

Init

local marker = Marker(
    markerType,    -- number
    Coords,        -- Coords object
    radius,        -- number
    r,             -- number
    g,             -- number
    b,             -- number
    alpha          -- number
)

Marker Types

--[[

Checkpoint types:
0-4---------- Cylinder: 1 arrow, 2 arrow, 3 arrows, CycleArrow, Checker
5-9---------- Cylinder: 1 arrow, 2 arrow, 3 arrows, CycleArrow, Checker (Z is on ground)
10-14-------- Ring: 1 arrow, 2 arrow, 3 arrows, CycleArrow, Checker
15-19-------- 1 arrow, 2 arrow, 3 arrows, CycleArrow, Checker      
20-24-------- Cylinder: 1 arrow, 2 arrow, 3 arrows, CycleArrow, Checker 
25-29-------- Cylinder: 1 arrow, 2 arrow, 3 arrows, CycleArrow, Checker    
30-34-------- Cylinder: 1 arrow, 2 arrow, 3 arrows, CycleArrow, Checker 
35-38-------- Ring: Airplane Up, Left, Right, UpsideDown
39----------- none
40----------- Ring: just a ring
41----------- none
42-44-------- Cylinder w/ number (uses 'reserved' parameter)
* changing reserved value:
	- 0-99 numbers
	- 100-109 arrow
	- 110-119 double arrow
	- 120-129 triple arrow
	- 130-139 ground big circle
	- 140-149 cycle
	- 150-159 ground slim circle
	- 160-169 ground circle with arrow
	- 170-179 ground circle with spaces
	- 180-189 world sphere
	- 190-199 dollar
	- 200-209 lines
	- 210-219 wolf
	- 220-229 ?
	- 230-239 plane
	- 240-249 helicopter
	- 250-255 boat
* restart at 256
45-47-------- Cylinder no arrow or number
48-51-------- none
54----------- ring with dollar inside
55----------- ring with wolf inside
56----------- ring with ? inside
57----------- ring with plane inside
58----------- ring with helicopter inside
59----------- ring with boat inside
60----------- ring with car inside
61----------- ring with motorbike inside
62----------- ring with bike inside
63----------- ring with truck inside
64----------- ring with parachute inside
65----------- ring with jetpack inside
66----------- ring with hurricane? inside

]]

Examples

-- create a marker
local marker = Marker(markerType, Coords(GarageData.GarageMenu), 1.5, 0, 0, 255, 100)
-- you can set any data inside the marker
marker.GarageData = GarageData
-- set a function that will be executed when inside (radius*1.5) of the marker
marker:Inside(function(this) -- this is the self data of the marker
	local player = CPlayer(-1)
	if player:IsInsideVehicle() then
		ShowHelpNotification('Press ~INPUT_CONTEXT~ to save your vehicle in ~y~'..this.GarageData.GarageName, true)
		if IsControlJustPressed(1, 38) then
			SaveOnGarage(this.GarageData)
		end
	else
		ShowHelpNotification('Press ~INPUT_CONTEXT~ to open the garage ~y~'..this.GarageData.GarageName, true)
		if IsControlJustPressed(1, 38) and not MenuOpen then
			OpenGarageMenu(this.GarageData)
		end
	end
	player = nil
end)
-- set a function that will execute when outside the marker
marker:Outside(function(this) -- this is the self data of the marker
        -- this.inside is a boolean to check if was inside
	if this.inside == true then
                -- update the inside to false so this tick will be executed once
		this.inside = false
	end
end)