SA-MP Forums Archive
Live map - 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: Live map (/showthread.php?tid=484458)



Live map - Jimmy0wns - 30.12.2013

So, i was thinking of creating a live map.
I might be able to do it but i have a few questions.

1. If you save the player's coordinates every x seconds and export that to the database and finally to the livemap that updates every x seconds, would that cause server lag and what is the best way to do it?
2. Would you like to see this released once its done?


Re: Live map - StaticYey - 30.12.2013

I don't think it would lag the server, the way I'm thinking of it, you'll be extracting every player on a 2D map, so you only need x pos and y pos for every online player, basically onlineplayers * 2 float values. If you are able to save those data into the database, (make a table like "map_positions" or so). Take the max player limit number, that's your rows, and use three columns one for the player id, one for x and one y. Afterwards, through php I guess access that table, get the coords and simulate them on a map on a browser. Could work.

You can enhance later on to show names too and stuff.


Re: Live map - Kyle - 30.12.2013

I update my player positions through a mysql query, every 1 second. One big string, not separate rows...

http://www.copsandrobbersrpg.com/map/


Re: Live map - Jimmy0wns - 31.12.2013

Quote:
Originally Posted by KyleSmith
Посмотреть сообщение
I update my player positions through a mysql query, every 1 second. One big string, not separate rows...

http://www.copsandrobbersrpg.com/map/
Could you send me a simple loop on how i can check the coordinates, i can do the MySQL myself.


Re: Live map - Kyle - 31.12.2013

Quote:
Originally Posted by Jimmy0wns
Посмотреть сообщение
Could you send me a simple loop on how i can check the coordinates, i can do the MySQL myself.
I just put their name then their X,Y,Z and some other information like team.

If the player is offlline I put "NULL", so for 3 slot server, if slot 1 was the only person on, slot 0 and 2 are offline, hence NULL.

NULL|KyleSmith,568.0,231.65,0.0|NULL


Re: Live map - Jimmy0wns - 31.12.2013

pawn Код:
SaveCoords(playerid)
{
    new Query[500];
    //87 format(Query, 500, "UPDATE `coords` SET `PositionX` = '%d', `PositionY` = '%d', `PositionZ` = '%d', `Angle` = '%d' LIMIT 1",
    cInfo[playerid][posX],
    cInfo[playerid][posY],
    cInfo[playerid][posZ],
    cInfo[playerid][angle],
    //92 mysql_query(Query);
}
What am i doing wrong here? As it gives me this error:
Код:
(87 -- 92) : error 001: expected token: ",", but found ";"
I used // to show where the lines are.


Re: Live map - Kyle - 31.12.2013

Cause you use // for the format and the cInfo lines are for the format.

If you comment out format you need to comment out cInfo too.


Re: Live map - Jimmy0wns - 31.12.2013

Quote:
Originally Posted by KyleSmith
Посмотреть сообщение
Cause you use // for the format and the cInfo lines are for the format.

If you comment out format you need to comment out cInfo too.
Read the post again, i used // to show where the lines are.


Re: Live map - Kyle - 31.12.2013

cInfo[playerid][angle], needs to be cInfo[playerid][angle]);


Re: Live map - doreto - 31.12.2013

cInfo[playerid][angle],