Skip to content

getPedControlState is broken #3992

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

Closed
1 task done
Xenius97 opened this issue Jan 30, 2025 · 4 comments
Closed
1 task done

getPedControlState is broken #3992

Xenius97 opened this issue Jan 30, 2025 · 4 comments
Labels
bug Something isn't working
Milestone

Comments

@Xenius97
Copy link
Contributor

Describe the bug

getPedControlState totally stopped working after #3964

Image

Steps to reproduce

Start editor with latest nightly

Version

Multi Theft Auto v1.6-release-22934

Additional context

No response

Relevant log output

Security Policy

  • I have read and understood the Security Policy and this issue is not security related.
@Xenius97 Xenius97 added the bug Something isn't working label Jan 30, 2025
@Xenius97
Copy link
Contributor Author

Xenius97 commented Jan 30, 2025

First argument should be ped now but before this it worked without that, vanilla freecam uses same way, this could cause compatible issues with older scripts.
Should be allow like before or fix in https://github.com/multitheftauto/mtasa-resources/blob/e92a509708daa1e319e1fb74c86444f659b552df/%5Beditor%5D/freecam/freecam.lua#L60

(update: pushed fix for default resources - multitheftauto/mtasa-resources#598)

@Nico8340
Copy link
Contributor

I tried to fix the problem in the following way and restore the old, but otherwise stupid, pointless way for backwards compatibility, but the argument parser does not currently allow this, so I would like to ask for help with this.

bool CLuaPedDefs::GetPedControlState(const std::variant<CClientPed*, std::string>& first, const std::optional<std::string>& second) noexcept
{
    bool        state;
    CClientPed* ped;
    std::string control;

    if (std::holds_alternative<CClientPed*>(first))
    {
        ped = std::get<CClientPed*>(first);

        if (!second)
            return false;

        control = *second;
    }
    else if (std::holds_alternative<std::string>(first))
    {
        ped = CStaticFunctionDefinitions::GetLocalPlayer();
        control = std::get<std::string>(first);
    }

    if (!ped)
        return false;

    if (!CStaticFunctionDefinitions::GetPedControlState(*ped, control, state))
        return false;

    return state;
}

@Nico8340
Copy link
Contributor

static_assert(sizeof(T) == 0, "Invalid parameter type provided to CLuaFunctionParser!");

@ghost
Copy link

ghost commented Jan 31, 2025

getControlState suffers the same

@botder botder closed this as completed in 0102dd2 Feb 7, 2025
@botder botder added this to the 1.6.1 milestone Feb 7, 2025
MTABot pushed a commit that referenced this issue Feb 7, 2025
0102dd2 Fix backwards compatibility for set/getPedControlState (Fixes #3992)
dce38ee Bump build
5bfb219 Update client en_US pot
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

Successfully merging a pull request may close this issue.

3 participants