Skip to content

Commit

Permalink
feat: add location to player data
Browse files Browse the repository at this point in the history
"Location" is a new data point sent to the interface. Should only be updated if the street, area or zone have changed when updating the new position.
  • Loading branch information
TGRHavoc committed May 17, 2019
1 parent 4b783ff commit db610a7
Show file tree
Hide file tree
Showing 3 changed files with 629 additions and 2 deletions.
8 changes: 6 additions & 2 deletions __resource.lua
Expand Up @@ -4,12 +4,16 @@ client_scripts{
"client/client.lua",
"client/reverse_weapon_hashes.lua",
"client/reverse_car_hashes.lua",
"client/reverse_location_hashes.lua",
"client/blips_client.lua"
}

exports{
exports {
"reverseWeaponHash",
"reverseVehicleHash"
"reverseVehicleHash",
"reverseStreetHash",
"reverseZoneHash",
"reverseAreaHash"
}

server_scripts{
Expand Down
16 changes: 16 additions & 0 deletions client/client.lua
Expand Up @@ -30,6 +30,7 @@ local defaultDataSet = {
["Weapon"] = "Unarmed", -- Weapon player has equiped (if any)
["icon"] = 6, -- Player blip id (will change with vehicles)
["Licence Plate"] = nil, -- To showcase the removal off data :D
["Location"] = "State of San Andreas", -- Player location
}

local temp = {}
Expand Down Expand Up @@ -159,6 +160,21 @@ Citizen.CreateThread(function()
-- Update every 5 meters.. Let's reduce the amount of spam
-- TODO: Maybe make this into a convar (e.g. accuracy_distance)
updateData("pos", {x = x, y=y, z=z})

-- Reverse the street, area and zone of the current location
local streetname = exports[GetCurrentResourceName()]:reverseStreetHash(GetStreetNameAtCoord(x,y,z))
local zone = exports[GetCurrentResourceName()]:reverseZoneHash(GetHashKey(GetNameOfZone(x, y, z)))
local area = exports[GetCurrentResourceName()]:reverseAreaHash(GetHashOfMapAreaAtCoords(x, y, z))

if (temp["streetname"] ~= streetname) or (temp["zone"] ~= zone) or (temp["area"] ~= area) then
local locationString = string.format("%s, %s (%s)", streetname, zone, area)

updateData("Location", locationString)
temp["streetname"] = streetname
temp["zone"] = zone;
temp["area"] = area
end

end

-- Update weapons
Expand Down

0 comments on commit db610a7

Please sign in to comment.