redditing Posted March 18, 2020 Share Posted March 18, 2020 I would like to know what commands I should use to create a custom radar Link to comment
The_GTA Posted March 18, 2020 Share Posted March 18, 2020 (edited) To draw the radar on screen you should use: dxDrawRectangle - for outline, style, etc dxDrawImageSection - putting the actual radar on screen with zooming support addEventHandler using the onClientRender event dxCreateRenderTarget and dxSetRenderTarget for drawing map information inside of a rectangle only (scissor rectangle) To prevent the original radar from rendering you should use: setPlayerHUDComponentVisible To query radar center and other relevant information map information you should use: getCamera getElementRotation getElementsByType using "radararea", "blip", "player", etc getElementPosition the radararea functions But I have to inform you that those functions alone will not make you a radar. You need to have a good understanding of how your radar should work, including the math behind it as well as the conventions to integrate it seamlessly into the Rockstar vision (north is into x=0,y=1 direction, etc). For advanced effects you should use: dxDrawImage using shaders Here are neat references for already implemented radars or map scripts: https://forum.multitheftauto.com/topic/122958-getworldfrommapposition/?do=findComment&comment=974403 https://forum.multitheftauto.com/topic/122507-help-dxradar-blip-problem/?tab=comments#comment-972908 https://forum.multitheftauto.com/topic/122303-help-why-this-doesnt-draw/?tab=comments#comment-972209 Since there are many threads on MTA forums about radar-logic that went unanswered feel free to post questions here. Maybe we can get this radar done together Edited March 18, 2020 by The_GTA 1 1 Link to comment
redditing Posted March 18, 2020 Author Share Posted March 18, 2020 U have 690 iq, thank u man Link to comment
The_GTA Posted March 18, 2020 Share Posted March 18, 2020 1 minute ago, redditing said: U have 690 iq, thank u man Thank you for this very nice compliment, redditing! ^^ I just happen to have a lot of experience with game design and MTA scripting. Remember to ask any questions if you are stuck making the resource. I will be there to help you. Link to comment
redditing Posted March 18, 2020 Author Share Posted March 18, 2020 setPlayerHudComponentVisible("radar", false) local screenW, screenH = guiGetScreenSize() local w = 300 local s = 400 local screenX, screenY = guiGetScreenSize() local minimap = dxCreateRenderTarget(s, s,true) addEventHandler("onClientRender", root, function() local x, y = getElementPosition(getLocalPlayer()) local rot = getElementRotation(getCamera()) dxDrawRectangle(screenW * 0.0078, screenH * 0.7398, screenW * 0.1521, screenH * 0.2472, tocolor(255, 0, 0, 255), false) masked = dxDrawRectangle(screenW * 0.0099, screenH * 0.7435, screenW * 0.1479, screenH * 0.2398, tocolor(0, 0, 0, 255), false) dxDrawImageSection(screenW * 0.0099, screenH * 0.7435, screenW * 0.1479, screenH * 0.2398, x, y, 256.0, 256.0, "HUD/RADAR/mapa.png", rot) local mapa = dxCreateRenderTarget(s, s, true) dxDrawImage(0, screenY - w, s, w, minimap) dxSetRenderTarget(minimap, false) end ) Okay I made this code but I have no idea what's next, will you help? Link to comment
The_GTA Posted March 18, 2020 Share Posted March 18, 2020 1 hour ago, redditing said: Okay I made this code but I have no idea what's next, will you help? Yes, let me comment on your code line 19: please do not create render targets each frame. you already did create the necessary render target in line 8. line 17: you should not use a path in dxDrawImageSection; I recommend you to use dxCreateTexture to load images into memory; it creates a texture element that you can pass into dxDrawImageSection. line 21: using dxSetRenderTarget at this point is wrong; it should be called at the start of the onClientRender event. then you can clear the render target again and use dxDrawImage at the end of onClientRender to draw your radar. I recommend to play around with render targets to understand how they work (they start from coordinate 0,0 if you draw inside them) That's it for the existing code. After you have successfully improved the code based on the guidelines above I can give you the following advice: try to calculate the coordinate on the map image (from 0 (beginning of image) to 1 (end of image)) that corresponds to the world coordinate x, y from the camera. imagine that the top left of the map image corresponds to -3000,3000 world coordinate and the bottom right to 3000,-3000 world coordinate. you could do this calculation even with school math knowledge plus trial&error. then draw a blip on the radar (location of the player?) - Martin 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