Jump to content

Bind key problem


mjau

Recommended Posts

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) 

Link to comment
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.

Link to comment
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.

Link to comment
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.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...