Tokio Posted May 19, 2019 Share Posted May 19, 2019 for index, info in ipairs(blips) do dxSetRenderTarget(MiniMap["RenderTarget"], true) local bx = info.x local by = info.y local actualDist = getDistanceBetweenPoints2D(playerX, playerY, bx, by) local dist = actualDist/(worldMaxSize/((worldWidth+worldHeight)/2)) local rot = findRotation(bx, by, playerX, playerY)-camZ local blipX, blipY = getPointFromDistanceRotation( (MiniMap_x+MiniMap["width"]+MiniMap_x)/2, (MiniMap_y+MiniMap_y+MiniMap["height"])/2, math.min(dist, math.sqrt((MiniMap_y+MiniMap_y+MiniMap["height"])/2-MiniMap_y^2 + MiniMap_x+MiniMap["width"]-(MiniMap_x+MiniMap["width"]+MiniMap_x)/2^2)), rot ) local blipX = math.max(MiniMap_x, math.min(MiniMap_x+MiniMap["width"], blipX)) local blipY = math.max(MiniMap_y, math.min(MiniMap_y+MiniMap["height"], blipY)) local color = 255 dxDrawImage(blipX - blipSize/2, blipY - blipSize/2, blipSize, blipSize, "blips/".. info.blipID ..".png",0,0,0,tocolor(255,2555,255,255)) dxSetRenderTarget() end Why not working? No errors/warnings.. Link to comment
Ayush Rathore Posted May 22, 2019 Share Posted May 22, 2019 (edited) On 19/05/2019 at 05:38, Tokio said: for index, info in ipairs(blips) do dxSetRenderTarget(MiniMap["RenderTarget"], true) local bx = info.x local by = info.y local actualDist = getDistanceBetweenPoints2D(playerX, playerY, bx, by) local dist = actualDist/(worldMaxSize/((worldWidth+worldHeight)/2)) local rot = findRotation(bx, by, playerX, playerY)-camZ local blipX, blipY = getPointFromDistanceRotation( (MiniMap_x+MiniMap["width"]+MiniMap_x)/2, (MiniMap_y+MiniMap_y+MiniMap["height"])/2, math.min(dist, math.sqrt((MiniMap_y+MiniMap_y+MiniMap["height"])/2-MiniMap_y^2 + MiniMap_x+MiniMap["width"]-(MiniMap_x+MiniMap["width"]+MiniMap_x)/2^2)), rot ) local blipX = math.max(MiniMap_x, math.min(MiniMap_x+MiniMap["width"], blipX)) local blipY = math.max(MiniMap_y, math.min(MiniMap_y+MiniMap["height"], blipY)) local color = 255 dxDrawImage(blipX - blipSize/2, blipY - blipSize/2, blipSize, blipSize, "blips/".. info.blipID ..".png",0,0,0,tocolor(255,2555,255,255)) dxSetRenderTarget() end After this you have to draw that render target also like this for index, info in ipairs(blips) do dxSetRenderTarget(MiniMap["RenderTarget"], true) local bx = info.x local by = info.y local actualDist = getDistanceBetweenPoints2D(playerX, playerY, bx, by) local dist = actualDist/(worldMaxSize/((worldWidth+worldHeight)/2)) local rot = findRotation(bx, by, playerX, playerY)-camZ local blipX, blipY = getPointFromDistanceRotation( (MiniMap_x+MiniMap["width"]+MiniMap_x)/2, (MiniMap_y+MiniMap_y+MiniMap["height"])/2, math.min(dist, math.sqrt((MiniMap_y+MiniMap_y+MiniMap["height"])/2-MiniMap_y^2 + MiniMap_x+MiniMap["width"]- (MiniMap_x+MiniMap["width"]+MiniMap_x)/2^2)), rot ) local blipX = math.max(MiniMap_x, math.min(MiniMap_x+MiniMap["width"], blipX)) local blipY = math.max(MiniMap_y, math.min(MiniMap_y+MiniMap["height"], blipY)) local color = 255 dxDrawImage(blipX - blipSize/2, blipY - blipSize/2, blipSize, blipSize, "blips/".. info.blipID ..".png",0,0,0,tocolor(255,255,255,255)) dxSetRenderTarget() end dxDrawImage(MiniMap_x,MiniMap_y,MiniMap["width"],MiniMap["height"], MiniMap["RenderTarget"],0,0,0,tocolor(255,255,255,255)) And also you have a typo in dxDrawImage in tocolor. I fixed it. Edited May 22, 2019 by Ayush Rathore Link to comment
Tokio Posted May 22, 2019 Author Share Posted May 22, 2019 6 hours ago, Ayush Rathore said: After this you have to draw that render target also like this for index, info in ipairs(blips) do dxSetRenderTarget(MiniMap["RenderTarget"], true) local bx = info.x local by = info.y local actualDist = getDistanceBetweenPoints2D(playerX, playerY, bx, by) local dist = actualDist/(worldMaxSize/((worldWidth+worldHeight)/2)) local rot = findRotation(bx, by, playerX, playerY)-camZ local blipX, blipY = getPointFromDistanceRotation( (MiniMap_x+MiniMap["width"]+MiniMap_x)/2, (MiniMap_y+MiniMap_y+MiniMap["height"])/2, math.min(dist, math.sqrt((MiniMap_y+MiniMap_y+MiniMap["height"])/2-MiniMap_y^2 + MiniMap_x+MiniMap["width"]- (MiniMap_x+MiniMap["width"]+MiniMap_x)/2^2)), rot ) local blipX = math.max(MiniMap_x, math.min(MiniMap_x+MiniMap["width"], blipX)) local blipY = math.max(MiniMap_y, math.min(MiniMap_y+MiniMap["height"], blipY)) local color = 255 dxDrawImage(blipX - blipSize/2, blipY - blipSize/2, blipSize, blipSize, "blips/".. info.blipID ..".png",0,0,0,tocolor(255,255,255,255)) dxSetRenderTarget() end dxDrawImage(MiniMap_x,MiniMap_y,MiniMap["width"],MiniMap["height"], MiniMap["RenderTarget"],0,0,0,tocolor(255,255,255,255)) And also you have a typo in dxDrawImage in tocolor. I fixed it. The blips are not showing.. :s Link to comment
Scripting Moderators ds1-e Posted May 23, 2019 Scripting Moderators Share Posted May 23, 2019 13 hours ago, Ayush Rathore said: After this you have to draw that render target also like this for index, info in ipairs(blips) do dxSetRenderTarget(MiniMap["RenderTarget"], true) local bx = info.x local by = info.y local actualDist = getDistanceBetweenPoints2D(playerX, playerY, bx, by) local dist = actualDist/(worldMaxSize/((worldWidth+worldHeight)/2)) local rot = findRotation(bx, by, playerX, playerY)-camZ local blipX, blipY = getPointFromDistanceRotation( (MiniMap_x+MiniMap["width"]+MiniMap_x)/2, (MiniMap_y+MiniMap_y+MiniMap["height"])/2, math.min(dist, math.sqrt((MiniMap_y+MiniMap_y+MiniMap["height"])/2-MiniMap_y^2 + MiniMap_x+MiniMap["width"]- (MiniMap_x+MiniMap["width"]+MiniMap_x)/2^2)), rot ) local blipX = math.max(MiniMap_x, math.min(MiniMap_x+MiniMap["width"], blipX)) local blipY = math.max(MiniMap_y, math.min(MiniMap_y+MiniMap["height"], blipY)) local color = 255 dxDrawImage(blipX - blipSize/2, blipY - blipSize/2, blipSize, blipSize, "blips/".. info.blipID ..".png",0,0,0,tocolor(255,255,255,255)) dxSetRenderTarget() end dxDrawImage(MiniMap_x,MiniMap_y,MiniMap["width"],MiniMap["height"], MiniMap["RenderTarget"],0,0,0,tocolor(255,255,255,255)) And also you have a typo in dxDrawImage in tocolor. I fixed it. Did you tried to add outputDebugString to check if code actually runs? If it doesn't show, a problem might be ipairs loop, which iterates only indexed table (in your case blips). Try to use pairs instead. Link to comment
Tokio Posted May 23, 2019 Author Share Posted May 23, 2019 14 hours ago, majqq said: Did you tried to add outputDebugString to check if code actually runs? If it doesn't show, a problem might be ipairs loop, which iterates only indexed table (in your case blips). Try to use pairs instead. I tried outputDebugString, but does not show. I tried pairs too, but does not working too.. :s Link to comment
Moderators IIYAMA Posted May 24, 2019 Moderators Share Posted May 24, 2019 13 hours ago, Tokio said: I tried outputDebugString, but does not show. I tried pairs too, but does not working too.. :s Set the rendertarget recording BEFORE the loop. Your current code only records 1 blip, clears+sets the rendertarget, records 1 blip, clears+sets the rendertarget, etc. Also unset the rendertarget AFTER the loop. Which I can't see in your current code because it is cut off. Link to comment
Tokio Posted May 25, 2019 Author Share Posted May 25, 2019 On 5/24/2019 at 9:14 AM, IIYAMA said: Set the rendertarget recording BEFORE the loop. Your current code only records 1 blip, clears+sets the rendertarget, records 1 blip, clears+sets the rendertarget, etc. Also unset the rendertarget AFTER the loop. Which I can't see in your current code because it is cut off. I tried that, but does not working. :s Link to comment
Moderators IIYAMA Posted May 25, 2019 Moderators Share Posted May 25, 2019 (edited) 1 hour ago, Tokio said: I tried that, but does not working. :s Your reply is just a status update, nothing more, nothing less... Do Work iterative Creating > Problem? > show code/results and ask for feedback > apply changes > TEST > Does it not work? > show NEW code/results and ask for feedback > apply changes > TEST > Does it not work? > show NEW code/results and ask for feedback > etc. Edited May 25, 2019 by IIYAMA Link to comment
Tokio Posted May 25, 2019 Author Share Posted May 25, 2019 dxSetRenderTarget(MiniMap["RenderTarget"], true) for index, info in pairs(blips) do local bx = info.x local by = info.y local actualDist = getDistanceBetweenPoints2D(playerX, playerY, bx, by) local dist = actualDist/(worldMaxSize/((worldWidth+worldHeight)/2)) local rot = findRotation(bx, by, playerX, playerY)-camZ local blipX, blipY = getPointFromDistanceRotation( (MiniMap_x+MiniMap["width"]+MiniMap_x)/2, (MiniMap_y+MiniMap_y+MiniMap["height"])/2, math.min(dist, math.sqrt((MiniMap_y+MiniMap_y+MiniMap["height"])/2-MiniMap_y^2 + MiniMap_x+MiniMap["width"]-(MiniMap_x+MiniMap["width"]+MiniMap_x)/2^2)), rot ) local blipX = math.max(MiniMap_x, math.min(MiniMap_x+MiniMap["width"], blipX)) local blipY = math.max(MiniMap_y, math.min(MiniMap_y+MiniMap["height"], blipY)) local color = 255 dxDrawImage(blipX - blipSize/2, blipY - blipSize/2, blipSize, blipSize, "blips/".. info.blipID ..".png",0,0,0,tocolor(255,255,255,255)) end dxSetRenderTarget() dxDrawImage(MiniMap_x, MiniMap_y, MiniMap["width"], MiniMap["height"], MiniMap["RenderTarget"], 0, 0, 0, tocolor(255,255,255,255)) This is the code... Link to comment
Moderators IIYAMA Posted May 25, 2019 Moderators Share Posted May 25, 2019 (edited) 1 hour ago, Tokio said: dxSetRenderTarget(MiniMap["RenderTarget"], true) for index, info in pairs(blips) do local bx = info.x local by = info.y local actualDist = getDistanceBetweenPoints2D(playerX, playerY, bx, by) local dist = actualDist/(worldMaxSize/((worldWidth+worldHeight)/2)) local rot = findRotation(bx, by, playerX, playerY)-camZ local blipX, blipY = getPointFromDistanceRotation( (MiniMap_x+MiniMap["width"]+MiniMap_x)/2, (MiniMap_y+MiniMap_y+MiniMap["height"])/2, math.min(dist, math.sqrt((MiniMap_y+MiniMap_y+MiniMap["height"])/2-MiniMap_y^2 + MiniMap_x+MiniMap["width"]-(MiniMap_x+MiniMap["width"]+MiniMap_x)/2^2)), rot ) local blipX = math.max(MiniMap_x, math.min(MiniMap_x+MiniMap["width"], blipX)) local blipY = math.max(MiniMap_y, math.min(MiniMap_y+MiniMap["height"], blipY)) local color = 255 dxDrawImage(blipX - blipSize/2, blipY - blipSize/2, blipSize, blipSize, "blips/".. info.blipID ..".png",0,0,0,tocolor(255,255,255,255)) end dxSetRenderTarget() dxDrawImage(MiniMap_x, MiniMap_y, MiniMap["width"], MiniMap["height"], MiniMap["RenderTarget"], 0, 0, 0, tocolor(255,255,255,255)) This is the code... Where are the blips located when the rendertarget is not being used? (screenshot ?) And what are the properties of the rendertarget? Edited May 25, 2019 by IIYAMA Link to comment
Tokio Posted June 9, 2019 Author Share Posted June 9, 2019 On 25/05/2019 at 21:53, IIYAMA said: Where are the blips located when the rendertarget is not being used? (screenshot ?) And what are the properties of the rendertarget? Blips: function addBlip(blipID, x, y, text, color) data = { blipID = blipID, x = x, y = y, text = text, color = color } table.insert(blips, data) end addBlip(52, -1940.97986, 568.07715, "Bank", tocolor(255,255,255,255)) addBlip(1, 256.24149, 2961.22998, "North", tocolor(255,255,255,255)) addBlip(18 ,1368.36072 ,-1279.73596, "Üzletek", tocolor(255,255,255,255)) addBlip(999999 ,1553.59485, -1675.84521, "Rendorseg", tocolor(255,255,255,255)) addBlip(10001,1850.17493, -1856.35034, "Rendorseg", tocolor(255,255,255,255)) addBlip(3223,-2053.66650, -49.28458, "Templom", tocolor(255,255,255,255)) addBlip(4324,268.89667 ,-1873.54370, "versenypálya", tocolor(255,255,255,255)) addBlip(969696,703.92871, -2829.69507, "bringarace", tocolor(255,255,255,255)) addBlip(543210 ,1932.81152, -1773.87366, "deli", tocolor(255,255,255,255)) addBlip(543210 ,1045.06812, -901.50098, "északi", tocolor(255,255,255,255)) addBlip(51 ,2779.62866, -2417.62134, "depo", tocolor(255,255,255,255)) addBlip(69 ,-1958.69971, 296.35953, "aszallito", tocolor(255,255,255,255)) addBlip(696 ,1769.72644, -1944.25537, "buszizej", tocolor(255,255,255,255)) addBlip(66999 ,830.25916 ,858.30060, "banyasz", tocolor(255,255,255,255)) addBlip(29 ,2104.32251 ,-1809.31726, "pizzafutarka", tocolor(255,255,255,255)) addBlip(65 ,-2126.23120, -200.79074, "vasasmelo", tocolor(255,255,255,255)) addBlip(123450 ,2192.60425,1990.83911, "bolti elado", tocolor(255,255,255,255)) addBlip(32321 ,2806.90942, 911.94543, "kukasssmelo", tocolor(255,255,255,255)) Rendertarget: function MiniMap.start() MiniMap["RenderTarget"] = dxCreateRenderTarget(MiniMap["width"], MiniMap["height"], true) end Link to comment
Moderators IIYAMA Posted June 9, 2019 Moderators Share Posted June 9, 2019 2 hours ago, Tokio said: addBlip(52, -1940.97986, 568.07715, "Bank", tocolor(255,255,255,255)) addBlip(52, -1940.97986, 568.07715, "Bank", tocolor(255,255,255,255)) On 25/05/2019 at 21:53, IIYAMA said: Where are the blips located when the rendertarget is not being used? (screenshot ?) * Where on your screen? * local blipX = math.max(MiniMap_x, math.min(MiniMap_x+MiniMap["width"], blipX)) local blipY = math.max(MiniMap_y, math.min(MiniMap_y+MiniMap["height"], blipY)) Link to comment
Tokio Posted June 9, 2019 Author Share Posted June 9, 2019 26 minutes ago, IIYAMA said: addBlip(52, -1940.97986, 568.07715, "Bank", tocolor(255,255,255,255)) * Where on your screen? * local blipX = math.max(MiniMap_x, math.min(MiniMap_x+MiniMap["width"], blipX)) local blipY = math.max(MiniMap_y, math.min(MiniMap_y+MiniMap["height"], blipY)) Here when the rendertarget is not used Link to comment
Moderators IIYAMA Posted June 9, 2019 Moderators Share Posted June 9, 2019 1 hour ago, Tokio said: Here when the rendertarget is not used The rendertarget will capture the image from the LEFT + TOP corner of the screen. As it is now, it will not be recorded within the rendertarget. Link to comment
Tokio Posted June 9, 2019 Author Share Posted June 9, 2019 6 minutes ago, IIYAMA said: The rendertarget will capture the image from the LEFT + TOP corner of the screen. As it is now, it will not be recorded within the rendertarget. Then what can i do? Link to comment
Moderators IIYAMA Posted June 9, 2019 Moderators Share Posted June 9, 2019 1 hour ago, Tokio said: Then what can i do? Render them at the top + left corner instead of the bottom + left corner. That shouldn't be a problem, it is your code after all. Link to comment
Tokio Posted June 9, 2019 Author Share Posted June 9, 2019 29 minutes ago, IIYAMA said: Render them at the top + left corner instead of the bottom + left corner. That shouldn't be a problem, it is your code after all. Now i see the blips with render target, but outside the radar.. how to fix this? Link to comment
Moderators IIYAMA Posted June 9, 2019 Moderators Share Posted June 9, 2019 1 minute ago, Tokio said: Now i see the blips with render target, but outside the radar.. how to fix this? I do not know what you are doing or have done. Link to comment
Tokio Posted June 9, 2019 Author Share Posted June 9, 2019 1 hour ago, IIYAMA said: I do not know what you are doing or have done. I created a new render target for blips, and now show the blips just inside the radar, but not in the right positions.. why? I just added the render target, i didn't changed anything.. local screenWidth, screenHeight = guiGetScreenSize() local worldWidth, worldHeight = 3000, 3000 MiniMap["width"] = math.floor(screenWidth/1920 * 450) MiniMap["height"] = math.floor(screenHeight/1080 * 250) local blipSize = 21 local PlayerBlipSize = 17 local MiniMap_x, MiniMap_y = 7, screenHeight - MiniMap["height"] - 10 local worldMaxSize = 6000 rt = dxCreateRenderTarget(MiniMap["width"], MiniMap["height"], true) dxSetRenderTarget(rt,true) for index, info in pairs(blips) do local bx = info.x local by = info.y local actualDist = getDistanceBetweenPoints2D(playerX, playerY, bx, by) local dist = actualDist/(worldMaxSize/((worldWidth+worldHeight)/2)) local rot = findRotation(bx, by, playerX, playerY)-camZ local blipX, blipY = getPointFromDistanceRotation( (MiniMap_x+MiniMap["width"]+MiniMap_x)/2, (MiniMap_y+MiniMap_y+MiniMap["height"])/2, math.min(dist, math.sqrt((MiniMap_y+MiniMap_y+MiniMap["height"])/2-MiniMap_y^2 + MiniMap_x+MiniMap["width"]-(MiniMap_x+MiniMap["width"]+MiniMap_x)/2^2)), rot ) local color = 255 dxDrawImage(blipX - blipSize/2, blipY - blipSize/2, blipSize, blipSize, "blips/".. info.blipID ..".png",0,0,0,tocolor(255,255,255,255)) if info.blipID == 1 then dxDrawImage(blipX - blipSize/2, blipY - blipSize/2, blipSize, blipSize, "blips/1.png",0,0,0,tocolor(255,255,255,255)) end end dxSetRenderTarget() dxDrawImage(MiniMap_x, MiniMap_y, MiniMap["width"], MiniMap["height"], rt, 0, 0, 0, tocolor(255,255,255,255)) Link to comment
Moderators IIYAMA Posted June 10, 2019 Moderators Share Posted June 10, 2019 (edited) Confusing Did you use this function perhaps? https://wiki.multitheftauto.com/wiki/DxSetAspectRatioAdjustmentEnabled Or did you not refresh the resource properly? Is the box at the right position? dxDrawRectangle (MiniMap_x, MiniMap_y, MiniMap["width"], MiniMap["height"]) Does the rendertarget actually capture the blips? (disable line 28 temporary) Where are the blips now located when the rendertarget doesn't capture? Edited June 10, 2019 by IIYAMA Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now