Jump to content

Player Map Math


Guest lolwtf

Recommended Posts

I suck at math. :lol:

I've been trying to make a player blip map like on AlienX's server, but the math boggles my mind. :shock:

How can I convert a player position to a pixel position on a map image?

Or better yet, does anyone know where I can find AlienX's map resource, or something similar?

Thanks. :)

Link to comment

Or better yet, does anyone know where I can find AlienX's map resource, or something similar?

There is a formula which gives you the value for the "world" position.

If nobody will give you that in time I won't be here I'll post it in the evening (I'm going to work now).

Link to comment
I suggest analizing this script: viewtopic.php?f=91&t=21256

I'm using this in my script, and it's the map that the blips will be attached to. :)

The formula does the opposite of what I want, so I thought it would be easy to reverse it, but I don't think it's that easy, and I'm certainly not capable of it. :lol:

Link to comment

If you still haven't got the formula then here is a LUA function:

function convertWorldXYToMapXY( x, y, imageSize_x, imageSize_y ) 
    return ((x*512)/6000)+(imageSize_x/2), ((-1*y*512)/6000)+(imageSize_y/2) 
end 

returns:

converted x and y of the "game's world" coords to map's image coords

PS. the conversion "stolen" from Xtream's Vehicle Map Plotter

Link to comment
If you still haven't got the formula then here is a LUA function:

function convertWorldXYToMapXY( x, y, imageSize_x, imageSize_y ) 
    return ((x*512)/6000)+(imageSize_x/2), ((-1*y*512)/6000)+(imageSize_y/2) 
end 

returns:

converted x and y of the "game's world" coords to map's image coords

Thanks! :D

It was off by a bit when I first tried it, but I changed it to this:

function convertWorldXYToMapXY( x, y, imageSize_x, imageSize_y ) 
    return ((x*imageSize_x)/6000)+(imageSize_x/2), ((-1*y*imageSize_y)/6000)+(imageSize_y/2) 
end 

And it worked perfectly. :)

Do you try to make it on the F11 map? Or another map? for F11 map you can use createBlipAttachedToElement or sth.

Nope, I'm using the "Radar Teleport" map script, which I believe I got here: http://forum.mtasa.com/viewtopic.php?f=91&t=21256&p=268591&hilit=radarteleport#p268319

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...