TGRHavoc / live_map

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

"livemap:internal_" Server Events appear to be non-existent - Nothing happens when they're called and they appear to be non-existent in code. #45

Closed JayMontana36 closed 3 years ago

JayMontana36 commented 3 years ago

Title states it all: The following events do not appear to exist at all in code and do not do anything at all when called server side:

Taking a look at this (server side events documented in the readme) and this (server side events documented on your docs site), with minor network/event optimization in mind, I thought why not just rewrite my script which used to trigger 6 (update) events every few seconds all at the same time to instead just trigger 1 single event with all of the data combined and then split up and distribute the data as needed server side between your live maps resource and my other scripts; the part with my scripts worked but not the part with live maps. Sample code below (cut down):


client.lua:

TriggerServerEvent('eventA', dataA, dataB, dataC)
TriggerServerEvent('eventB', dataA, dataB, dataC)

server.lua

RegisterNetEvent('eventA') AddEventHandler('eventA', function(dataA, dataB, dataC)
    local pId = GetPlayerIdentifier(source, 0)
    TriggerEvent("livemap:internal_AddPlayerData", pId, "dataA", tostring(dataA))
    TriggerEvent("livemap:internal_AddPlayerData", pId, "dataB", tostring(dataB))
    TriggerEvent("livemap:internal_AddPlayerData", pId, "dataC", tostring(dataC))
end
RegisterNetEvent('eventB') AddEventHandler('eventB', function(dataA, dataB, dataC)
    local pId = GetPlayerIdentifier(source, 0)
    TriggerEvent("livemap:internal_UpdatePlayerData", pId, "dataA", tostring(dataA))
    TriggerEvent("livemap:internal_UpdatePlayerData", pId, "dataB", tostring(dataB))
    TriggerEvent("livemap:internal_UpdatePlayerData", pId, "dataC", tostring(dataC))
end

Expected results from the code above: Client sends a set or pack of data to the server all at one time, server then distributes the received data to the respective events (live maps, and live maps displays the data)

What happens with the code above: Client sends a set or pack of data to the server all at one time, server then distributes the received data to the respective events (live maps), nothing happens (live maps does not print any error or react and displays nothing).

TGRHavoc commented 3 years ago

Great to see someone actually using the interfaces provided to write their own custom code and stuff :smile:

Anyways, yes. It seems that the internal server events were neglected when I moved the code base over to JS... Should be an easy fix, and it will definitely be one of the first things implemented when I get my setup back up and running.

If you can't wait that long or, want something you can quickly insert yourself, the following code block should be inserted inside the wrapper.js file on line 41.

    on("livemap:internal_AddPlayerData", (id, k, d) => {
        SocketController.AddPlayerData(id, k, d);
    });

    on("livemap:internal_UpdatePlayerData", (id, k, d) => {
        SocketController.UpdatePlayerData(id, k, d);
    });

    on("livemap:internal_RemovePlayerData", (id, k) => {
        SocketController.RemovePlayerData(id, k);
    });

    on("livemap:internal_RemovePlayer", (id) => {
        SocketController.RemovePlayer(id);
    });