Client
function trim(s) -- from [url=http://lua-users.org/wiki/StringTrim]http://lua-users.org/wiki/StringTrim[/url]
return s:match "^%s*(.-)%s*$"
end
addEventHandler("onClientGUIClick", resourceRoot, function( )
if source == button then
local text = guiGetText(edit)
if trim(text) ~= "" then
triggerServerEvent("onPlayerSendMessage", localPlayer, text)
else
outputChatBox("Please Fill out the message field", 255, 0, 0)
end
end
end)
addEvent("onClientSendMessage", true)
addEventHandler("onClientSendMessage", root, function(name, message)
guiSetText(memo, guiGetText(memo).."\n"..name:gsub("#%x%x%x%x%x%x", "").." : "..message)
end)
Server
addEvent("onPlayerSendMessage", true)
addEventHandler("onPlayerSendMessage", root, function(message)
if client == source then
triggerServerEvent("onClientSendMessage", root, getPlayerName(client), message)
end
end)