JeViCo Posted July 20, 2018 Share Posted July 20, 2018 Hello everyone! How can i make minimap using custom image? I made something like this: local radarX, radarY, radarWidth, radarHeight = 120, 420, 258, 128 local x, y = getElementPosition(localPlayer) local mapsize = 3072 --print(x) dxDrawImageSection(radarX, radarY, radarWidth, radarHeight, x/6000, y/-6000, 270, 270, "files/radar_map.jpg") I know that gta sa's map size is 6000x6000 and my image resolution is 3072x3072. I can't understand what to do right now Link to comment
Discord Moderators Pirulax Posted July 20, 2018 Discord Moderators Share Posted July 20, 2018 (edited) Its -3072 - 3072, so its 3072*2 so its 6144. And please, create a texture for the radar with dxCreateTexture with textureFormat = "dxt3", otherwise the radar itself, just to draw the image will eat 8-10-% CPU. function getMapCoordsFromWorldCoords(x, y, imgSize) imgSize = imgSize or 3072 return ((x + 3072) / 6144) * imgSize, (-(y - 3072) / 6144) * imgSize end With this function you can get the 2D coords on the map from world position. For zoom you need to make the image smaller(zoom in) or bigger(zoom out). I hope I helped you If it returns inaccurate positions use this function instead: function getMapCoordsFromWorldCoords(x, y, imgSize) imgSize = imgSize or 3072 return ((x + 3000) / 6000) * imgSize, (-(y - 3000) / 6000) * imgSize end The way I did it was, that I got the position from this function, then i subbed usize/2, vsize/2. So i got the U and V. The size'll be usize and vsize. I have a lot of hard work, and time in figuring this out, so, I'll not tell every "secret". Think a little bit. Edited July 20, 2018 by Pirulax 1 Link to comment
JeViCo Posted July 22, 2018 Author Share Posted July 22, 2018 i found minimap script where i got essential calculations. Thanks anyway Link to comment
Discord Moderators Pirulax Posted July 22, 2018 Discord Moderators Share Posted July 22, 2018 (edited) Have a nice day Edited July 22, 2018 by Pirulax Link to comment
JeViCo Posted July 22, 2018 Author Share Posted July 22, 2018 well\ i met another problem. I tried to place blips using your function, function from another script to get coords but i can't see them\ :с what am i doing wrong 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