-- client side:
GUIEditor_Label = {}
GUIEditor_Window = {}
GUIEditor_Button = {}
GUIEditor_Edit = {}
GUIEditor_Label[1] = guiCreateLabel(218,558,387,41,"",false)
guiLabelSetColor(GUIEditor_Label[1],255,255,255)
guiLabelSetVerticalAlign(GUIEditor_Label[1],"top")
guiLabelSetHorizontalAlign(GUIEditor_Label[1],"left",false)
GUIEditor_Window[1] = guiCreateWindow(221,83,310,341,"",false)
guiSetVisible ( GUIEditor_Window[1] , false )
GUIEditor_Edit[1] = guiCreateEdit(10,25,287,47,"",false,GUIEditor_Window[1])
GUIEditor_Button[1] = guiCreateButton(9,295,126,35,"Send Text",false,GUIEditor_Window[1])
close = guiCreateButton(173,294,126,35,"Close",false,GUIEditor_Window[1])
font = guiCreateFont("font.ttf", 12)
addEvent ( "showWindow", true )
addEventHandler ( "showWindow", root,
function ( )
guiSetVisible ( GUIEditor_Window[1], true )
showCursor ( true )
end
)
addEventHandler ( "onClientGUIClick", root,
function ( )
if ( source == GUIEditor_Button[1] ) then
local text = guiGetText(GUIEditor_Edit[1])
triggerServerEvent ( "sendText", localPlayer, text )
elseif ( source == close ) then
guiSetVisible ( GUIEditor_Window[1], false )
showCursor ( false )
end
end
)
addEvent ( "returnText", true )
addEventHandler ( "returnText", root,
function ( text )
guiSetText ( GUIEditor_Label[1], " admin : "..text )
guiSetFont(GUIEditor_Label[1], font)
guiLabelSetColor ( GUIEditor_Label[1], 255, 0, 0 )
end
)
-- server side:
addCommandHandler ( "text",
function ( thePlayer )
local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) -- get his account name
if isObjectInACLGroup ( "user.".. accName, aclGetGroup ( "Admin" ) ) then
triggerClientEvent ( thePlayer, "showWindow", thePlayer )
end
end
)
addEvent ( "sendText", true )
addEventHandler ( "sendText", root,
function ( text )
triggerClientEvent ( "returnText", root, text )
end
)