SA-MP Forums Archive
[Tool/Web/Other] PHP - A map that displays a red square at specified 2d 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: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Tools and Files (https://sampforum.blast.hk/forumdisplay.php?fid=82)
+---- Thread: [Tool/Web/Other] PHP - A map that displays a red square at specified 2d coords (/showthread.php?tid=432442)



[PHP] [WEB] Display a red square on the map at specified coordinates - im - 22.04.2013

What is this?

This can be used in a web panel to show a red square at given coordinates. I use it to be able to show where a specific car is in game.
This uses a 800x800 .jpg map. I also included a higher resolution of the image in case you want to create a bigger map, change the quality of the image or whatever.

This may not work if your hosting doesn't have GD.. something enabled.

Usage
Code:
<img src="map.php?x=1450&y=2770" />
The above code will display this image (red square in top-right):


Download


http://www.solidfiles.com/d/b3bf15403e/
https://dl.dropboxusercontent.com/u/.../php%20map.zip

http://pastebin.com/9UGrE50R (you can find the .jpg image in the zip above)


Re: PHP - A map that displays a red square at specified 2d coords - Ighost - 22.04.2013

Good job..


Re : PHP - A map that displays a red square at specified 2d coords - scott1 - 23.04.2013

Hello,

when i use it i got an error,

Max


Re: PHP - A map that displays a red square at specified 2d coords - Niko_boy - 23.04.2013

instead if u had posted image sepratly it would be easier to get a preview , any ways it seem simple but Nice


Re: PHP - A map that displays a red square at specified 2d coords - zDevon - 05.05.2013

Awesome work, I could get some use out of this.


Re: PHP - A map that displays a red square at specified 2d coords - nGen.SoNNy - 06.03.2014

If anyone wanna use the map_full.jpg just edit this:

pawn Code:
$img = imagecreatefromjpeg("map_full.jpg");

$x = $_GET["x"]/3.90;
$y = $_GET["y"]/3.90;

$x = $x + 768;
$y = -($y - 768);



Re: PHP - A map that displays a red square at specified 2d coords - Misiur - 06.03.2014

Hey, at least cast the variable to integer!
PHP Code:
$x = (int) $_GET["x"] / 3.90;
$y = (int) $_GET["y"] / 3.90
Why?

Quote:

map.php?x=PEOPLEARE&y=EVIL
map.php?x[]=sometimes&x[]=alittletoomuch&y=-100000

Oh, and well, I don't think negative dimensions are a good input too, so absolute value maybe?

Have a nice day!


Re: PHP - A map that displays a red square at specified 2d coords - nGen.SoNNy - 06.03.2014

You don't know anything about sa:mp coordinates then.
http://rse-samp.com/map/map.php?x=-1988.43&y=-1988.43


Re: PHP - A map that displays a red square at specified 2d coords - Misiur - 08.03.2014

I meant that values passed to imagefilledrectangle should be checked first if they are valid coords (and in this case - positive values).


Re: PHP - A map that displays a red square at specified 2d coords - ApoziX - 13.04.2020

Hello I am trying to create the same thing just replacing the red square with image

Thats the code but its not the same location where map.php?x=1450&y=2770

PHP Code:
<?php
$img 
imagecreatefromjpeg("map.jpg");
$sim imagecreatefrompng("pin.png");
if( isset(
$_GET["x"]) && isset($_GET["y"]) ) {
  
// the map is GTA SAn andreas is 6000x6000
  // the image that i use is 800x800 6000/800 = 7.5
  
  
$x $_GET["x"]/7.5;
  
$y $_GET["y"]/7.5;
  
  
// 0.0 0.0 is at the center of the map, in PHP 0.0 0.0 is in the top left corner, so I added / substracted 400. the map is 800x800 px, 400x400 is at the center of the map.
  
       
$x $x 400;
       
$y = -($y 400);
  
        
$sx imagesx($img);
    
    
$sy imagesy($sim);
    
        
$marge_right $_GET["x"]/5.5;
    
    
$marge_bottom $_GET["y"]/5.5;
    
imagecopy($img$simimagesx($img) - $sx $marge_rightimagesy($img) - $sy $marge_bottom00imagesx($sim), imagesy($sim));
}
header ('Content-Type: image/png');
imagepng($img);
imagepng($sim);
imagedestroy($img);
imagedestroy($sim);
?>