[Release] LiveMap


#1

NOTE: Make sure you’re using the latest FXServer. If not, you’re going to get errors.

So, a while back I said that I was working on a live map for FiveM (back when Ctizen.MP was still a thing). Well, I’ve been working on it and I think it’s ready for release :smiley:.

At the minute, the web interface is very basic.

If you want to test out the functionality, I have a demo server up and running. Just direct connect to “tgrhavoc.me” (or, have a look on the server list for “Havocs Test Server!”), and you can load up the map at http://map.tgrhavoc.me/.

This resource comes in two parts. There’s the “resource” (live_map) and the “interface” (live_map-interface).

Installing live_map

  • Download the latest version from here
  • Extract into it’s own folder (i.e. resources/live_map, can be wherever you like)
  • Configure the server.cfg file
  • Start the server

If you have successfully installed it, you should see the following in the console:

Installing live_map-interface

  • Download the latest version from here
  • Download the map images from here
  • Extract into your webserver (however you want to configure this, I suggest extracting into it’s own directory)
  • Extract the images to images/map/ (You can change this).
  • Change the values inside utils/config.php
  • Check it works :slight_smile:

Configuring live_map

If you just want to get this up and running, you don’t need to configure anything. Just start it up and you should be good to go!

Otherwise, you can configure the resource by changing convars (make sure these are above the start live_map).

Name Type Default Value Description
socket_port int 30121 Sets the port the socket server should listen on
livemap_debug int 0 Sets how much information gets printed to the console (0 = none, 1 = basic information, 2 = all)
blip_file string “server/blips.json” Sets the file that will contain the generated blips (saved and loaded on the server) that is exposed via HTTP
livemap_access_control string “*” Sets the domain that is allowed to access the blips.json file (E.g. “https://example.com” will only allow the UI on http://example.com to get the blips), “*” will allow everyone

Configuring live_map-interface

You will need to configure the interface to get stuff working.

The main variables that you need to change in the utils/config.php file are:

$fivemIP // Set this to your FiveM server IP (or domain)
$fivemPort // Set this to the FiveM port (usually 30120)
$socketPort // Set this to the socket port (set in the convar, default 30121)
$liveMapName // Set this to the name of the resource (if you changed it, default "live_map")
// E.g., if you changed the resource folder to `resources/map` then you would have to change "$liveMapName" to "map"

All the variables are commented so, you should get an idea of what happens when you change them.

Phew… Time to talk events. In an effort to make the addon useful to other developers, I’ve created a few events that can be used to make changes to the data being sent to the UI.

Client to Server events

Below you can find some info on the server events that must be triggered by the client.

Note, when using livemap:AddPlayerData or livemap:UpdatePlayerData if the player has been removed using livemap:RemovePlayer they will be tracked again.

Name Parameters Description
livemap:AddPlayerData key (string), data (any) Adds data to a player that gets sent over Websockets
livemap:UpdatePlayerData key (string), data (any) Updates the data that is associated with the player. Uses the same “key” as the above event.
livemap:RemovePlayerData key (string) Removed data associated with the player. Uses the same “key” as the above events.
livemap:RemovePlayer Stops sending a player data over Websockets

Example usage:

-- Set the player's "Name" to "Havoc"
TriggerServerEvent("livemap:AddPlayerData", "Name", "Havoc")

-- Update the player's name to "John Doe"
TriggerServerEvent("livemap:UpdatePlayerData", "Name", "John Doe")

-- Remove "Name" from the player (stops displaying it in the UI)
TriggerServerEvent("livemap:RemovePlayerData", "Name")

-- Removes a player from the websockets (stops tracking them)
TriggerServerEvent("livemap:RemovePlayer")

Server Events

Below you can find information on some server-only events. This can only be called on the server.

Name Parameters Description
livemap:internal_AddPlayerData identifier (string), key (string), value (any) Adds data with the key that gets sent over Websockets for the player with the specified identifier
livemap:internal_UpdatePlayerData identifier (string), key (string), value (any) Updated the data that is associated with the player with the identifier
livemap:internal_RemovePlayerData identifier (string), key (string) Removed the data that is associated with the player with the identifier
livemap:internal_RemovePlayer identifier (string) Removes a player from the websocket data array (stops tracking the player)

Example usage:

-- Get the player's identifier
identifiier = GetPlayerIdentifier(source, 0)

-- Set the player's "Name" to "Havoc"
TriggerEvent("livemap:internal_AddPlayerData", identifier, "Name", "Havoc")

-- Update the player's "Name"  to "John Doe"
TriggerEvent("livemap:internal_UpdatePlayerData", identifier, "Name", "John Doe")

-- Removes the player's "Name"
TriggerEvent("livemap:internal_RemovePlayerData", identifier, "Name")

-- Removes the player
TriggerEvent("livemap:internal_RemovePlayer", identifier)

But… But what about the blips? How do I get them working?

Well, young Jimmy boy. There’s a command for that! While in-game admins can run the command blips generate to generate a fresh blip file. This will take all the blips shown on the map and put them into the “blip_file”. Next time the UI requests the blips (refresh the page) you should see the blips in all their glory!

There’s also some (two) events that you can call on the client

Name Parameters Description
livemap:AddBlip table (blip to add) Adds a blip to the “blip_file” so that it can be showed on the web interface
livemap:UpdateBlip table (blip to update) Updates the blip to the table given

The structure of the blip is as follows:

{
    sprite = Number (required) -- The sprite used when creating the blip
    pos = Table (requires) -- contains the X Y and Z coordinates of the blip
    {
        x = Float (required) -- X coordinate of the blip
        y = Float (required) -- Y coordinate of the blip
        z = Float (required) -- Z coordinate of the blip
    }
    name = String (optional) -- Name to show on the interface (defaults to the name of the blip e.g. "Drugs")
    description = String (optional) -- Description of the blip shown on the interface
}

Oh boy, this post was longer than I intended… I hope I’ve covered everything and answered any questions you may have had. If not, feel free to ask I’ll try my best to answer them.

Edit: This is still WIP as it hasn’t been tested on a server will a high load (e.g. a lot of players and a lot of spectators).


[Request] Live Street Map
Live ingame text chat, Outside the game
[Release] Postal Code Map - New & Improved - v1.1
Exporting Player Blio Locations to a WEB Based map (Similar to SAMP)
NightShade Gaming || Dev Search
Live Patrol Map
Staff Please Delete001
LiveMap hosting free
#2

I tested this before release, and I can safely say it works as intended and is a must-have resource for those that want to have a live map for their server. :smiley:


#3

I too can agree with this, it updates very often. It also displays the vehicle the player is in and can be a very neat thing to have :smiley:


#4

Ah I remember you working on this a while ago.
Thanks for the release, looking real good!


#5

Impressive, even Bootium rates it.

(but seriously, one of the best releases I’ve seen in a heck of a long time)


#6

Looks amazing!!

One request if I may, Could you at some point add the map with street names and postal codes?

Or is this simply us going and popping in the images found a the below ling in place of the images in this threat?

( [Release] Modified GTA V Street Names w/ Block Numbers )


#7

Sooo coool! Btw, can you make a login form for that?


#8

I’ve already thought about adding street names to the map, I’ve even created an issue for it (just don’t know how I want to add it, to the tiles themselves or just as another property attached to a player) :stuck_out_tongue:. As for the postal codes, to me it seems a bit cluttered and unnecessary.

That’s not something I’m going to do. If you want to add a login page yourself, feel free. If you don’t know anything about PHP, you could even password protect that page with .htaccess


#9

Great work @Havoc I wanted to start on something like this but I’m in between like 50 projects and IRL. Plus i really didn’t know where to start. Awesome work m8.


#10

i am receiving this error during start up

Error running system event handling function for resource live_map: citizen:/scripting/lua/scheduler.lua:41: Failed to execute thread: citizen:/scripting/lua/json.lua:397: bad argument #1 to 'strfind' (string expected, got nil)
stack traceback:
        [C]: in function 'string.find'
        citizen:/scripting/lua/json.lua:397: in upvalue 'scanwhite'
        citizen:/scripting/lua/json.lua:553: in function <citizen:/scripting/lua/json.lua:551>
        (...tail calls...)
        server/update_check.lua:13: in local 'userCallback'
        citizen:/scripting/lua/scheduler.lua:260: in upvalue 'handler'
        citizen:/scripting/lua/scheduler.lua:163: in function <citizen:/scripting/lua/scheduler.lua:162>
stack traceback:
        [C]: in function 'error'
        citizen:/scripting/lua/scheduler.lua:41: in field 'CreateThreadNow'
        citizen:/scripting/lua/scheduler.lua:162: in function <citizen:/scripting/lua/scheduler.lua:131>

#11

I can understand your thoughts behind that however, it is useful in role play scenarios as I’m sure you are aware. A possible solution could be a hover option. Hover over a section of the map and it tell you the closest postal code for that location.

And I would assume your reply to that is, “is it worth the effort” to which I reply… /shrug


#12

Using it on our servers, Awesome, Works perfectly, 10/10,


#13

how do you get the blips.json


#14

if @Havoc does respond good luck, otherwise I’ll ask my server dev tomorrow, i’ll let you know!


#15

getting this error on start (on a linux server):

 Loaded live_map.net, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null into ScriptDomain_1314571693
Failed to instantiate instance of script Havoc.Live_Map.LiveMap: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.TypeLoadException: Could not resolve type with token 01000037 (from typeref, class/assembly CitizenFX.Core.Native.API, CitizenFX.Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null)
  at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
  at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in <d7e663f2f7cd4ab6929018ec5233f09d>:0 
   --- End of inner exception stack trace ---
  at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00014] in <d7e663f2f7cd4ab6929018ec5233f09d>:0 
  at System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic) [0x000a8] in <d7e663f2f7cd4ab6929018ec5233f09d>:0 
  at System.RuntimeType.CreateInstanceSlow (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x00009] in <d7e663f2f7cd4ab6929018ec5233f09d>:0 
  at System.RuntimeType.CreateInstanceDefaultCtor (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x00027] in <d7e663f2f7cd4ab6929018ec5233f09d>:0 
  at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) [0x00020] in <d7e663f2f7cd4ab6929018ec5233f09d>:0 
  at System.Activator.CreateInstance (System.Type type) [0x00000] in <d7e663f2f7cd4ab6929018ec5233f09d>:0 
  at CitizenFX.Core.InternalManager.CreateAssemblyInternal (System.Byte[] assemblyData, System.Byte[] symbolData) [0x0004f] in /src/code/client/clrcore/InternalManager.cs:80 
Started resource live_map
hitch warning: frame time of 325 milliseconds

#16

Your seeing shit mate!


#17

After running the command, you can stop the resource to save the file. Then you can edit it (if you know what you’re doing) and the changes will be present when it starts again.

Make sure you’re running the latest server artifact. I’ve got the resource running on a Debian server without any issues.


#18

Could you make sure you have the “versions.json” file and that it is readable.


#19

@Havoc could you explain this for me? What file can it not find? My web server is a separate server if that makes any difference.


#20

Looks like "“mysql.net” is causing this error, not live_map. Please ask the developer of that plugin :slight_smile: