Basic Marker/TriggerEvent LUA

Looking at a basic marker to TriggerEvent

I’ve tried this

pos1= {
    x=-984,
    y=-2641,
    z=13,
}

Citizen.CreateThread(function ()
    while true do
        Citizen.Wait(5)
        local player = GetPlayerPed(-1)
        local playerLoc = GetEntityCoords(player)


        DrawMarker(1, pos1.x, pos1.y, pos1.z, 0, 0, 0, 0, 0, 0, 1.501, 1.5001, 0.5001, 255, 255, 255, 255, 0, 0, 0, 0)       
        if CheckPos(playerLoc.x, playerLoc.y, playerLoc.z, pos1.x, pos1.y, pos1.z, 2) and IsControlJustReleased(1, 38) then
                    TriggerEvent(Respawn:Rewhateveritwas)
        end
    end
end)

Just getting no marker or anything

Hi,

A marker need to be draw every frame, so Citizen.Wait(0) instead of Citizen.Wait(5), then DrawMarker need float not int (-984.0): doc . Samething for dirX… need to be like 0.0.

What is CheckPos ? Is exist in your resource?

Last thing, you forgot some " here: TriggerEvent(Respawn:Rewhateveritwas)

OK, so I altered a few things, the maker shows up, but I don’t get a notifications and I can’t trigger the event:

ESX = nil

Citizen.CreateThread(function()
    while ESX == nil do
        TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
        Citizen.Wait(0)
    end
end)

RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer)
    PlayerData = xPlayer
end)

function hintToDisplay(text)
    SetTextComponentFormat("STRING")
    AddTextComponentString(text)
    DisplayHelpTextFromStringLabel(0, 0, 1, -1)
end

local place = {
    {x = 895.39,y = -179.52,z = 73.7}
}

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        for k in pairs(place) do
            DrawMarker(27, place[k].x, place[k].y, place[k].z, 0, 0, 0, 0, 0, 0, 1.001, 1.0001, 0.5001, 0, 255, 50, 200, 0, 0, 0, 0)
        end
    end
end)

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)

        for k in pairs(place) do

            local plyCoords = GetEntityCoords(GetPlayerPed(-1), false)
            local dist = Vdist(plyCoords.x, plyCoords.y, plyCoords.z, place[k].x, place[k].y, place[k].z)

            if dist <= 0.5 then
                --doesnt spam notifcations only shows top corner
                hintToDisplay('Press ~INPUT_CONTEXT~ to Respawn Character')
                
                if IsControlJustPressed(0, 38) then -- "E"
                    TriggerEvent('respawn:RespawnCharacter')
                end            
            end
        end
    end
end)

instead of 0.5 try 1 and see if it works.

Nope, doesn’t do anything :confused:

This will for sure work, but you will need to modify it to your liking

quickKey = 38 --- E
local ESX = nil
local PlayerData                = {}
RegisterNetEvent('esx:playerLoaded')
AddEventHandler('esx:playerLoaded', function(xPlayer)
  PlayerData = xPlayer
end)


RegisterNetEvent('esx:setJob')
AddEventHandler('esx:setJob', function(job)
  PlayerData.job = job
end)

Citizen.CreateThread(function()
	while ESX == nil do
		TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
		Citizen.Wait(0)
	end
end)
HintToDisplayPoint = {
	{895.39,-179.52,73.7}
}
Citizen.CreateThread(function ()
	while true do
		Citizen.Wait(0)
		if IsPedStill(GetPlayerPed(-1)) then 
			for i = 1, #HintToDisplayPoint do
				hintCoords2 = HintToDisplayPoint[i]
				DrawMarker(-27, hintCoords2[1], hintCoords2[2], hintCoords2[3], 0, 0, 0, 0, 0, 0, 5.0, 5.0, 2.0, 0, 157, 0, 155, 0, 0, 2, 0, 0, 0, 0)
				if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(-1)), garageCoords2[1], garageCoords2[2], garageCoords2[3], true ) < 5 then
				 ESX.ShowHelpNotification('Press ~INPUT_CONTEXT~ to Respawn Character')
					if(IsControlJustPressed(1, quickKey)) then
						TriggerEvent('respawn:RespawnCharacter')
						insidemarkercheck = true
					end
				   end
				end
			end
		end
	end
end)
local menuEnabled = false

Give this a try I kinda snipped it from my own resource, may be missing a end or not but if it doesn’t work let me know if it works let me know

Hmm… so I tried your code, it didn’t work. I went back to my code and now it’s giving me a notification message but doesn’t call the triggerevent

Anyone know what the problem is?

Vdist is 3D so checking for 0.5 or 1.0 is very short. Try with something like 2.0, then reduce when it works

1 Like

Show us your Eventcode

Would it matter even though I’ve got the notification in the top left to say press e?

Huh? You get the notification now?

I start the resource, I got over the marker and it comes up Press E to respawn… Nothing happens

What is 'respawn:RespawnCharacter'?

It’s a script I made so when you respawn is clears the area, works if I make as a command

And exactly this part of your script we want to see. Maybe there is an error