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

PutPlayerInVehicle Desync #910

Open
denisbranisteanu opened this issue Apr 6, 2024 · 1 comment
Open

PutPlayerInVehicle Desync #910

denisbranisteanu opened this issue Apr 6, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@denisbranisteanu
Copy link

Describe the bug
After applying PutPlayerInVehicle to a player who is currently driving any vehicle, the player will still appear to other players as the driver of the original vehicle after the function executes. Meanwhile, the original vehicle will begin moving as if it were being controlled by the player, alongside the new vehicle.

To Reproduce
Steps to reproduce the behavior:

  1. Spawn a vehicle and get inside it as the driver.
  2. Spawn another vehicle and use the PutPlayerInVehicle function for the driver's seat.

Expected behavior
To synchronize with all players that the player has been teleported to a new vehicle.

Screenshots and/or logs
https://youtu.be/z_WwqUj2_0I

Release version
open.mp 1.2.0.2670 (W)

Script for testing

// In order to get the front position of the vehicle, use this function
stock Vehicle_GetRelativePos(vehicleid, &Float:x, &Float:y, &Float:z, Float:xoff = 0.0, Float:yoff = 0.0, Float:zoff = 0.0)
{
    if(!IsValidVehicle(vehicleid))
        return INVALID_VEHICLE_ID;

    new Float: angle;
    GetVehicleZAngle(vehicleid, angle);

    angle = 360 - angle;
    GetVehiclePos(vehicleid, x, y, z);

    x = floatsin(angle, degrees) * yoff + floatcos(angle, degrees) * xoff + x;
    y = floatcos(angle, degrees) * yoff - floatsin(angle, degrees) * xoff + y;
    z = zoff + z;
    return 1;
}

// Command to test the bug
@command() testcommand(playerid, params[], help)
{
    new Float:x,
        Float:y,
        Float:z,
        Float:rotation;
    
    if(IsPlayerInAnyVehicle(playerid))
    {
        Vehicle_GetRelativePos(GetPlayerVehicleID(playerid), x, y, z, 0.0, 10.00);
        GetVehicleZAngle(GetPlayerVehicleID(playerid), rotation);
    }
    else
    {
        GetPlayerPos(playerid, x, y, z);
        GetPlayerFacingAngle(playerid, rotation);
    }

    // After getting new coordinates, we will create a vehicle
    // and if player is already in a vehicle, we will teleport it
    // from the old car to the new car

    // From DRIVER state to DRIVER state

    new carid = CreateVehicle(411, x, y, z, rotation, -1, -1, -1);
    PutPlayerInVehicle(playerid, carid, 0);

    // Turn on the engine
    SetVehicleParamsEx(carid, true, false, false, false, false, false, false);
    return 1;
}
@denisbranisteanu denisbranisteanu added the bug Something isn't working label Apr 6, 2024
@LDami
Copy link

LDami commented Apr 23, 2024

It is probably a client issue, I can reproduce the issue on a SA-MP server.
We can also experience it while spectating a player: https://www.youtube.com/watch?v=USeWnlcpbFg

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

2 participants