Skip to content

Commit

Permalink
Merge pull request Itokoyamato#203 from clementlacroix4/master
Browse files Browse the repository at this point in the history
Itokoyamato authored Oct 10, 2020
2 parents 3c53208 + 844b5cb commit bed182e
Showing 3 changed files with 14 additions and 5 deletions.
3 changes: 1 addition & 2 deletions fivem_script/tokovoip_script/nui/script.js
Original file line number Diff line number Diff line change
@@ -180,14 +180,13 @@ function receivedClientCall (event) {

// Start with a status OK by default, and change the status if issues are encountered
voipStatus = OK;

if (eventName == 'updateConfig') {
updateConfig(payload);

} else if (voip) {
if (eventName == 'initializeSocket') {
$.post(`http://${scriptName}/nuiLoaded`)
init(payload);

} else if (eventName == 'updateTokovoipInfo') {
if (connected)
updateTokovoipInfo(payload, 1);
12 changes: 11 additions & 1 deletion fivem_script/tokovoip_script/src/c_main.lua
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@ local animStates = {}
local displayingPluginScreen = false;
local HeadBone = 0x796e;
local radioVolume = 0;
local nuiLoaded = false

--------------------------------------------------------------------------------
-- Plugin functions
@@ -256,7 +257,10 @@ AddEventHandler("initializeVoip", function()
print("TokoVoip: FiveM Server ID is " .. voip.fivemServerId);

voip.processFunction = clientProcessing; -- Link the processing function that will be looped
voip:initialize(); -- Initialize the websocket and controls
while not nuiLoaded do
voip:initialize(); -- Initialize the websocket and controls
Citizen.Wait(5000)
end
voip:loop(); -- Start TokoVoip's loop
end);

@@ -406,6 +410,12 @@ AddEventHandler("updateVoipTargetPed", function(newTargetPed, useLocal)
useLocalPed = useLocal
end)

-- Used to prevent bad nui loading
RegisterNUICallback("nuiLoaded", function(data, cb)
nuiLoaded = true
cb("ok")
end)

-- Make exports available on first tick
exports("addPlayerToRadio", addPlayerToRadio);
exports("removePlayerFromRadio", removePlayerFromRadio);
4 changes: 2 additions & 2 deletions ws_server/index.js
Original file line number Diff line number Diff line change
@@ -98,12 +98,12 @@ app.get('/playerbyip', (req, res) => {
return res.status(204).send();
});

app.get('getmyip', (req, res) => {
app.get('/getmyip', (req, res) => {
const ip = (lodash.get(req, `headers.['x-forwarded-for']`) || lodash.get(req, `headers.['x-real-ip']`) || lodash.get(req, 'connection.remoteAddress')).replace('::ffff:', '');
res.send(ip);
});

http.on('upgrade', (req, socket) => {
http.on('/upgrade', (req, socket) => {
if (!req._query || !req._query.from) return socket.destroy();
if (req._query.from === 'ts3' && !req._query.uuid) return socket.destroy();
});

0 comments on commit bed182e

Please sign in to comment.