If someone uses this, other people will probably find this “so called release” on the forums and spam the command on their server. You should add in a permission system.
AddEventHandler('chatMessage', function(source, name, msg)
sm = stringsplit(msg, " ");
if sm[1] == "/announce" then
CancelEvent()
TriggerClientEvent("chatMessage", -1, "^4Admin Announcement", {255, 255, 255}, string.sub(msg,10))
end
sm = stringsplit(msg, " ");
if sm[1] == "/oannounce" then
CancelEvent()
TriggerClientEvent("chatMessage", -1, "^2Owner Announcement", {255, 255, 255}, string.sub(msg,11))
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
also remove the part from "end " to sm = stringsplit thats so unnecessary
just use elseif
AddEventHandler('chatMessage', function(source, name, msg)
sm = stringsplit(msg, " ");
if sm[1] == "/announce" then
CancelEvent()
TriggerClientEvent("chatMessage", -1, "^4Admin Announcement", {255, 255, 255}, string.sub(msg,10))
elseif sm[1] == "/oannounce" then
CancelEvent()
TriggerClientEvent("chatMessage", -1, "^2Owner Announcement", {255, 255, 255}, string.sub(msg,11))
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