Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local playerloc = GetEntityCoords(GetPlayerPed(-1))
local streethash = GetStreetNameAtCoord(playerloc.x, playerloc.y, playerloc.z)
street = GetStreetNameFromHashKey(streethash)
local ped = GetPlayerPed(-1)
local veh = GetVehiclePedIsIn(ped, false)
local mph = 2.236936
local speed = GetEntitySpeed(veh) * mph
if IsPedInAnyVehicle(GetPlayerPed(-1)) then
if street == "East Joshua Road" then
speedlimit = 50
else if speed >50 then
DrawText(1.400, 1.425, 1.0,1.0,0.50, "~p~Speedlimittttttt: ~w~" .. speedlimit .."~p~ mph", 255,255,255,255)
end
end
end)
function DrawTxt(x,y ,width,height,scale, text, r,g,b,a)
SetTextFont(6)
SetTextProportional(0)
SetTextScale(scale, scale)
SetTextColour(r, g, b, a)
SetTextDropShadow(0, 0, 0, 0,255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextOutline()
SetTextEntry("STRING")
AddTextComponentString(text)
DrawText(x - width/2, y - height/2 + 0.005)
end```
thats the code and what it does if there going over the speed limit text should pop up but it doesnt what is wrong?
zee
2
elseif btw. Also, you’re not ending that If condition.
if street == this then
elseif street == that then
end
Like this?
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local playerloc = GetEntityCoords(GetPlayerPed(-1))
local streethash = GetStreetNameAtCoord(playerloc.x, playerloc.y, playerloc.z)
street = GetStreetNameFromHashKey(streethash)
local ped = GetPlayerPed(-1)
local veh = GetVehiclePedIsIn(ped, false)
local mph = 2.236936
local speed = GetEntitySpeed(veh) * mph
if IsPedInAnyVehicle(GetPlayerPed(-1)) then
if street == "East Joshua Road" then
speedlimit = 50
else if speed >50 then
DrawText(1.400, 1.425, 1.0,1.0,0.50, "~p~Speedlimittttttt: ~w~" .. speedlimit .."~p~ mph", 255,255,255,255)
end
end
end
end)
function DrawTxt(x,y ,width,height,scale, text, r,g,b,a)
SetTextFont(6)
SetTextProportional(0)
SetTextScale(scale, scale)
SetTextColour(r, g, b, a)
SetTextDropShadow(0, 0, 0, 0,255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextOutline()
SetTextEntry("STRING")
AddTextComponentString(text)
DrawText(x - width/2, y - height/2 + 0.005)
end```
zee
4
Change else if to elseif it’s triggering my OCD.
1 Like
zee
6
That else if might break it/require an additional end. Not sure though.
alright let me test it out in game
it doesn’t seem to work i cant find any issues with the code
zee
9
Try drive the vehicle over 50MPH
zee
10
I’m on my phone so it’s really hard for me to send you updated code.
zee
11
if street == 'East Joshua Road' then
speedlimit = 50
end
if speed > 50 then
--draw text function
end
doesnt work if your on your phone and its hard dont worry about helping me
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
local playerloc = GetEntityCoords(GetPlayerPed(-1))
local streethash = GetStreetNameAtCoord(playerloc.x, playerloc.y, playerloc.z)
street = GetStreetNameFromHashKey(streethash)
local ped = GetPlayerPed(-1)
local veh = GetVehiclePedIsIn(ped, false)
local mph = 2.236936
local speed = GetEntitySpeed(veh) * mph
if IsPedInAnyVehicle(GetPlayerPed(-1)) then
if street == 'East Joshua Road' then
speedlimit = 50
end
if speed > 50 then
DrawText(1.400, 1.425, 1.0,1.0,0.50, "~p~Speedlimittttttt: ~w~" .. speedlimit .."~p~ mph", 255,255,255,255)
end
end
end
end)
function DrawTxt(x,y ,width,height,scale, text, r,g,b,a)
SetTextFont(6)
SetTextProportional(0)
SetTextScale(scale, scale)
SetTextColour(r, g, b, a)
SetTextDropShadow(0, 0, 0, 0,255)
SetTextEdge(1, 0, 0, 0, 255)
SetTextOutline()
SetTextEntry("STRING")
AddTextComponentString(text)
DrawText(x - width/2, y - height/2 + 0.005)
end
i did doesnt work dont worry about helping me if its to hard sence your on your phone
zee
15
Could be that street doesn’t return ‘East Joshua Road’. Try adding an else condition in the street check.
It does i know that for a fact
maybe the draw text is whats wrong?
zee
19
You getting any errors when restarting the resource? Check F8 console.