multitheftauto / mtasa-blue

Multi Theft Auto is a game engine that incorporates an extendable network play element into a proprietary commercial single-player game.
https://multitheftauto.com
GNU General Public License v3.0
1.38k stars 424 forks source link

getPedControlState returns false for "enter_exit" control #2327

Open jayceon123 opened 3 years ago

jayceon123 commented 3 years ago

Describe the bug The getPedControlState function returns false everytime for the "enter_exit" control. Only tested with the localPlayer.

To reproduce

addEventHandler("onClientRender", root,
    function()
        dxDrawText(tostring(getPedControlState(localPlayer, "enter_exit")), 400, 200)
    end
)

Expected behaviour Return with the real value.

Screenshots /

Version MTA:SA Client 20935 MTA:SA Server 20935

Additional context /

Lpsd commented 3 years ago

getPedControlState("enter_exit") is not valid. Please refer to https://wiki.multitheftauto.com/wiki/GetPedControlState and fix your example.

jayceon123 commented 3 years ago

Fixed.

Lpsd commented 3 years ago

Did you just remove the line or did you also test it too? I'd assume your issue was because of getPedControlState failing due to invalid arguments (and not executing the line afterwards).

jayceon123 commented 3 years ago

I tested one by one first, and just put together in the example. E.: Tested multiple controls too.

iPollo commented 3 years ago

The same behavior happens with me, always returning false, even for both cases below:

addEventHandler("onClientVehicleStartEnter", root, function(player,seat,door)
    if (player == localPlayer and seat == 0)then
            print(getPedControlState(localPlayer, "enter_exit"))
    end
end)

and

addEventHandler("onClientRender", root, function()

    print(getPedControlState(localPlayer, "enter_exit"))

end)
patrikjuvonen commented 3 years ago

Confirmed it returns false when pressing or holding the bound key near or not a vehicle.

However, not sure what the use-case for this is right now. Can you describe the use-case where you would need the control state of enter_exit? You do know there are ped tasks you can use to determine a lot of actions accurately?

Meanwhile we should probably look into the reason why this is returning false, and under what conditions it would return true.

jayceon123 commented 3 years ago

I just wanted to do something when the player presses the key that binded to the control, so I tried to use it with this way without the bindKey function, but faced with this not expected behaviour.

Just found out, the 'change_camera' control returns false too. Maybe there are some more affected controls.

patrikjuvonen commented 3 years ago

We should check back when these issues started happening. I have a feeling this is a regression from some recent changes.

Zangomangu commented 3 years ago

It has been like this forever, reason is here

https://github.com/multitheftauto/mtasa-blue/blob/c58c3678f263d810f61eb5aecba48e6c4b4dce0c/Client/mods/deathmatch/logic/CClientPad.cpp#L333-L345

enter_exit is "ButtonTriangle" and change_cam "Select" on the game pad, so should be fixable with the following

case 9:
    return State.ButtonTriangle == 255;
    break;            // enter_exit
case 10:
    return State.Select == 255;
    break;            // change_cam

EDIT: Why is there a break after a return in this code lol

Yamsha75 commented 1 year ago

Is there any potential issue with implementing this change? I don't see why "enter_exit" should remain an exception here