22small
Members-
Posts
5 -
Joined
-
Last visited
22small's Achievements
Vic (3/54)
1
Reputation
-
I've resolved the issue, it's displaying the district properly now. I managed to find the solution, thanks to everyone who submitted their ideas.
-
Doesn't do what I need it to I need district = "Vice Point" from that table to show below my speedo, from the code of my very first post. Cuz it's not showing anything with the code that I gave on the first post which is this. BUT with this code, it stopped showing either, unless I remove everything with value.streetzone, then it will only show "Template Name" above my speedo. Though I need "District Template" to show Below my speedo. local names = { -- nodes, name and district { { 1703957, 1703958 }, name = "Template Name", district = "District Template" }, } for k, node in ipairs( names ) do for _, route in ipairs( node ) do if #route == 1 then local value = getNodeByID( vehicleNodes, route[1] ) if value then if not value.streetname then value.streetname = node.name elseif value.streetname ~= node.name then value.streetname = value.streetname .. "/" .. node.name if not value.streetzone then value.streetzone = node.district elseif value.streetzone ~= node.district then value.streetzone = value.streetzone .. "/" .. node.district end end else for i = 1, #route - 1 do local path = calculatePathByNodeIDs( math.abs(route[i]), math.abs(route[i+1]) ) for key, value in ipairs(path) do if value.id == -route[i] or value.id == -route[i+1] then elseif not value.streetname then value.streetname = node.name elseif value.streetname ~= node.name then value.streetname = value.streetname .. "/" .. node.name elseif not value.streetzone then value.streetzone = node.district elseif value.streetzone ~= node.district then value.streetzone = value.streetzone .. "/" .. node.district end end end end end end end local cacheX, cacheY, cacheZ = 0, 0, 0 addEventHandler("onClientRender", getRootElement(), function() local x, y, z = getElementPosition(getLocalPlayer()) if cacheX ~= x or cacheY ~= y or cacheZ ~= z then local node = findNodeClosestToPoint(vehicleNodes, x, y, z) setElementData(getLocalPlayer(), "speedo:street", node.streetname) setElementData(getLocalPlayer(), "speedo:zone", node.district) cacheX = x cacheY = y cacheZ = z end end ) -- street names local streetname = getElementData(getLocalPlayer(), "speedo:street" ) if streetname and getVehicleType(vehicle) ~= "Boat" and getVehicleType(vehicle) ~= "Helicopter" and getVehicleType(vehicle) ~= "Plane" then local width = dxGetTextWidth( streetname ) local x = width < 200 and ( x - 110 - width / 2 ) or ( x - 10 - width ) dxDrawRectangle( x - 8, y - 296, width + 17, 24, tocolor( 5, 5, 5, 220 ) ) dxDrawText( streetname, x, y - 292 ) end -- district names local streetzone = getElementData(getLocalPlayer(), "speedo:zone" ) if streetzone and getVehicleType(vehicle) ~= "Boat" and getVehicleType(vehicle) ~= "Helicopter" and getVehicleType(vehicle) ~= "Plane" then local width = dxGetTextWidth( streetzone ) local x = width < 200 and ( x - 110 - width / 2 ) or ( x - 10 - width ) dxDrawRectangle( x - 8, y - 76-5, width + 17, 24, tocolor( 5, 5, 5, 220 ) ) dxDrawText( streetzone, x, y - 72-5 ) end
-
ERROR: Loading script failed: gps-system\c_streetNames.lua:5 ']' expected near ',' I got this error in debugscript from the edit you made, although there wasn't any change to define the district anywhere else, like I had tried on my first submit so that it would display with the dxDraw
-
Thanks for your solution, though it's not what I'm looking for heh. I'm using a custom map, though using vehicle nodes to clarify the street name, but I'm trying to use that same table string to add a custom district to it. Below is the base of what I first had, this just only shows me "Interstate 89" in game above the speedo. I'm trying to get Vice Point to show below the speedo. local names = { -- Node, street, district { { 1703957, 1703958 }, name = "Interstate 89", district = "Vice Point" }, } for k, node in ipairs( names ) do for _, route in ipairs( node ) do if #route == 1 then local value = getNodeByID( vehicleNodes, route[1] ) if value then if not value.streetname then value.streetname = node.name elseif value.streetname ~= node.name then value.streetname = value.streetname .. "/" .. node.name end end else for i = 1, #route - 1 do local path = calculatePathByNodeIDs( math.abs(route[i]), math.abs(route[i+1]) ) for key, value in ipairs(path) do if value.id == -route[i] or value.id == -route[i+1] then elseif not value.streetname then value.streetname = node.name elseif value.streetname ~= node.name then value.streetname = value.streetname .. "/" .. node.name end end end end end end local cacheX, cacheY, cacheZ = 0, 0, 0 addEventHandler("onClientRender", getRootElement(), function() local x, y, z = getElementPosition(getLocalPlayer()) if cacheX ~= x or cacheY ~= y or cacheZ ~= z then local node = findNodeClosestToPoint(vehicleNodes, x, y, z) setElementData(getLocalPlayer(), "speedo:street", node.streetname) cacheX = x cacheY = y cacheZ = z end end ) I copied the code for streetname, and changed it so that it would/should show the district data below the speedo. Though that hasn't worked yet. local streetname = getElementData(getLocalPlayer(), "speedo:street" ) if streetname and getVehicleType(vehicle) ~= "Boat" and getVehicleType(vehicle) ~= "Helicopter" and getVehicleType(vehicle) ~= "Plane" then local width = dxGetTextWidth( streetname ) local x = width < 200 and ( x - 110 - width / 2 ) or ( x - 10 - width ) dxDrawRectangle( x - 8, y - 296, width + 17, 24, tocolor( 5, 5, 5, 220 ) ) dxDrawText( streetname, x, y - 292 ) end -- district names local streetzone = getElementData(getLocalPlayer(), "speedo:zone" ) if streetzone and getVehicleType(vehicle) ~= "Boat" and getVehicleType(vehicle) ~= "Helicopter" and getVehicleType(vehicle) ~= "Plane" then local width = dxGetTextWidth( streetzone ) local x = width < 200 and ( x - 110 - width / 2 ) or ( x - 10 - width ) dxDrawRectangle( x - 8, y - 76-5, width + 17, 24, tocolor( 5, 5, 5, 220 ) ) dxDrawText( streetzone, x, y - 72-5 ) end
-
Hey there, I'm working on displaying custom street names and districts on my speedo, I'm working with nodes. I managed to get the street names to display on the nodes I want it to, now what I'm trying to do is get the district's to do the same. I tried doing the exact same thing as what was done with the street names, though this doesn't seem to work as now both won't appear on the speedometer. What did I do wrong? local names = { -- nodes, name and district { { 1703957, 1703958 }, name = "Template Name", district = "District Template" }, } for k, node in ipairs( names ) do for _, route in ipairs( node ) do if #route == 1 then local value = getNodeByID( vehicleNodes, route[1] ) if value then if not value.streetname then value.streetname = node.name elseif value.streetname ~= node.name then value.streetname = value.streetname .. "/" .. node.name if not value.streetzone then value.streetzone = node.district elseif value.streetzone ~= node.district then value.streetzone = value.streetzone .. "/" .. node.district end end else for i = 1, #route - 1 do local path = calculatePathByNodeIDs( math.abs(route[i]), math.abs(route[i+1]) ) for key, value in ipairs(path) do if value.id == -route[i] or value.id == -route[i+1] then elseif not value.streetname then value.streetname = node.name elseif value.streetname ~= node.name then value.streetname = value.streetname .. "/" .. node.name elseif not value.streetzone then value.streetzone = node.district elseif value.streetzone ~= node.district then value.streetzone = value.streetzone .. "/" .. node.district end end end end end end end local cacheX, cacheY, cacheZ = 0, 0, 0 addEventHandler("onClientRender", getRootElement(), function() local x, y, z = getElementPosition(getLocalPlayer()) if cacheX ~= x or cacheY ~= y or cacheZ ~= z then local node = findNodeClosestToPoint(vehicleNodes, x, y, z) setElementData(getLocalPlayer(), "speedo:street", node.streetname) setElementData(getLocalPlayer(), "speedo:zone", node.district) cacheX = x cacheY = y cacheZ = z end end ) This is my code that displays streetnames, and should be displaying the district right underneath it. -- street names local streetname = getElementData(getLocalPlayer(), "speedo:street" ) if streetname and getVehicleType(vehicle) ~= "Boat" and getVehicleType(vehicle) ~= "Helicopter" and getVehicleType(vehicle) ~= "Plane" then local width = dxGetTextWidth( streetname ) local x = width < 200 and ( x - 110 - width / 2 ) or ( x - 10 - width ) dxDrawRectangle( x - 8, y - 296, width + 17, 24, tocolor( 5, 5, 5, 220 ) ) dxDrawText( streetname, x, y - 292 ) end -- district names local streetzone = getElementData(getLocalPlayer(), "speedo:zone" ) if streetzone and getVehicleType(vehicle) ~= "Boat" and getVehicleType(vehicle) ~= "Helicopter" and getVehicleType(vehicle) ~= "Plane" then local width = dxGetTextWidth( streetzone ) local x = width < 200 and ( x - 110 - width / 2 ) or ( x - 10 - width ) dxDrawRectangle( x - 8, y - 76-5, width + 17, 24, tocolor( 5, 5, 5, 220 ) ) dxDrawText( streetzone, x, y - 72-5 ) end