3d rp chat [help] message showns in every player head

Everything that says -1 = everyone. Change that to source or get the player itself that typed the /me command.

Also chatMessage is deprecated for client-side as well and needs to be changed to chat:addMessage
https://docs.fivem.net/docs/scripting-manual/migrating-from-deprecated/chat-messages/

It would be better just to re-write the resource itself.

Server. Lua was re rewritten by someone cause i was getting system /me is not valid command. Now it works. After that everyone started to get the message instead of just me. And oh gosh i know very little of coding . But i will change the chatmessage to chat:addchatmessage. Could you give it a bet look to the server.lua if anything is wrong there? And thanks man i rally want this to be fully working

My friend wrote hello and it appears on my head

All the stuff that references -1 is everyone and not just the player itself. Change everything that says -1 to source. Just keep that in mind. I wrote a small example of grabbing player coordinates and properly sending it to chat to the person that typed the command. Maybe you can learn from my example to you.

-- Command Test
function cmdTest (source, args, rawCommand)
	local myArgs = table.concat(args, " ")
	local player = GetPlayerName(source)
	local ped = GetPlayerPed(source)
	local coords = GetEntityCoords(ped, false)
	local x, y, z = table.unpack(coords)
	local heading = GetEntityHeading(ped)
	print("player: "..player)
	print("ped: "..ped)
	print("x: "..x..", y: "..y..", z: "..z..", heading: "..heading)
	-- if source == 1 then it is a player. If source == 0 then it is console. We can add an if statement later, this was just for demonstration.
	print("source: "..source)
	-- Check to see if any arguments were passed. If so, then show what was passed
	if args[1] ~= nil then
		print("args: "..myArgs)
	end
	print("rawCommand: "..rawCommand)
	-- We can use this to send to player's chat, as only client-side of this function is deprecated.
	TriggerClientEvent("chatMessage", source, player.."'s POS", {255, 255, 0}, "x: "..x..", y: "..y..", z: "..z..", heading: "..heading)
	-- heck we can even add some html to format our message
	TriggerClientEvent("chat:addMessage", source, {
		template = '<h3>Player Information</h3><hr><b><font color=red>Player Name</font></b>: <font color=yellow>{0}</font><br><b><font color=red>Arguments</font></b>: <font color=yellow>{1}</font>',
		args = { player, myArgs }})
	-- Add an embeded image in chat
	TriggerClientEvent("chat:addMessage", source, {
		template = '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAABmJL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J/GrNmseqFq/zUVHAiUMHfxRvb98sKzQoM4ZASSFsV7kZp2QfMfzm6wFf4KVb12/45AuNcwmXcAmXcAnTwX8ASqKbZVGNPOwAAAAASUVORK5CYII=" height="16"> <b>{0}</b>: {1}',
		args = { 'shortybsd', 'Leave the poor snails alone!' }})
end
RegisterCommand("test", cmdTest)

For the resource you are using, I would re-write the entire thing. I am a bit different than most of the guys here. I for one do not put functions inside functions inside other functions aka First-Class functions or Nested functions. It looks horrible. Also, I put mostly everything I can in server-side and I only pass TriggerClientEvent/TriggerServerEvent when I have no other choice.

The example I made you above is all server side. Maybe you can learn and understand a bit of that.

Your server.lua should be something like this

RegisterCommand('rp', function(source, args, rawCommand)
	local playerPed = GetPlayerPed(source)
	local msg = table.concat(args, " ")
	TriggerClientEvent('sendMessageRp', -1, playerPed, GetPlayerName(source), msg)
end)

RegisterCommand('try', function(source, args, rawCommand)
	local playerPed = GetPlayerPed(source)
	local msg = table.concat(args, " ")
	TriggerClientEvent('sendMessageTry', -1, playerPed, GetPlayerName(source), msg, math.random(1, 2))
end)

RegisterCommand('do', function(source, args, rawCommand)
	local playerPed = GetPlayerPed(source)
	local msg = table.concat(args, " ")
	TriggerClientEvent('sendMessageDo', -1, playerPed, GetPlayerName(source), msg)
end)

RegisterCommand('me', function(source, args, rawCommand)
	local playerPed = GetPlayerPed(source)
	local msg = table.concat(args, " ")
	TriggerClientEvent('sendMessageMe', source, playerPed, GetPlayerName(source), msg)

end)

RegisterCommand('loc', function(source, args, rawCommand)
	local playerPed = GetPlayerPed(source)
	local msg = table.concat(args, " ")
	TriggerClientEvent('sendMessageLoc', -1, playerPed, GetPlayerName(source), msg)
end)

Notice in the above code, all 4 commands sends them globally/drawtext globally on every character. If the /me works like intended and the others spam all players. Just change -1 to source on the 3 other commands. /restart your_resource and you should be good.

Yup i see now . And it makes sense. I think that the guy whi rewrote it for me thought that sendmessage would be the same as chatmessage which makes sense putting -1 if that means everyone. Okay one more thing i learned i will change all that when i get home thanks much appreciated shorty. Ill keep you updated on the result

If that doesn’t work let me know. I might have to switch it back to all global players, then run an if check on the coordinates of the player that typed the command to only force that player to display info over his/her head.

Wish everyone was helpful has you are. Thanks i will let you know.

If you trigger this event only on the client that has done the command, the text will only appear to him. The bug he is talking about should have been resolved with version 2.0, I believe he is using a modified version.

He indeed is, one of his friends added in multiple parameters that aren’t needed, called and used variables which were not needed as well. It is a mess lol.

Yeah so i was using the original files but wanted to add only a comand for /rp wich would be doing sign language for those who dont have a mic or having problems could still rp in the server. So when i added that comand . It was working but in the chat, system rp is not a valid command and so to every comand /me /do /try. So he decided to help. It stoped spaming chat the system cause i guess the commands were valid. Then i told him about the problem of everyone getting the message and he ignored. Thats why i came here for help. Ill be soon home to test it out. Please feel free to edit. Or put me in the right way im here to learn and really want this script to work so that everyone with or without a mic can still have fun .

Original Project
2.0 server.lua
2.0 client.lua
delete __resource.lua and replace with fxmanifest.lua, my forked version

then add all your commands your guy added, but add them correctly :wink:

[Release] [Standalone] Optimized 3D RP CHAT with Queue. Ok , but this is actutually the original project the one im talking about
. It does /me /do /try and has ooc but i changed it to /loc for local and only added /rp for sign language.

My goodness I went blind. That guy used chatMessage to parse commands. That needs to use RegisterCommand. Use Elio’s I linked above and scrap that resource bro.

so i went on the script i have and changed and remove -1 to source the players stop seeing it, but i can see it above my head but they also can’t see it above my head so they cant read it.
so right now it’s only showing to me. i am talking about the script i had

here, i tried the script you sent me and i was able to add the command /do /loc and it works now i don’t know how to add /try to give me the results random success and failure could you help me on that? i would be using this script then . thanks

allright after messing in everything find out it needed source and -1 and not to delete -1. its fixed

ik im late but what do u mean by it needed source mines say source but my /me still show up for everybody no matter where theya re at