Azorah Posted March 24, 2016 Share Posted March 24, 2016 Hi, I have a mod which is out, and only works for keyboard users (Well, opening menu etc.) I recently got a controller to play my games with and I realised how much of a hassle it is to switch just for a mod, and I want to add it to mine so when people use it, won't get frustrated. Obviously, you use if (e.KeyCodes == Keys.L) <-- for L key. But what would the controller code be? I tried a bunch of little things which I was pretty sure wouldn't work, and they didn't. I know the controller codes, but how do I add them to my mod, so everyone can use it easily, thanks BobFromReboot 1 Link to comment Share on other sites More sharing options...
stillhere Posted March 24, 2016 Share Posted March 24, 2016 You would use if (Game.IsControlJustPressed(2, GTA.Control.ScriptPadUp)){ //do something} only works OnTick. Replace "ScriptPadUp" with anything from here: http://pastebin.com/5um8q0rd Link to comment Share on other sites More sharing options...
Azorah Posted March 24, 2016 Author Share Posted March 24, 2016 You would use if (Game.IsControlJustPressed(2, GTA.Control.ScriptPadUp)){ //do something} only works OnTick. Replace "ScriptPadUp" with anything from here: http://pastebin.com/5um8q0rd Thanks, but the pastebin shows controls, how do I know which one would be DPadUp, or DPadDown etc. ? Link to comment Share on other sites More sharing options...
jedijosh920 Posted March 24, 2016 Share Posted March 24, 2016 You would use if (Game.IsControlJustPressed(2, GTA.Control.ScriptPadUp)){ //do something} only works OnTick. Replace "ScriptPadUp" with anything from here: http://pastebin.com/5um8q0rd Thanks, but the pastebin shows controls, how do I know which one would be DPadUp, or DPadDown etc. ? Really dude? It's quite obvious. PhoneUp = 172, PhoneDown = 173, PhoneLeft = 174, PhoneRight = 175, Link to comment Share on other sites More sharing options...
Azorah Posted March 24, 2016 Author Share Posted March 24, 2016 You would use if (Game.IsControlJustPressed(2, GTA.Control.ScriptPadUp)){ //do something} only works OnTick. Replace "ScriptPadUp" with anything from here: http://pastebin.com/5um8q0rd Thanks, but the pastebin shows controls, how do I know which one would be DPadUp, or DPadDown etc. ? Really dude? It's quite obvious. PhoneUp = 172, PhoneDown = 173, PhoneLeft = 174, PhoneRight = 175; I was talking about how in .ini files they say Dpad etc. not phone, because I also want it in a .ini, also the dpad was just a example I want the right bumper as the button. Link to comment Share on other sites More sharing options...
stillhere Posted March 24, 2016 Share Posted March 24, 2016 You would use if (Game.IsControlJustPressed(2, GTA.Control.ScriptPadUp)){ //do something} only works OnTick. Replace "ScriptPadUp" with anything from here: http://pastebin.com/5um8q0rd Thanks, but the pastebin shows controls, how do I know which one would be DPadUp, or DPadDown etc. ? Really dude? It's quite obvious. PhoneUp = 172, PhoneDown = 173, PhoneLeft = 174, PhoneRight = 175; I was talking about how in .ini files they say Dpad etc. not phone, because I also want it in a .ini, also the dpad was just a example I want the right bumper as the button. JediJosh is right, although there are many other ways to do it. For example, right bumper could be "VehicleHandbrake", "ScriptRB", "Frontendrb", etc. Anything that starts with "Script" will ONLY work with gamepads, whereas "VehicleHandbrake" for example will work on gamepads (RB) and keyboard (Spacebar by default). Also, the "ScriptPad" ones are for dpad, and the "ScriptR" ones are for the face buttons (ABXY). Link to comment Share on other sites More sharing options...
Azorah Posted March 24, 2016 Author Share Posted March 24, 2016 You would use if (Game.IsControlJustPressed(2, GTA.Control.ScriptPadUp)){ //do something} only works OnTick. Replace "ScriptPadUp" with anything from here: http://pastebin.com/5um8q0rd Thanks, but the pastebin shows controls, how do I know which one would be DPadUp, or DPadDown etc. ? Really dude? It's quite obvious. PhoneUp = 172, PhoneDown = 173, PhoneLeft = 174, PhoneRight = 175; I was talking about how in .ini files they say Dpad etc. not phone, because I also want it in a .ini, also the dpad was just a example I want the right bumper as the button. JediJosh is right, although there are many other ways to do it. For example, right bumper could be "VehicleHandbrake", "ScriptRB", "Frontendrb", etc. Anything that starts with "Script" will ONLY work with gamepads, whereas "VehicleHandbrake" for example will work on gamepads (RB) and keyboard (Spacebar by default). Also, the "ScriptPad" ones are for dpad, and the "ScriptR" ones are for the face buttons (ABXY). Alright thanks, is ScriptRRight Right bumper though? Link to comment Share on other sites More sharing options...
stillhere Posted March 24, 2016 Share Posted March 24, 2016 You would use if (Game.IsControlJustPressed(2, GTA.Control.ScriptPadUp)){ //do something} only works OnTick. Replace "ScriptPadUp" with anything from here: http://pastebin.com/5um8q0rd Thanks, but the pastebin shows controls, how do I know which one would be DPadUp, or DPadDown etc. ? Really dude? It's quite obvious. PhoneUp = 172, PhoneDown = 173, PhoneLeft = 174, PhoneRight = 175; I was talking about how in .ini files they say Dpad etc. not phone, because I also want it in a .ini, also the dpad was just a example I want the right bumper as the button. JediJosh is right, although there are many other ways to do it. For example, right bumper could be "VehicleHandbrake", "ScriptRB", "Frontendrb", etc. Anything that starts with "Script" will ONLY work with gamepads, whereas "VehicleHandbrake" for example will work on gamepads (RB) and keyboard (Spacebar by default). Also, the "ScriptPad" ones are for dpad, and the "ScriptR" ones are for the face buttons (ABXY). Alright thanks, is ScriptRRight Right bumper though? I believe it's "B" on the xbox controller. Again, the "ScriptR" ones are for the face buttons (ABXY) if I recall correctly. Link to comment Share on other sites More sharing options...
Azorah Posted March 24, 2016 Author Share Posted March 24, 2016 What would the Right bumper be? You would use if (Game.IsControlJustPressed(2, GTA.Control.ScriptPadUp)){ //do something} only works OnTick. Replace "ScriptPadUp" with anything from here: http://pastebin.com/5um8q0rd Thanks, but the pastebin shows controls, how do I know which one would be DPadUp, or DPadDown etc. ? Really dude? It's quite obvious. PhoneUp = 172, PhoneDown = 173, PhoneLeft = 174, PhoneRight = 175; I was talking about how in .ini files they say Dpad etc. not phone, because I also want it in a .ini, also the dpad was just a example I want the right bumper as the button. JediJosh is right, although there are many other ways to do it. For example, right bumper could be "VehicleHandbrake", "ScriptRB", "Frontendrb", etc. Anything that starts with "Script" will ONLY work with gamepads, whereas "VehicleHandbrake" for example will work on gamepads (RB) and keyboard (Spacebar by default). Also, the "ScriptPad" ones are for dpad, and the "ScriptR" ones are for the face buttons (ABXY). Alright thanks, is ScriptRRight Right bumper though? I believe it's "B" on the xbox controller. Again, the "ScriptR" ones are for the face buttons (ABXY) if I recall correctly. What would the right bumper be??? Link to comment Share on other sites More sharing options...
stillhere Posted March 24, 2016 Share Posted March 24, 2016 Bro.. read my comment again lol For example, right bumper could be "VehicleHandbrake", "ScriptRB", "Frontendrb", etc. Anything that starts with "Script" will ONLY work with gamepads, whereas "VehicleHandbrake" for example will work on gamepads (RB) and keyboard (Spacebar by default). jedijosh920 1 Link to comment Share on other sites More sharing options...
jedijosh920 Posted March 25, 2016 Share Posted March 25, 2016 Bro.. read my comment again lol For example, right bumper could be "VehicleHandbrake", "ScriptRB", "Frontendrb", etc. Anything that starts with "Script" will ONLY work with gamepads, whereas "VehicleHandbrake" for example will work on gamepads (RB) and keyboard (Spacebar by default). Lol, he doesn't know how to make a global variable or what a boolean/integer means, so go easy on him, I talk to him a lot on Skype. stillhere 1 Link to comment Share on other sites More sharing options...
Azorah Posted March 25, 2016 Author Share Posted March 25, 2016 Bro.. read my comment again lol For example, right bumper could be "VehicleHandbrake", "ScriptRB", "Frontendrb", etc. Anything that starts with "Script" will ONLY work with gamepads, whereas "VehicleHandbrake" for example will work on gamepads (RB) and keyboard (Spacebar by default). Lol, he doesn't know how to make a global variable or what a boolean/integer means, so go easy on him, I talk to him a lot on Skype. I know what they are now lmao I'm a pretty big noob though stillhere 1 Link to comment Share on other sites More sharing options...
alex8b Posted March 25, 2016 Share Posted March 25, 2016 Can anyone post a full list of corresponding buttons for gampad, eg Gampad A = Control.Scriptblablabla What does the number 2 in "IsControlJustPressed(2..." mean? Should it be different for xinput and direct input (dual shock 4) gamepads? I noticed that many of the actions (Controls) are bound to the same buttons on gamepad. So do they trigger only depending on a context (eg are you in vehicle or not)? What if you call disable on them? Does it disable them only for that context? Link to comment Share on other sites More sharing options...
Azorah Posted March 25, 2016 Author Share Posted March 25, 2016 Can anyone post a full list of corresponding buttons for gampad, eg Gampad A = Control.Scriptblablabla What does the number 2 in "IsControlJustPressed(2..." mean? Should it be different for xinput and direct input (dual shock 4) gamepads? I noticed that many of the actions (Controls) are bound to the same buttons on gamepad. So do they trigger only depending on a context (eg are you in vehicle or not)? What if you call disable on them? Does it disable them only for that context? Exactly what I was thinking with the list and find a way to not make it work on keyboard, as in the controller Dpad left makes A open the menu too. Link to comment Share on other sites More sharing options...
stillhere Posted March 31, 2016 Share Posted March 31, 2016 (edited) Can anyone post a full list of corresponding buttons for gampad, eg Gampad A = Control.Scriptblablabla What does the number 2 in "IsControlJustPressed(2..." mean? Should it be different for xinput and direct input (dual shock 4) gamepads? I noticed that many of the actions (Controls) are bound to the same buttons on gamepad. So do they trigger only depending on a context (eg are you in vehicle or not)? What if you call disable on them? Does it disable them only for that context? The "2" is the index, but I'm not exactly sure what it refers to. Just know that it works lol This is the full list of controls: http://pastebin.com/5um8q0rd Some are self-explanatory, like "Sprint", which is obviously the A button on an Xbox controller. The "context" you speak of would be "if statements" technically. For example: if (Game.Player.Character.IsInVehicle()) //if the player is in any vehicle{ if (Game.IsControlPressed(2, GTA.Control.Sprint)) //if the player is in any vehicle AND you press the Sprint button (A on Xbox) { //Do whatever you want here }} So basically if you are in a vehicle and you press the Sprint button, it will do whatever you put inside the brackets where "//Do whatever you want" is. You can also disable a control using "Game.DisableControl(2, GTA.Control.Sprint)". For example, in the same code as above: if (Game.Player.Character.IsInVehicle()) //if the player is in any vehicle{ if (Game.IsControlPressed(2, GTA.Control.Sprint)) //if the player is in any vehicle AND you press the Sprint button (A on Xbox) { Game.DisableControl(2, GTA.Control.Sprint) ////if the player is in any vehicle AND you press the Sprint button (A on Xbox), you will not sprint, but you will do what ever you indicate within the brackets here. //Do whatever you want here }} Exactly what I was thinking with the list and find a way to not make it work on keyboard, as in the controller Dpad left makes A open the menu too. Place this in your script under OnTick: bool UsingKeyboard = Function.Call<bool>(Hash._GET_LAST_INPUT_METHOD, 2); Then for example, if you want to make the menu open with DPad Left only with a controller, you would do this: if (Game.IsControlPressed(2, GTA.Control.ScriptPadLeft) && UsingKeyboard == false) //if ScriptPadLeft (Dpad Left) and you are not using a keyboard, open the menu.{//Open Menu} Edited March 31, 2016 by stillhere Link to comment Share on other sites More sharing options...
alex8b Posted March 31, 2016 Share Posted March 31, 2016 Hi! Thanks for these explanations. But I still have some questions. if (Game.Player.Character.IsInVehicle()) //if the player is in any vehicle{ if (Game.IsControlPressed(2, GTA.Control.Sprint)) //if the player is in any vehicle AND you press the Sprint button (A on Xbox) { //Do whatever you want here }} By context I meant that there's no such an action as "Sprint" when you are in a vehicle (you cannot run when you are sitting in a vehicle). But as far as I understand IsControlPressed will work with GTA.Control.Sprint anyway even if you are in a vehicle. Moreover there are thousand other actions on A button: Phone select HeavyMeleeAttack etc. Do they all return true when you press A button on a gamepad even if you are in a different context? What if a player uses an alternative control schema. Is there any control enum that will show A button state no matter which schema is used? What are the control codes for LeftThumb (StealthMode)? RightThumb? stillhere 1 Link to comment Share on other sites More sharing options...
Azorah Posted March 31, 2016 Author Share Posted March 31, 2016 (edited) Stillhere thank you for explaining the input method part! Exactly what I needed! Thanks! Edited March 31, 2016 by Azorah stillhere 1 Link to comment Share on other sites More sharing options...
stillhere Posted April 1, 2016 Share Posted April 1, 2016 Hi! Thanks for these explanations. But I still have some questions. if (Game.Player.Character.IsInVehicle()) //if the player is in any vehicle{ if (Game.IsControlPressed(2, GTA.Control.Sprint)) //if the player is in any vehicle AND you press the Sprint button (A on Xbox) { //Do whatever you want here }} By context I meant that there's no such an action as "Sprint" when you are in a vehicle (you cannot run when you are sitting in a vehicle). But as far as I understand IsControlPressed will work with GTA.Control.Sprint anyway even if you are in a vehicle. Moreover there are thousand other actions on A button: Phone select HeavyMeleeAttack etc. Do they all return true when you press A button on a gamepad even if you are in a different context? What if a player uses an alternative control schema. Is there any control enum that will show A button state no matter which schema is used? What are the control codes for LeftThumb (StealthMode)? RightThumb? I just tested using Sprint while in a vehicle, and the script still runs. But I can't say it would return true in any context as I've only tested a few controls myself. I believe the purpose of these control keys is that they can be used with pretty much any controller (I think). Like if you used VehicleAccelerate, and someone using one of those racing wheel gamepads hit the gas pedal, it would return true I think. I think the control keys that start with "Script" are only for Xinput devices, like Xbox and PS3 (what I currently use), I can't test it though. The control key for LeftThumb on an Xinput controller would be ScriptLS (LS being Left Stick), and RightThumb being ScriptRS. But I can't find a Stealth key.. If you used VehicleHorn, it would also be the Left Stick Click (even works when not in a vehicle, which is the stealth key); that would be E on a keyboard though, rather than the default stealth key (CTRL). Hope I'm making sense lol. Link to comment Share on other sites More sharing options...
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