From d1428ef2202f8c06971da2399b7c35c2f7810ec7 Mon Sep 17 00:00:00 2001 From: Avarian Knight Date: Tue, 2 Nov 2021 05:33:20 -0500 Subject: [PATCH] fix: stack /me's properly - also don't show /me's for people out of line of sight --- client/client.lua | 59 ++++++++++++++++++++++++++--------------- fxmanifest.lua | 2 ++ server/filterwords.json | 2 -- 3 files changed, 39 insertions(+), 24 deletions(-) diff --git a/client/client.lua b/client/client.lua index 711723f..ccaf9e7 100644 --- a/client/client.lua +++ b/client/client.lua @@ -16,7 +16,36 @@ function Draw3DText(coords, str) end end -local tags = {} +local displayCount = {} +local currentDisplaying = {} +local sleepUntil3dMe = promise.new() +CreateThread(function() + while true do + Citizen.Await(sleepUntil3dMe) + local plyPed = PlayerPedId() + local tblLength = #currentDisplaying + local displayOccurance = {} + for i = tblLength, 1, -1 do + local display = currentDisplaying[i] + displayOccurance[display.ply] = displayOccurance[display.ply] or 0 + displayOccurance[display.ply] += 1 + local tgtPed = GetPlayerPed(display.ply) + local hasLos = HasEntityClearLosToEntity(plyPed, tgtPed, 13) + local tgtCoords = GetEntityCoords(tgtPed) + if hasLos then + Draw3DText(tgtCoords + vector3(0, 0, 0.90 + (0.10 * displayOccurance[display.ply])), display.text) + end + if display.displayTime < GetGameTimer() then + table.remove(currentDisplaying, i) + end + end + if tblLength == 0 then + sleepUntil3dMe = promise.new() + end + Wait(0) + end +end) + local plyNetId = GetPlayerServerId(PlayerId()) RegisterNetEvent('3dme:show3dme', function(serverId, text) local tgtPly = GetPlayerFromServerId(serverId) @@ -26,25 +55,11 @@ RegisterNetEvent('3dme:show3dme', function(serverId, text) args = {text} }) end - - if GetConvarInt('3dme_useGamertags', 0) == 1 then - if tags[serverId] then - RemoveMpGamerTag(tags[serverId]) - Wait(50) - end - tags[serverId] = CreateFakeMpGamerTag(GetPlayerPed(tgtPly), text, false, false, "", false) - Wait(GetConvarInt('3dme_displayTime', 10000)) - RemoveMpGamerTag(tags[serverId]) - else - CreateThread(function() - local displayTime = GetConvarInt('3dme_displayTime', 10000) + GetGameTimer() - while displayTime > GetGameTimer() do - local tgtPed = GetPlayerPed(tgtPly) - local tgtCoords = GetEntityCoords(tgtPed) - Draw3DText(tgtCoords + vector3(0, 0, 1.0), text) - Wait(0) - end - end) - end + currentDisplaying[#currentDisplaying + 1] = { + displayTime = GetConvarInt('3dme_displayTime', 10000) + GetGameTimer(), + ply = tgtPly, + text = text + } + sleepUntil3dMe:resolve() end -end) \ No newline at end of file +end) diff --git a/fxmanifest.lua b/fxmanifest.lua index 380e207..b589316 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -1,6 +1,8 @@ fx_version 'adamant' game 'gta5' +lua54 'yes' + author 'Avarian Knight' description '/me with word filtering & OneSync Infinity support' version '1.0' diff --git a/server/filterwords.json b/server/filterwords.json index b2ca6a1..142c22e 100644 --- a/server/filterwords.json +++ b/server/filterwords.json @@ -1,6 +1,5 @@ [ "coon", - "dick", "fag", "faggot", "simp", @@ -27,7 +26,6 @@ "tard", "trannie", "tranny", - "twat", "wetback", "whore", "wigger"