Chat proximity

Hey, im trying to make my /me command (3dme script), to be visible to players near me. I created a function so it would display the message in chat but cant get it to work with proximity. Any ideas? This is my function:

local function onShareChat(chattext, target)
    local player = GetPlayerFromServerId(target)
    if player ~= -1 or target == GetPlayerServerId(PlayerId()) then
        local ped = GetPlayerPed(player)
        local dist = Vdist2(coordsMe, coords)
        if dist < 2500 then
            TriggerEvent('chat:addMessage', {
                color = { 255, 255, 255 },
                multiline = true,
                --args = { text}
                --template = '<div style="padding: 0.5vw; margin: 0.5vw; background-color: rgba(0, 0, 0, 0.6); border-radius: 5px;"><i class="fas fa-user-crown"></i> {0} </div>',
                args = { chattext }
            })
        end
    end
end

The method i tried doesnt work… It still displays the chat message to everyone no matter how far away i am.
Server side:

local function onMeCommand(source, args)
    local text = "~b~*~s~ " .. table.concat(args, " ") .. " ~b~*"
    local chattext = "(/me) " .. GetPlayerName(source) .. " (" .. source .. ") : " .. "* " .. table.concat(args, " ") .. " *"
    TriggerClientEvent('3dme:shareDisplay', -1, text, source)
    TriggerClientEvent('3dme:shareChat', -1, chattext, source)
end

Thank you!!

I am not sure how exactly to fix this; however, if you want to go with the easy route I would advise using this resource.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.