crazyde21 Posted September 14, 2013 Share Posted September 14, 2013 My question is: When I "F5" status "up", "Gui" can not close! help.! client addEvent( "moneyn", true ) addEventHandler( "moneyn", getRootElement(), function(qian) bindKey ( "F5", "down",function() qianbao.window[1] = guiCreateWindow(0.33, 0.28, 0.25, 0.16, "钱包", true) guiWindowSetSizable(qianbao.window[1], false) guiSetAlpha(qianbao.window[1], 1.00) qianbao.label[1] = guiCreateLabel(0.10, 0.18, 0.34, 0.24, "你的金钱:", true, qianbao.window[1]) guiSetFont(qianbao.label[1], "default-bold-small") guiLabelSetColor(qianbao.label[1], 247, 246, 121) guiLabelSetHorizontalAlign(qianbao.label[1], "center", true) guiLabelSetVerticalAlign(qianbao.label[1], "center") qianbao.label[2] = guiCreateLabel(0.34, 0.38, 0.48, 0.23,"请登录!", true, qianbao.window[1]) guiSetText ( qianbao.label[2], qian ) guiLabelSetColor(qianbao.label[2], 213, 72, 92) guiLabelSetVerticalAlign(qianbao.label[2], "center") qianbao.staticimage[1] = guiCreateStaticImage(0.04, 0.18, 0.92, 0.76, ":login_mysql/images/qianbao.png", true, qianbao.window[1]) guiSetAlpha(qianbao.staticimage[1], 0.23) guiSetProperty(qianbao.button[1], "NormalTextColour", "FFAAAAAA") end ) end ) bindKey ( "F5", "up",function() guiSetVisible(qianbao.window[1],false) end ) server addEventHandler("onPlayerJoin", getRootElement(), function(player) setTimer(function() handler = mysql_connect( host, username, password, db ) if handler then local result = mysql_query(handler, "SELECT Money FROM players WHERE Username='crazyde21'")-- Execute the query for result,row in mysql_rows(result) do -- Iterate through all the result rows mysql_field_seek(result, 1) -- Reset the field cursor to the first field for k,qian in ipairs(row) do local field = mysql_fetch_field(result) -- Retreive the field data triggerClientEvent("moneyn",getRootElement(),qian) end end end end,10000,0) end ) Link to comment
DNL291 Posted September 14, 2013 Share Posted September 14, 2013 Try this: Client: addEvent( "moneyn", true ) addEventHandler("onClientResourceStart", resourceRoot, function() qianbao.window[1] = guiCreateWindow(0.33, 0.28, 0.25, 0.16, "钱包", true) guiSetVisible(qianbao.window[1], false) guiWindowSetSizable(qianbao.window[1], false) guiSetAlpha(qianbao.window[1], 1.00) qianbao.label[1] = guiCreateLabel(0.10, 0.18, 0.34, 0.24, "你的金钱:", true, qianbao.window[1]) guiSetFont(qianbao.label[1], "default-bold-small") guiLabelSetColor(qianbao.label[1], 247, 246, 121) guiLabelSetHorizontalAlign(qianbao.label[1], "center", true) guiLabelSetVerticalAlign(qianbao.label[1], "center") qianbao.label[2] = guiCreateLabel(0.34, 0.38, 0.48, 0.23,"请登录!", true, qianbao.window[1]) guiSetText ( qianbao.label[2], qian ) guiLabelSetColor(qianbao.label[2], 213, 72, 92) guiLabelSetVerticalAlign(qianbao.label[2], "center") qianbao.staticimage[1] = guiCreateStaticImage(0.04, 0.18, 0.92, 0.76, ":login_mysql/images/qianbao.png", true, qianbao.window[1]) guiSetAlpha(qianbao.staticimage[1], 0.23) guiSetProperty(qianbao.button[1], "NormalTextColour", "FFAAAAAA") end) addEventHandler( "moneyn", getRootElement(), function(qian) bindKey("F5", "down", function() toggleWindow() end) end ) function toggleWindow() guiSetVisible(qianbao.window[1], not guiGetVisible(qianbao.window[1])) showCursor(guiGetVisible(qianbao.window[1])) end Server: addEventHandler("onPlayerJoin", getRootElement(), function() setTimer(function() handler = mysql_connect( host, username, password, db ) if handler then local result = mysql_query(handler, "SELECT Money FROM players WHERE Username='crazyde21'")-- Execute the query for result,row in mysql_rows(result) do -- Iterate through all the result rows mysql_field_seek(result, 1) -- Reset the field cursor to the first field for k,qian in ipairs(row) do local field = mysql_fetch_field(result) -- Retreive the field data triggerClientEvent(source,"moneyn",getRootElement(),qian) end end end end,10000,0) end ) Link to comment
crazyde21 Posted September 14, 2013 Author Share Posted September 14, 2013 "F5" invalid, I want is to press "F5" out "GUI", key state "up" and then guiSetVisible false Link to comment
DNL291 Posted September 14, 2013 Share Posted September 14, 2013 I'm not sure i understand what you meant but, use "both" in keyState argument of the bindKey function. Link to comment
Castillo Posted September 14, 2013 Share Posted September 14, 2013 bindKey("F5", "down", function() toggleWindow() end) What's the point of creating another function? you can just bind it to "toggleWindow" function. bindKey ( "F5", "down", toggleWindow ) Link to comment
crazyde21 Posted September 14, 2013 Author Share Posted September 14, 2013 Thank you for your suggestion. Problem solved! Thank 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