How to increase rpchat commands range?

I want to make some commands, but i don’t know

how can i increase or deincrease rpchat range.

Not for all just for whisper, shout commands.

In my server only using chat.

So i need advise and help is anyone know about it?

Depends what version of rpchat you are using.
Please share a link to a GitHub repo for the one you are using, or upload it as a .zip (I am at work and can’t open .rar or .7z files on the work PC).

https://drive.google.com/file/d/1LHW1KNCJpYKHa-xTDbCHJTWPTViTSvyK/view?usp=sharing

this ver

When creating a new command with rp_chat, you have 2 built in options;

  1. Global to all players by triggering the client event “chat:addMessage”
  2. Proximity to nearby players by triggering the client event “esx_rpchat:sendProximityMessage”

With option 2, if you check the event with that name, in the CLIENT file, you will see a distance check. It is 20 by default. Increasing this will increase the distance a player can be and still see the chat message triggered by the command. This will increase the range for ALL proximity commands though (/me and /do by default).

client/main.lua:

RegisterNetEvent('esx_rpchat:sendProximityMessage')
AddEventHandler('esx_rpchat:sendProximityMessage', function(playerId, title, message, color)
	local player = PlayerId()
	local target = GetPlayerFromServerId(playerId)

	local playerPed = PlayerPedId()
	local targetPed = GetPlayerPed(target)
	local playerCoords = GetEntityCoords(playerPed)
	local targetCoords = GetEntityCoords(targetPed)

	if target ~= -1 then
		if target == player or #(playerCoords - targetCoords) < 20 then -- This number is the distance
			TriggerEvent('chat:addMessage', {args = {title, message}, color = color})
		end
	end
end)

If you are hoping to add more commands like /whisper or /shout and have different ranges for each, you will need to add a new parameter at the end of “esx_rpchat:sendProximityMessage” which will be the distance as a number, and send this number when triggering the event. Then just change that 20 to the parameter you created. You can do that like this;

client/main.lua:

RegisterNetEvent('esx_rpchat:sendProximityMessage')
AddEventHandler('esx_rpchat:sendProximityMessage', function(playerId, title, message, color, distance)
	local player = PlayerId()
	local target = GetPlayerFromServerId(playerId)

	local playerPed = PlayerPedId()
	local targetPed = GetPlayerPed(target)
	local playerCoords = GetEntityCoords(playerPed)
	local targetCoords = GetEntityCoords(targetPed)

	if target ~= -1 then
		if target == player or #(playerCoords - targetCoords) < distance then
			TriggerEvent('chat:addMessage', {args = {title, message}, color = color})
		end
	end
end)

server/main.lua:

-- Edit the /me command to send a distance at the end of this trigger. eg. 25
TriggerClientEvent('esx_rpchat:sendProximityMessage', -1, playerId, _U('me_prefix', playerName), args, {153, 102, 255}, 25)

-- Edit the /do command to send a distance at the end of this trigger. eg. 30
TriggerClientEvent('esx_rpchat:sendProximityMessage', -1, playerId, _U('do_prefix', playerName), args, {102, 0, 153}, 30)

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