Esx_rpchat everyone can see proximity messages (/me ; /do)

Hello, so we got a problem that our players can see everyone’s /me and /do commands, but the same script on another server works perfectly. es_extended V1 final ; essentialmode 6.4.2

*server.lua*
RegisterCommand('me', function(source, args, user)
      local name = GetPlayerName(source)
      TriggerClientEvent("sendProximityMessageMe", -1, source, name, table.concat(args, " "))
  end, false)
*client.lua*

RegisterNetEvent('sendProximityMessageMe')
AddEventHandler('sendProximityMessageMe', function(id, name, message)
  local myId = PlayerId()
  local pid = GetPlayerFromServerId(id)
  if pid == myId then 
    TriggerEvent('chatMessage', "", {255, 0, 0}, " ^1/me ^0  "  .. name ..  " (ID " .. id .. ") ".."^8: ^0  " .. message)
  elseif GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(myId)), GetEntityCoords(GetPlayerPed(pid)), true) < 19.999 then
    TriggerEvent('chatMessage', "", {255, 0, 0}, " ^1/me ^0 "  .. name ..  " (ID " .. id .. ") ".."^8: ^0 " .. message)
  end
end)

I dont see why that code wouldn’t work - do you get any errors in F8 console or the server console?

What do you wanna do, exactly? 'cause if you want to send a proximity message, you’ll need to make a loop that pass around all players, like GetActivePlayers() loops.

1 Like

No errors in server console, or in F8 console, as i said this code worked in another server with older es_extended, maybe thats the problem is es_extended?

i wanna do that people only arround this player who sent a /me or /do message can see the message not a whole map

You 've tried to remove the true condition in GetDistanceBetweenCoords, or use other Vector verification?

Yes, i’ve tried that nothing still everyone can see the /me /do commands

I mean why and how you are using essentialmode with ESX v1 final?

You dont need it at all. If you are using es_extended v1 final u dont need essentialmode.

So thats can be the problem?

We’ve deleted the essential mode, when testing with 2 players, everything is good, but when i join then everyone can see the chat :smiley: Whats the problem?

How do you mean but when i join then they see the chat xd?

I mean that everything is working with 2 players, but when i connect to the server and type “/me example” then everyone can see the proximity chat :tired_face:

Go to your /me script and find trigger where is triggering chat and delete it. so me command will be printed als 3d text above head but no in chat

edit. sorry i didnt see ur 1st post. so baiscily delete chat add message after then.

so leave this:

elseif GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(myId)), GetEntityCoords(GetPlayerPed(pid)), true) < 19.999 then
    TriggerEvent('chatMessage', "", {255, 0, 0}, " ^1/me ^0 "  .. name ..  " (ID " .. id .. ") ".."^8: ^0 " .. message)

Okay, thanks i’ll try it :slight_smile:

Just leave that but still u are printing it into chat. i dont know what me command u want to make but if you want like this. When i type /me example be printed into chat but player in 20 meters can see it into chat other players not then just leave that

GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(myId)), GetEntityCoords(GetPlayerPed(pid)), true) < 19.999 then

I want only players in 20 meters can see others /me commands. I think its the same as yours comment :smiley:

1 Like
RegisterNetEvent('sendProximityMessageMe')
AddEventHandler('sendProximityMessageMe', function(id, name, message)
  local myId = PlayerId()
  local pid = GetPlayerFromServerId(id)
  if GetDistanceBetweenCoords(GetEntityCoords(GetPlayerPed(myId)), GetEntityCoords(GetPlayerPed(pid)), true) < 19.999 then
    TriggerEvent('chatMessage', "", {255, 0, 0}, " ^1/me ^0 "  .. name ..  " (ID " .. id .. ") ".."^8: ^0 " .. message)
  end
end)

Hi. Ok, try do this:

RegisterCommand('me', function(source, args, user)
   local name = GetPlayerName(source)

   TriggerClientEvent('sendProximityMessageMe', source, name, table.concat(args, ''))
end, false)
RegisterNetEvent('sendProximityMessageMe')

AddEventHandler('sendProximityMessageMe', function(name, message)
   local playerid = PlayerId()
   local ped = GetPlayerPed(playerid)
   local coords = GetEntityCoords(ped)

   for k, v in pairs(GetActivePlayers()) do
      local v_ped = GetPlayerPed(v)
      local v_coords = GetEntityCoords(v_ped)

      if GetDistanceBetweenCoords(v_coords.x, v_coords.y, v_coords.z, coords.x, coords.y, coords.z) <= 20.0 then
         -- call a server event from here, with GetPlayerServerId(v), containing the name, message, etc.
      end
   end
end)

Or you can save the player positions on server side… The way that you wanna do it, at least i, would change the true condition, as i was said.

Now i can’t see my own message, so i think i need to triggerevent before if GetDistance yes?

Nothing appears in the chat with /me or /do commands, no errors in F8 or server console :no_mouth:

1 Like