Snoop.Cat Posted January 29, 2013 Share Posted January 29, 2013 hello i want to enable the cursor when i thype the comand /chatop and when close gui disable it how i can do it ? this is smartchat resource , plz help local extension = f_createChatPlugin("Options") local window,optionstab,layouttab,width,height,h,highest addCommandHandler("resetsmartchat", function () f_resetChatBoxSettings() end ) addCommandHandler("chatop", function () width = 500 h = dxGetFontHeight()*1.6 height = h createGui() end ) addCommandHandler("smartchat", function () setTimer(function () f_setChatBoxSetting("settings.enablesmartchat",not settings.enablesmartchat) f_saveChatBoxSettings() end,500,1) end ) addEvent("onChatExtensionStart") addEventHandler("onChatExtensionStart",extension, function (tab) width = 500 h = dxGetFontHeight()*1.6 height = h createGui() destroyElement(tab) end ) function createGui () if window and isElement(window) then return false end window = guiCreateWindow(0,0,800,600,"Smartchat Options",false) guiSetAlpha(window,1) guiWindowSetSizable(window,false) tabpanel = guiCreateTabPanel(0,h,700,500,false,window) -- layout local highest = 0 for part,info in pairs (layout) do local tab = guiCreateTab(longstring(part),tabpanel) if part == "general" then for setting,value in pairs (settings) do createOption(longstring(setting),tab,value,"settings."..setting) end end for subpart,value in pairs (info) do if subpart == "size" then createOption("Width",tab,value.x,"layout."..part.."."..subpart..".x") createOption("Height",tab,value.y,"layout."..part.."."..subpart..".y") elseif subpart == "pos" then createOption("Left",tab,value.x,"layout."..part.."."..subpart..".x") createOption("Top",tab,value.y,"layout."..part.."."..subpart..".y") elseif string.find(subpart,"font") then createOption("Font",tab,value.name,"layout."..part.."."..subpart..".name") createOption("Font Scale",tab,value.scale,"layout."..part.."."..subpart..".scale") createOption("Font Color",tab,value.color,"layout."..part.."."..subpart..".color") else createOption(longstring(subpart),tab,value,"layout."..part.."."..subpart) end end if height > highest then highest = height end height = h end -- resize height = highest local w = (width-40)/3 guiSetSize(window,width,height+4*h,false) guiSetSize(tabpanel,width,highest+1.5*h,false) guiSetPosition(window,(screenX/2)-(width/2),(screenY/2)-((highest+4*h)/2),false) -- buttons height = highest+3*h addEventHandler("onClientGUIClick",createButton("Ok",10,w,window),function (btn,state) if state == "up" and btn == "left" then f_saveChatBoxSettings() destroyElement(window) end end,false) addEventHandler("onClientGUIClick",createButton("Cancel",20+w,w,window),function (btn,state) if state == "up" and btn == "left" then destroyElement(window) f_loadChatBoxSettings() end end,false) applybutton = createButton("Apply",30+2*w,w,window) guiSetEnabled(applybutton,false) addEventHandler("onClientGUIClick",applybutton,function (btn,state) if state == "up" and btn == "left" then f_saveChatBoxSettings() guiSetEnabled(applybutton,false) end end,false) end addEventHandler("onClientGUIClick",root, function (key,state) if key ~= "left" or state ~= "up" then return end local table = getElementData(source,"smartchat.table") if table then if getElementType(source) == "gui-checkbox" then f_setChatBoxSetting(table,guiCheckBoxGetSelected(source)) guiSetEnabled(applybutton,true) elseif getElementType(source) == "gui-button" then guiSetText(source,"press any key") currentbutton = source currenttable = table addEventHandler("onClientKey",root,onKeyChange) end end local default = getElementData(source,"smartchat.default") if default then local value = f_getChatBoxSetting(string.gsub(string.gsub(default,"settings","defaultsettings"),"layout","defaultlayout")) f_setChatBoxSetting(default,value) local gui = getElementData(source,"smartchat.gui") if gui then if getElementType(gui) == "gui-checkbox" then guiCheckBoxSetSelected(gui,value) elseif type(value) == "number" and getElementType(gui) == "gui-button" then guiSetProperty(gui,"NormalTextColour",string.upper(string.sub(fromColor(value,true),2))) guiSetProperty(gui,"PushedTextColour",string.upper(string.sub(fromColor(value,true),2))) else guiSetText(gui,value) end guiSetEnabled(applybutton,true) end end local table = getElementData(source,"smartchat.color") if table then local window = guiCreateWindow((screenX/2)-188,(screenY/2)-80,375,185,"color",false) guiWindowSetSizable(window,false) guiWindowSetMovable(window,false) guiSetAlpha(window,1) guiCreateLabel(10,30,40,15,"Red:",false,window) guiCreateLabel(10,60,40,15,"Green:",false,window) guiCreateLabel(10,90,40,15,"Blue:",false,window) guiCreateLabel(10,120,40,15,"Alpha:",false,window) local gr = guiCreateScrollBar(50,30,200,15,true,false,window) local gg = guiCreateScrollBar(50,60,200,15,true,false,window) local gb = guiCreateScrollBar(50,90,200,15,true,false,window) local ga = guiCreateScrollBar(50,120,200,15,true,false,window) local r,g,b,a = fromColor(f_getChatBoxSetting(table),false) guiScrollBarSetScrollPosition(gr,r/2.5) guiScrollBarSetScrollPosition(gg,g/2.5) guiScrollBarSetScrollPosition(gb,b/2.5) guiScrollBarSetScrollPosition(ga,a/2.5) guiSetEnabled(applybutton,true) local oldsource = source function onRender () local r = guiScrollBarGetScrollPosition(gr)*2.5 local g = guiScrollBarGetScrollPosition(gg)*2.5 local b = guiScrollBarGetScrollPosition(gb)*2.5 local a = guiScrollBarGetScrollPosition(ga)*2.5 dxDrawRectangle((screenX/2)+73,(screenY/2)-50,105,105,tocolor(r,g,b,a),true) f_setChatBoxSetting(table,tocolor(r,g,b,a)) guiSetProperty(oldsource,"NormalTextColour",string.upper(string.format("%.2X%.2X%.2X%.2X",a,r,g,b))) guiSetProperty(oldsource,"PushedTextColour",string.upper(string.format("%.2X%.2X%.2X%.2X",a,r,g,b))) end addEventHandler("onClientRender",root,onRender) local button = guiCreateButton(153,143,70,30,"Close",false,window) addEventHandler("onClientGUIClick",button, function () removeEventHandler("onClientRender",root,onRender) destroyElement(window) end ) end end,true ) addEventHandler("onClientGUIChanged",root, function () local table = getElementData(source,"smartchat.table") if table then if tonumber(guiGetText(source)) then f_setChatBoxSetting(table,tonumber(guiGetText(source))) guiSetEnabled(applybutton,true) end end end ) addEventHandler("onClientGUIComboBoxAccepted",root, function (box) local table = getElementData(source,"smartchat.table") if table then f_setChatBoxSetting(table,fonts[guiComboBoxGetItemText(box,guiComboBoxGetSelected(box))]) guiSetEnabled(applybutton,true) end end ) function onKeyChange (key,pressing) if pressing then return end f_setChatBoxSetting(currenttable,key) guiSetText(currentbutton,key) currenttable = nil currentbutton = nil guiSetEnabled(applybutton,true) removeEventHandler("onClientKey",root,onKeyChange) end function createOption (name,parent,value,gtable) local name = longstring(name) local w1,w2,w3 = dxGetTextWidth(name),0,dxGetTextWidth("default")*1.2 local label = guiCreateLabel(30,height,w1,h,name,false,parent) guiLabelSetHorizontalAlign(label,"center") guiLabelSetVerticalAlign(label,"center") local child if type(value) == "boolean" then w2 = 10 child = guiCreateCheckBox(40+w1,height,20,h,"",value,false,parent) setElementData(child,"smartchat.table",gtable) elseif string.find(name,"Key") then w2 = dxGetTextWidth("press any key")*1.1 child = guiCreateButton(40+w1,height,w2,h,tostring(value),false,parent) setElementData(child,"smartchat.table",gtable) elseif name == "Width" or name == "Height" or name == "Lines" or gettok(name,2," ") == "Scale" or name == "Left" or name == "Top" then w2 = 50 child = guiCreateEdit(40+w1,height,w2,h,tostring(value),false,parent) setElementData(child,"smartchat.table",gtable) elseif name == "Font" or gettok(name,2," ") == "Font" then w2 = 150 child = guiCreateComboBox(40+w1,height,w2,7*h,"",false,parent) for font,name in pairs (fonts) do local item = guiComboBoxAddItem(child,font) if name == value then guiComboBoxSetSelected(child,item) end end setElementData(child,"smartchat.table",gtable) elseif string.find(name,"Color") then w2 = 30 child = guiCreateButton(40+w1,height,w2,h,"▉",false,parent) guiSetProperty(child,"NormalTextColour",string.upper(string.sub(fromColor(value,true),2))) guiSetProperty(child,"PushedTextColour",string.upper(string.sub(fromColor(value,true),2))) setElementData(child,"smartchat.color",gtable) elseif type(value) == "table" then local text = table.concat(value,", ") guiLabelSetVerticalAlign(guiCreateLabel(40+w1,height,dxGetTextWidth(text),h,text,false,parent),"center") end if child then local defaultbutton = guiCreateButton(50+w1+w2,height,w3,h,"default",false,parent) setElementData(defaultbutton,"smartchat.default",gtable) setElementData(defaultbutton,"smartchat.gui",child) end height=height+h end function createButton (string,start,width,parent) return guiCreateButton(start,height,width,h,string,false,parent) end local replace = { ["nickcompletion"]="Nick Completion", Link to comment
Blaawee Posted January 29, 2013 Share Posted January 29, 2013 first ask the script owner Link to comment
Snoop.Cat Posted January 29, 2013 Author Share Posted January 29, 2013 i did what u say me on pm , i already asked owner but no responses , well the scriot u gaved me only showing the cursor when i open the gui , but not closing when i hit the close button Link to comment
Snoop.Cat Posted January 29, 2013 Author Share Posted January 29, 2013 plz help , srry for double post Link to comment
Lloyd Logan Posted January 29, 2013 Share Posted January 29, 2013 addEventHandler("onClientGUIClick", button, showIt) function showIt( thePlayer ) showCusor( false ) end You could do that and for when you type function openChat( thePlayer ) showCursor( true ) end addCommandHandler("showit", openChat) EDIT : I am on my phone just now so some of that may be incorrect! Link to comment
Snoop.Cat Posted January 30, 2013 Author Share Posted January 30, 2013 i dont understand , i need when i thype /chatop cursor shows whit gui and when i click on OK button cursor stop showing and gui closes at it normally do. Link to comment
iPrestege Posted January 30, 2013 Share Posted January 30, 2013 i dont understand , i need when i thype /chatop cursor shows whit gui and when i click on OK button cursor stop showing and gui closes at it normally do. You mean you want to show the gui using command? maybe like that ^ : function open() guiSetVisible(WND,not guiGetVisible(WND)) showCursor(guiGetVisible(WND)) guiSetInputEnabled(guiGetVisible(WND)) end addCommandHandler("chatop", open) Wnd = You,re Window chatop = The command 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