Jump to content

GTA live map


Recommended Posts


I wrote an online player map with the card of GTA using the Google Maps API. So now this works like a charm for SA-MP. I would like to support MTA as well, but I dont really know to script Lua. So I think it would be cool if someone is interested to add this, to script a small Lua script.

The result data has to look like the following:

<?xml version="1.0" encoding="UTF-8"?> 
    <player id="0"> 
    <player id="1"> 

If someone is interested in adding this to his server, feel free to reply or write a PM.

Ah and just to prevent questions: This works with all servers, it is just preconfigured on all delux servers (more info in the SA-MP forum topic).

Edited by Guest
Link to post

Looks nice. We will be releasing a SA-MP emulation/interpreter with DP3, so you could choose to wait a little longer, or of course learn Lua. The latter would be a good choice anyways.

Link to post

Nice site! Try adapting this code to your needs (the update interval and line 22 to be exact):

local UPDATE_INTERVAL = 1000 
function getPlayersAsXML() 
    local result = '<?xml version="1.0" encoding="UTF-8"?>\n<positions>\n' 
    for i,player in ipairs(getElementsByType('player')) do 
        local x, y, z = getElementPosition(player) 
        result = result .. 
            '\t<player id="' .. (i-1) .. '">\n' .. 
            '\t\t<name>' .. getClientName(player) .. '</name>\n' .. 
            '\t\t<score>' .. (getElementData(player, 'Score') or 0) .. '</score>\n' .. 
            '\t\t<x>' .. x .. '</x>\n' .. 
            '\t\t<y>' .. y .. '</y>\n' .. 
            '\t\t<z>' .. z .. '</z>\n' .. 
            '\t\t<health>' .. getElementHealth(player) .. '</health>\n' .. 
    result = result .. '</positions>' 
    return result 
function sendPlayers() 
    callRemote('http://yoursite.com/players.php', playersSent, getPlayersAsXML()) 
function playersSent() 
addEventHandler('onResourceStart', getResourceRootElement(getThisResource()), 
        setTimer(sendPlayers, UPDATE_INTERVAL, 0) 

See the callRemote documentation for more details on sending data to a php page.

Link to post

Sure, just use this instead of sendPlayers (don't forget to change it in setTimer as well):

function savePlayers() 
    local file = fileOpen('players.xml') 
    fileWrite(file, getPlayersAsXML()) 

The file will be created in the resource's folder.

Link to post
  • 4 months later...

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...