How do you make so you press E in a drawmarker and it displays a text?

How would i go about adding so that it says press E in a drawmarker and when u press E it displays a message for example saying Hello?

Citizen.CreateThread(function()
while true do
Wait(0)
DrawMarker(27, 1039.83, -775.31, 58.02, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 2.0, 2.0, 2.0, 255, 255, 255, 255, false, true, 2, false, false, false, false)
end
end)

1 Like

You can simply have a esx notification or have something show in chat, Are you trying to display it on its own text in the middle of the screen?

I want it to have the same notification as esx_drugs etc with the Press E to ***

local table = {
    {x = 27, y = 1039.83, z = -775.31} -- Enter the coords of the maker here --
}

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        for k in pairs(table) do
            -- Draw Marker Here --
            DrawMarker(1, table[k].x, table[k].y, table[k].z, 0, 0, 0, 0, 0, 0, 1.001, 1.0001, 0.5001, 0, 0, 255, 200, 0, 0, 0, 0)
        end
    end
end)

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

        for k in pairs(table) do

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

            if dist <= 1.2 then
				DrawTxt("Press E To Do Something")
				if IsControlJustPressed(1,51) then
					-- do something --
				end
            end
        end
    end
end)

function DrawTxt(text)
  SetTextFont(0)
  SetTextProportional(1)
  SetTextScale(0.0, 0.45)
  SetTextDropshadow(1, 0, 0, 0, 255)
  SetTextEdge(1, 0, 0, 0, 255)

  SetTextDropShadow()
  SetTextOutline()
  SetTextEntry("STRING")
  AddTextComponentString(text)
  DrawText(0.174, 0.855)
end
1 Like

How would i go about making it so that when u press e it switches ur job to something different? like off duty/on duty?

Depends on what script you are using.

Im using esx if thats what you’re asking

You want to trigger
esx:showNotification
then add a string in