SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts > Tools and Files

Reply
 
Thread Tools Display Modes
Old 22/04/2013, 04:30 PM   #1
im
Huge Clucker
 
im's Avatar
 
Join Date: Mar 2012
Location: România
Posts: 213
Reputation: 21
Default [PHP] [WEB] Display a red square on the map at specified coordinates

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)
__________________

Last edited by im; 22/04/2013 at 07:58 PM.
im is offline   Reply With Quote
Old 22/04/2013, 10:45 PM   #2
Ighost
Big Clucker
 
Join Date: Dec 2012
Location: Netherlands / Egypt
Posts: 165
Reputation: 6
Default Re: PHP - A map that displays a red square at specified 2d coords

Good job..
__________________

  • SAMP servers 0.10 US$ per slot
  • Premium Quality Servers
  • Low Ping
  • Hosted Tabs for Just 14 US$
  • All SAMP servers are supported by the premium Panel "GameCP"
  • Free webhosting with more then 50 slots.
Ighost is offline   Reply With Quote
Old 23/04/2013, 09:13 AM   #3
scott1
Huge Clucker
 
Join Date: Oct 2008
Posts: 434
Reputation: 3
Default Re : PHP - A map that displays a red square at specified 2d coords

Hello,

when i use it i got an error,

Max
__________________
scott1 is offline   Reply With Quote
Old 23/04/2013, 09:25 AM   #4
Niko_boy
High-roller
 
Niko_boy's Avatar
 
Join Date: Aug 2010
Location: Somewhere i belong
Posts: 1,336
Reputation: 138
Default Re: PHP - A map that displays a red square at specified 2d coords

instead if u had posted image sepratly it would be easier to get a preview , any ways it seem simple but Nice
__________________
nope[IMG]http://*******/1r0SOkH_[/IMG]
•••[CLOSED]LCS•Freeroam•DM•Stunts•••AutoArena [0.3z][No SkinShot][sixtytiger.com]Want a decent Attack Defend Gamemode?
N/A176.31.229.148:7830Get This! Attack-Defend(v2.3.1)
Niko_boy is offline   Reply With Quote
Old 05/05/2013, 03:48 PM   #5
zDevon
Huge Clucker
 
Join Date: Jan 2012
Location: Charlotte, NC (USA)
Posts: 298
Reputation: 31
Default Re: PHP - A map that displays a red square at specified 2d coords

Awesome work, I could get some use out of this.
zDevon is offline   Reply With Quote
Old 06/03/2014, 11:32 AM   #6
nGen.SoNNy
Gangsta
 
nGen.SoNNy's Avatar
 
Join Date: Sep 2009
Location: Romania
Posts: 929
Reputation: 69
Default Re: PHP - A map that displays a red square at specified 2d coords

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);
__________________
If i've helped you, please click
nGen.SoNNy is offline   Reply With Quote
Old 06/03/2014, 11:52 AM   #7
Misiur
High-roller
 
Misiur's Avatar
 
Join Date: Jul 2009
Location: Poland
Posts: 2,528
Reputation: 556
Default Re: PHP - A map that displays a red square at specified 2d coords

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!
Misiur is offline   Reply With Quote
Old 06/03/2014, 12:08 PM   #8
nGen.SoNNy
Gangsta
 
nGen.SoNNy's Avatar
 
Join Date: Sep 2009
Location: Romania
Posts: 929
Reputation: 69
Default Re: PHP - A map that displays a red square at specified 2d coords

You don't know anything about sa:mp coordinates then.
http://rse-samp.com/map/map.php?x=-1988.43&y=-1988.43
__________________
If i've helped you, please click
nGen.SoNNy is offline   Reply With Quote
Old 08/03/2014, 10:47 AM   #9
Misiur
High-roller
 
Misiur's Avatar
 
Join Date: Jul 2009
Location: Poland
Posts: 2,528
Reputation: 556
Default Re: PHP - A map that displays a red square at specified 2d coords

I meant that values passed to imagefilledrectangle should be checked first if they are valid coords (and in this case - positive values).
Misiur is offline   Reply With Quote
Old 13/04/2020, 10:51 PM   #10
ApoziX
Little Clucker
 
ApoziX's Avatar
 
Join Date: Mar 2018
Posts: 14
Reputation: 0
Default Re: PHP - A map that displays a red square at specified 2d coords

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);

?>
ApoziX is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SA-MP on multiple displays Johnson_boy Everything and Nothing 2 11/11/2012 08:42 PM
No Cars and Vehicles Displays Laure Scripting Help 2 21/04/2012 12:50 PM
Dialog displays to wrong player. DJGama101 Scripting Help 4 31/03/2012 07:28 PM
Displays for any house. Lynn Scripting Help 0 26/12/2011 12:25 AM
Why doesn't it displays? [GOD]Dragonster82 Scripting Help 5 29/09/2011 10:15 AM


All times are GMT. The time now is 02:00 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.