[MOD] Simple Live MAP

Place for sharing your game modifications for Life is Feudal: Your Own

MacDante
 
Posts: 95
Joined: 12 May 2015, 10:08

[MOD] Simple Live MAP

Post by MacDante » 18 Dec 2015, 11:39

I wrote simple PHP code script to show on map guild claims.

What you need:
1. Put file map.php to any on server example 'map'
2. put map.jpg to this same folder (in this case 'map')
3. Change db connection in map.php file
4. change styles of claims.

Run map on-line: http://www.yourdomain.com/map

PS: If you want use this script on own site, no problem only don't delete my nick from code please :)

Example 1: http://www.commonwealth-lif.eu/map
Example 2: http://ddo.pl/lif

The attachment map.zip is no longer available


map: http://ddo.pl/lif/map.jpg
Attachments
map.zip
Mapa MySQL PHP
(1.58 KiB) Downloaded 1984 times
Last edited by MacDante on 18 Mar 2016, 12:42, edited 3 times in total.


MaT_T
 
Posts: 5
Joined: 12 Dec 2015, 09:43

Re: [MOD] Simple Live MAP

Post by MaT_T » 25 Dec 2015, 22:52

Hello,
Thank you for sharing, I download and install the LiveMap but obviously it functioning in php 5.4 / 5.5 ...
I tried php 5.2, only one error "guild_herb Does not exit"
Do you have a solution ?
Thanks in advance.
A +


MasterChief
True Believer
 
Posts: 55
Joined: 04 Oct 2014, 11:11

Re: [MOD] Simple Live MAP

Post by MasterChief » 25 Dec 2015, 23:19

sane for me. guild_herb does not exist


MacDante
 
Posts: 95
Joined: 12 May 2015, 10:08

Re: [MOD] Simple Live MAP

Post by MacDante » 26 Dec 2015, 01:49

Sorry i put additional SQL with my own DB changes :)

You should change SQL line in map.php file on:

Code: Select all
$sql = "select gl.*, (gl.CenterGeoID >> 18) as terID,(gl.CenterGeoID & ((1 << 9) - 1)) as `x`, ((gl.CenterGeoID >> 9) & ((1 << (9)) - 1)) as `y`, g.Name as guild
from guild_lands as gl
left join guilds g on gl.GuildID=g.ID";


i put correct file in first post


MasterChief
True Believer
 
Posts: 55
Joined: 04 Oct 2014, 11:11

Re: [MOD] Simple Live MAP

Post by MasterChief » 26 Dec 2015, 14:21

works now, thx ;)


Cogollops
 
Posts: 40
Joined: 04 Dec 2015, 14:56
Location: Spain

Re: [MOD] Simple Live MAP

Post by Cogollops » 02 Feb 2016, 00:08

Please help error:


Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/u898016643/public_html/lif/map.php on line 7

Warning: mysql_connect(): Access denied for user 'lif_1'@'xx.xxx.xxx.xx' (using password: YES) in /home/u898016643/public_html/lif/map.php on line 7
Nie moge podlaczyc sie do bazy: Access denied for user 'lif_1'@'xx.xxx.xxx.xx' (using password: YES)

La ip configurada en map.php no concuerda con la que sale en el error, el map.php y el server estan en distintos servidores.

Como puedo solucionar este problema?

Image
Image

Image


MacDante
 
Posts: 95
Joined: 12 May 2015, 10:08

Re: [MOD] Simple Live MAP

Post by MacDante » 02 Feb 2016, 00:36

try use data connect to SQL from config_local.cs from main server root
but instead local IP use external IP do DB.

Also check in DB policy Access to external connect.


Cogollops
 
Posts: 40
Joined: 04 Dec 2015, 14:56
Location: Spain

Re: [MOD] Simple Live MAP

Post by Cogollops » 02 Feb 2016, 01:24

I'm not good, nor idiot, I introduced my external IP, but the error jumps with me where I stayed the ip map.php file, without connecting to the ip map.php introduced into the file ...

It is rare and nose como fix, have little experience in php and database.

My DB is version: MariaDB 5.5

Translation from google translator, sorry.
Image

Image


Cogollops
 
Posts: 40
Joined: 04 Dec 2015, 14:56
Location: Spain

Re: [MOD] Simple Live MAP

Post by Cogollops » 02 Feb 2016, 01:35

New error!!:

Parse error: syntax error, unexpected '.216' (T_DNUMBER) in /home/u898016643/public_html/map/map.php on line 7

Configuration map.php:

Line
1 <?php
2 $SERVER = "xx.xx.xxx.xxx:3306";
3 $USER = "xxxxxx";
4 $DB = "xxxx";
5 $PASS = "xxxxxx";
6
7 mysql_connect (xx.xx.xxx.xxx:3306, $USER, $PASS) or die ('Nie moge podlaczyc sie do bazy: ' . mysql_error());
8 mysql_selectdb($DB);
9 ?>

Changes $SERVER for IP:PORT.
And new error...

What???

URL:
http://sops.esy.es/map/map.php
Image

Image


MacDante
 
Posts: 95
Joined: 12 May 2015, 10:08

Re: [MOD] Simple Live MAP

Post by MacDante » 02 Feb 2016, 09:48

i see parse error its problem with delimiter or else part of code in this probably problem is with IP, write ip in "" in mysql_connect or use $SERVER parameter.

Parse error: syntax error, unexpected '.216' (T_DNUMBER) in /home/u898016643/public_html/map/map.php on line 7

Try copy this and change only xx, yyy and zzz values i 1-4 lines.

<?
$SERVER = "xx.xx.xxx.xxx:3306";
$USER = "lif_yyy";
$DB = "lif_yyy";
$PASS = "zzzzzzzz";

mysql_connect ($SERVER, $USER, $PASS) or die ('cant connect to DB: ' . mysql_error());
mysql_selectdb($DB);
?>


Cogollops
 
Posts: 40
Joined: 04 Dec 2015, 14:56
Location: Spain

Re: [MOD] Simple Live MAP

Post by Cogollops » 02 Feb 2016, 15:19

Using the parameter "$ Server" on mysql_connect, do not connect properly, and when I change the ip directly connecting chips but I error: Parse error: syntax .....
And when I use the parameter that should be properly, I jump with this error:

Deprecated: mysql_connect (): The mysql extension is deprecated and will be removed in the future: Instead use mysqli or PDO in /home/xxxxxxxx/public_html/map/map.php on line 7

Warning: mysql_connect (): Access denied for user 'lif_1'@'xx.xxx.xxx.xx' (using password: YES) in /home/xxxxxxxx/public_html/map/map.php on line 7
cant connect to DB: Access denied for user 'lif_1'@'xx.xxx.xxx.xx' (using password: YES)

The funny thing is that I ip appears in lif_1@xx.xxx.xxx.xx, does not correspond with my MariaDB ip, ip displayed is the web hosting that hosts the map.php archive and no longer what to do...

It may be due to some configuration MariaDB does not accept external connections well ????
There are some command settings for MariaDB in the my.ini file or some other?

Thank you for your patience.
Image

Image


MacDante
 
Posts: 95
Joined: 12 May 2015, 10:08

Re: [MOD] Simple Live MAP

Post by MacDante » 02 Feb 2016, 15:51

Warning: mysql_connect (): Access denied for user 'lif_1'@'xx.xxx.xxx.xx'

That mean you don't have access to DB from this user from External connect. Only you can enter to DB via local connection.

You must change for this user privileges on SQL server.


Cogollops
 
Posts: 40
Joined: 04 Dec 2015, 14:56
Location: Spain

Re: [MOD] Simple Live MAP

Post by Cogollops » 11 Feb 2016, 22:58

:Yahoo!: I work anymore map online!; visit it, please: Clic here! ;)

:shock: Now I just have to figure out why I get this error:

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/xxxxxxxxx/public_html/map/index.php on line 7

I can only fix this error .
I would also like to know if you can add other information on the map ( players , weather conditions or other details of the server) , or bring the cursor on a guild , which appeared a list of members within the guild .

I hope your answer , thank you very much !
Image

Image


Kortal
 
Posts: 8
Joined: 02 Jan 2016, 23:33

Re: [MOD] Simple Live MAP

Post by Kortal » 12 Feb 2016, 16:05

Thanks MacDante for your great work.
I have updated a bit the code and added some more other things.

+ updated to mysqli
+ migrated config to a separated file
+ grid on mouse over the map
+ guild members list on mouse over the guild claim
+ optional online count: need to have lifdscp (lif-dedicated-server-control-panel-lifds-cp-t15168/)
+ optional online player list: need to have lifdscp (lif-dedicated-server-control-panel-lifds-cp-t15168/)
+ optional weather display (today and tomorrow): need to copy the cm_weather1.xml file into map folder

css by Jakommo.

Image

download: https://mega.nz/#!k84kwbJI!yet-vK3qqPAh ... RZjPb-XXSY


Cogollops
 
Posts: 40
Joined: 04 Dec 2015, 14:56
Location: Spain

Re: [MOD] Simple Live MAP

Post by Cogollops » 12 Feb 2016, 17:14

OMG, thank you very much! :Yahoo!:
Image

Image


Cogollops
 
Posts: 40
Joined: 04 Dec 2015, 14:56
Location: Spain

Re: [MOD] Simple Live MAP

Post by Cogollops » 12 Feb 2016, 18:28

Other error:

Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean given in /home/u898016643/public_html/map/index.php on line 87

Please, help!
Image

Image


Cogollops
 
Posts: 40
Joined: 04 Dec 2015, 14:56
Location: Spain

Re: [MOD] Simple Live MAP

Post by Cogollops » 12 Feb 2016, 20:52

:beer: Since it was discovered , it works perfectly , thanks also! 8-)
Image

Image


MacDante
 
Posts: 95
Joined: 12 May 2015, 10:08

Re: [MOD] Simple Live MAP

Post by MacDante » 15 Feb 2016, 09:20

Some players ask me how show players position on map. Ok i show how, but this isnfo is TOP METAGAMING info nad can broke any fair play.

Code: Select all
<?

$sql = "select *, (GeoID >> 18) as terID,(GeoID & ((1 << 9) - 1)) as `x`, ((GeoID >> 9) & ((1 << (9)) - 1)) as `y`  from `character` where IsActive=1";

$res = mysql_query($sql) or die("sql error: " . mysql_error());
$sum_players = mysql_num_rows($res);
      $sum_players=0;
   while( $row = mysql_fetch_array($res) ) {
      $x=0;
      $y=0;
      $size = $_POST['size'];
      $name = $row['Name']." ".$row['LastName'];
   
      if ($row['terID'] == 442) {
         $y=1533-$row['y'];
         $x=$row['x'];
      }
      else if ($row['terID'] == 443) {
         $y=1533-$row['y'];
         $x=$row['x']+511;         
      }
      else if ($row['terID'] == 444) {
         $y=1533-$row['y'];
         $x=$row['x']+1022;         
      }
      else if ($row['terID'] == 445) {
         $y=1022-$row['y'];
         $x=$row['x'];         
      }
      else if ($row['terID'] == 446) {
         $y=1022-$row['y'];
         $x=$row['x']+511;         
      }
      else if ($row['terID'] == 447) {
         $y=1022-$row['y'];
         $x=$row['x']+1022;         
      }
      else if ($row['terID'] == 448) {
         $y=511-$row['y'];
         $x=$row['x'];         
      }
      else if ($row['terID'] == 449) {
         $y=511-$row['y'];
         $x=$row['x']+511;         
      }            
      else if ($row['terID'] == 450) {
         $y=511-$row['y'];
         $x=$row['x']+1022;         
      }                                 
      print "<div style='border: 1px; background: red;' class='player' title='player: $name' style='left:".($x-(2))."px; top: ".($y-(2))."px; ' ></div>";
   }
   print "<div style='position: absolute; margin:0; padding: 0; background: green; width: 1px; height: 1px; left: 1px; top:1533px'></div>";
?>      


You should add this code between start <div class='map> and end </div>

remember its show last known player position, if you want show actual you should refresh browser (its not dynamical)


Cogollops
 
Posts: 40
Joined: 04 Dec 2015, 14:56
Location: Spain

Re: [MOD] Simple Live MAP

Post by Cogollops » 16 Feb 2016, 14:20

Thank, very much!
Image

Image


Cogollops
 
Posts: 40
Joined: 04 Dec 2015, 14:56
Location: Spain

Re: [MOD] Simple Live MAP

Post by Cogollops » 16 Feb 2016, 14:33

It does not work correctly!
Image

Image


MacDante
 
Posts: 95
Joined: 12 May 2015, 10:08

Re: [MOD] Simple Live MAP

Post by MacDante » 16 Feb 2016, 15:43

any error ? or what ?


Cogollops
 
Posts: 40
Joined: 04 Dec 2015, 14:56
Location: Spain

Re: [MOD] Simple Live MAP

Post by Cogollops » 17 Feb 2016, 00:58

No, excuse me for not specifying the problem. :oops:
Php error does not appear on the page, just only see the guild's me as before, the players do not appear. :Search:

Web: http://cogollops.es/MAP :sorry:
Last edited by Cogollops on 07 Mar 2016, 11:43, edited 1 time in total.
Image

Image


MacDante
 
Posts: 95
Joined: 12 May 2015, 10:08

Re: [MOD] Simple Live MAP

Post by MacDante » 17 Feb 2016, 09:01

its simple my scrip is to MYSQL and you use script to MYSQLI.

Propobably correct script to MYSQLII should be this:

Code: Select all
$sql = "select *, (GeoID >> 18) as terID,(GeoID & ((1 << 9) - 1)) as `x`, ((GeoID >> 9) & ((1 << (9)) - 1)) as `y`  from `character` where IsActive=1";


$res = mysqli_query($db_handle, $sql) or die("error: " . mysqli_error($db_handle));
$sum_players=0;
   while( $row = mysqli_fetch_array($res) ) {
      $x=0;
      $y=0;
      $size = $_POST['size'];
      $name = $row['Name']." ".$row['LastName'];
   
      if ($row['terID'] == 442) {
         $y=1533-$row['y'];
         $x=$row['x'];
      }
      else if ($row['terID'] == 443) {
         $y=1533-$row['y'];
         $x=$row['x']+511;         
      }
      else if ($row['terID'] == 444) {
         $y=1533-$row['y'];
         $x=$row['x']+1022;         
      }
      else if ($row['terID'] == 445) {
         $y=1022-$row['y'];
         $x=$row['x'];         
      }
      else if ($row['terID'] == 446) {
         $y=1022-$row['y'];
         $x=$row['x']+511;         
      }
      else if ($row['terID'] == 447) {
         $y=1022-$row['y'];
         $x=$row['x']+1022;         
      }
      else if ($row['terID'] == 448) {
         $y=511-$row['y'];
         $x=$row['x'];         
      }
      else if ($row['terID'] == 449) {
         $y=511-$row['y'];
         $x=$row['x']+511;         
      }           
      else if ($row['terID'] == 450) {
         $y=511-$row['y'];
         $x=$row['x']+1022;         
      }                                 
      print "<div style='border: 1px; background: red;' class='player' title='player: $name' style='left:".($x-(2))."px; top: ".($y-(2))."px; ' ></div>";
   }
   print "<div style='position: absolute; margin:0; padding: 0; background: green; width: 1px; height: 1px; left: 1px; top:1533px'></div>";


Cogollops
 
Posts: 40
Joined: 04 Dec 2015, 14:56
Location: Spain

Re: [MOD] Simple Live MAP

Post by Cogollops » 18 Feb 2016, 14:28

I does not work, you pass a link to the code used:

http://pastebin.com/b5Ps1JmZ


I do not understand why
Image

Image


MacDante
 
Posts: 95
Joined: 12 May 2015, 10:08

Re: [MOD] Simple Live MAP

Post by MacDante » 18 Feb 2016, 15:45

i dont know how it happen but is error inline :

is
Code: Select all
print "<div style='border: 1px; background: red;' class='player' title='player: $name' style='left:".($x-(2))."px; top: ".($y-(2))."px; ' ></div>";

sholud be:
Code: Select all
print "<div style='border: 1px solid yellow; background: yellow; left:".($x-(2))."px; top: ".($y-(2))."px; width: 2px; height: 2px; position: absolute;' class='player' title='player: $name' ></div>";


PS: i dont use table 'lifdscp_online_character', but if is in this table position with player last position, this script can show only online players. But now show all active players registered on server.


Cogollops
 
Posts: 40
Joined: 04 Dec 2015, 14:56
Location: Spain

Re: [MOD] Simple Live MAP

Post by Cogollops » 19 Feb 2016, 14:14

Thanks, it works! ;)

So you could have this same map, showing the guilds and players unused -> lifdscp_online_character ??? :shock:

Could you tell me how to change that please? :oops:

And one thing I also wanted to comment on, the player that are within the radius of the guild, when I put the cursor over the player's information for the guild but I get Player. :Search:

Again, thanks for everything, I hope your answer. :beer:
Image

Image


MacDante
 
Posts: 95
Joined: 12 May 2015, 10:08

Re: [MOD] Simple Live MAP

Post by MacDante » 19 Feb 2016, 22:09

in player line in style add: z-index: 100;

print "<div style='z-index: 100; border: 1px solid yellow; background: yellow; left:".($x-(2))."px; top: ".($y-(2))."px; width: 2px; height: 2px; position: absolute;' class='player' title='player: $name' ></div>";


Cogollops
 
Posts: 40
Joined: 04 Dec 2015, 14:56
Location: Spain

Re: [MOD] Simple Live MAP

Post by Cogollops » 19 Feb 2016, 22:56

Okay :D , now how you could use this script without using lifdscp_online_character ??? :Search:

I imagine and it makes sense to connect this script with the database, but any configuration changes lifdscp_online_character ??? :Search:

I await your response with many thanks. :beer:
Image

Image


MacDante
 
Posts: 95
Joined: 12 May 2015, 10:08

Re: [MOD] Simple Live MAP

Post by MacDante » 20 Feb 2016, 00:04

i don't use 'lifdscp_online_character' and i can't see actual online players (Jugadores Conectados)
And i don't know what is stored in 'lifdscp_online_character ' and when is saved.

I dont have anny idea whether in this table is store last player position or not (if is then you can use this table to show only online players on the map).


Cogollops
 
Posts: 40
Joined: 04 Dec 2015, 14:56
Location: Spain

Re: [MOD] Simple Live MAP

Post by Cogollops » 20 Feb 2016, 04:10

You could replace the lifdscp_online_character, for this other script baron_players, I found these forums also:

http://pastebin.com/ht8TxHxm

Whichever way is and tell me what you think, thanks.
Image

Image

Return to Game mods