• Announcements

    • jhxp

      Forums are online again after a maintenance.   18/03/17

      MTA Forums maintenance is completed, although some automatic time-heavy tasks are still in process and will be finished eventually in background. Expect some features such as Forum Search to not display all results until all processes are finished. Please let us know if you spot a forum feature that worked correctly before the maintenance but does not work anymore now. Thanks. --MTA Team
    • jhxp

      Multi Theft Auto: San Andreas 1.5.4 is out!   21/04/17

      Click the link in the announcement for more details.  

Jayceon

Members
  • Content count

    22
  • Joined

  • Last visited

Community Reputation

1 Neutral

1 Follower

About Jayceon

  • Rank
    Civilian

Details

  • Gang
    crips

Recent Profile Visitors

364 profile views
  1. Thanks your answer, but this function is same problem. I now try to add previous road angle to every next road angle and then calculate it.
  2. I tried it, but the same problem.
  3. Hello. I started to create a real GPS with sound effects (like -> turn left, turn right, go x meters and turn left/right), but when i'm try to get the road angles the left/right turns fails. function createGPSRoute(x, y) local occupiedVehicle = getPedOccupiedVehicle(localPlayer) if occupiedVehicle then local vehicleX, vehicleY, vehicleZ = getElementPosition(occupiedVehicle) local _, _, vehicleRotation = getElementRotation(occupiedVehicle) gpsRoute = calculatePathByCoords(vehicleX, vehicleY, vehicleZ, x, y, 0) gpsWaypoints = {} if #gpsRoute ~= 0 then local possibleRoutes = {} for k, v in pairs(gpsRoute) do --[[ -- -- First attempt -- local nextNodeID = k + 1 local nextNode = gpsRoute[nextNodeID] if nextNode then table.insert(possibleRoutes, {k, nextNodeID}) end ]] local previousNodeID = k - 1 local previousNode = gpsRoute[previousNodeID] if previousNode then table.insert(possibleRoutes, {k, previousNodeID}) end end local turns = {} -- only the gps gui, turn left/right, go x meters.. local previousRoadAngle = 0 local previousRoadDirection = "" local forwardRoadCount = 0 local forwardRoadDistance = 750 for k, v in pairs(possibleRoutes) do local roadAngle = getAngle(gpsRoute[v[2]].x, gpsRoute[v[2]].y, gpsRoute[v[1]].x, gpsRoute[v[1]].y) local roadDirection = "N/A" local roadDistance = getDistanceBetweenPoints3D(vehicleX, vehicleY, vehicleZ, gpsRoute[v[1]].x, gpsRoute[v[1]].y, gpsRoute[v[1]].z) if roadAngle <= 360 and roadAngle >= 180 then roadDirection = "right" elseif roadAngle >= 0 and roadAngle <= 180 then roadDirection = "left" end if k == 1 then previousRoadAngle = roadAngle previousRoadDirection = roadDirection end local nextNode = possibleRoutes[k + 1] table.insert(gpsWaypoints, {k, roadDirection, roadDistance, roadAngle}) -- this table for render to visible nodes and for the minimap lines if nextNode then local isTurnRoad = false if previousRoadAngle ~= roadAngle or roadDirection ~= previousRoadDirection then local angleDifference = getAnglesDifference(previousRoadAngle, roadAngle) if angleDifference ~= 0 then if angleDifference <= -12 or angleDifference >= 12 then table.insert(turns, {k, roadDirection, roadDistance}) isTurnRoad = true end end end if not isTurnRoad then if roadDistance >= forwardRoadDistance then -- add every 750 meters isForwardRoad = true forwardRoadDistance = forwardRoadDistance + 750 table.insert(turns, {k, "forward", roadDistance}) end end previousRoadAngle = roadAngle previousRoadDirection = roadDirection end if k == #possibleRoutes then table.insert(turns, {"end", "end", roadDistance}) -- the last node, when reach it the gps destination switch off end end outputConsole(inspect(turns)) -- print the possible turns/directions. format: {table id, direction (left/right/forward), distance between) end end end function getAnglesDifference(angle1, angle2) angle1 = angle1 % 360 angle2 = angle2 % 360 local difference = (angle1 - angle2) % 360 if difference <= 180 then return difference else return -(360 - difference) end end function getAngle(x1, y1, x2, y2) local angle = -math.deg(math.atan2(x2 - x1, y2 - y1)) if angle < 0 then angle = angle + 360 end return angle end --[[ -- I tried the next function, but the same problem function getAngle(x1, y1, x2, y2) return (360 - math.deg(math.atan2((x2 - x1), (y2 - y1)))) % 360 end]] Thanks the replies.
  4. Hello. I tried to get the crossroad and crossroad angles but i don't know how. I'm using the vehicle nodes path and i have small code to get road nodes angle but it get all nodes and i'm only need the crossroads. The current code: function createGPSRoute(x, y, x2, y2) local occupiedVehicle = getPedOccupiedVehicle(localPlayer) local vehicleX, vehicleY, vehicleZ = getElementPosition(occupiedVehicle) if occupiedVehicle then local startNode = findNodePosition(x, y) local endNode = findNodePosition(x2, y2) local gpsRoute = getNodePath(startNode, endNode) if #gpsRoute ~= 0 then local gpsWaypoints = {} for k, v in pairs(gpsRoute) do local nextNode = gpsRoute[k + 1] if nextNode then local roadRotation = (360 - math.deg(math.atan2((nextNode.x - vehicleX), (nextNode.y - vehicleY)))) % 360 local _, _, vehicleRotation = getElementRotation(occupiedVehicle) local vehicleRotation = vehicleRotation or 0 local roadAngle = (roadRotation - vehicleRotation) % 360 local distance = getDistanceBetweenPoints3D(vehicleX, vehicleY, vehicleZ, nextNode.x, nextNode.y, nextNode.z) local accuracy = distance < 7 and 20 or 6 if roadAngle > -accuracy and roadAngle < accuracy then table.insert(gpsWaypoints, {nextNode.neighbours, "forward", distance}) elseif roadAngle <= 360 and roadAngle >= 180 then table.insert(gpsWaypoints, {nextNode.neighbours, "right", distance}) elseif roadAngle >= 0 and roadAngle <= 180 then table.insert(gpsWaypoints, {nextNode.neighbours, "left", distance}) end end end outputConsole(inspect(gpsWaypoints)) -- debug to console end end end Thanks the replies.
  5. Thanks ccw. Now everything good.
  6. Hello. Today i started the MTA and the MTA automatically download new update before start. In the menu and at the top of the screen appeared a red stripe with the following message: Your operating system is outdated and prone to security vulnerabilities. You should consider updating as soon as possible. I'm using Windows 10 Pro with a newest update. Thanks the replies, sorry my english.
  7. Solved.
  8. The 2D display
  9. Hello. I have a custom F11 map, but i has some problem with "waypoint" create. When i'm click on map, the waypoint makes not in the cursor position, the waypoint has a small offset (left, right, up, down) and this is not good. local screenX, screenY = guiGetScreenSize() local mapTextureSize = 3072 local bigmapMapUnit = mapTextureSize / 6000 local bigmapWidth = screenX - 60 local bigmapHeight = screenY - 60 local bigmapX = 30 local bigmapY = 30 local bigmapCurrentZoom = 1.5 local playerX, playerY, playerZ = 0, 0, 0 -- automatic updating in render function getWorldFromMapPosition(mapX, mapY) -- This function dont work correctly (mapX, mapY = cursor relative X,Y) local worldX = playerX + ((mapX * (((bigmapX + bigmapWidth) / bigmapCurrentZoom) * 2)) - ((bigmapX + bigmapWidth) / bigmapCurrentZoom)) local worldY = playerY - ((mapY * (((bigmapY + bigmapHeight) / bigmapCurrentZoom) * 2)) - ((bigmapY + bigmapHeight) / bigmapCurrentZoom)) return worldX, worldY end function getMapFromWorldPosition(worldX, worldY) local mapX = (bigmapX + bigmapWidth / 2) + ((worldX - playerX) * bigmapCurrentZoom) * bigmapMapUnit local mapY = (bigmapY + bigmapHeight / 2) - ((worldY - playerY) * bigmapCurrentZoom) * bigmapMapUnit return mapX, mapY end Thanks the replies.
  10. local screenX, screenY = guiGetScreenSize() local responsiveMultiplier = (screenX + 2048) / (2048 * 2) local testRectangleWidth = 256 * responsiveMultiplier local testRectangleHeight = 128 * responsiveMultiplier local testFont = dxCreateFont("fontPath.ttf", 14 * responsiveMultiplier, false, "antialiased") local marginOffset = 10 local rightSideOfTheScreen = (screenX - marginOffset) - testRectangleWidth local centerTheBoxY = (screenY - testRectangleHeight) / 2 dxDrawRectangle(rightSideOfTheScreen, centerTheBoxY, testRectangleWidth, testRectangleHeight, tocolor(0, 0, 0, 150)) -- on dxDrawText scale is 1.0 or smaller when you have custom font, responsiveMultiplier only using it in dxCreateFont
  11. Big thanks to you. I'm now very happy. Thank you.
  12. Thanks the reply, i'm waiting your example.
  13. Hello everyone! I tried to make custom wheels to vehicles (like tuning element) but i have some problems with code. When the wheel camber angle is not default, the wheel get not good rotations. local createdCustomWheels = {} bindKey("f2", "down", function() local vehicle = getPedOccupiedVehicle(localPlayer) if vehicle then addCustomWheel(vehicle, 1075, "front") end end ) addEventHandler("onClientPreRender", root, function() for vehicle, value in pairs(createdCustomWheels) do if vehicle and isElement(vehicle) and isElementStreamedIn(vehicle) then local vehicleX, vehicleY, vehicleZ = getElementPosition(vehicle) if value["wheel_lf_dummy"] then local componentX, componentY, componentZ = getVehicleComponentPosition(vehicle, "wheel_lf_dummy") local componentRX, componentRY, componentRZ = getVehicleComponentRotation(vehicle, "wheel_lf_dummy") attachElements(value["wheel_lf_dummy"], vehicle, componentX, componentY, componentZ, componentRX, -15 + componentRY, componentRZ) end if value["wheel_rf_dummy"] then local componentX, componentY, componentZ = getVehicleComponentPosition(vehicle, "wheel_rf_dummy") local componentRX, componentRY, componentRZ = getVehicleComponentRotation(vehicle, "wheel_rf_dummy") attachElements(value["wheel_rf_dummy"], vehicle, componentX, componentY, componentZ, componentRX, -15 + componentRY, componentRZ) end end end end ) function addCustomWheel(vehicle, wheelId, side) if vehicle and wheelId and side then local vehicleX, vehicleY, vehicleZ = getElementPosition(vehicle) if side == "front" then local lfX, lfY, lfZ = getVehicleComponentPosition(vehicle, "wheel_lf_dummy") local rfX, rfY, rfZ = getVehicleComponentPosition(vehicle, "wheel_rf_dummy") setVehicleComponentVisible(vehicle, "wheel_lf_dummy", false) setVehicleComponentVisible(vehicle, "wheel_rf_dummy", false) createdCustomWheels[vehicle] = {} createdCustomWheels[vehicle]["wheel_lf_dummy"] = createObject(wheelId, vehicleX, vehicleY, vehicleZ) createdCustomWheels[vehicle]["wheel_rf_dummy"] = createObject(wheelId, vehicleX, vehicleY, vehicleZ) setElementCollidableWith(createdCustomWheels[vehicle]["wheel_lf_dummy"], vehicle, false) setElementCollidableWith(createdCustomWheels[vehicle]["wheel_rf_dummy"], vehicle, false) setObjectScale(createdCustomWheels[vehicle]["wheel_lf_dummy"], 0.7) setObjectScale(createdCustomWheels[vehicle]["wheel_rf_dummy"], 0.7) attachElements(createdCustomWheels[vehicle]["wheel_lf_dummy"], vehicle, lfX, lfY, lfZ, 0, 0, 0) attachElements(createdCustomWheels[vehicle]["wheel_rf_dummy"], vehicle, rfX, rfY, rfZ, 0, 0, 0) end end end
  14. This interested me. And how calculate this with processLineOfSight?
  15. Thanks your reply.