Mergevos / open-vehicle-plus

Modify your vehicles however you want. From top to bottom.
28 stars 10 forks source link

Bumpers #56

Open bbmeb opened 11 months ago

bbmeb commented 11 months ago

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 commented 11 months ago

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

iamjexcdevvv commented 11 months ago

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 commented 11 months ago

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 commented 11 months ago

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