Calculating on screen X, Y from world coords - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Calculating on screen X, Y from world coords (
/showthread.php?tid=633968)
Calculating on screen X, Y from world coords -
Riwerry - 10.05.2017
Hey, I'm trying to figure out how this would be possible to do, but I have no idea.
I have a map created of textdraws and then red marker, which should display position on the map according to world X Y coordinates.
Does anybody have idea how could I calculate marker position by world X Y?
![](https://ctrlv.cz/shots/2017/05/11/S1Y5.png)
On screen red marker positions are here X=426.500000 and Y=317.200000
Re: Calculating on screen X, Y from world coords -
Vince - 11.05.2017
You need to find out the width and height of your scaled map. Then divide those values by 6000 to get the scaled value of 1 meter, e.g. if you map is 600 pixels wide then 1 meter corresponds to 0.1 pixel. Once you have that value you take the actual world coordinates, add 3000 (because the game map reaches from -3000 to 3000 but the scaled map reaches 0 to 6000) and then you multiply those values with the baseline value of 0.1.
Re: Calculating on screen X, Y from world coords -
Riwerry - 11.05.2017
Okay, tried to make it as you said, but sadly point is being shown far away from where it should be.
pawn Код:
new
Float:scalex = 243.6 / 6000, //243.6 is the width
Float:scaley = 264.0 / 6000, //264 is the height
Float:screenx = MDC_g_sPlayer[playerid][E_MDC_LOOKUP_ACTIVE_ADRESS_POS][0] + 3000, //Real world X + 3000
Float:screeny = MDC_g_sPlayer[playerid][E_MDC_LOOKUP_ACTIVE_ADRESS_POS][1] + 3000 //Real world Y + 3000
;
MDC_g_sPlayer[playerid][E_MDC_TEXTDRAW][33] = CreatePlayerTextDraw(playerid, screenx * scalex, screeny * scaley, "hud:radar_waypoint");