Jump to content
  • 0

GTA live map


[M]deLUX

Question

livemap_announce.jpg

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"?> 
  
<positions> 
    <player id="0"> 
        <name>huso</name> 
        <score>0</score> 
        <x>-2983.335937</x> 
        <y>464.685119</y> 
  
        <z>39.873157</z> 
        <health>58.000000</health> 
    </player> 
    <player id="1"> 
        <name>sunza1</name> 
        <score>0</score> 
        <x>-2767.353759</x> 
  
        <y>2331.064697</y> 
        <z>71.656829</z> 
        <health>100.000000</health> 
    </player> 
</positions> 
  

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 comment

8 answers to this question

Recommended Posts

  • 0

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' .. 
            '\t</player>\n' 
    end 
    result = result .. '</positions>' 
    return result 
end 
  
function sendPlayers() 
    callRemote('http://yoursite.com/players.php', playersSent, getPlayersAsXML()) 
end 
  
function playersSent() 
     
end 
  
addEventHandler('onResourceStart', getResourceRootElement(getThisResource()), 
    function() 
        setTimer(sendPlayers, UPDATE_INTERVAL, 0) 
    end 
)  

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

Link to comment
  • 0

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()) 
    fileClose(file) 
end 

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

Link to comment

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