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 is broken #3992

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

getPedControlState is broken #3992

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

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!");

@derxgbb
Copy link

derxgbb commented Jan 31, 2025

getControlState suffers the same

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

3 participants