Maffine Posted September 21, 2018 Share Posted September 21, 2018 Hello everyone, I'm working on a project in which I want to disable phone controls (scroll down, scroll up, select etc) However when I use Game.DisableControlThisFrame(2, GTA.Control.PhoneSelect); the inputs seem to stick to active when I put out my phone. The only input that can be disabled is the arrowup (phone/phoneup) Has anyone been messing around with phone controls? Anything would be greatly helpful. Link to comment Share on other sites More sharing options...
Guest Posted September 22, 2018 Share Posted September 22, 2018 (edited) I think the one that actually brings the phone up, is Control.Phone, PhoneSelect might be the button that activates the current phone selection. Here's some useful code I found a while back, when you press a control, it displays a UI.Notify for each Control that corresponds to what you have pressed. using System; using System.Drawing; using System.Collections; using System.Collections.Generic; using GTA; namespace DisplayPressedControl { public class cDisplayPressedControl : Script { public cDisplayPressedControl() { Tick += onTick; Interval = 0; } private void onTick(object sender, EventArgs e) { foreach (Control control in Enum.GetValues(typeof(Control))) { if (Game.IsControlJustPressed(2, control)) UI.Notify(control.ToString()); } } } } I meant to add, just drop that into a DisplayPressedControl.cs file and put it in the scripts folder. Edited September 22, 2018 by Guest Link to comment Share on other sites More sharing options...
Maffine Posted September 22, 2018 Author Share Posted September 22, 2018 6 minutes ago, LeeC2202 said: I think the one that actually brings the phone up, is Control.Phone, PhoneSelect might be the button that activates the current phone selection. Here's some useful code I found a while back, when you press a control, it displays a UI.Notify for each Control that corresponds to what you have pressed. using System; using System.Drawing; using System.Collections; using System.Collections.Generic; using GTA; namespace DisplayPressedControl { public class cDisplayPressedControl : Script { public cDisplayPressedControl() { Tick += onTick; Interval = 0; } private void onTick(object sender, EventArgs e) { foreach (Control control in Enum.GetValues(typeof(Control))) { if (Game.IsControlJustPressed(2, control)) UI.Notify(control.ToString()); } } } } Thanks LeeC2202, but it is exactly the select button that I want to disable with no luck. It looks like the game script itself prevents it (I cant even figure out why would they bother XD) Link to comment Share on other sites More sharing options...
Guest Posted September 22, 2018 Share Posted September 22, 2018 Well it's possible that PhoneSelect is also the same as FrontendAccept, which is Gamepad A or Return. That's why you have to find out all the controls that might perform that function and block them all (if required). This is why many people use Game.DisableAllControlsThisFrame(2) and then just enable the ones they want, or test with IsDisabledControlJustPressed etc... Link to comment Share on other sites More sharing options...
Maffine Posted September 22, 2018 Author Share Posted September 22, 2018 3 hours ago, LeeC2202 said: Well it's possible that PhoneSelect is also the same as FrontendAccept, which is Gamepad A or Return. That's why you have to find out all the controls that might perform that function and block them all (if required). This is why many people use Game.DisableAllControlsThisFrame(2) and then just enable the ones they want, or test with IsDisabledControlJustPressed etc... Yes I thought about that too. To test that I try to switch on DisableAllControlsThisFrame when the character is holding a phone. It turns out that even in that situation the phone controls are activated. How strange. Link to comment Share on other sites More sharing options...
Guest Posted September 22, 2018 Share Posted September 22, 2018 Hmmm, that is strange then... if I get chance later I will try and remember to have a look at that. I tend to use addon peds 99% of the time, so I never use the phone. I will post back anything I find out later, possibly tomorrow. Link to comment Share on other sites More sharing options...
Maffine Posted September 22, 2018 Author Share Posted September 22, 2018 56 minutes ago, LeeC2202 said: Hmmm, that is strange then... if I get chance later I will try and remember to have a look at that. I tend to use addon peds 99% of the time, so I never use the phone. I will post back anything I find out later, possibly tomorrow. Wow, that's so nice of you. Thx a lot. Link to comment Share on other sites More sharing options...
Guest Posted September 22, 2018 Share Posted September 22, 2018 It's very strange what happens with the phone. I created a small mod that disabled all controls after you activated the phone. All the direction controls were still active apart from Up, which is also the same control that opens the phone. If I went into the emails with the Gamepad A button, I could only move down and couldn't exit the email app. If I went into emails with the keyboard, I couldn't move down, read emails or exit the app... I had to reset the scripts to get out. So my guess is that some of the controls, with some of the input devices are being checked with IsControlJustPressed and IsDisabledControlJustPressed, which is probably why you can't block everything. But it doesn't seem as though that's consistent, because not every screen reacts the same. This is very possibly one of those cases where different modules in the phone screen, were handed out to different developers. As such, each one probably did things slightly differently, didn't check for inputs the same etc... that kind of thing. That can result in inconsistent behaviour across parts of the UI. I worked as a support programmer on a boxing game on the Gameboy back in 2000 or thereabouts. I had certain screens and certian parts of the UI to handle and other programmers did other sections, so it's been a common practice for a long while to do share UI responsibility. It relies on the lead programmer or a producer to make sure that all screens are consistent in functionality but as I have mentioned in other threads, I suspect the R* producers are pretty clueless, because some screw-ups in this game are inexcusable. So the end result is that it looks like the phone is going to cause you problems and the best solution I would suggest, is to prevent it being shown during critical times. You could either block it from being opened, or there is this native: _DISABLE_PHONE_THIS_FRAME. But I can't see a way to block all inputs from the test mod I just created.... sorry I haven't been able to offer much help. Link to comment Share on other sites More sharing options...
Maffine Posted September 23, 2018 Author Share Posted September 23, 2018 (edited) 16 hours ago, LeeC2202 said: It's very strange what happens with the phone. I created a small mod that disabled all controls after you activated the phone. All the direction controls were still active apart from Up, which is also the same control that opens the phone. If I went into the emails with the Gamepad A button, I could only move down and couldn't exit the email app. If I went into emails with the keyboard, I couldn't move down, read emails or exit the app... I had to reset the scripts to get out. So my guess is that some of the controls, with some of the input devices are being checked with IsControlJustPressed and IsDisabledControlJustPressed, which is probably why you can't block everything. But it doesn't seem as though that's consistent, because not every screen reacts the same. This is very possibly one of those cases where different modules in the phone screen, were handed out to different developers. As such, each one probably did things slightly differently, didn't check for inputs the same etc... that kind of thing. That can result in inconsistent behaviour across parts of the UI. I worked as a support programmer on a boxing game on the Gameboy back in 2000 or thereabouts. I had certain screens and certian parts of the UI to handle and other programmers did other sections, so it's been a common practice for a long while to do share UI responsibility. It relies on the lead programmer or a producer to make sure that all screens are consistent in functionality but as I have mentioned in other threads, I suspect the R* producers are pretty clueless, because some screw-ups in this game are inexcusable. So the end result is that it looks like the phone is going to cause you problems and the best solution I would suggest, is to prevent it being shown during critical times. You could either block it from being opened, or there is this native: _DISABLE_PHONE_THIS_FRAME. But I can't see a way to block all inputs from the test mod I just created.... sorry I haven't been able to offer much help. Thanks LeeC, you are really a pro and thanks for all your help. That information really means a lot to me. PS: I cant agree more with the developer confusion part. I did a little experiment last night. Turns out some command in the game script constantly turns the bools back into true once it is turned otherwise. Normally the addon commands will simply overwrite them but this time they don't. So it must be something else than a direct command. My best guess is that the developer on this part uses the GAMEPLAY::SET_BIT function —— I heard that it was used by R* to set bools, instead of simply disable the control like other developers did. I'll try whether i can set bits as the game does. Edited September 23, 2018 by Maffine Link to comment Share on other sites More sharing options...
Guest Posted September 23, 2018 Share Posted September 23, 2018 (edited) Yeah, they do use Bits for bools quite a lot and it's good practice if the bools are related. I mostly use bools and in truth, it's lazy... but it's quick and readable. I have another mod that transmits a lot of info over to an extrernal Windows app, for tracking entity movement / direction / type etc... and that uses bits for bools. You can get 8 bools into a single byte, so when you are shifting round 200+ pieces of entity data, compressing them like that makes sense. I tend to use AND, OR and XOR working with bits though, purely because it's an old habit from assembly language days. I forget that there are natives to do that, although it seems a bit wasteful to call a function to do a simple bit test/set. It's worth getting the decompiled scripts, look for related natives and see how they are handling data around those natives. If you see a lot of bit related calls, then you're probably on the right track. Edit: P.s. sorry for all my rambling comments. Edited September 23, 2018 by Guest Link to comment Share on other sites More sharing options...
Maffine Posted September 23, 2018 Author Share Posted September 23, 2018 9 hours ago, LeeC2202 said: Yeah, they do use Bits for bools quite a lot and it's good practice if the bools are related. I mostly use bools and in truth, it's lazy... but it's quick and readable. I have another mod that transmits a lot of info over to an extrernal Windows app, for tracking entity movement / direction / type etc... and that uses bits for bools. You can get 8 bools into a single byte, so when you are shifting round 200+ pieces of entity data, compressing them like that makes sense. I tend to use AND, OR and XOR working with bits though, purely because it's an old habit from assembly language days. I forget that there are natives to do that, although it seems a bit wasteful to call a function to do a simple bit test/set. It's worth getting the decompiled scripts, look for related natives and see how they are handling data around those natives. If you see a lot of bit related calls, then you're probably on the right track. Edit: P.s. sorry for all my rambling comments. Oh that makes sense! Really it's so nice to get help from expert. Again thx a lot Link to comment Share on other sites More sharing options...