mjau Posted October 8, 2011 Posted October 8, 2011 Hi ive created a gui and want it to open when i hold f2 and when i release f2 it closes it worked but because i was just testig i changed the command handler for binding the keys to an event handler now the gui get stuck and doest go away when i release f2 hers new binkey code addEventHandler("onClientPlayerSpawn",root, function() bindKey ( "F2", "down", openGui ) bindKey ( "F2", "up", closeGui ) bindKey ( "F2", "down", stats ) end ) old function bindkeys() bindKey ( "F2", "down", openGui ) bindKey ( "F2", "up", closeGui ) bindKey ( "F2", "down", stats ) end addCommandHandler("bindme", bindkeys)
^Dev-PoinT^ Posted October 8, 2011 Posted October 8, 2011 the code is right but the problem its on Gui code but the gui code here to see the error and ,root, use for serverside only?
mjau Posted October 8, 2011 Author Posted October 8, 2011 (edited) NVM Edited October 9, 2011 by Guest
^Dev-PoinT^ Posted October 8, 2011 Posted October 8, 2011 This mybe work function openGui() guiSetVisible (GUIEditor_Window[1], true) end P.S iam not sure
mjau Posted October 8, 2011 Author Posted October 8, 2011 dont work now it dont even open the gui it says bad arguent at gusetvisible thing dev point gave me it expected gui elemtn got nil
Castillo Posted October 8, 2011 Posted October 8, 2011 GUIEditor_Window = {} GUIEditor_Label = {} function infoGui() GUIEditor_Window[1] = guiCreateWindow(347,257,452,339,"K-Info",false) guiWindowSetMovable(GUIEditor_Window[1],false) guiWindowSetSizable(GUIEditor_Window[1],false) GUIEditor_Label[1] = guiCreateLabel(8,22,157,17,"Health:",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[1],255,0,0) guiSetFont(GUIEditor_Label[1],"default-bold-small") GUIEditor_Label[2] = guiCreateLabel(6,53,157,17,"Armour:",false,GUIEditor_Window[1]) guiSetFont(GUIEditor_Label[2],"default-bold-small") GUIEditor_Label[3] = guiCreateLabel(7,85,157,17,"Ping:",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[3],0,0,255) guiSetFont(GUIEditor_Label[3],"default-bold-small") GUIEditor_Label[4] = guiCreateLabel(7,115,157,17,"Serial:",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[4],9,255,0) guiSetFont(GUIEditor_Label[4],"default-bold-small") GUIEditor_Label[5] = guiCreateLabel(7,143,157,17,"IP:",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[5],255,255,0) guiSetFont(GUIEditor_Label[5],"default-bold-small") GUIEditor_Label[8] = guiCreateLabel(8,305,88,18,"Made By Kimmis",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[8],0,0,255) end addEventHandler("onClientPlayerSpawn",root, function() if not isElement(GUIEditor_Window[1]) then infoGui() end bindKey ( "F2", "down", openGui ) end ) function stats() local ping = getElementData (getLocalPlayer(), "ping") local ip = getElementData (getLocalPlayer(), "ip") local serial = getElementData (getLocalPlayer(), "serial") local health = getElementData (getLocalPlayer(), "health") local armour = getElementData (getLocalPlayer(), "armour") local nick = getElementData (getLocalPlayer(), "nick") guiSetText(GUIEditor_Label[4], "Serial: " ..tostring(serial).. " " ,true, GUIEditor_Window[1]) guiSetText(GUIEditor_Label[3], "Ping: " ..tostring(ping).. " " ,true, GUIEditor_Window[1]) guiSetText(GUIEditor_Label[5], "IP: " ..tostring(ip).. " " ,true, GUIEditor_Window[1]) guiSetText(GUIEditor_Label[1], "Health: " ..tostring(health).. " " ,true, GUIEditor_Window[1]) guiSetText(GUIEditor_Label[2], "Armour: " ..tostring(armour).. " " ,true, GUIEditor_Window[1]) end function openGui() if not guiGetVisible(GUIEditor_Window[1]) then stats() infoGui() else guiSetVisible ( GUIEditor_Window[1], false ) end end Not tested.
mjau Posted October 8, 2011 Author Posted October 8, 2011 i used your code then i get a debug error Attemtp to call global "bindkey" A nil value and f2 dont work at all
Castillo Posted October 8, 2011 Posted October 8, 2011 Huh? the function bindKey exists..... and is client & server side, so should work...
Castillo Posted October 8, 2011 Posted October 8, 2011 What exactly doesn't work? do you get any error(s)?
mjau Posted October 8, 2011 Author Posted October 8, 2011 No errors and when i join the gui shows up then i press f2 and nothing happens it shouldnt show up when i join and it should atleast close when i hit f2...
Castillo Posted October 8, 2011 Posted October 8, 2011 GUIEditor_Window = {} GUIEditor_Label = {} function infoGui() GUIEditor_Window[1] = guiCreateWindow(347,257,452,339,"K-Info",false) guiWindowSetMovable(GUIEditor_Window[1],false) guiWindowSetSizable(GUIEditor_Window[1],false) guiSetVisible ( GUIEditor_Window[1], false ) GUIEditor_Label[1] = guiCreateLabel(8,22,157,17,"Health:",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[1],255,0,0) guiSetFont(GUIEditor_Label[1],"default-bold-small") GUIEditor_Label[2] = guiCreateLabel(6,53,157,17,"Armour:",false,GUIEditor_Window[1]) guiSetFont(GUIEditor_Label[2],"default-bold-small") GUIEditor_Label[3] = guiCreateLabel(7,85,157,17,"Ping:",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[3],0,0,255) guiSetFont(GUIEditor_Label[3],"default-bold-small") GUIEditor_Label[4] = guiCreateLabel(7,115,157,17,"Serial:",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[4],9,255,0) guiSetFont(GUIEditor_Label[4],"default-bold-small") GUIEditor_Label[5] = guiCreateLabel(7,143,157,17,"IP:",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[5],255,255,0) guiSetFont(GUIEditor_Label[5],"default-bold-small") GUIEditor_Label[8] = guiCreateLabel(8,305,88,18,"Made By Kimmis",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[8],0,0,255) end addEventHandler("onClientResourceStart",resourceRoot, function() bindKey ( "F2", "down", openGui ) end ) function stats() local ping = getElementData (getLocalPlayer(), "ping") local ip = getElementData (getLocalPlayer(), "ip") local serial = getElementData (getLocalPlayer(), "serial") local health = getElementData (getLocalPlayer(), "health") local armour = getElementData (getLocalPlayer(), "armour") local nick = getElementData (getLocalPlayer(), "nick") guiSetText(GUIEditor_Label[4], "Serial: " ..tostring(serial).. " " ,true, GUIEditor_Window[1]) guiSetText(GUIEditor_Label[3], "Ping: " ..tostring(ping).. " " ,true, GUIEditor_Window[1]) guiSetText(GUIEditor_Label[5], "IP: " ..tostring(ip).. " " ,true, GUIEditor_Window[1]) guiSetText(GUIEditor_Label[1], "Health: " ..tostring(health).. " " ,true, GUIEditor_Window[1]) guiSetText(GUIEditor_Label[2], "Armour: " ..tostring(armour).. " " ,true, GUIEditor_Window[1]) end function openGui() if not isElement(GUIEditor_Window[1]) then infoGui() end if not guiGetVisible(GUIEditor_Window[1]) then stats() guiSetVisible ( GUIEditor_Window[1], true ) else guiSetVisible ( GUIEditor_Window[1], false ) end end The script should work.
mjau Posted October 9, 2011 Author Posted October 9, 2011 It wokrs but i have to press 1 time to open and one to close but hlding it is not that important Tnx for the help Solidsnake
MTA Team qaisjp Posted October 10, 2011 MTA Team Posted October 10, 2011 GUIEditor_Window = {} GUIEditor_Label = {} function infoGui() GUIEditor_Window[1] = guiCreateWindow(347,257,452,339,"K-Info",false) guiWindowSetMovable(GUIEditor_Window[1],false) guiWindowSetSizable(GUIEditor_Window[1],false) guiSetVisible ( GUIEditor_Window[1], false ) GUIEditor_Label[1] = guiCreateLabel(8,22,157,17,"Health:",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[1],255,0,0) guiSetFont(GUIEditor_Label[1],"default-bold-small") GUIEditor_Label[2] = guiCreateLabel(6,53,157,17,"Armour:",false,GUIEditor_Window[1]) guiSetFont(GUIEditor_Label[2],"default-bold-small") GUIEditor_Label[3] = guiCreateLabel(7,85,157,17,"Ping:",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[3],0,0,255) guiSetFont(GUIEditor_Label[3],"default-bold-small") GUIEditor_Label[4] = guiCreateLabel(7,115,157,17,"Serial:",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[4],9,255,0) guiSetFont(GUIEditor_Label[4],"default-bold-small") GUIEditor_Label[5] = guiCreateLabel(7,143,157,17,"IP:",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[5],255,255,0) guiSetFont(GUIEditor_Label[5],"default-bold-small") GUIEditor_Label[8] = guiCreateLabel(8,305,88,18,"Made By Kimmis",false,GUIEditor_Window[1]) guiLabelSetColor(GUIEditor_Label[8],0,0,255) end addEventHandler("onClientResourceStart",resourceRoot, function() bindKey ( "F2", "both", openGui ) end ) function stats() local ping = getElementData (getLocalPlayer(), "ping") local ip = getElementData (getLocalPlayer(), "ip") local serial = getElementData (getLocalPlayer(), "serial") local health = getElementData (getLocalPlayer(), "health") local armour = getElementData (getLocalPlayer(), "armour") local nick = getElementData (getLocalPlayer(), "nick") guiSetText(GUIEditor_Label[4], "Serial: " ..tostring(serial).. " " ,true, GUIEditor_Window[1]) guiSetText(GUIEditor_Label[3], "Ping: " ..tostring(ping).. " " ,true, GUIEditor_Window[1]) guiSetText(GUIEditor_Label[5], "IP: " ..tostring(ip).. " " ,true, GUIEditor_Window[1]) guiSetText(GUIEditor_Label[1], "Health: " ..tostring(health).. " " ,true, GUIEditor_Window[1]) guiSetText(GUIEditor_Label[2], "Armour: " ..tostring(armour).. " " ,true, GUIEditor_Window[1]) end function openGui() if not isElement(GUIEditor_Window[1]) then infoGui() end if not guiGetVisible(GUIEditor_Window[1]) then stats() guiSetVisible ( GUIEditor_Window[1], true ) else guiSetVisible ( GUIEditor_Window[1], false ) end end The script should work. no problem kimmis.
Castillo Posted October 10, 2011 Posted October 10, 2011 qais, isn't that the same script as I mine..?
mjau Posted October 10, 2011 Author Posted October 10, 2011 well he used both on bindkey instead of down ...
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