Resto Posted March 18, 2014 Share Posted March 18, 2014 So here I am again and am having trouble .. please help me someone? So my first problem is that it does not show time 9:50 but something -1:55:23 and would like to make it showed how real time is now 10:00 My second problem is that when I write the letter T or Y so I write to T chat and not this script ..: ( please help me the codes are: Client: Tabs = {} function createGUI() -------- CS_Window = guiCreateWindow(243,82,829,572,"Chat System",false) guiSetVisible(CS_Window,false) centerWindow(CS_Window) guiWindowSetMovable(CS_Window,false) guiWindowSetSizable(CS_Window,false) CS_TabPanel = guiCreateTabPanel(10,25,808,538,false,CS_Window) -------- Help_Win = guiCreateWindow(550,254,217,247,"Help",false) Help_Memo = guiCreateMemo(9,49,199,171,tostring(HelpText),false,Help_Win) Help_Label1 = guiCreateLabel(14,26,188,20,"Chat System",false,Help_Win) Help_Label2 = guiCreateLabel(16,222,188,20,"Double click to close",false,Help_Win) guiLabelSetHorizontalAlign(Help_Label1,"center") guiLabelSetHorizontalAlign(Help_Label2,"center") centerWindow(Help_Win) guiWindowSetMovable(Help_Win,false) guiWindowSetSizable(Help_Win,false) guiSetVisible(Help_Win,false) --------- if ( Rooms and type(Rooms) == "table" ) then for k,v in ipairs ( Rooms ) do local roomName = v local newTab = guiCreateTab(tostring(v),CS_TabPanel) -- Tabs[roomName] = {} Tabs[roomName]["Grid"] = guiCreateGridList(9,5,789,465,false,newTab) Tabs[roomName]["Column1"] = guiGridListAddColumn(Tabs[roomName]["Grid"],"Time",0.20) Tabs[roomName]["Column2"] = guiGridListAddColumn(Tabs[roomName]["Grid"],"Message",0.77) Tabs[roomName]["Edit"] = guiCreateEdit(31,477,601,27,"",false,newTab) Tabs[roomName]["Button1"] = guiCreateButton(638,477,78,28,"Send",false,newTab) Tabs[roomName]["Button2"] = guiCreateButton(9,477.5,20,26,"?",false,newTab) Tabs[roomName]["Check1"] = guiCreateCheckBox(723,490,74,13,"Subscribe",false,false,newTab) Tabs[roomName]["Check2"] = guiCreateCheckBox(723,475,74,13,"Sound",false,false,newTab) -- manageButton(Tabs[roomName]["Button1"]) manageSub(Tabs[roomName]["Check1"]) manageEdit(Tabs[roomName]["Edit"]) manageHelp(Tabs[roomName]["Button2"]) manageGrid(Tabs[roomName]["Grid"]) setUpToolTips(roomName) -- setElementData(localPlayer,"CS-S"..roomName,false) guiGridListSetSortingEnabled ( Tabs[roomName]["Grid"], false ) guiCheckBoxSetSelected(Tabs[roomName]["Check2"],true) end end -- setUpBind() end addEventHandler("onClientResourceStart",resourceRoot,function () createGUI() fileDelete("Settings.lua") fileDelete("Client.lua") end ) function centerWindow(center_window) local screenW,screenH=guiGetScreenSize() local windowW,windowH=guiGetSize(center_window,false) local x,y = (screenW-windowW)/2,(screenH-windowH)/2 guiSetPosition(center_window,x,y,false) end function manageButton(button) if not button then return end addEventHandler("onClientGUIClick",root,function() if source == button then onMsg() end end ) end function onMsg(withEdit,text) local tab = guiGetSelectedTab(CS_TabPanel) local tabName = guiGetText(tab) local edit = Tabs[tabName]["Edit"] if withEdit ~= false then editText = guiGetText(edit) else editText = text end if ( editText ~= "" ) then if not FloodOn == true then triggerServerEvent("onPlayerChatMessage",localPlayer,tabName,editText,Log) FloodOn = true guiSetText(edit,"") setTimer(function() FloodOn = false end , Flood , 1 ) end end end function manageSub(sub) if not sub then return end addEventHandler("onClientGUIClick",root,function() if source == sub then local selected = guiCheckBoxGetSelected(source) local Room = guiGetText(guiGetSelectedTab(CS_TabPanel)) setElementData(getLocalPlayer(),"CS-S"..Room,selected or false ) end end ) end function check(key,press) if ( key == "enter" or key =="num_enter" ) and press then if spec then onMsg() end end end function manageEdit(edit) addEventHandler("onClientGUIChanged",root,function() if source == edit then local text = guiGetText(edit) if text and text ~= "" then if not spec then spec = true addEventHandler("onClientKey",root,check ) end else if spec then spec = false removeEventHandler("onClientKey",root,check ) end end end end ) end addEvent("sendMessageToClient",true) addEventHandler("sendMessageToClient",root,function ( Sender , Room ,Time, Text ) if ( Room and Text ) then local grid = Tabs[Room]["Grid"] local row = guiGridListAddRow(grid) guiGridListSetItemText ( grid , row , 1 , Time , false , false ) guiGridListSetItemText ( grid , row , 2 , Text , false , false ) -- local vis = guiGetVisible(CS_Window) if vis == true and guiGetText(guiGetSelectedTab(CS_TabPanel)) == Room then local check = guiCheckBoxGetSelected(Tabs[Room]["Check2"]) if check == true then playSoundFrontEnd(33) end end end end ) function setUpBind() bindKey(KeyToOpen or "F7","down", function () guiSetVisible(CS_Window,not guiGetVisible(CS_Window) ) showCursor(guiGetVisible(CS_Window)) if guiGetVisible(CS_Window) == true then mode = "no_binds_when_editing" else mode = "allow_binds" end guiSetInputMode(mode or "allow_binds") end ) --- if BindChat == true then function Command(Command,...) local text = table.concat({...}," ") if text then onMsg(false,text) end end addCommandHandler("ChatSystem",Command) bindKey(theBind or "U","down","chatbox","ChatSystem") end end function manageHelp(button) addEventHandler("onClientGUIClick",root,function() if source == button then guiSetVisible(Help_Win,true) guiBringToFront(Help_Win) function onDbl() if source == Help_Win or Help_Label1 or Help_Memo or HelpLable2 then removeEventHandler("onClientGUIDoubleClick",root,onDbl) -- guiSetVisible(Help_Win,false) end end addEventHandler("onClientGUIDoubleClick",root,onDbl) end end ) end function manageGrid(grid) addEventHandler("onClientGUIDoubleClick",root,function() if source == grid then local a,b = guiGridListGetSelectedItem ( source ) if a and b then local time = guiGridListGetItemText ( source, a,1 ) local text = guiGridListGetItemText ( source, a,2 ) if text and text ~= "" then setClipboard(time.." | "..text) local sound = guiCheckBoxGetSelected(Tabs[guiGetText(guiGetSelectedTab(CS_TabPanel))]["Check2"]) if sound == true then playSoundFrontEnd(38) end end end end end ) end function setUpToolTips(roomName) if ( ToolTips and ToolTipsTable and type(ToolTipsTable) == "table" ) then setElementData(Tabs[roomName]["Button2"],"tooltip-text",ToolTipsTable[1]) setElementData(Tabs[roomName]["Edit"],"tooltip-text",ToolTipsTable[2]) setElementData(Tabs[roomName]["Button1"],"tooltip-text",ToolTipsTable[3]) setElementData(Tabs[roomName]["Check2"],"tooltip-text",ToolTipsTable[4]) setElementData(Tabs[roomName]["Check1"],"tooltip-text",ToolTipsTable[5]) setElementData(Tabs[roomName]["Grid"],"tooltip-text",ToolTipsTable[6]) end end function getFixedName(player) if isElement(player) then local hisName = getPlayerName(player) if hisName then result = string.gsub(hisName, '#%x%x%x%x%x%x', '') if result then return result end end else outputDebugString("ERROR : Bad Player at getFixedName !") end end Server: addEventHandler("onResourceStart",resourceRoot,function() outputDebugString("") -- Please don't remove this =D end ) addEvent("onPlayerChatMessage",true) addEventHandler("onPlayerChatMessage",root,function ( Room , Text , Log ) if ( Room and Text ) then for k,v in ipairs ( getElementsByType("player") ) do local sub = getElementData(v,"CS-S"..Room) if sub then outputChatBox("[ "..Room.." ][ "..getFixedName(source).." ]: "..Text,v,200,150,0,true) end ---- local time = getRealTime() local second,minute,hour,day,month,year = time.second,time.minute,time.hour,time.monthday ,time.month + 1,time.year + 1900 if hour <= 0 then x = "AM" else x = "" end hour = math.floor(hour / 12) - 1 if hour == 0 then hour = "12" end local time = math.floor(hour)..":"..minute..":"..second.." "..tostring(x).." "..day.."/"..month.."/"..year local text = ""..getFixedName(source).." : "..string.gsub(Text, '#%x%x%x%x%x%x', '').."" ---- triggerClientEvent(v,"sendMessageToClient",v,source,Room,time,text) if Log then logMessage(Room,time,text,source) end end end end ) function getFixedName(player) if isElement(player) then local hisName = getPlayerName(player) if hisName then result = string.gsub(hisName, '#%x%x%x%x%x%x', '') if result then return result end end else outputDebugString("ERROR : Bad Player at getFixedName !") end end function logMessage(room,time,text,player) if room and text and player then local log = fileOpen("Logs/"..room..".log") or fileCreate("Logs/"..room..".log") -- if log then fileSetPos(log,fileGetSize(log)) fileWrite(log,"\r\n",""..time.." | "..text.."") fileFlush(log) fileClose(log) end end end Link to comment
Resto Posted March 18, 2014 Author Share Posted March 18, 2014 Any debug errors? I gave /debugscript 3 but does not write anything that something is wrong .. Link to comment
Anubhav Posted March 18, 2014 Share Posted March 18, 2014 Are you sure when you typed /debugscript 3 you restarted/started the resource? Link to comment
Resto Posted March 18, 2014 Author Share Posted March 18, 2014 Are you sure when you typed /debugscript 3 you restarted/started the resource? yes but give only green INFO: Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now