Skip to content

Commit

Permalink
fix: stack /me's properly
Browse files Browse the repository at this point in the history
- also don't show /me's for people out of line of sight
  • Loading branch information
AvarianKnight committed Nov 2, 2021
1 parent 4fee321 commit d1428ef
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 24 deletions.
59 changes: 37 additions & 22 deletions client/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
end)
2 changes: 2 additions & 0 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
2 changes: 0 additions & 2 deletions server/filterwords.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[
"coon",
"dick",
"fag",
"faggot",
"simp",
Expand All @@ -27,7 +26,6 @@
"tard",
"trannie",
"tranny",
"twat",
"wetback",
"whore",
"wigger"
Expand Down

0 comments on commit d1428ef

Please sign in to comment.