From 1cb1ef2eee6543955539ba65d9aa7a73522ee64c Mon Sep 17 00:00:00 2001 From: Slyforn Date: Wed, 11 Nov 2020 10:36:11 +1100 Subject: [PATCH 01/31] Added up to date fxmanifest file. Optimized code Replaced old UIDraw system with NUI system - Broke data driven config.lua system - Could be further optimized - there is no need to send NUIMessages unless data has changed. --- streetLabel/client.lua | 263 ++++++----------------------------- streetLabel/config.lua | 2 +- streetLabel/fxmanifest.lua | 21 +++ streetLabel/html/index.html | 24 ++++ streetLabel/html/listener.js | 24 ++++ streetLabel/html/style.css | 50 +++++++ 6 files changed, 164 insertions(+), 220 deletions(-) create mode 100644 streetLabel/fxmanifest.lua create mode 100644 streetLabel/html/index.html create mode 100644 streetLabel/html/listener.js create mode 100644 streetLabel/html/style.css diff --git a/streetLabel/client.lua b/streetLabel/client.lua index c762933..4cdf28f 100644 --- a/streetLabel/client.lua +++ b/streetLabel/client.lua @@ -1,230 +1,55 @@ -function drawTxt(x,y ,width,height,scale, text, r,g,b,a) - if not HideHud then - SetTextFont(4) - SetTextProportional(0) - SetTextScale(scale, scale) - SetTextColour(r, g, b, a) - SetTextDropShadow(0, 0, 0, 0,255) - SetTextEdge(1, 0, 0, 0, 255) - SetTextDropShadow() - SetTextOutline() - SetTextEntry("STRING") - AddTextComponentString(text) - DrawText(x - width/2, y - height/2 + 0.005) - end -end +-- Variables +local directions = {[0] = 'N', [45] = 'NW', [90] = 'W', [135] = 'SW', [180] = 'S', [225] = 'SE', [270] = 'E', [315] = 'NE', [360] = 'N', } -function drawTxt2(x,y ,width,height,scale, text, r,g,b,a) - if not HideHud then - SetTextFont(6) - SetTextProportional(0) - SetTextScale(scale, scale) - SetTextColour(r, g, b, a) - SetTextDropShadow(0, 0, 0, 0,255) - SetTextEdge(1, 0, 0, 0, 255) - SetTextDropShadow() - SetTextOutline() - SetTextEntry("STRING") - AddTextComponentString(text) - DrawText(x - width/2, y - height/2 + 0.005) - end -end +local playerPedID; +local localPed; +local localVehicle = 0; +local coords; +local zone; +local zoneLabel; + +local streetHash1; +local streetHash2; + +local playerDirection; -local directions = { [0] = 'N', [45] = 'NW', [90] = 'W', [135] = 'SW', [180] = 'S', [225] = 'SE', [270] = 'E', [315] = 'NE', [360] = 'N', } Citizen.CreateThread(function() + while true do - Citizen.Wait(1) - local ped = GetPlayerPed(-1) - local vehicle = GetVehiclePedIsIn(ped, false) - local directions = { [0] = 'N', [45] = 'NW', [90] = 'W', [135] = 'SW', [180] = 'S', [225] = 'SE', [270] = 'E', [315] = 'NE', [360] = 'N', } - - local pos = GetEntityCoords(PlayerPedId()) - local var1, var2 = GetStreetNameAtCoord(pos.x, pos.y, pos.z, Citizen.ResultAsInteger(), Citizen.ResultAsInteger()) - local current_zone = GetLabelText(GetNameOfZone(pos.x, pos.y, pos.z)) - - for k,v in pairs(directions)do - direction = GetEntityHeading(PlayerPedId()) - if(math.abs(direction - k) < 22.5)then - direction = v - break - end - end + localPed = GetPlayerPed(-1); + playerPedID = PlayerPedId(); - if (checkForVehicle == false) then - if GetStreetNameFromHashKey(var1) and GetNameOfZone(pos.x, pos.y, pos.z) then - if GetStreetNameFromHashKey(var1) then - if direction == 'N' then - drawTxt(x-0.335, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.306, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.315, y+0.42, 1.0,1.0,1.0, direction, dir_r, dir_g, dir_b, dir_a) - if GetStreetNameFromHashKey(var2) == "" then - drawTxt2(x-0.285, y+0.45, 1.0,1.0,0.45, current_zone, town_r, town_g, town_b, town_a) - else - drawTxt2(x-0.285, y+0.45, 1.0,1.0,0.45, GetStreetNameFromHashKey(var2) .. ", " .. GetLabelText(GetNameOfZone(pos.x, pos.y, pos.z)), str_around_r, str_around_g, str_around_b, str_around_a) - end - drawTxt2(x-0.285, y+0.42, 1.0,1.0,0.55, GetStreetNameFromHashKey(var1), curr_street_r, curr_street_g, curr_street_b, curr_street_a) - elseif direction == 'NE' then - drawTxt(x-0.335, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.298, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.315, y+0.42, 1.0,1.0,1.0, direction, dir_r, dir_g, dir_b, dir_a) - if GetStreetNameFromHashKey(var2) == "" then - drawTxt2(x-0.277, y+0.45, 1.0,1.0,0.45, current_zone, town_r, town_g, town_b, town_a) - else - drawTxt2(x-0.277, y+0.45, 1.0,1.0,0.45, GetStreetNameFromHashKey(var2) .. ", " .. GetLabelText(GetNameOfZone(pos.x, pos.y, pos.z)), str_around_r, str_around_g, str_around_b, str_around_a) - end - drawTxt2(x-0.277, y+0.42, 1.0,1.0,0.55, GetStreetNameFromHashKey(var1),curr_street_r, curr_street_g, curr_street_b, curr_street_a) - elseif direction == 'E' then - drawTxt(x-0.335, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.309, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.315, y+0.42, 1.0,1.0,1.0, direction, dir_r, dir_g, dir_b, dir_a) - if GetStreetNameFromHashKey(var2) == "" then - drawTxt2(x-0.288, y+0.45, 1.0,1.0,0.45, current_zone, town_r, town_g, town_b, town_a) - else - drawTxt2(x-0.288, y+0.45, 1.0,1.0,0.45, GetStreetNameFromHashKey(var2) .. ", " .. GetLabelText(GetNameOfZone(pos.x, pos.y, pos.z)), str_around_r, str_around_g, str_around_b, str_around_a) - end - drawTxt2(x-0.288, y+0.42, 1.0,1.0,0.55, GetStreetNameFromHashKey(var1), curr_street_r, curr_street_g, curr_street_b, curr_street_a) - elseif direction == 'SE' then - drawTxt(x-0.335, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.298, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.315, y+0.42, 1.0,1.0,1.0, direction, dir_r, dir_g, dir_b, dir_a) - if GetStreetNameFromHashKey(var2) == "" then - drawTxt2(x-0.275, y+0.45, 1.0,1.0,0.45, current_zone, town_r, town_g, town_b, town_a) - else - drawTxt2(x-0.275, y+0.45, 1.0,1.0,0.45, GetStreetNameFromHashKey(var2) .. ", " .. GetLabelText(GetNameOfZone(pos.x, pos.y, pos.z)), str_around_r, str_around_g, str_around_b, str_around_a) - end - drawTxt2(x-0.275, y+0.42, 1.0,1.0,0.55, GetStreetNameFromHashKey(var1), curr_street_r, curr_street_g, curr_street_b, curr_street_a) - elseif direction == 'S' then - drawTxt(x-0.335, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.307, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.315, y+0.42, 1.0,1.0,1.0, direction, dir_r, dir_g, dir_b, dir_a) - if GetStreetNameFromHashKey(var2) == "" then - drawTxt2(x-0.285, y+0.45, 1.0,1.0,0.45, current_zone, town_r, town_g, town_b, town_a) - else - drawTxt2(x-0.285, y+0.45, 1.0,1.0,0.45, GetStreetNameFromHashKey(var2) .. ", " .. GetLabelText(GetNameOfZone(pos.x, pos.y, pos.z)), str_around_r, str_around_g, str_around_b, str_around_a) - end - drawTxt2(x-0.285, y+0.42, 1.0,1.0,0.55, GetStreetNameFromHashKey(var1), curr_street_r, curr_street_g, curr_street_b, curr_street_a) - elseif direction == 'SW' then - drawTxt(x-0.335, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.292, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.315, y+0.42, 1.0,1.0,1.0, direction, dir_r, dir_g, dir_b, dir_a) - if GetStreetNameFromHashKey(var2) == "" then - drawTxt2(x-0.270, y+0.45, 1.0,1.0,0.45, current_zone, town_r, town_g, town_b, town_a) - else - drawTxt2(x-0.270, y+0.45, 1.0,1.0,0.45, GetStreetNameFromHashKey(var2) .. ", " .. GetLabelText(GetNameOfZone(pos.x, pos.y, pos.z)), str_around_r, str_around_g, str_around_b, str_around_a) - end - drawTxt2(x-0.270, y+0.42, 1.0,1.0,0.55, GetStreetNameFromHashKey(var1), curr_street_r, curr_street_g, curr_street_b, curr_street_a) - elseif direction == 'W' then - drawTxt(x-0.335, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.303, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.315, y+0.42, 1.0,1.0,1.0, direction, dir_r, dir_g, dir_b, dir_a) - if GetStreetNameFromHashKey(var2) == "" then - drawTxt2(x-0.280, y+0.45, 1.0,1.0,0.45, current_zone, town_r, town_g, town_b, town_a) - else - drawTxt2(x-0.280, y+0.45, 1.0,1.0,0.45, GetStreetNameFromHashKey(var2) .. ", " .. GetLabelText(GetNameOfZone(pos.x, pos.y, pos.z)), str_around_r, str_around_g, str_around_b, str_around_a) - end - drawTxt2(x-0.280, y+0.42, 1.0,1.0,0.55, GetStreetNameFromHashKey(var1), curr_street_r, curr_street_g, curr_street_b, curr_street_a) - elseif direction == 'NW' then - drawTxt(x-0.335, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.290, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.315, y+0.42, 1.0,1.0,1.0, direction, dir_r, dir_g, dir_b, dir_a) - if GetStreetNameFromHashKey(var2) == "" then - drawTxt2(x-0.266, y+0.45, 1.0,1.0,0.45, current_zone, town_r, town_g, town_b, town_a) - else - drawTxt2(x-0.266, y+0.45, 1.0,1.0,0.45, GetStreetNameFromHashKey(var2) .. ", " .. GetLabelText(GetNameOfZone(pos.x, pos.y, pos.z)), str_around_r, str_around_g, str_around_b, str_around_a) - end - drawTxt2(x-0.266, y+0.42, 1.0,1.0,0.55, GetStreetNameFromHashKey(var1), curr_street_r, curr_street_g, curr_street_b, curr_street_a) - end - end - end - else - if (vehicle ~= 0) then - if GetStreetNameFromHashKey(var1) and GetNameOfZone(pos.x, pos.y, pos.z) then - if GetStreetNameFromHashKey(var1) then - if direction == 'N' then - drawTxt(x-0.335, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.306, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.315, y+0.42, 1.0,1.0,1.0, direction, dir_r, dir_g, dir_b, dir_a) - if GetStreetNameFromHashKey(var2) == "" then - drawTxt2(x-0.285, y+0.45, 1.0,1.0,0.45, current_zone, town_r, town_g, town_b, town_a) - else - drawTxt2(x-0.285, y+0.45, 1.0,1.0,0.45, GetStreetNameFromHashKey(var2) .. ", " .. GetLabelText(GetNameOfZone(pos.x, pos.y, pos.z)), str_around_r, str_around_g, str_around_b, str_around_a) - end - drawTxt2(x-0.285, y+0.42, 1.0,1.0,0.55, GetStreetNameFromHashKey(var1), curr_street_r, curr_street_g, curr_street_b, curr_street_a) - elseif direction == 'NE' then - drawTxt(x-0.335, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.298, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.315, y+0.42, 1.0,1.0,1.0, direction, dir_r, dir_g, dir_b, dir_a) - if GetStreetNameFromHashKey(var2) == "" then - drawTxt2(x-0.277, y+0.45, 1.0,1.0,0.45, current_zone, town_r, town_g, town_b, town_a) - else - drawTxt2(x-0.277, y+0.45, 1.0,1.0,0.45, GetStreetNameFromHashKey(var2) .. ", " .. GetLabelText(GetNameOfZone(pos.x, pos.y, pos.z)), str_around_r, str_around_g, str_around_b, str_around_a) - end - drawTxt2(x-0.277, y+0.42, 1.0,1.0,0.55, GetStreetNameFromHashKey(var1),curr_street_r, curr_street_g, curr_street_b, curr_street_a) - elseif direction == 'E' then - drawTxt(x-0.335, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.309, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.315, y+0.42, 1.0,1.0,1.0, direction, dir_r, dir_g, dir_b, dir_a) - if GetStreetNameFromHashKey(var2) == "" then - drawTxt2(x-0.288, y+0.45, 1.0,1.0,0.45, current_zone, town_r, town_g, town_b, town_a) - else - drawTxt2(x-0.288, y+0.45, 1.0,1.0,0.45, GetStreetNameFromHashKey(var2) .. ", " .. GetLabelText(GetNameOfZone(pos.x, pos.y, pos.z)), str_around_r, str_around_g, str_around_b, str_around_a) - end - drawTxt2(x-0.288, y+0.42, 1.0,1.0,0.55, GetStreetNameFromHashKey(var1), curr_street_r, curr_street_g, curr_street_b, curr_street_a) - elseif direction == 'SE' then - drawTxt(x-0.335, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.298, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.315, y+0.42, 1.0,1.0,1.0, direction, dir_r, dir_g, dir_b, dir_a) - if GetStreetNameFromHashKey(var2) == "" then - drawTxt2(x-0.275, y+0.45, 1.0,1.0,0.45, current_zone, town_r, town_g, town_b, town_a) - else - drawTxt2(x-0.275, y+0.45, 1.0,1.0,0.45, GetStreetNameFromHashKey(var2) .. ", " .. GetLabelText(GetNameOfZone(pos.x, pos.y, pos.z)), str_around_r, str_around_g, str_around_b, str_around_a) - end - drawTxt2(x-0.275, y+0.42, 1.0,1.0,0.55, GetStreetNameFromHashKey(var1), curr_street_r, curr_street_g, curr_street_b, curr_street_a) - elseif direction == 'S' then - drawTxt(x-0.335, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.307, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.315, y+0.42, 1.0,1.0,1.0, direction, dir_r, dir_g, dir_b, dir_a) - if GetStreetNameFromHashKey(var2) == "" then - drawTxt2(x-0.285, y+0.45, 1.0,1.0,0.45, current_zone, town_r, town_g, town_b, town_a) - else - drawTxt2(x-0.285, y+0.45, 1.0,1.0,0.45, GetStreetNameFromHashKey(var2) .. ", " .. GetLabelText(GetNameOfZone(pos.x, pos.y, pos.z)), str_around_r, str_around_g, str_around_b, str_around_a) - end - drawTxt2(x-0.285, y+0.42, 1.0,1.0,0.55, GetStreetNameFromHashKey(var1), curr_street_r, curr_street_g, curr_street_b, curr_street_a) - elseif direction == 'SW' then - drawTxt(x-0.335, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.292, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.315, y+0.42, 1.0,1.0,1.0, direction, dir_r, dir_g, dir_b, dir_a) - if GetStreetNameFromHashKey(var2) == "" then - drawTxt2(x-0.270, y+0.45, 1.0,1.0,0.45, current_zone, town_r, town_g, town_b, town_a) - else - drawTxt2(x-0.270, y+0.45, 1.0,1.0,0.45, GetStreetNameFromHashKey(var2) .. ", " .. GetLabelText(GetNameOfZone(pos.x, pos.y, pos.z)), str_around_r, str_around_g, str_around_b, str_around_a) - end - drawTxt2(x-0.270, y+0.42, 1.0,1.0,0.55, GetStreetNameFromHashKey(var1), curr_street_r, curr_street_g, curr_street_b, curr_street_a) - elseif direction == 'W' then - drawTxt(x-0.335, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.303, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.315, y+0.42, 1.0,1.0,1.0, direction, dir_r, dir_g, dir_b, dir_a) - if GetStreetNameFromHashKey(var2) == "" then - drawTxt2(x-0.280, y+0.45, 1.0,1.0,0.45, current_zone, town_r, town_g, town_b, town_a) - else - drawTxt2(x-0.280, y+0.45, 1.0,1.0,0.45, GetStreetNameFromHashKey(var2) .. ", " .. GetLabelText(GetNameOfZone(pos.x, pos.y, pos.z)), str_around_r, str_around_g, str_around_b, str_around_a) - end - drawTxt2(x-0.280, y+0.42, 1.0,1.0,0.55, GetStreetNameFromHashKey(var1), curr_street_r, curr_street_g, curr_street_b, curr_street_a) - elseif direction == 'NW' then - drawTxt(x-0.335, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.290, y+0.66, 1.0,1.5,1.4, " | ", border_r, border_g, border_b, border_a) - drawTxt(x-0.315, y+0.42, 1.0,1.0,1.0, direction, dir_r, dir_g, dir_b, dir_a) - if GetStreetNameFromHashKey(var2) == "" then - drawTxt2(x-0.266, y+0.45, 1.0,1.0,0.45, current_zone, town_r, town_g, town_b, town_a) - else - drawTxt2(x-0.266, y+0.45, 1.0,1.0,0.45, GetStreetNameFromHashKey(var2) .. ", " .. GetLabelText(GetNameOfZone(pos.x, pos.y, pos.z)), str_around_r, str_around_g, str_around_b, str_around_a) - end - drawTxt2(x-0.266, y+0.42, 1.0,1.0,0.55, GetStreetNameFromHashKey(var1), curr_street_r, curr_street_g, curr_street_b, curr_street_a) - end - end + localVehicle = GetVehiclePedIsIn(localPed, false); + coords = GetEntityCoords(playerPedID); + zone = GetNameOfZone(coords.x, coords.y, coords.z); + zoneLabel = GetLabelText(zone); + + if(checkForVehicle == false or localVehicle ~= 0) then + + local var1, var2 = GetStreetNameAtCoord(coords.x, coords.y, coords.z, Citizen.ResultAsInteger(), Citizen.ResultAsInteger()) + streetHash1 = GetStreetNameFromHashKey(var1); + streetHash2 = GetStreetNameFromHashKey(var2); + playerDirection = GetEntityHeading(playerPedID); + + for k,v in pairs(directions)do + if(math.abs(playerDirection - k) < 22.5)then + playerDirection = v + break end end + + local street2 = ""; + if(streetHash2 == "") then street2 = zoneLabel; + else street2 = streetHash2..", "..zoneLabel; end + + SendNUIMessage({type = 'streetLabelMSG', active = true, direction = playerDirection, zone = streetHash1, street = street2}); + else + SendNUIMessage({type = 'streetLabelMSG', active = false}); end + + -- Wait for half a second. + Citizen.Wait(500); + end end) \ No newline at end of file diff --git a/streetLabel/config.lua b/streetLabel/config.lua index 76c4e74..a21b697 100644 --- a/streetLabel/config.lua +++ b/streetLabel/config.lua @@ -37,4 +37,4 @@ town_a = 255 -- Determine rather the HUD should only display when player(s) are inside a vehicle or not - checkForVehicle = true \ No newline at end of file + checkForVehicle = false \ No newline at end of file diff --git a/streetLabel/fxmanifest.lua b/streetLabel/fxmanifest.lua new file mode 100644 index 0000000..4085fb3 --- /dev/null +++ b/streetLabel/fxmanifest.lua @@ -0,0 +1,21 @@ +-- Script Description +fx_version 'cerulean' +games { 'gta5' } + +author 'Lowheartrate' +description 'Street Label by Lowheartrate' +version '1.X.X' + +-- Client Scripts +client_scripts { + 'config.lua', + 'client.lua' +} + +ui_page('html/index.html') + +files({ + 'html/index.html', + 'html/listener.js', + 'html/style.css' +}) \ No newline at end of file diff --git a/streetLabel/html/index.html b/streetLabel/html/index.html new file mode 100644 index 0000000..8bc916b --- /dev/null +++ b/streetLabel/html/index.html @@ -0,0 +1,24 @@ + + + + Street Label + + + + + + +
+ + + + + + + + +
+
+ + + \ No newline at end of file diff --git a/streetLabel/html/listener.js b/streetLabel/html/listener.js new file mode 100644 index 0000000..7c29461 --- /dev/null +++ b/streetLabel/html/listener.js @@ -0,0 +1,24 @@ +window.onload = (e) => { + window.addEventListener('message', onMessageRecieved); +}; + +var direction; +var zone; +var street; + +function onMessageRecieved(event){ + var item = event.data; + if(item !== undefined && item.type === "streetLabelMSG"){ + if(item.active === false){ + $("#container").hide(); + } else { + $("#container").show(); + direction = "| "+item.direction+" |"; + zone = item.zone; + street = item.street; + $('#direction').text(direction); + $(document.getElementById("zone").innerHTML = zone); + $(document.getElementById("street").innerHTML = street); + } + } +} \ No newline at end of file diff --git a/streetLabel/html/style.css b/streetLabel/html/style.css new file mode 100644 index 0000000..d1bc9cf --- /dev/null +++ b/streetLabel/html/style.css @@ -0,0 +1,50 @@ +* { + color: #FFF; + font-weight: bold; + font-family: Impact, Helvetica, Arial, sans-serif; +} + +table, th, td { + border: 0px solid black; + border-collapse: collapse; +} + +th, td { + padding: 5px; + text-align: left; +} + +#container { + color: rgb(241, 235, 235); + position: absolute; + + height: 100px; + width: 30%; + + transform: translate(-50%, -50%); + top: 95%; + left: 32%; + + font-size: 46px; + + text-align: left; + text-shadow: 3px 3px #00000080; + + -webkit-text-stroke-width: 2px; + -webkit-text-stroke-color: #000000D9; +} + +#direction { + color: rgb(241, 235, 235); + font-size: 72px; +} + +#zone { + color: rgb(241, 235, 235); + font-size: 28px; +} + +#street { + color: rgb(217, 185, 46); + font-size: 32px; +} \ No newline at end of file From fde6998f07c797c26e1f9075216ee1144670b75a Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Wed, 11 Nov 2020 09:51:22 -0500 Subject: [PATCH 02/31] added contributor, Slyforn --- fxmanifest.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 fxmanifest.lua diff --git a/fxmanifest.lua b/fxmanifest.lua new file mode 100644 index 0000000..8bd8e2a --- /dev/null +++ b/fxmanifest.lua @@ -0,0 +1,21 @@ +-- Script Description +fx_version 'cerulean' +games { 'gta5' } + +author 'lowheartrate & Slyforn' +description 'Street Label by lowheartrate' +version '1.1.0' + +-- Client Scripts +client_scripts { + 'config.lua', + 'client.lua' +} + +ui_page('html/index.html') + +files({ + 'html/index.html', + 'html/listener.js', + 'html/style.css' +}) \ No newline at end of file From b32db6455ae202fb6a4bbf37a1d7553da2124fc7 Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Wed, 11 Nov 2020 09:51:59 -0500 Subject: [PATCH 03/31] cleaned up code + removed table --- client.lua | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ html/index.html | 24 ++++++++++++++++++ html/listener.js | 38 +++++++++++++++++++++++++++++ html/style.css | 50 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 175 insertions(+) create mode 100644 client.lua create mode 100644 html/index.html create mode 100644 html/listener.js create mode 100644 html/style.css diff --git a/client.lua b/client.lua new file mode 100644 index 0000000..8c42a07 --- /dev/null +++ b/client.lua @@ -0,0 +1,63 @@ +-- Variables +local directions = { + N = 360, + NE = 315, + E = 270, + SE = 225, + S = 180, + SW = 135, + W = 90, + NW = 45, + N = 0, +} + +Citizen.CreateThread(function() + while true do + local ped = PlayerPedId(); + local veh = GetVehiclePedIsIn(ped); + local pos = GetEntityCoords(ped); + local zone = GetLabelText(GetNameOfZone(pos.x, pos.y, pos.z)); + + if (checkForVehicle == false or localVehicle ~= 0) then + local var1, var2 = GetStreetNameAtCoord(pos.x, pos.y, pos.z, Citizen.ResultAsInteger(), Citizen.ResultAsInteger()) + local street = GetStreetNameFromHashKey(var1); + local crossing = GetStreetNameFromHashKey(var2); + local direction = GetEntityHeading(ped); + + for k, v in pairs(directions) do + if (math.abs(direction - v) < 22.5) then + direction = k + break + end + end + + SendNuiMessage({ + type = 'open', + active = true, + direction, + zone, + street + }) + + else + if (veh) then + SendNuiMessage({ + type = 'open', + active = true, + direction, + zone, + street + }) + else + SendNuiMessage({ + type = 'close', + active = false + }) + end + end + + -- Wait for half a second. + Citizen.Wait(500); + + end +end) \ No newline at end of file diff --git a/html/index.html b/html/index.html new file mode 100644 index 0000000..8bc916b --- /dev/null +++ b/html/index.html @@ -0,0 +1,24 @@ + + + + Street Label + + + + + + +
+ + + + + + + + +
+
+ + + \ No newline at end of file diff --git a/html/listener.js b/html/listener.js new file mode 100644 index 0000000..c85a0f9 --- /dev/null +++ b/html/listener.js @@ -0,0 +1,38 @@ +window.onload = (e) => { + let item = event.data; + + if (item && item.type === 'open') { + // ternary operator to display container depending on item.active value + if (!item.active) { + $("#container").hide(); + } else { + $("#container").show(); + + const direction = `| ${item.direction} |`; + const zone = item.zone; + const street = item.street; + + $("#direction").textContent = direction; + $("#street").textContent = street; + $("#zone").textContent = zone; + } + } + // window.addEventListener('message', onMessageRecieved); +}; + +function onMessageRecieved(event){ + var item = event.data; + if(item !== undefined && item.type === "streetLabelMSG"){ + if(item.active === false){ + $("#container").hide(); + } else { + $("#container").show(); + direction = "| "+item.direction+" |"; + zone = item.zone; + street = item.street; + $('#direction').text(direction); + $(document.getElementById("zone").innerHTML = zone); + $(document.getElementById("street").innerHTML = street); + } + } +} \ No newline at end of file diff --git a/html/style.css b/html/style.css new file mode 100644 index 0000000..d1bc9cf --- /dev/null +++ b/html/style.css @@ -0,0 +1,50 @@ +* { + color: #FFF; + font-weight: bold; + font-family: Impact, Helvetica, Arial, sans-serif; +} + +table, th, td { + border: 0px solid black; + border-collapse: collapse; +} + +th, td { + padding: 5px; + text-align: left; +} + +#container { + color: rgb(241, 235, 235); + position: absolute; + + height: 100px; + width: 30%; + + transform: translate(-50%, -50%); + top: 95%; + left: 32%; + + font-size: 46px; + + text-align: left; + text-shadow: 3px 3px #00000080; + + -webkit-text-stroke-width: 2px; + -webkit-text-stroke-color: #000000D9; +} + +#direction { + color: rgb(241, 235, 235); + font-size: 72px; +} + +#zone { + color: rgb(241, 235, 235); + font-size: 28px; +} + +#street { + color: rgb(217, 185, 46); + font-size: 32px; +} \ No newline at end of file From c300624e49a81f44e1d35c17d5e11a5907852e28 Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Wed, 11 Nov 2020 10:01:03 -0500 Subject: [PATCH 04/31] Revert "added contributor, Slyforn" This reverts commit fde6998f07c797c26e1f9075216ee1144670b75a. --- fxmanifest.lua | 21 --------------------- 1 file changed, 21 deletions(-) delete mode 100644 fxmanifest.lua diff --git a/fxmanifest.lua b/fxmanifest.lua deleted file mode 100644 index 8bd8e2a..0000000 --- a/fxmanifest.lua +++ /dev/null @@ -1,21 +0,0 @@ --- Script Description -fx_version 'cerulean' -games { 'gta5' } - -author 'lowheartrate & Slyforn' -description 'Street Label by lowheartrate' -version '1.1.0' - --- Client Scripts -client_scripts { - 'config.lua', - 'client.lua' -} - -ui_page('html/index.html') - -files({ - 'html/index.html', - 'html/listener.js', - 'html/style.css' -}) \ No newline at end of file From 09be54bfa1b2ea8abce4624afc6d78b89416a297 Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Wed, 11 Nov 2020 10:01:13 -0500 Subject: [PATCH 05/31] Revert "Revert "added contributor, Slyforn"" This reverts commit c300624e49a81f44e1d35c17d5e11a5907852e28. --- fxmanifest.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 fxmanifest.lua diff --git a/fxmanifest.lua b/fxmanifest.lua new file mode 100644 index 0000000..8bd8e2a --- /dev/null +++ b/fxmanifest.lua @@ -0,0 +1,21 @@ +-- Script Description +fx_version 'cerulean' +games { 'gta5' } + +author 'lowheartrate & Slyforn' +description 'Street Label by lowheartrate' +version '1.1.0' + +-- Client Scripts +client_scripts { + 'config.lua', + 'client.lua' +} + +ui_page('html/index.html') + +files({ + 'html/index.html', + 'html/listener.js', + 'html/style.css' +}) \ No newline at end of file From 8cbe809e18c0649d916af4dfe3f4903d0b004751 Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Wed, 11 Nov 2020 10:01:27 -0500 Subject: [PATCH 06/31] Revert "cleaned up code + removed table" This reverts commit b32db6455ae202fb6a4bbf37a1d7553da2124fc7. --- client.lua | 63 ------------------------------------------------ html/index.html | 24 ------------------ html/listener.js | 38 ----------------------------- html/style.css | 50 -------------------------------------- 4 files changed, 175 deletions(-) delete mode 100644 client.lua delete mode 100644 html/index.html delete mode 100644 html/listener.js delete mode 100644 html/style.css diff --git a/client.lua b/client.lua deleted file mode 100644 index 8c42a07..0000000 --- a/client.lua +++ /dev/null @@ -1,63 +0,0 @@ --- Variables -local directions = { - N = 360, - NE = 315, - E = 270, - SE = 225, - S = 180, - SW = 135, - W = 90, - NW = 45, - N = 0, -} - -Citizen.CreateThread(function() - while true do - local ped = PlayerPedId(); - local veh = GetVehiclePedIsIn(ped); - local pos = GetEntityCoords(ped); - local zone = GetLabelText(GetNameOfZone(pos.x, pos.y, pos.z)); - - if (checkForVehicle == false or localVehicle ~= 0) then - local var1, var2 = GetStreetNameAtCoord(pos.x, pos.y, pos.z, Citizen.ResultAsInteger(), Citizen.ResultAsInteger()) - local street = GetStreetNameFromHashKey(var1); - local crossing = GetStreetNameFromHashKey(var2); - local direction = GetEntityHeading(ped); - - for k, v in pairs(directions) do - if (math.abs(direction - v) < 22.5) then - direction = k - break - end - end - - SendNuiMessage({ - type = 'open', - active = true, - direction, - zone, - street - }) - - else - if (veh) then - SendNuiMessage({ - type = 'open', - active = true, - direction, - zone, - street - }) - else - SendNuiMessage({ - type = 'close', - active = false - }) - end - end - - -- Wait for half a second. - Citizen.Wait(500); - - end -end) \ No newline at end of file diff --git a/html/index.html b/html/index.html deleted file mode 100644 index 8bc916b..0000000 --- a/html/index.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - Street Label - - - - - - -
- - - - - - - - -
-
- - - \ No newline at end of file diff --git a/html/listener.js b/html/listener.js deleted file mode 100644 index c85a0f9..0000000 --- a/html/listener.js +++ /dev/null @@ -1,38 +0,0 @@ -window.onload = (e) => { - let item = event.data; - - if (item && item.type === 'open') { - // ternary operator to display container depending on item.active value - if (!item.active) { - $("#container").hide(); - } else { - $("#container").show(); - - const direction = `| ${item.direction} |`; - const zone = item.zone; - const street = item.street; - - $("#direction").textContent = direction; - $("#street").textContent = street; - $("#zone").textContent = zone; - } - } - // window.addEventListener('message', onMessageRecieved); -}; - -function onMessageRecieved(event){ - var item = event.data; - if(item !== undefined && item.type === "streetLabelMSG"){ - if(item.active === false){ - $("#container").hide(); - } else { - $("#container").show(); - direction = "| "+item.direction+" |"; - zone = item.zone; - street = item.street; - $('#direction').text(direction); - $(document.getElementById("zone").innerHTML = zone); - $(document.getElementById("street").innerHTML = street); - } - } -} \ No newline at end of file diff --git a/html/style.css b/html/style.css deleted file mode 100644 index d1bc9cf..0000000 --- a/html/style.css +++ /dev/null @@ -1,50 +0,0 @@ -* { - color: #FFF; - font-weight: bold; - font-family: Impact, Helvetica, Arial, sans-serif; -} - -table, th, td { - border: 0px solid black; - border-collapse: collapse; -} - -th, td { - padding: 5px; - text-align: left; -} - -#container { - color: rgb(241, 235, 235); - position: absolute; - - height: 100px; - width: 30%; - - transform: translate(-50%, -50%); - top: 95%; - left: 32%; - - font-size: 46px; - - text-align: left; - text-shadow: 3px 3px #00000080; - - -webkit-text-stroke-width: 2px; - -webkit-text-stroke-color: #000000D9; -} - -#direction { - color: rgb(241, 235, 235); - font-size: 72px; -} - -#zone { - color: rgb(241, 235, 235); - font-size: 28px; -} - -#street { - color: rgb(217, 185, 46); - font-size: 32px; -} \ No newline at end of file From 7490d4907cfc029b1be494e497ace465d213813d Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Wed, 11 Nov 2020 10:21:58 -0500 Subject: [PATCH 07/31] Cleaned up code --- client.lua | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 client.lua diff --git a/client.lua b/client.lua new file mode 100644 index 0000000..86acc55 --- /dev/null +++ b/client.lua @@ -0,0 +1,62 @@ +-- Variables +local directions = { + N = 360, + NE = 315, + E = 270, + SE = 225, + S = 180, + SW = 135, + W = 90, + NW = 45, + N = 0, +} + +local veh = 0; +local streetHash1, streetHash2, playerDirection; + +Citizen.CreateThread(function() + while true do + local ped = GetPlayerPed(-1); + local veh = GetVehiclePedIsIn(ped, false); + + local coords = GetEntityCoords(PlayerPedId()); + local zone = GetNameOfZone(coords.x, coords.y, coords.z); + local zoneLabel = GetLabelText(zone); + + if(checkForVehicle == false or veh ~= 0) then + local var1, var2 = GetStreetNameAtCoord(coords.x, coords.y, coords.z, Citizen.ResultAsInteger(), Citizen.ResultAsInteger()) + streetHash1 = GetStreetNameFromHashKey(var1); + streetHash2 = GetStreetNameFromHashKey(var2); + playerDirection = GetEntityHeading(PlayerPedId()); + + for k, v in pairs(directions) do + if (math.abs(playerDirection - v) < 22.5) then + playerDirection = k; + break; + end + end + + local street2 = ''; + if (streetHash2 == '') then + street2 = zoneLabel; + else + street2 = streetHash2..', '..zoneLabel; + end + + SendNUIMessage({ + type = 'msg', + active = true, + direction = playerDirection, + zone = streetHash1, + street = street2 + }); + else + SendNUIMessage({ + type = 'msg', + active = false + }); + end + -- Wait for half a second. + Citizen.Wait(500); + end +end) \ No newline at end of file From cbeb7f1fad8eadf2a2a583a54a50d86553337cab Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Wed, 11 Nov 2020 10:22:26 -0500 Subject: [PATCH 08/31] Updated configuration file --- config.lua | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 config.lua diff --git a/config.lua b/config.lua new file mode 100644 index 0000000..fe374b6 --- /dev/null +++ b/config.lua @@ -0,0 +1,4 @@ +-- This will be of more use later on... + +-- Determine rather the HUD should only display when player(s) are inside a vehicle or not +checkForVehicle = false \ No newline at end of file From f08b42155dd12081e4c45c4cfd7248358c6ca78c Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Wed, 11 Nov 2020 10:22:54 -0500 Subject: [PATCH 09/31] Cleaned up code + removed table --- html/index.html | 24 ++++++++++++++++++++++++ html/style.css | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 html/index.html create mode 100644 html/style.css diff --git a/html/index.html b/html/index.html new file mode 100644 index 0000000..b914778 --- /dev/null +++ b/html/index.html @@ -0,0 +1,24 @@ + + + + + + + + Street Label + + + + + + +
+

+ +
+

+

+
+
+ + \ No newline at end of file diff --git a/html/style.css b/html/style.css new file mode 100644 index 0000000..cdd6c50 --- /dev/null +++ b/html/style.css @@ -0,0 +1,46 @@ +/* googleFonts */ +@import url('https://fonts.googleapis.com/css2?family=Archivo&display=swap'); + +/* General styling */ +* { + box-sizing: border-box; + font-family: 'Archivo', sans-serif; + margin: 0; padding: 0; +} + +#container { + display: flex; + align-items: center; + justify-content: center; + + background: rgba(143,164,196,0.45); + background: transparent; + color: rgb(241, 235, 235); + padding: 0 10px; + + position: absolute; + bottom: 17px; left: 17%; +} + +#container > div { + flex-flow: flex-col; + justify-content: space-between; +} + +/* Customization option(s) */ +#direction { + color: rgb(241, 235, 235); + font-size: 42px; + margin: 0 5px; +} + +#zone { + color: rgb(241, 235, 235); + font-size: 20px; + margin: 0 5px; +} +#street { + color: rgb(217, 185, 46); + font-size: 24px; + margin: 0 5px; +} \ No newline at end of file From d5c4931550b954b4dbf0a2955857227f055205f2 Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Wed, 11 Nov 2020 10:23:13 -0500 Subject: [PATCH 10/31] Cleaned up code --- html/listener.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 html/listener.js diff --git a/html/listener.js b/html/listener.js new file mode 100644 index 0000000..5e11b0c --- /dev/null +++ b/html/listener.js @@ -0,0 +1,21 @@ +window.onload = (e) => { + window.addEventListener('message', onMessageRecieved); +}; + +function onMessageRecieved(event){ + let item = event.data; + if (item && item.type === 'msg') { + if (!item.active) { + $("#container").hide(); + } else { + $("#container").show(); + let direction = `| ${item.direction} |`; + let zone = item.zone; + let street = item.street; + + $('#direction').text(direction); + $('#zone').text(zone); + $('#street').text(street); + } + } +} \ No newline at end of file From fa70f92017d47dcdda71ff05227843021be52c40 Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Wed, 11 Nov 2020 10:24:23 -0500 Subject: [PATCH 11/31] Removed un-needed folder/dir. --- streetLabel/__resource.lua | 11 -------- streetLabel/client.lua | 55 ------------------------------------ streetLabel/config.lua | 40 -------------------------- streetLabel/fxmanifest.lua | 21 -------------- streetLabel/html/index.html | 24 ---------------- streetLabel/html/listener.js | 24 ---------------- streetLabel/html/style.css | 50 -------------------------------- 7 files changed, 225 deletions(-) delete mode 100644 streetLabel/__resource.lua delete mode 100644 streetLabel/client.lua delete mode 100644 streetLabel/config.lua delete mode 100644 streetLabel/fxmanifest.lua delete mode 100644 streetLabel/html/index.html delete mode 100644 streetLabel/html/listener.js delete mode 100644 streetLabel/html/style.css diff --git a/streetLabel/__resource.lua b/streetLabel/__resource.lua deleted file mode 100644 index 63ea5c9..0000000 --- a/streetLabel/__resource.lua +++ /dev/null @@ -1,11 +0,0 @@ --- Manifest -resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' - --- Script Description -description 'Street Label byLowheartrate' - --- Client Scripts -client_scripts { - 'config.lua', - 'client.lua' -} diff --git a/streetLabel/client.lua b/streetLabel/client.lua deleted file mode 100644 index 4cdf28f..0000000 --- a/streetLabel/client.lua +++ /dev/null @@ -1,55 +0,0 @@ --- Variables -local directions = {[0] = 'N', [45] = 'NW', [90] = 'W', [135] = 'SW', [180] = 'S', [225] = 'SE', [270] = 'E', [315] = 'NE', [360] = 'N', } - -local playerPedID; -local localPed; -local localVehicle = 0; -local coords; -local zone; -local zoneLabel; - -local streetHash1; -local streetHash2; - -local playerDirection; - -Citizen.CreateThread(function() - - while true do - - localPed = GetPlayerPed(-1); - playerPedID = PlayerPedId(); - - localVehicle = GetVehiclePedIsIn(localPed, false); - coords = GetEntityCoords(playerPedID); - zone = GetNameOfZone(coords.x, coords.y, coords.z); - zoneLabel = GetLabelText(zone); - - if(checkForVehicle == false or localVehicle ~= 0) then - - local var1, var2 = GetStreetNameAtCoord(coords.x, coords.y, coords.z, Citizen.ResultAsInteger(), Citizen.ResultAsInteger()) - streetHash1 = GetStreetNameFromHashKey(var1); - streetHash2 = GetStreetNameFromHashKey(var2); - playerDirection = GetEntityHeading(playerPedID); - - for k,v in pairs(directions)do - if(math.abs(playerDirection - k) < 22.5)then - playerDirection = v - break - end - end - - local street2 = ""; - if(streetHash2 == "") then street2 = zoneLabel; - else street2 = streetHash2..", "..zoneLabel; end - - SendNUIMessage({type = 'streetLabelMSG', active = true, direction = playerDirection, zone = streetHash1, street = street2}); - else - SendNUIMessage({type = 'streetLabelMSG', active = false}); - end - - -- Wait for half a second. - Citizen.Wait(500); - - end -end) \ No newline at end of file diff --git a/streetLabel/config.lua b/streetLabel/config.lua deleted file mode 100644 index a21b697..0000000 --- a/streetLabel/config.lua +++ /dev/null @@ -1,40 +0,0 @@ --- Use the following variable(s) to adjust the position. - -- adjust the x-axis (left/right) - x = 1.000 - -- adjust the y-axis (top/bottom) - y = 1.000 --- If you do not see the HUD after restarting script you adjusted the x/y axis too far. - --- Use the following variable(s) to adjust the color(s) of each element. - -- Use the following variables to adjust the color of the border around direction. - border_r = 255 - border_g = 255 - border_b = 255 - border_a = 100 - - -- Use the following variables to adjust the color of the direction user is facing. - dir_r = 255 - dir_g = 255 - dir_b = 255 - dir_a = 255 - - -- Use the following variables to adjust the color of the street user is currently on. - curr_street_r = 240 - curr_street_g = 200 - curr_street_b = 80 - curr_street_a = 255 - - -- Use the following variables to adjust the color of the street around the player. (this will also change the town the user is in) - str_around_r = 255 - str_around_g = 255 - str_around_b = 255 - str_around_a = 255 - - -- Use the following variables to adjust the color of the city the player is in (without there being a street around them) - town_r = 255 - town_g = 255 - town_b = 255 - town_a = 255 - - -- Determine rather the HUD should only display when player(s) are inside a vehicle or not - checkForVehicle = false \ No newline at end of file diff --git a/streetLabel/fxmanifest.lua b/streetLabel/fxmanifest.lua deleted file mode 100644 index 4085fb3..0000000 --- a/streetLabel/fxmanifest.lua +++ /dev/null @@ -1,21 +0,0 @@ --- Script Description -fx_version 'cerulean' -games { 'gta5' } - -author 'Lowheartrate' -description 'Street Label by Lowheartrate' -version '1.X.X' - --- Client Scripts -client_scripts { - 'config.lua', - 'client.lua' -} - -ui_page('html/index.html') - -files({ - 'html/index.html', - 'html/listener.js', - 'html/style.css' -}) \ No newline at end of file diff --git a/streetLabel/html/index.html b/streetLabel/html/index.html deleted file mode 100644 index 8bc916b..0000000 --- a/streetLabel/html/index.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - Street Label - - - - - - -
- - - - - - - - -
-
- - - \ No newline at end of file diff --git a/streetLabel/html/listener.js b/streetLabel/html/listener.js deleted file mode 100644 index 7c29461..0000000 --- a/streetLabel/html/listener.js +++ /dev/null @@ -1,24 +0,0 @@ -window.onload = (e) => { - window.addEventListener('message', onMessageRecieved); -}; - -var direction; -var zone; -var street; - -function onMessageRecieved(event){ - var item = event.data; - if(item !== undefined && item.type === "streetLabelMSG"){ - if(item.active === false){ - $("#container").hide(); - } else { - $("#container").show(); - direction = "| "+item.direction+" |"; - zone = item.zone; - street = item.street; - $('#direction').text(direction); - $(document.getElementById("zone").innerHTML = zone); - $(document.getElementById("street").innerHTML = street); - } - } -} \ No newline at end of file diff --git a/streetLabel/html/style.css b/streetLabel/html/style.css deleted file mode 100644 index d1bc9cf..0000000 --- a/streetLabel/html/style.css +++ /dev/null @@ -1,50 +0,0 @@ -* { - color: #FFF; - font-weight: bold; - font-family: Impact, Helvetica, Arial, sans-serif; -} - -table, th, td { - border: 0px solid black; - border-collapse: collapse; -} - -th, td { - padding: 5px; - text-align: left; -} - -#container { - color: rgb(241, 235, 235); - position: absolute; - - height: 100px; - width: 30%; - - transform: translate(-50%, -50%); - top: 95%; - left: 32%; - - font-size: 46px; - - text-align: left; - text-shadow: 3px 3px #00000080; - - -webkit-text-stroke-width: 2px; - -webkit-text-stroke-color: #000000D9; -} - -#direction { - color: rgb(241, 235, 235); - font-size: 72px; -} - -#zone { - color: rgb(241, 235, 235); - font-size: 28px; -} - -#street { - color: rgb(217, 185, 46); - font-size: 32px; -} \ No newline at end of file From 2464fa8f0a4c02d8573d525c50d51b15d6c10267 Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Wed, 11 Nov 2020 10:25:22 -0500 Subject: [PATCH 12/31] Fixed ugly syntax --- fxmanifest.lua | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fxmanifest.lua b/fxmanifest.lua index 8bd8e2a..33f1db6 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -8,14 +8,14 @@ version '1.1.0' -- Client Scripts client_scripts { - 'config.lua', - 'client.lua' + 'config.lua', + 'client.lua' } ui_page('html/index.html') files({ - 'html/index.html', - 'html/listener.js', - 'html/style.css' + 'html/index.html', + 'html/listener.js', + 'html/style.css' }) \ No newline at end of file From f35d08ccb752ee07dd100ad6258d93e932243b06 Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Wed, 11 Nov 2020 14:22:00 -0500 Subject: [PATCH 13/31] Cleaned up code --- html/style.css | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/html/style.css b/html/style.css index cdd6c50..f0668a7 100644 --- a/html/style.css +++ b/html/style.css @@ -27,20 +27,23 @@ justify-content: space-between; } +/* Customization option(s) */ +#direction, #zone, #street { + text-shadow: 2px 2px 3px rgba(0,0,0,0.45); + margin: 0 5px; +} + /* Customization option(s) */ #direction { color: rgb(241, 235, 235); font-size: 42px; - margin: 0 5px; } #zone { color: rgb(241, 235, 235); font-size: 20px; - margin: 0 5px; } #street { color: rgb(217, 185, 46); font-size: 24px; - margin: 0 5px; } \ No newline at end of file From 8ad504f4135654b4c19d05321d765b4583a3558a Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Wed, 11 Nov 2020 14:22:15 -0500 Subject: [PATCH 14/31] Fixed minor bug(s) --- client.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/client.lua b/client.lua index 86acc55..51b620a 100644 --- a/client.lua +++ b/client.lua @@ -8,7 +8,7 @@ local directions = { SW = 135, W = 90, NW = 45, - N = 0, + -- N = 0, <= will result in the HUD breaking above 315deg } local veh = 0; @@ -32,7 +32,11 @@ Citizen.CreateThread(function() for k, v in pairs(directions) do if (math.abs(playerDirection - v) < 22.5) then playerDirection = k; - break; + break; + else + -- fallback to N + playerDirection = 'N'; + break; end end From 05925325d1ca385816d9ae8f05581575c380d651 Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Thu, 12 Nov 2020 23:29:08 -0500 Subject: [PATCH 15/31] Fully responsive + color options! --- html/index.html | 6 +++++- html/style.css | 43 ++++++++++++++++++++++--------------------- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/html/index.html b/html/index.html index b914778..e5fd35b 100644 --- a/html/index.html +++ b/html/index.html @@ -13,7 +13,11 @@
-

+
+ | +

+ | +

diff --git a/html/style.css b/html/style.css index f0668a7..ecfcfe4 100644 --- a/html/style.css +++ b/html/style.css @@ -9,21 +9,32 @@ } #container { - display: flex; align-items: center; - justify-content: center; - - background: rgba(143,164,196,0.45); - background: transparent; + bottom: 17px; color: rgb(241, 235, 235); + display: flex; + flex-direction: row; + justify-content: center; + left: 17%; padding: 0 10px; - position: absolute; - bottom: 17px; left: 17%; +} + +#container > section { + align-items: center; + display: flex; + flex-direction: row; +} + +#container > section > span { + color: rgba(255,255,255,0.65); + font-size: 4vw; + margin: 0 5px; } #container > div { - flex-flow: flex-col; + display: flex; + flex-direction: column; justify-content: space-between; } @@ -34,16 +45,6 @@ } /* Customization option(s) */ -#direction { - color: rgb(241, 235, 235); - font-size: 42px; -} - -#zone { - color: rgb(241, 235, 235); - font-size: 20px; -} -#street { - color: rgb(217, 185, 46); - font-size: 24px; -} \ No newline at end of file +#direction {font-size: 3.5vw;} +#street {font-size: 2vw;} +#zone {font-size: 1.45vw;} \ No newline at end of file From 4179e70fc5e7c5de0932f9876d7bcc7ce4c30dd9 Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Thu, 12 Nov 2020 23:39:52 -0500 Subject: [PATCH 16/31] Added configuration functionality --- html/listener.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/html/listener.js b/html/listener.js index 5e11b0c..384e5a5 100644 --- a/html/listener.js +++ b/html/listener.js @@ -17,5 +17,46 @@ function onMessageRecieved(event){ $('#zone').text(zone); $('#street').text(street); } + } + + if (item && item.type === 'data') { + /* color customization */ + let direction = [item.direction.r, item.direction.g, item.direction.b, item.direction.a]; + let zone = [item.zone.r, item.zone.g, item.zone.b, item.zone.a]; + let street = [item.street.r, item.street.g, item.street.b, item.street.a]; + let directionDOM = $('#direction'); let zoneDOM = $('#zone'); let streetDOM = $('#street'); + + // Initialize DOM-elements with proper styling elements! + directionDOM.css('color', 'rgba('+direction.join(', ')+')'); + zoneDOM.css('color', 'rgba('+zone.join(', ')+')'); + streetDOM.css('color', 'rgba('+street.join(', ')+')'); + + if (directionDOM.css('color').toString() !=='rgba('+direction.join(', ')+')'.toString()) { + console.log('ERROR => directionDOM styles are not configured properly :('); + console.log('CONFIGURED => rgba('+direction.join(', ')+')'.toString()); + console.log('SET =>', directionDOM.css('color').toString()); + + directionDOM.css('color', 'rgba('+direction.join(', ')+')'); + } else { console.log('SUCCESS! => direction is properly configured!'); } + + if (zoneDOM.css('color').toString() !== 'rgba('+zone.join(', ')+')'.toString()) { + console.log('ERROR => zoneDOM styles are not configured properly :('); + console.log('CONFIGURED => rgba('+zone.join(', ')+')'.toString()); + console.log('SET =>', zoneDOM.css('color').toString()); + + zoneDOM.css('color', 'rgba('+zone.join(', ')+')'); + } else { console.log('SUCCESS! => zone is properly configured!'); } + + if (streetDOM.css('color').toString() !== 'rgba('+street.join(', ')+')'.toString()) { + console.log('ERROR => zoneDOM styles are not configured properly :('); + console.log('CONFIGURED => rgba('+street.join(', ')+')'.toString()); + console.log('SET =>', streetDOM.css('color').toString()); + + streetDOM.css('color', 'rgba('+street.join(', ')+')'); + } else { console.log('SUCCESS! => street is properly configured!'); } + + /* position/sizing */ + + /* view */ } } \ No newline at end of file From f1695d58a5a9759b0f376a26afb1f240b8231ae1 Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Thu, 12 Nov 2020 23:40:25 -0500 Subject: [PATCH 17/31] More customization options! --- config.lua | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/config.lua b/config.lua index fe374b6..8ce9466 100644 --- a/config.lua +++ b/config.lua @@ -1,4 +1,33 @@ --- This will be of more use later on... +config = { + -- Color customization options + colours = { + current = { + r=255; + g=255; + b=255; + a=0.9; + }; + crossing = { + r=240; + g=220; + b=80; + a=0.9; + }; + direction = { + r=240; + g=220; + b=80; + a=0.9; + }; + }; + + -- General HUD positioning/sizing + position = { + offsetX = 0; -- Recommended to increment by x + offsetY = 0; -- Recommended to increment by x + size = 100; + }; --- Determine rather the HUD should only display when player(s) are inside a vehicle or not -checkForVehicle = false \ No newline at end of file + vehicleCheck = true; -- Rather or not to display HUD when player(s) are inside a vehicle + view = 'classic'; -- classic: original Street Label look -- dynamic: new dynamic inline HUD +} \ No newline at end of file From b240f64ad030054e184d26af4361e6f7b7ffb399 Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Thu, 12 Nov 2020 23:42:01 -0500 Subject: [PATCH 18/31] Added configuration functionality --- client.lua | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/client.lua b/client.lua index 51b620a..09276d9 100644 --- a/client.lua +++ b/client.lua @@ -15,7 +15,22 @@ local veh = 0; local streetHash1, streetHash2, playerDirection; Citizen.CreateThread(function() - while true do + + -- Wait half a second before sending data NUI message :? + Citizen.Wait(500); + + SendNUIMessage({ + type = 'data', + view = config.view, + direction = config.colours.direction, + zone = config.colours.current, + street = config.colours.crossing, + offsetX = config.position.offsetX, + offsetY = config.position.offsetY, + size = config.position.size + }); + + while true do local ped = GetPlayerPed(-1); local veh = GetVehiclePedIsIn(ped, false); From e2a525e44172dcc6ac98bddb6b7bb994b96ea66f Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Fri, 13 Nov 2020 00:41:04 -0500 Subject: [PATCH 19/31] Further instructions! --- README.md | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 663eb8a..583dfba 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,29 @@ # streetLabel -streetLabel adds a hud much like **[Player Location Display](https://www.gta5-mods.com/scripts/player-location-display-v3-50)** by **LtCaine**. +streetLabel adds a slick UI on the bottom of your players display showing various information about their location on the HUD. This mod was inspired by **[Lt. Caine](https://www.gta5-mods.com/users/LtCine)**'s most popular client side mod known as **[Player Location Display](https://www.gta5-mods.com/scripts/player-location-display-v3-50)**. + +### Preview +![streetlabel-preview](https://i.imgur.com/0B7OxoA.png) ### Features -- Configuration file to change colors and position of each hud element. -- Ability to set hud to show *only when* players are in a vehicle. +- The left most portion of this mod will display the direction the player is currently facing. +- The top line of text will display the name of the street the player is currently on. +- The bottom line will show the name of the street around the player or city/town. +- Many customizable configuration options to customize the HUD to your liking, including colors & `vehicleCheck` ## Download & Installation ### Using Git ``` -cd resources +cd /server-data/resources git clone https://github.com/lowheartrate/streetLabel ``` ### Manually -- Download and insert `streetLabel` folder into your **/server-data/resources/** directory. +- Download the most recent `.zip` file/archive from the **[releases](https://github.com/codibez/streetLabel/releases) page. +- Extract the contents to your `server-data/resources/` directory. ## Installation -- Add this to your `server.cfg`: - +- Ensure you've added the following to your `server.cfg` file: ``` start streetLabel ``` From 4671556ee944be84d7969fdb49f9bff9a9a9efb5 Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Fri, 13 Nov 2020 00:42:11 -0500 Subject: [PATCH 20/31] minor changes --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 583dfba..21041b0 100644 --- a/README.md +++ b/README.md @@ -14,12 +14,12 @@ streetLabel adds a slick UI on the bottom of your players display showing variou ### Using Git ``` -cd /server-data/resources +cd server-data/resources/ git clone https://github.com/lowheartrate/streetLabel ``` ### Manually -- Download the most recent `.zip` file/archive from the **[releases](https://github.com/codibez/streetLabel/releases) page. +- Download the most recent `.zip` file/archive from the **[releases](https://github.com/codibez/streetLabel/releases)** page. - Extract the contents to your `server-data/resources/` directory. ## Installation From 9d204ffdcbd11aba440f2f1c0aea605cbd370a0c Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Fri, 13 Nov 2020 09:51:15 -0500 Subject: [PATCH 21/31] Cleaned up syntax --- config.lua | 69 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 39 insertions(+), 30 deletions(-) diff --git a/config.lua b/config.lua index 8ce9466..ebe2a7e 100644 --- a/config.lua +++ b/config.lua @@ -1,33 +1,42 @@ config = { - -- Color customization options - colours = { - current = { - r=255; - g=255; - b=255; - a=0.9; - }; - crossing = { - r=240; - g=220; - b=80; - a=0.9; - }; - direction = { - r=240; - g=220; - b=80; - a=0.9; - }; - }; - - -- General HUD positioning/sizing - position = { - offsetX = 0; -- Recommended to increment by x - offsetY = 0; -- Recommended to increment by x - size = 100; - }; + -- Customization options + border = { + r = 255; + g = 255; + b = 255; + a = 0.65; + size = 5; + }; - vehicleCheck = true; -- Rather or not to display HUD when player(s) are inside a vehicle - view = 'classic'; -- classic: original Street Label look -- dynamic: new dynamic inline HUD + current = { + r = 255; + g = 255; + b = 255; + a = 0.9; + size = 2.5; + }; + + crossing = { + r = 240; + g = 220; + b = 80; + a = 0.9; + size = 2; + }; + + direction = { + r = 240; + g = 220; + b = 80; + a = 0.9; + size = 4; + }; + + position = { + -- 0:100 + offsetX = 17; + offsetY = 2.5; + }; + + vehicleCheck = true; -- Rather or not to display HUD when player(s) are inside a vehicle } \ No newline at end of file From 966c32dc0b5a4ab1f4c07cd657454a46d3f090c9 Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Fri, 13 Nov 2020 09:51:46 -0500 Subject: [PATCH 22/31] Initialized borders in NUI-Message --- client.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/client.lua b/client.lua index 09276d9..33f6624 100644 --- a/client.lua +++ b/client.lua @@ -22,6 +22,7 @@ Citizen.CreateThread(function() SendNUIMessage({ type = 'data', view = config.view, + border = config.border, direction = config.colours.direction, zone = config.colours.current, street = config.colours.crossing, From 5b0a2b2f2c29d9d9f18f85ca326e3e110a242916 Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Fri, 13 Nov 2020 09:53:19 -0500 Subject: [PATCH 23/31] Functional color variables! --- html/index.html | 4 ++-- html/listener.js | 59 ++++++++++++++++++++---------------------------- html/style.css | 16 ++----------- 3 files changed, 28 insertions(+), 51 deletions(-) diff --git a/html/index.html b/html/index.html index e5fd35b..295b010 100644 --- a/html/index.html +++ b/html/index.html @@ -14,9 +14,9 @@
- | + |

- | + |
diff --git a/html/listener.js b/html/listener.js index 384e5a5..1c7ddb1 100644 --- a/html/listener.js +++ b/html/listener.js @@ -20,43 +20,32 @@ function onMessageRecieved(event){ } if (item && item.type === 'data') { - /* color customization */ - let direction = [item.direction.r, item.direction.g, item.direction.b, item.direction.a]; + /* color customization */ + let border = [item.border.r, item.border.g, item.border.b, item.border.a]; + let borderDOM = document.querySelectorAll('#border'); + let direction = [item.direction.r, item.direction.g, item.direction.b, item.direction.a]; let zone = [item.zone.r, item.zone.g, item.zone.b, item.zone.a]; let street = [item.street.r, item.street.g, item.street.b, item.street.a]; - let directionDOM = $('#direction'); let zoneDOM = $('#zone'); let streetDOM = $('#street'); - - // Initialize DOM-elements with proper styling elements! - directionDOM.css('color', 'rgba('+direction.join(', ')+')'); - zoneDOM.css('color', 'rgba('+zone.join(', ')+')'); - streetDOM.css('color', 'rgba('+street.join(', ')+')'); - - if (directionDOM.css('color').toString() !=='rgba('+direction.join(', ')+')'.toString()) { - console.log('ERROR => directionDOM styles are not configured properly :('); - console.log('CONFIGURED => rgba('+direction.join(', ')+')'.toString()); - console.log('SET =>', directionDOM.css('color').toString()); - - directionDOM.css('color', 'rgba('+direction.join(', ')+')'); - } else { console.log('SUCCESS! => direction is properly configured!'); } - - if (zoneDOM.css('color').toString() !== 'rgba('+zone.join(', ')+')'.toString()) { - console.log('ERROR => zoneDOM styles are not configured properly :('); - console.log('CONFIGURED => rgba('+zone.join(', ')+')'.toString()); - console.log('SET =>', zoneDOM.css('color').toString()); - - zoneDOM.css('color', 'rgba('+zone.join(', ')+')'); - } else { console.log('SUCCESS! => zone is properly configured!'); } - - if (streetDOM.css('color').toString() !== 'rgba('+street.join(', ')+')'.toString()) { - console.log('ERROR => zoneDOM styles are not configured properly :('); - console.log('CONFIGURED => rgba('+street.join(', ')+')'.toString()); - console.log('SET =>', streetDOM.css('color').toString()); - - streetDOM.css('color', 'rgba('+street.join(', ')+')'); - } else { console.log('SUCCESS! => street is properly configured!'); } - - /* position/sizing */ - + + // jQuery #direction to proper color & font-size configuration + $('#direction').css('color', 'rgba('+direction.join(', ')+')'); + $('#direction').css('font-size', item.direction.size + 'vw'); + + // jQuery #street to proper color & font-size configuration + $('#street').css('color', 'rgba('+street.join(', ')+')'); + $('#street').css('font-size', item.street.size + 'vw'); + + // jQuery #zone to proper color & font-size configuration + $('#zone').css('color', 'rgba('+zone.join(', ')+')'); + $('#zone').css('font-size', item.zone.size + 'vw'); + + for (let i=0; i section > span { - color: rgba(255,255,255,0.65); - font-size: 4vw; - margin: 0 5px; + justify-content: center; } #container > div { @@ -42,9 +35,4 @@ #direction, #zone, #street { text-shadow: 2px 2px 3px rgba(0,0,0,0.45); margin: 0 5px; -} - -/* Customization option(s) */ -#direction {font-size: 3.5vw;} -#street {font-size: 2vw;} -#zone {font-size: 1.45vw;} \ No newline at end of file +} \ No newline at end of file From 129325d75e317b539574862d387f3ed24e866f46 Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Fri, 13 Nov 2020 10:32:06 -0500 Subject: [PATCH 24/31] Ability to move hud, functioning! --- html/listener.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/html/listener.js b/html/listener.js index 1c7ddb1..7470b3c 100644 --- a/html/listener.js +++ b/html/listener.js @@ -45,6 +45,9 @@ function onMessageRecieved(event){ } /* HUD position */ + let container = document.getElementById('container'); + if (item.offsetX) { container.style.left = item.offsetX + '%' } + if (item.offsetY) { container.style.right = item.offsetY + '%' } /* view */ } From 813dfe073e43f225f3cbfac959641c5d52bacc97 Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Fri, 13 Nov 2020 16:32:18 -0500 Subject: [PATCH 25/31] Fixed minor bug with direction --- html/listener.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/html/listener.js b/html/listener.js index 7470b3c..cf7d00f 100644 --- a/html/listener.js +++ b/html/listener.js @@ -9,7 +9,7 @@ function onMessageRecieved(event){ $("#container").hide(); } else { $("#container").show(); - let direction = `| ${item.direction} |`; + let direction = item.direction; let zone = item.zone; let street = item.street; @@ -49,6 +49,7 @@ function onMessageRecieved(event){ if (item.offsetX) { container.style.left = item.offsetX + '%' } if (item.offsetY) { container.style.right = item.offsetY + '%' } - /* view */ + /* view */ + } } \ No newline at end of file From 04967b6d880aa94d7b33b4b5d97b9fb43bb399f7 Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Fri, 13 Nov 2020 16:32:50 -0500 Subject: [PATCH 26/31] Fixed minor bug with direction --- client.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/client.lua b/client.lua index 33f6624..b2395de 100644 --- a/client.lua +++ b/client.lua @@ -1,6 +1,6 @@ -- Variables local directions = { - N = 360, + N = 360, 0, NE = 315, E = 270, SE = 225, @@ -47,7 +47,13 @@ Citizen.CreateThread(function() for k, v in pairs(directions) do if (math.abs(playerDirection - v) < 22.5) then - playerDirection = k; + playerDirection = k; + + if (playerDirection == 1) then + playerDirection = 'N'; + break; + end + break; else -- fallback to N From ff327659da5f57f4e26e7fcc646d39331907bc6e Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Fri, 13 Nov 2020 17:35:36 -0500 Subject: [PATCH 27/31] intial values --- config.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config.lua b/config.lua index ebe2a7e..d197993 100644 --- a/config.lua +++ b/config.lua @@ -5,7 +5,7 @@ config = { g = 255; b = 255; a = 0.65; - size = 5; + size = 4; }; current = { @@ -13,7 +13,7 @@ config = { g = 255; b = 255; a = 0.9; - size = 2.5; + size = 1.45; }; crossing = { @@ -29,7 +29,7 @@ config = { g = 220; b = 80; a = 0.9; - size = 4; + size = 3.5; }; position = { From c3789f374d43827773f31373aa0228dd0af65b53 Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Fri, 13 Nov 2020 17:35:58 -0500 Subject: [PATCH 28/31] more *minor* bug fixes :) --- client.lua | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/client.lua b/client.lua index b2395de..6d2bcd8 100644 --- a/client.lua +++ b/client.lua @@ -7,7 +7,7 @@ local directions = { S = 180, SW = 135, W = 90, - NW = 45, + NW = 45 -- N = 0, <= will result in the HUD breaking above 315deg } @@ -23,12 +23,11 @@ Citizen.CreateThread(function() type = 'data', view = config.view, border = config.border, - direction = config.colours.direction, - zone = config.colours.current, - street = config.colours.crossing, + direction = config.direction, + zone = config.current, + street = config.crossing, offsetX = config.position.offsetX, - offsetY = config.position.offsetY, - size = config.position.size + offsetY = config.position.offsetY }); while true do @@ -54,10 +53,6 @@ Citizen.CreateThread(function() break; end - break; - else - -- fallback to N - playerDirection = 'N'; break; end end From 0b8383bc672a58222bdd3f63025b6d061a7088c3 Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Fri, 13 Nov 2020 17:37:33 -0500 Subject: [PATCH 29/31] organized/fixed code --- html/listener.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/html/listener.js b/html/listener.js index cf7d00f..907104a 100644 --- a/html/listener.js +++ b/html/listener.js @@ -20,11 +20,14 @@ function onMessageRecieved(event){ } if (item && item.type === 'data') { + let container = document.getElementById('container'); + /* color customization */ let border = [item.border.r, item.border.g, item.border.b, item.border.a]; let borderDOM = document.querySelectorAll('#border'); + let direction = [item.direction.r, item.direction.g, item.direction.b, item.direction.a]; - let zone = [item.zone.r, item.zone.g, item.zone.b, item.zone.a]; + let zone = [item.zone.r, item.zone.g, item.zone.b, item.zone.a]; let street = [item.street.r, item.street.g, item.street.b, item.street.a]; // jQuery #direction to proper color & font-size configuration @@ -45,11 +48,9 @@ function onMessageRecieved(event){ } /* HUD position */ - let container = document.getElementById('container'); if (item.offsetX) { container.style.left = item.offsetX + '%' } if (item.offsetY) { container.style.right = item.offsetY + '%' } /* view */ - } } \ No newline at end of file From 6fa862ea323d816c5690c4a40dce1b9d06681e41 Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Fri, 13 Nov 2020 20:57:32 -0500 Subject: [PATCH 30/31] Final bug fixes? --- client.lua | 11 +++++------ html/listener.js | 14 ++++++++------ html/style.css | 17 ++++++++--------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/client.lua b/client.lua index 6d2bcd8..2521182 100644 --- a/client.lua +++ b/client.lua @@ -16,12 +16,11 @@ local streetHash1, streetHash2, playerDirection; Citizen.CreateThread(function() - -- Wait half a second before sending data NUI message :? - Citizen.Wait(500); + -- Wait a single second before sending data NUI message :? + Citizen.Wait(1000); SendNUIMessage({ - type = 'data', - view = config.view, + type = 'streetLabel:DATA', border = config.border, direction = config.direction, zone = config.current, @@ -65,7 +64,7 @@ Citizen.CreateThread(function() end SendNUIMessage({ - type = 'msg', + type = 'streetLabel:MSG', active = true, direction = playerDirection, zone = streetHash1, @@ -73,7 +72,7 @@ Citizen.CreateThread(function() }); else SendNUIMessage({ - type = 'msg', + type = 'streetLabel:MSG', active = false }); end diff --git a/html/listener.js b/html/listener.js index 907104a..cfa0f23 100644 --- a/html/listener.js +++ b/html/listener.js @@ -3,12 +3,14 @@ window.onload = (e) => { }; function onMessageRecieved(event){ - let item = event.data; - if (item && item.type === 'msg') { + let item = event.data; + + if (item && item.type === 'streetLabel:MSG') { if (!item.active) { $("#container").hide(); } else { - $("#container").show(); + $("#container").show(); + let direction = item.direction; let zone = item.zone; let street = item.street; @@ -19,7 +21,7 @@ function onMessageRecieved(event){ } } - if (item && item.type === 'data') { + if (item && item.type === 'streetLabel:DATA') { let container = document.getElementById('container'); /* color customization */ @@ -42,14 +44,14 @@ function onMessageRecieved(event){ $('#zone').css('color', 'rgba('+zone.join(', ')+')'); $('#zone').css('font-size', item.zone.size + 'vw'); - for (let i=0; i section { @@ -31,7 +31,6 @@ justify-content: space-between; } -/* Customization option(s) */ #direction, #zone, #street { text-shadow: 2px 2px 3px rgba(0,0,0,0.45); margin: 0 5px; From 59dfcfb9ab3f9188de550b81b458a9f5c3fac3e1 Mon Sep 17 00:00:00 2001 From: Codi Bezouka-Smith <8846438+codibez@users.noreply.github.com> Date: Fri, 13 Nov 2020 21:06:37 -0500 Subject: [PATCH 31/31] Fixed ugly syntax Overall went over any misleading syntax to make it look official for release. --- client.lua | 62 +++++++++++++++++++++---------------------- config.lua | 70 ++++++++++++++++++++++++------------------------- fxmanifest.lua | 10 +++---- html/index.html | 12 ++++----- html/style.css | 36 ++++++++++++------------- 5 files changed, 95 insertions(+), 95 deletions(-) diff --git a/client.lua b/client.lua index 2521182..f6dcd17 100644 --- a/client.lua +++ b/client.lua @@ -16,23 +16,23 @@ local streetHash1, streetHash2, playerDirection; Citizen.CreateThread(function() - -- Wait a single second before sending data NUI message :? - Citizen.Wait(1000); + -- Wait a single second before sending data NUI message :? + Citizen.Wait(1000); - SendNUIMessage({ - type = 'streetLabel:DATA', - border = config.border, - direction = config.direction, - zone = config.current, - street = config.crossing, - offsetX = config.position.offsetX, - offsetY = config.position.offsetY - }); + SendNUIMessage({ + type = 'streetLabel:DATA', + border = config.border, + direction = config.direction, + zone = config.current, + street = config.crossing, + offsetX = config.position.offsetX, + offsetY = config.position.offsetY + }); - while true do + while true do local ped = GetPlayerPed(-1); - local veh = GetVehiclePedIsIn(ped, false); - + local veh = GetVehiclePedIsIn(ped, false); + local coords = GetEntityCoords(PlayerPedId()); local zone = GetNameOfZone(coords.x, coords.y, coords.z); local zoneLabel = GetLabelText(zone); @@ -45,14 +45,14 @@ Citizen.CreateThread(function() for k, v in pairs(directions) do if (math.abs(playerDirection - v) < 22.5) then - playerDirection = k; - - if (playerDirection == 1) then - playerDirection = 'N'; - break; - end + playerDirection = k; + + if (playerDirection == 1) then + playerDirection = 'N'; + break; + end - break; + break; end end @@ -64,19 +64,19 @@ Citizen.CreateThread(function() end SendNUIMessage({ - type = 'streetLabel:MSG', - active = true, - direction = playerDirection, - zone = streetHash1, - street = street2 - }); + type = 'streetLabel:MSG', + active = true, + direction = playerDirection, + zone = streetHash1, + street = street2 + }); else SendNUIMessage({ - type = 'streetLabel:MSG', - active = false - }); + type = 'streetLabel:MSG', + active = false + }); end -- Wait for half a second. Citizen.Wait(500); - end + end end) \ No newline at end of file diff --git a/config.lua b/config.lua index d197993..bad94fe 100644 --- a/config.lua +++ b/config.lua @@ -1,42 +1,42 @@ config = { - -- Customization options - border = { - r = 255; - g = 255; - b = 255; - a = 0.65; - size = 4; - }; + -- Customization options + border = { + r = 255; + g = 255; + b = 255; + a = 0.65; + size = 4; + }; - current = { - r = 255; - g = 255; - b = 255; - a = 0.9; - size = 1.45; - }; + current = { + r = 255; + g = 255; + b = 255; + a = 0.9; + size = 1.45; + }; - crossing = { - r = 240; - g = 220; - b = 80; - a = 0.9; - size = 2; - }; + crossing = { + r = 240; + g = 220; + b = 80; + a = 0.9; + size = 2; + }; - direction = { - r = 240; - g = 220; - b = 80; - a = 0.9; - size = 3.5; - }; + direction = { + r = 240; + g = 220; + b = 80; + a = 0.9; + size = 3.5; + }; - position = { - -- 0:100 - offsetX = 17; - offsetY = 2.5; - }; + position = { + -- 0:100 + offsetX = 17; + offsetY = 2.5; + }; - vehicleCheck = true; -- Rather or not to display HUD when player(s) are inside a vehicle + vehicleCheck = true; -- Rather or not to display HUD when player(s) are inside a vehicle } \ No newline at end of file diff --git a/fxmanifest.lua b/fxmanifest.lua index 33f1db6..c4fde55 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -8,14 +8,14 @@ version '1.1.0' -- Client Scripts client_scripts { - 'config.lua', - 'client.lua' + 'config.lua', + 'client.lua' } ui_page('html/index.html') files({ - 'html/index.html', - 'html/listener.js', - 'html/style.css' + 'html/index.html', + 'html/listener.js', + 'html/style.css' }) \ No newline at end of file diff --git a/html/index.html b/html/index.html index 295b010..f3a61af 100644 --- a/html/index.html +++ b/html/index.html @@ -9,20 +9,20 @@ - +
- | -

- | -
+ | +

+ | +

-
+
\ No newline at end of file diff --git a/html/style.css b/html/style.css index 3b3050f..b1ef6b4 100644 --- a/html/style.css +++ b/html/style.css @@ -3,35 +3,35 @@ /* General styling */ * { - box-sizing: border-box; - font-family: 'Archivo', sans-serif; - margin: 0; padding: 0; + box-sizing: border-box; + font-family: 'Archivo', sans-serif; + margin: 0; padding: 0; } #container { - align-items: center; - color: rgb(241, 235, 235); - display: flex; - flex-direction: row; - justify-content: center; - padding: 0 10px; - position: absolute; + align-items: center; + color: rgb(241, 235, 235); + display: flex; + flex-direction: row; + justify-content: center; + padding: 0 10px; + position: absolute; } #container > section { - align-items: center; - display: flex; - flex-direction: row; - justify-content: center; + align-items: center; + display: flex; + flex-direction: row; + justify-content: center; } #container > div { - display: flex; - flex-direction: column; + display: flex; + flex-direction: column; justify-content: space-between; } #direction, #zone, #street { - text-shadow: 2px 2px 3px rgba(0,0,0,0.45); - margin: 0 5px; + text-shadow: 2px 2px 3px rgba(0,0,0,0.45); + margin: 0 5px; } \ No newline at end of file