Kazafka Posted February 3, 2020 Posted February 3, 2020 (edited) Is there any universal way, to convert GTA SA coordinates to pixels? I tried with this: local x, y = getElementPosition(localPlayer) x = (256 * x) / 6000 --(Player's coords times myMinimapWidth) devided by GTASAMaxCoords y = (256 * y) / 6000 --Same as upper's But it's not giving me positive results. Anyone knows the way? Edited February 3, 2020 by VaporZ
Moderators Patrick Posted February 3, 2020 Moderators Posted February 3, 2020 (edited) Looks good. I think you spoil it elsewhere. Edited February 3, 2020 by stPatrick
Kazafka Posted February 3, 2020 Author Posted February 3, 2020 10 minutes ago, stPatrick said: Looks good. I think you spoil it elsewhere. Look at this, perhaps ur right: pliki = { mapa = "files/colormap.png", gracz = "files/playerblip.png" } hud = { szer = 320, przez = 200 } addEventHandler("onClientResourceStart", resourceRoot, function() setPlayerHudComponentVisible("radar", false) end) addEventHandler("onClientResourceStop", resourceRoot, function() setPlayerHudComponentVisible("radar", true) end) addEventHandler("onClientRender", root, function() local w, h = guiGetScreenSize() local x, y, z = getElementPosition(localPlayer) local mult = 320 / 6000 local sX = x * mult local sY = y * mult local r = getScreenRotationFromWorldPosition(x, y, z) dxDrawImageSection(9, 24, hud.szer, hud.szer, sX, sY, hud.szer, hud.szer, pliki.mapa, r--[[ - 72]], 0, 0, tocolor(255, 255, 255, hud.przez)) end) Results are negative, for my expectations.
-ffs-PLASMA Posted February 3, 2020 Posted February 3, 2020 (edited) At line 24, you already divide image size by 6000 and then in 26/27 you multiply it with player position but you need to multiply image size with player position first before dividing it by 6000. Edited February 3, 2020 by -ffs-PLASMA
Kazafka Posted February 3, 2020 Author Posted February 3, 2020 1 minute ago, -ffs-PLASMA said: At line 24, you already divide image size by 6000 and then in 26/27 you multiply it with player position but you need to multiply image size with player position first before dividing it by 6000. Ok, but look at this at logic side: local x, y, z = getElementPosition(localPlayer) local mult = 320 / 6000 local sx = x * mult --Example: 16 (x) * 0.05 (320 / 6000) = 0.8 local sy = y * mult --Isn't that same as: local sx = (x * 320) / 6000 --Example: 16 (x) * 0.05 (320 / 6000) = 0.8 local sy = (y * 320) / 6000 If you still not see the similarity, look: (16 * 320) / 6000 is pretty the same as 16 * (320 / 6000)
Kazafka Posted February 3, 2020 Author Posted February 3, 2020 2 hours ago, stPatrick said: Looks good. I think you spoil it elsewhere. Well, I have another question, skipping previous, why this don't rendering target? pliki = { mapa = "files/colormap.png" } hud = { szer = 320, przez = 200 } addEventHandler("onClientResourceStart", resourceRoot, function() setPlayerHudComponentVisible("radar", false) image = dxCreateRenderTarget(hud.szer, hud.szer, true) end) addEventHandler("onClientResourceStop", resourceRoot, function() setPlayerHudComponentVisible("radar", true) destroyElement(image) end) addEventHandler("onClientRender", root, function() local x, y, z = getElementPosition(localPlayer) local r = getScreenRotationFromWorldPosition(x, y, z) dxSetRenderTarget(image) -dxSetBlendMode("blend") dxDrawImageSection(9, 24, 3000, 3000, x, y, 3000, 3000, pliki.mapa) end)
sacr1ficez Posted February 3, 2020 Posted February 3, 2020 20 minutes ago, VaporZ said: Well, I have another question, skipping previous, why this don't rendering target? pliki = { mapa = "files/colormap.png" } hud = { szer = 320, przez = 200 } addEventHandler("onClientResourceStart", resourceRoot, function() setPlayerHudComponentVisible("radar", false) image = dxCreateRenderTarget(hud.szer, hud.szer, true) end) addEventHandler("onClientResourceStop", resourceRoot, function() setPlayerHudComponentVisible("radar", true) destroyElement(image) end) addEventHandler("onClientRender", root, function() local x, y, z = getElementPosition(localPlayer) local r = getScreenRotationFromWorldPosition(x, y, z) dxSetRenderTarget(image) -dxSetBlendMode("blend") dxDrawImageSection(9, 24, 3000, 3000, x, y, 3000, 3000, pliki.mapa) end) Not finished comment i guess? -dxSetBlendMode("blend") Perhaps do you use /debugscript 3 because it doesn't seems to?
Kazafka Posted February 3, 2020 Author Posted February 3, 2020 48 minutes ago, majqq said: Not finished comment i guess? Nah, miss click. But why it doesn't render dxDrawImageSection()
Scripting Moderators thisdp Posted February 4, 2020 Scripting Moderators Posted February 4, 2020 Hope you can find the solution in my dxlib: https://wiki.multitheftauto.com/wiki/Dgs
Kazafka Posted February 4, 2020 Author Posted February 4, 2020 5 hours ago, thisdp said: Hope you can find the solution in my dxlib: https://wiki.multitheftauto.com/wiki/Dgs Nope I've already managed it to work successfully, but thank you for recommendation!
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