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

Bumpers #56

Open
bbmeb opened this issue Jul 27, 2023 · 4 comments
Open

Bumpers #56

bbmeb opened this issue Jul 27, 2023 · 4 comments

Comments

@bbmeb
Copy link

bbmeb commented Jul 27, 2023

I'm trying recognize the vehicle bumpers with the" Vehicle_GetPanelsCondition", the system recognizes the front bumper as a back bumper, the back bumper doesn't even recognize.

CMD:test(playerid, params[])
{
    new VEHICLE_PANELS_CONDITION: front_left, VEHICLE_PANELS_CONDITION: front_right, VEHICLE_PANELS_CONDITION: back_left, VEHICLE_PANELS_CONDITION: back_right, VEHICLE_PANELS_CONDITION: front_bumper, VEHICLE_PANELS_CONDITION: back_bumper, VEHICLE_PANELS_CONDITION: windshield;

    Vehicle_GetPanelsCondition(GetPlayerVehicleID(playerid), front_left, front_right, back_left, back_right, front_bumper, back_bumper, windshield);

    SendClientMessage(playerid, -1, "front_bumper: %d | back_bumper: %d", front_bumper, back_bumper);

    return 1;
}

Screens, logs:
sa-mp-009
[18:27:55] front_bumper: 0 | back_bumper: 2
sa-mp-010
[18:28:25] front_bumper: 0 | back_bumper: 3
sa-mp-011
18:28:42] front_bumper: 0 | back_bumper: 3

@Mergevos
Copy link
Owner

Hello @bbmeb,
I please you to test this code with default open.mp functions and tell me what results you've got.

@iamjexcdevvv
Copy link
Contributor

I've tried your code provided and produce the same results I tried it without the use of this library aswell and same result I got

image

image

here's the code

`@cmd() test(playerid, params[], help)
{
new VEHICLE_PANELS_CONDITION:front_left, VEHICLE_PANELS_CONDITION:front_right, VEHICLE_PANELS_CONDITION:back_left, VEHICLE_PANELS_CONDITION:back_right, VEHICLE_PANELS_CONDITION:front_bumper, VEHICLE_PANELS_CONDITION:back_bumper, VEHICLE_PANELS_CONDITION:windshield;

Vehicle_GetPanelsCondition(GetPlayerVehicleID(playerid), front_left, front_right, back_left, back_right, front_bumper, back_bumper, windshield);

SendClientMessage(playerid, -1, "front_bumper: %d | back_bumper: %d", front_bumper, back_bumper);
return COMMAND_OK;

}

@cmd() test1(playerid, params[], help)
{
new VEHICLE_PANEL_STATUS:panels, VEHICLE_DOOR_STATUS:doors, VEHICLE_LIGHT_STATUS:lights, VEHICLE_TYRE_STATUS:tires;
new vehicleid = GetPlayerVehicleID(playerid);
GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
UpdateVehicleDamageStatus(vehicleid, (panels | VEHICLE_PANEL_STATUS:0b00000000001100000000000000000000), doors, lights, tires);
return COMMAND_OK;
}`

@iamjexcdevvv
Copy link
Contributor

iamjexcdevvv commented Jul 28, 2023

Additionally I tried with samp server and it works fine either openmp causing this bug or the code itself we'll see what we can do

image

image

Code I've used to reproduce this issue

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp(cmdtext, "/test1", true)) {
        new panels, doors, lights, tires;
        new vehicleid = GetPlayerVehicleID(playerid);
        GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
        UpdateVehicleDamageStatus(vehicleid, (panels | 0b00000000001100000000000000000000), doors, lights, tires);
        return 1;
        // Returning 1 informs the server that the command has been processed.
        // OnPlayerCommandText won't be called in other scripts.
    } else if (!strcmp(cmdtext, "/test", true)) {
        new str[32];
        new panels, doors, lights, tires;
        new front_left_panel, front_right_panel, rear_left_panel, rear_right_panel, windshield, front_bumper, rear_bumper;

        GetVehicleDamageStatus(GetPlayerVehicleID(playerid), panels, doors, lights, tires);
        decode_panels(panels, front_left_panel, front_right_panel, rear_left_panel, rear_right_panel, windshield, front_bumper, rear_bumper);

        format(str, sizeof(str), "front_bumper: %d | back_bumper: %d", front_bumper, rear_bumper);
        SendClientMessage(playerid, -1, str);
        return 1;
    }
    return 0;
}

decode_panels(panels, &front_left_panel, &front_right_panel, &rear_left_panel, &rear_right_panel, &windshield, &front_bumper, &rear_bumper)
{
    front_left_panel = panels & 15;
    front_right_panel = panels >> 4 & 15;
    rear_left_panel = panels >> 8 & 15;
    rear_right_panel = panels >> 12 & 15;
    windshield = panels >> 16 & 15;
    front_bumper = panels >> 20 & 15;
    rear_bumper = panels >> 24 & 15;
}

@Mergevos
Copy link
Owner

So this issue might be related to open.mp. Could you try storing the result without decoding the panels?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants