TGRHavoc / live_map

A FiveM addon for live maps
https://docs.tgrhavoc.co.uk/livemap-resource/
62 stars 38 forks source link

License Plate doesn't get removed from data #68

Closed matsn0w closed 3 years ago

matsn0w commented 3 years ago

Describe the bug When entering a vehicle, the license plate gets added to the player data. (here). This works fine, except that it won't get removed after leaving the vehicle.

To Reproduce Steps to reproduce the behavior:

  1. Enter a vehicle
  2. Watch player data in the interface
  3. Leave vehicle
  4. Watch player data again, license plate should still be visible

Expected behavior License plate should be removed from player info.

Screenshots image

Desktop (please complete the following information):

Possible Solution Not sure what's going on, I tried adding some different kind of info (emergency status, see example below) and this works as expected.

Additional context/Screenshots In doVehicleUpdate():

-- check if the siren is turned on
local siren_on = IsVehicleSirenOn(vehicle)

-- add the emergency status to the data table
data["Emergency"] = siren_on and "Yes" or "No"

-- update the player data
TriggerServerEvent("livemap:UpdatePlayerData", "Emergency", data["Emergency"])

and


Citizen.CreateThread(function()
    while true do
        Wait(10)

        if NetworkIsPlayerActive(PlayerId()) then

            -- Update Vehicle (and icon)
            if IsPedInAnyVehicle(PlayerPedId()) then
                doVehicleUpdate()

            elseif data["Licence Plate"] ~= nil or data["Vehicle"] ~= nil then
                -- No longer in a vehicle, remove "Licence Plate" if present
                data["Licence Plate"] = nil
                data["Vehicle"] = nil
                data["Emergency"] = nil
                temp["vehicle"] = nil

                -- Remove it from socket communication
                TriggerServerEvent("livemap:RemovePlayerData", "Licence Plate")
                TriggerServerEvent("livemap:RemovePlayerData", "Emergency")
                TriggerServerEvent("livemap:RemovePlayerData", "Vehicle")
            end
        end
    end
end)
TGRHavoc commented 3 years ago

Describe the bug When entering a vehicle, the license plate gets added to the player data. (here). This works fine, except that it won't get removed after leaving the vehicle.

To Reproduce Steps to reproduce the behavior:

1. Enter a vehicle

2. Watch player data in the interface

3. Leave vehicle

4. Watch player data again, license plate should still be visible

Expected behavior License plate should be removed from player info.

Screenshots image

Desktop (please complete the following information):

* OS: Windows 10 Pro 64-bit

* Browser: Microsoft Edge

* Version: 92.0.902.78

Possible Solution Not sure what's going on, I tried adding some different kind of info (emergency status, see example below) and this works as expected.

Additional context/Screenshots In doVehicleUpdate():

-- check if the siren is turned on
local siren_on = IsVehicleSirenOn(vehicle)

-- add the emergency status to the data table
data["Emergency"] = siren_on and "Yes" or "No"

-- update the player data
TriggerServerEvent("livemap:UpdatePlayerData", "Emergency", data["Emergency"])

and

Citizen.CreateThread(function()
    while true do
        Wait(10)

        if NetworkIsPlayerActive(PlayerId()) then

            -- Update Vehicle (and icon)
            if IsPedInAnyVehicle(PlayerPedId()) then
                doVehicleUpdate()

            elseif data["Licence Plate"] ~= nil or data["Vehicle"] ~= nil then
                -- No longer in a vehicle, remove "Licence Plate" if present
                data["Licence Plate"] = nil
                data["Vehicle"] = nil
                data["Emergency"] = nil
                temp["vehicle"] = nil

                -- Remove it from socket communication
                TriggerServerEvent("livemap:RemovePlayerData", "Licence Plate")
                TriggerServerEvent("livemap:RemovePlayerData", "Emergency")
                TriggerServerEvent("livemap:RemovePlayerData", "Vehicle")
            end
        end
    end
end)

Yup. Because I can't keep my spelling of "Licence Plate" consistent...

@all-contributors add @matsn0w for bug

allcontributors[bot] commented 3 years ago

@TGRHavoc

I could not determine your intention.

Basic usage: @all-contributors please add @someone for code, doc and infra

For other usages see the documentation

TGRHavoc commented 3 years ago

@all-contributors please add @matsn0w for bug

allcontributors[bot] commented 3 years ago

@TGRHavoc

I've put up a pull request to add @matsn0w! :tada:

matsn0w commented 3 years ago

Lol, thanks bro :)

matsn0w commented 3 years ago

Oh, now you've fixed it the wrong way around XD I'll submit a PR.

matsn0w commented 3 years ago

see #70