Hello,
Just needed a little help scripting my commands. So what i need help with is the serverID to show up in the chat as well as the commands, for example if typed /do test into my chat i receive Do | Valk: test. Whereas I would like to type /do test and receive Do | Valk (serverID): test.
My commands are written like this:
do.lua
AddEventHandler('chatMessage', function(source, name, msg)
sm = stringsplit(msg, " ");
if sm[1] == "/do" then
CancelEvent()
TriggerClientEvent('chatMessage', -1, "Do | " .. name, { 255, 0, 0 }, string.sub(msg,5))
end
end)
function stringsplit(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={} ; i=1
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
end
return t
end
and on client side you would have something like this
AddEventHandler('chatMessage', function(author, color, text, serverID)
local myCoords = GetEntityCoords(GetPlayerPed(-1))
local pedCoords = GetEntityCoords(GetPlayerPed(GetPlayerFromServerId(serverID))
local dist = #(myCoords - pedCoords)
if dist > 100 then
return
end
local args = { text }
if author ~= "" then
table.insert(args, 1, author)
end
SendNUIMessage({
type = 'ON_MESSAGE',
message = {
color = color,
multiline = true,
args = args
}
})
end)
You would change the dist > to whatever you want the max distance for it to draw to be so it doesn’t show for distances greater than that.