Hello. I am creating my first fivem server for roleplay and I have downloaded this chat but in the commands like /me and /do I only get the ID and I would like the character’s name to come out as well, as in the photo. Does anyone know how I could do it?
I think the command line is this, but I’m not sure.
-- ME
RegisterNetEvent('qb_rpchat:sendMe', function(playerId, title, message, color)
local source = PlayerId()
local target = GetPlayerFromServerId(playerId)
if target ~= -1 then
local sourcePed, targetPed = PlayerPedId(), GetPlayerPed(target)
local sourceCoords, targetCoords = GetEntityCoords(sourcePed), GetEntityCoords(targetPed)
if targetPed == source or #(sourceCoords - targetCoords) < 20 then
TriggerEvent('chat:addMessage', {template =
'<div style="font-weight:bold;margin-bottom: 4px;width:fit-content;padding: 2px 8px 5px 8px;margin-right: 0.40vw;background-color: rgba(0, 0, 0, 0.7);border-radius: 8px;border: rgba(40, 161, 25, 1) 2px solid;color: rgb(40, 161, 25);"> {0}: <span style="color:white;font-weight">'.. message ..'</span></div>',
args = { "[ME] - " .. playerId .. "", message }
})
end
end
end)
Assuming that you downloaded the mentioned script and are using the same one. Inquiring into the code itself, the author offers a function that allows access to the name of the character, the modified code would look something like this:
RegisterNetEvent('qb_rpchat:sendMe', function(playerId, title, message, color)
local source = PlayerId()
local target = GetPlayerFromServerId(playerId)
if target ~= -1 then
local sourcePed, targetPed = PlayerPedId(), GetPlayerPed(target)
local sourceCoords, targetCoords = GetEntityCoords(sourcePed), GetEntityCoords(targetPed)
local characterName = GetPlayerName2(playerId)
if targetPed == source or #(sourceCoords - targetCoords) < 20 then
TriggerEvent('chat:addMessage', {template =
'<div style="font-weight:bold;margin-bottom: 4px;width:fit-content;padding: 2px 8px 5px 8px;margin-right: 0.40vw;background-color: rgba(0, 0, 0, 0.7);border-radius: 8px;border: rgba(40, 161, 25, 1) 2px solid;color: rgb(40, 161, 25);"> {0}: <span style="color:white;font-weight">'.. message ..'</span></div>',
args = { "[ME] - " .. playerId .. " - " .. characterName .. " ", message }
})
end
end
end)
yes, I’m using that one. I am putting it in the client/main.lua
I have tried to install it from 0, without any modification and replacing the original /me with the one you told me and the same error continues. Maybe I’m doing something wrong since I’m new to all this.