I want to make a simple command.
/test [arg1] [arg2]
I want a chat message to appear to all players when the command is ran.
[Test] [arg1] [arg2]
Preferably not in all white, maybe a little color to it.
I want to make a simple command.
/test [arg1] [arg2]
I want a chat message to appear to all players when the command is ran.
[Test] [arg1] [arg2]
Preferably not in all white, maybe a little color to it.
i still have no idea, im completely new to this
client:
RegisterNetEvent('EventName')
AddEventHandler('EventName', function()
TriggerEvent("chatMessage", "Sender Name", {150, 50, 180}, "text to send")
end)
server:
AddEventHandler('chatMessage', function(player, playerName, message)
if message:sub(1) == '/test' then
TriggerClientEvent('EventName', player)
CancelEvent()
end
end)
Edit for your liking
I also believe this has all you need
does not work
Did you add them to your resource file?
client_script ‘client.lua’
server_script ‘server.lua’
Did you start the resource?
Did you change any of the code and broke it?
Okay very funny. I did not mean actually “sender name: text to send” i meant /test [arg1] [arg2] and the chat output is “[Test] [arg1] [arg2]”
Elaborate what “test” is, and what the “arguments” are, so anyone might be able to decipher you lack of information and point you in the right direction.
is it like /test 1+1 = 2? <- math
or /test server shutting down in 10? <- string
User Types: /test Billy Bob
Chat output to all plyers: [Test] [username of person who issued the /test command] Billy Bob
So do that then? PlayerName … String
String = args[2]
PlayerName = source
Edit: Is this what you want?
AddEventHandler('chatMessage', function(player, playerName, message)
local args = stringsplit(message, " ")
if message == '/test' then
CancelEvent()
elseif args[1] ~= "/test" then
CancelEvent()
elseif args[2] ~= nil then
TriggerClientEvent('chatMessage', -1, playerName .. " used command /test", { 255, 0, 0 } args[2] .." ".. args[3] .. " " .. args[4])
CancelEvent()
end
end)
function stringsplit(self, delimiter)
local a = self:Split(delimiter)
local t = {}
for i = 0, #a - 1 do
table.insert(t, a[i])
end
return t
end