Hey guys.
So i recently started to mess around with the Chat options etc…
And i came to the conclusion that i wanted the 3D me to be the default chat.
I’ve come pretty far, however its not functioning as i would want it hence i’m here asking for help.
So once the user enters a message its being printed in a 3d textdraw on the person, however the issue right now is, its not only printing on the person sending out the message, but its printing it on everyone in the server, and i’m quite lost as i have no clue right now what i’m doing wrong.
my serverside is looking like this.
AddEventHandler('_chat:messageEntered', function(author, color, message)
if not message or not author then
return
end
if not WasEventCanceled() then
TriggerClientEvent('sendProximityMessage', -1, author, tostring(message))
end
end)
after that its calling the client side.
RegisterNetEvent('sendProximityMessage')
AddEventHandler('sendProximityMessage', function(author, message)
local monid = PlayerId()
local sonid = GetPlayerFromServerId(id)
if sonid == monid then
--TriggerEvent('chat:addMessage', message)
TriggerEvent('3dme:triggerDisplay', message, author)
elseif Vdist(GetEntityCoords(GetPlayerPed(monid)), GetEntityCoords(GetPlayerPed(sonid))) < 6 then
--TriggerEvent('chat:addMessage', message)
TriggerEvent('3dme:triggerDisplay', message, author)
end
end)
local meDisplayTime = 7000 -- Duration of the display of the text : 1000ms = 1sec
local slashMeOffsets = {}
RegisterNetEvent('3dme:triggerDisplay')
AddEventHandler('3dme:triggerDisplay', function(text, source)
local mePed = GetPlayerFromServerId(source)
local offset = 0.1
if slashMeOffsets[mePed] == nil or slashMeOffsets[mePed] < 1 then
slashMeOffsets[mePed] = 1
end
offset = offset + (slashMeOffsets[mePed]*0.10)
Display(mePed, text, offset)
end)
function Display(mePlayer, text, offset)
local displaying = true
Citizen.CreateThread(function()
Wait(meDisplayTime)
displaying = false
end)
Citizen.CreateThread(function()
slashMeOffsets[mePlayer] = slashMeOffsets[mePlayer] + 1
while displaying do
Wait(0)
local coordsMe = GetEntityCoords(GetPlayerPed(mePlayer), false)
local coords = GetEntityCoords(PlayerPedId(), false)
local dist = GetDistanceBetweenCoords(coordsMe['x'], coordsMe['y'], coordsMe['z'], coords['x'], coords['y'], coords['z'], true)
if dist < 6 then
DrawText3Ds(coordsMe['x'], coordsMe['y'], coordsMe['z']+offset, text)
end
end
slashMeOffsets[mePlayer] = slashMeOffsets[mePlayer] - 1
end)
end
