Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetPedControlState returns true for the other player when using setPedControlState for yourself #3874

Open
EnoNeK opened this issue Dec 4, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@EnoNeK
Copy link

EnoNeK commented Dec 4, 2024

Describe the bug

If you use setPedControlState on yourself, then getPedControlState used on a nearby player will return true, even if the player is not executing any controls

Steps to reproduce

  1. Set yourself a control for example vehicle_left
    setPedControlState(localPlayer, "vehicle_left", true)
  2. Now use getPedControlState on the player next to you with the same control we set for ourselves
local player = getPlayerFromName("xyz") 
outputChatBox(inspect(getPedControlState(player, "vehicle_left")))

You can now see that the function will return true if the player does not turn left

Version

Client: 1.6-release-22789
Server: 1.6-release-22789

@EnoNeK EnoNeK added the bug Something isn't working label Dec 4, 2024
@Lpsd
Copy link
Member

Lpsd commented Dec 4, 2024

CClientPed* pPed = CStaticFunctionDefinitions::GetLocalPlayer();

The Lua definition doesn't read the ped argument from getPedControlState, it always uses the local player. Not sure how long it's been like that lol

@Lpsd
Copy link
Member

Lpsd commented Dec 4, 2024

Since 934ba8c you can't set/get control state other than local player.

The note on https://wiki.multitheftauto.com/wiki/SetPedControlState needs updating as it's incorrect

@TheNormalnij
Copy link
Member

int CLuaPedDefs::GetPedControlState(lua_State* luaVM)
{
    // Verify the argument
    CClientPed*      pPed = CStaticFunctionDefinitions::GetLocalPlayer();
    SString          strControl = "";
    CScriptArgReader argStream(luaVM);

    if (argStream.NextIsUserData())
    {
        argStream.ReadUserData(pPed);
    }

Are you sure?

@ds1-e
Copy link
Contributor

ds1-e commented Dec 4, 2024

#3867 kinda related

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants