[Release] mtracker a sonar like tracking app

This release is a trackify replacement. In case you do have not played GTA: Online or GTAV, it is a cellphone app that tracks the position of an entity (Player, Civilian, Vehicle, etc.) in the world and instead of displaying a symbol on the map you just get a red dot on your phone and if you travel towards the red dot on your phone you will ultimately meet that entity. See the merged screenshots below. The image is made with scaling set to "LOG".

Sample Implementation

targetsEntity = {}
spawnPos = {{-397.80331420898,-2164.9846191406,15.8256015777588},{1227.6180419922,2719.5869140625,40.005180358887}}
stuffSpawned = false

Citizen.CreateThread(function()
  while true do
    Citizen.Wait(0)
    if IsControlJustReleased(1,213) then -- home key
      if not stuffSpawned then
  		  local vhash = GetHashKey('boxville')
  		  local dhash = GetHashKey('s_m_y_airworker')
  		  RequestModel(vhash)
  		  while not HasModelLoaded(vhash) do
  				Citizen.Wait(1)
  		  end
  		  local v1 = CreateVehicle(vhash, spawnPos[1][1],spawnPos[1][2],spawnPos[1][3], 0.0, true, false)
  		  local v2 = CreateVehicle(vhash, spawnPos[2][1],spawnPos[2][2],spawnPos[2][3], 0.0, true, false)
  		  SetVehicleOnGroundProperly(v1)
  		  SetVehicleOnGroundProperly(v2)

  			RequestModel(dhash)
  			while not HasModelLoaded(dhash) do
  				Citizen.Wait(1)
  		  end
  		  local d1 = CreatePedInsideVehicle(v1, 4, dhash, -1, true, 0)
  		  local d2 = CreatePedInsideVehicle(v2, 4, dhash, -1, true, 0)
  			TaskVehicleDriveWander(d1, v1, 20.0, 536871299)
  			TaskVehicleDriveWander(d2, v2, 20.0, 536871299)
        stuffSpawned = true

  		  table.insert(targetsEntity,v1)
  		  table.insert(targetsEntity,v2)
        TriggerEvent('mtracker:settargets', targetsEntity)
      end
		  TriggerEvent('mtracker:start')
    end
  end
end)

This script spawns two boxvilles of the LS Department of Water and Power who drive around randomly through the world. I think the AI script only truely triggers when you are close enough to them, but it is good enough to understand the workings of the app.

How to use the App

Configure with the cfg.lua should be self explanatory. The default settings work with the current implementation. Use the following client events to use the application:

  • Call mtracker:settargets to set target entities, like vehicles, players or whatever you like, it has to be an entity. (Ped / Vehicle / Object)
  • Use mtracker:start and mtracker:stop to start and stop the app.
  • Use mtracker:removealltargets to remove all targets.
  • Use exports.mtracker:isrunning() to check if the app is running or not.

You can download it from: https://github.com/GHMatti/FiveM-Scripts/tree/master/mtracker

Changelog
  • 20180102: Initial Release
  • 20180103: Changed isrunning to be an export, as synchronous feedback is needed. Removed an unneeded utility function.

Q&A

  • For what can I use the app? Players tracking players (through cellphones?), Missions to find certain vehicles, etc.
  • Why do you not use the app_trackify scaleform? All cellphone apps are intrinsically linked to the cellphone scaleform. This means that any data input is handled by the cellphone scaleform instead of the app scaleform. And I just wanted to write my own cellphones.
  • I want to customize it for my own phone implementation, what to do? mtracker automatically scales to your background image. The current image uses #0060b8 as a background color with a black-transparent grandient on top. The tracker_bar, in case you want to replace this too, is white and uses a #0096ff shadow, same as the player symbol, which is taken from the original trackify app. You might need to adjust the circle spacing by adjusting var stepsize = 55; to a smaller or bigger value in tracker.html. Finally you need to fiddle a bit with the css of the ids: #phone #bgfill #appwrapper with the right and bottom values, and in case of #bgfill also with the width and height to make it look neat.

This is very likely my last release (using lua) as the lua-C# messaging interface is pissing me off due to some kinks it has. I started already migrating most of my stuff to C#, and might release in the future whatever is doable as a standalone release.

13 Likes

Crazy release, I’m impressed, I already got like 10 things I could use this for, Thanks!

2 Likes

what might those be even :open_mouth:

also, events rather than exports? interesting choice

vector3’s were the straw that broke my back. If you try to trigger events with GetEntityCoords as parameter it throws errors. There were some others but I do not recall. Same stuff happens on exports.

It started with native functions like Settimera(0), Gettimera() not working, well maybe Settimera does, but it is not running. If I have to write wrappers / reimplementations for functions anyways, instead of putting them into every project, I might as well just migrate to C# and just run it as one dll and have a big nice vehicle, ped and player : ped object which wraps important functions.

I feel that the concept of events is easier to handle for most people, then figuring “how do I call this export?” Probably should rewrite the isrunning stuff to an export though. But I wanted to get it out of the way. Probably will do though.

DO i need a Phone script for this If yes, can someone link me one?

You need nothing, just the mtracker directory from the link. Then use the events described in the post.

To use it on your server. Or just use the sample script to test it out.

Changed isrunning to be an export. so no callback is needed.

Nice dude ! Keep up the good work =)

1 Like

When it’s not taking things like vector3 just use a key table like

local c = GetEntityCoords(GetPlayerPed(-1))
whateverthatisnottakingvector3({x = c.x, y = c.y, z = c.z})

I also use events a lot instead of exports.

Maybe I should try exports one day ^^

PS: I love that script GJ !

1 Like

in the download link I cant download it makes me copy paste into my own new file.

you click on fat fivem-scripts. then click on clone or download, then hit download zip.

Ahhhh cant believe I didn’t see that, thank you!!

Hello,

can someone explain me short and nice, please, how i can implement

…Gamers, for using it for ambulance to search gamers without phone.

and

…spezial cars, like police or felon?

thx!

Âżanyone can help with this?

Hi,

I typed the events in the chat box or whatever and nothing happened :neutral_face:

Help please!

Try and use the provided example.

I did, but nothing happened so I don’t know whats up… I also used the developer console [F8] but that didn’t work either!

how i can use it and where i type the commands?and does it works with onoline players?

I tried to use this resource, but apparently it contains"prohibited logic".

i got it working, it’s a bit weird, and some parts are outdated. but it works if you spend just a little time looking at the code.

here is a hint.
replace line 22 with

table.insert(targetsEntitys, targets)

other than that, just use the calls in the first post. remember they are client events, not exports.
so use them like this in a client script

TriggerEvent(‘mtracker:start’)

and this in a server script

TriggerEvent(‘mtracker:start’)

still works wonders, and is gonna be used in a future script i am working on, with hacking as a sidejob on an esx server.