openmultiplayer / server-beta-old

open.mp server beta releases
142 stars 14 forks source link

[BEHAVIOR DIFFERENCE]: Entering a different VW & Int with a vehicle won't put you inside the vehicle sometimes #84

Closed RichanoG closed 2 years ago

RichanoG commented 2 years ago

Description

If you are inside a vehicle and have some sort of way which teleports you and your vehicle into a different virtual world & interior (see code snippet) will sometimes not put you into the vehicle again if you intend to with PutPlayerInVehicle. It eventually desyncs you after which you can't for example teleport or see checkpoints (see vid from 0:12 to 0:50 and 1:07 to 1:33). Entering a vehicle again seems to re-sync you.

How to re-produce this behavior difference

Code snippet is not the same as used in the video (slimmed down), but the problem still occurs the same way as in the video.


#include <a_samp>
#include <streamer>
#include <zcmd>

main() { }

CMD:spawnveh(playerid, const params[])
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    CreateVehicle(560, x + 2.0, y + 2.0, z, 0.0, -1, -1, -1); // Spawn sultan

    return 1;
}

CMD:testcmd(playerid, const params[])
{
    new vehicle = GetPlayerVehicleID(playerid);
    new Float:portX = 0.0, Float:portY = 0.0, Float:portZ = 4.0, Float:angle = 180.0;

    TogglePlayerControllable(playerid, false);

    Streamer_UpdateEx(playerid, portX, portY, portZ, 1, 1, -1, 1000, 1);

    //GetXYInFrontOfPos(portX, portY, angle, -2);

    SetPlayerInterior(playerid, 1);
    SetPlayerVirtualWorld(playerid, 1);
    SetPlayerFacingAngle(playerid, angle + 180.0);
    SetPlayerPos(playerid, portX, portY, portZ + 3.5);
    SetCameraBehindPlayer(playerid);

    SetVehicleZAngle(vehicle, angle + 180.0);

    SetVehicleVirtualWorld(vehicle, 1);
    LinkVehicleToInterior(vehicle, 1);

    SetVehiclePos(vehicle, portX, portY, portZ);
    PutPlayerInVehicle(playerid, vehicle, 0);
    return 1;
}

Relevant log output

-

open.mp server version

open.mp server public beta build 4

Operating system or distribution

Debian 11

Contact information

Richano#9220 rishanogopal@gmail.com

Additional information

This behaviour is common on players with around 300 ping. Video: https://www.youtube.com/watch?v=551C2UiP3VY

AmyrAhmady commented 2 years ago

This is a common problem found in samp as well, it's because a vehicle is not streamed to player yet when PutPlayerInVehicle is called when a player is having network connection issues, we tried to fix this behavior as much as we could (it already works better than samp) but any further issues are out of our hands

AmyrAhmady commented 2 years ago

Fixed in build6, tested and confirmed working after changes by @RichanoG