Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

Controller Support


Azorah
 Share

Recommended Posts

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 :r*:

  • Like 1
Link to comment
Share on other sites

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

jedijosh920

 

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

 

 

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. :r*:

Link to comment
Share on other sites

 

 

 

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. :r*:

 

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

 

 

 

 

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. :r*:

 

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

 

 

 

 

 

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. :r*:

 

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

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. :r*:

 

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

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).
  • Like 1
Link to comment
Share on other sites

jedijosh920

 

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.

Link to comment
Share on other sites

 

 

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

Link to comment
Share on other sites

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

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

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 by stillhere
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

Stillhere thank you for explaining the input method part! Exactly what I needed! Thanks!

Edited by Azorah
Link to comment
Share on other sites

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

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
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.