Jump to content

Can't seem to get OnKeyDown to work.


ArrowFX

Recommended Posts

Hello everyone, I am currently making a mod and everything was going great until recently, You see I need to use OnKeyDown but it doesn't seem to be working and I can't for the life of me figure out why. Please take a look at my code and tell me if you know why.

 

 

Int godMode_K
Int TAI_K
Int TCL_K
Int TM_K

Int godModeKeyCode
Int TAIKey
Int TCLKey
Int TMKey


Function RegisterForKey(Int KeyCode) Native

/Code for things\

ElseIf (page == "Hotkeys")

SetCursorFillMode(LEFT_TO_RIGHT)

SetCursorPosition(0)
AddHeaderOption("God Mode Hotkey")
SetCursorPosition(2)
godMode_K = AddKeyMapOption("God Mode Hotkey", godModeKeyCode)

SetCursorPosition(1)
AddHeaderOption("Toggle Collision Hotkey")
SetCursorPosition(3)
TCL_K = AddKeyMapOption("Toggle Collision Hotkey", TCLKey)

SetCursorPosition(4)
AddHeaderOption("Toggle AI Hotkey")
SetCursorPosition(6)
TAI_K = AddKeyMapOption("Toggle AI Hotkey", TAIKey)

SetCursorPosition(5)
AddHeaderOption("Toggle Menus Hotkey")
SetCursorPosition(7)
TM_K = AddKeyMapOption("Toggle Menus Hotkey", TMKey)


Event OnOptionKeyMapChange(int option, int keyCode, string conflictControl, string conflictName)

if(option == godMode_K)

bool continue = True

if(conflictControl != "")

string msg

if(conflictName != "")

msg = "This key is already mapped to:\n\"" + conflictControl + "\"\n(" + conflictName + ")\n\nAre you sure you want to continue?"

Else

msg = "This key is already mapped to:\n\"" + conflictControl + "\"\n\nAre you sure you want to continue?"

EndIf

continue = ShowMessage(msg, true, "$Yes", "$No")

EndIf

if(continue)

godModeKeyCode = keyCode
SetKeyMapOptionValue(godMode_K, godModeKeyCode)



EndIf

ElseIf (option == TAI_K)

bool continue = True

if(conflictControl != "")

string msg

if(conflictName != "")

msg = "This key is already mapped to:\n\"" + conflictControl + "\"\n(" + conflictName + ")\n\nAre you sure you want to continue?"

Else

msg = "This key is already mapped to:\n\"" + conflictControl + "\"\n\nAre you sure you want to continue?"

EndIf

continue = ShowMessage(msg, true, "$Yes", "$No")

EndIf

if(continue)

TAIKey = keyCode
SetKeyMapOptionValue(TAI_K, TAIKey)

EndIf

ElseIf (option == TCL_K)

bool continue = True

if(conflictControl != "")

string msg

if(conflictName != "")

msg = "This key is already mapped to:\n\"" + conflictControl + "\"\n(" + conflictName + ")\n\nAre you sure you want to continue?"

Else

msg = "This key is already mapped to:\n\"" + conflictControl + "\"\n\nAre you sure you want to continue?"

EndIf

continue = ShowMessage(msg, true, "$Yes", "$No")

EndIf

if(continue)

TCLKey = keyCode
SetKeyMapOptionValue(TCL_K, TCLKey)

EndIf

ElseIf (option == TM_K)

bool continue = True

if(conflictControl != "")

string msg

if(conflictName != "")

msg = "This key is already mapped to:\n\"" + conflictControl + "\"\n(" + conflictName + ")\n\nAre you sure you want to continue?"

Else

msg = "This key is already mapped to:\n\"" + conflictControl + "\"\n\nAre you sure you want to continue?"

EndIf

continue = ShowMessage(msg, true, "$Yes", "$No")

EndIf

if(continue)

TMKey = keyCode
SetKeyMapOptionValue(TM_K, TMKey)


EndIf


EndIf

RegisterForKey(godModeKeyCode)
RegisterForKey(TAIKey)
RegisterForKey(TCLKey)
RegisterForKey(TMKey)

EndEvent

Event OnKeyDown(Int KeyCode)


If (keycode == godModeKeyCode)

godmodeToggle = !godmodeToggle
Debug.SetGodMode(godmodeToggle)

EndIf

If(keycode == TCLKey)

debug.ToggleCollisions()

EndIf

If(keycode == TMKey)

debug.ToggleMenus()

EndIf

If(keycode == TAIKey)

debug.ToggleAI()

EndIf

EndEvent

string function GetCustomControl(int keyCode)

if (keyCode == godModeKeyCode)

return "Toggles God Mode"
else
return ""

EndIf

if (keycode == TCLKey)

return "Toggles Collision"
else
return ""

EndIf

If (keycode == TAIKey)

return "Toggles AI"
else
return ""

EndIf

If (keycode == TMKey)

return "Toggles Menus"
else
return ""

endIf

endFunction

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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