What is the command to make trigger a controller Button?
-
What is the command to check if player has triggered a certain button
-
@dani703q Not sure what you mean? C# Scripting? And by player you obviously don't mean Michael, you mean the user right?
if (e.KeyCode == Keys.NumPad1)
not sure how do this with a controller, have always used keyboard with my own scripts but I guess it's a mapping issue. Obviously controller is limited, but I would use the same keyboard key the controller replaces with its own buttons (mapped as in the game settings).
-
@dani703q One easy way to check for gamepad input, is to use this native function, it works for both keyboard and gamepad, so you don't have to code two different listeners for the input sources if you use that native. The list of controls for that function can be found here
-
@JohnFromGWN i Mean C#scripting for The user itself, if(e.keycode == ()) that is for only keyboard keys but I wanna know how to make a controller one,
-
@JustDancePC thank you! is use this command if(Game.IsControlJustPressed(0, GTA.Control.Context)) but in does not work on when i press the button on controller but it works for the keyboard
-
@dani703q Does your game actually recognize the controller? I use an xbox controller and it works perfectly
-
@JustDancePC i use ps4 controller
-
@dani703q if the controller is recognized so should the script. Would really help to see your code, this is not a hardware issue.
-
@dani703q Well, that's probably the issue. For this native function to work as expected, the controller must be recognized by the game as a gamepad input source. This happens automatically with Xbox controllers, but with PlayStation it's another story
-
@JustDancePC ok. I bought the Xbox controller as well for compatability reasons, but never scripted with it.
Either way, you want to see the code to rule out issues.
-
@JohnFromGWN Well, he showed this line:
if(Game.IsControlJustPressed(0, GTA.Control.Context))
, that should work for both keyboard and gamepad, if it only works with keyboard that means he, at least, is using the function correctly. I'm more inclined to think the issue is the PS4 controller because in Windows, games normally don't detect the controller, you have to use software such as DS4 to make it work
-
@JustDancePC sorry, i missed that, it was buried in the message.
-
@JustDancePC thank you it worked from the start I just found I used the command on (on key down) instead of on every tick
-
@dani703q Bruh
-
Surprised game didn't go in endless loop and crash.
Anyway glad you figured it out.