openmultiplayer / open.mp

Open Multiplayer, a multiplayer mod fully backwards compatible with SA-MP
https://open.mp
Mozilla Public License 2.0
424 stars 78 forks source link

OnPlayerExitVehicle is not called for Tram #898

Closed LDami closed 3 months ago

LDami commented 3 months ago

Describe the bug The callback OnPlayerExitVehicle is not called when the player leave the Tramway. OnPlayerEnterVehicle is correctly called.

To Reproduce Steps to reproduce the behavior:

  1. Run a script with:
    new tramID;
    public OnGameModeInit()
    {
    SetGameModeText("My first open.mp gamemode!");
    AddPlayerClass(0, -2271.82, 533.43, 35.01, 351.1646, WEAPON_GRENADE, 50, WEAPON_KNIFE, 1, WEAPON_COLT45, 100);
    tramID = AddStaticVehicle(449, -2264.78, 540.54, 35.54, 180, -1, -1); // Tram
    return 1;
    }
    public OnPlayerSpawn(playerid)
    {
    SetPlayerInterior(playerid, 0);
    PutPlayerInVehicle(playerid, tramID, 0);
    return 1;
    }
    public OnPlayerExitVehicle(playerid, vehicleid)
    {
    SendClientMessage(playerid, 0xFFFFFF, "You left the tram !");
    return 1;
    }
  2. Spawn a tramway (id 449)
  3. Enter it by PutPlayerInVehicle or by pressing G
  4. Leave the tram

Expected behavior The callback OnPlayerExitVehicle must be called (the message "You left the tram !" must be displayed).

Release version 1.2.0.2670

BeckzyBoi commented 3 months ago

Is it called when leaving brown streak (model ID 538) as passenger, or when leaving the brown streak carriage (model ID 570)?

If not then I guess that this is normal behaviour, as (as passenger) players don't leave these vehicles in the usual manner - basically the player position is set to next to the vehicle.

LDami commented 3 months ago

Yes it is the same with brown streak. Is it possible to detect when a player leave trams or trains ?

BeckzyBoi commented 3 months ago

Simply use OnPlayerStateChange and store the players vehicle ID when they enter a vehicle, then (again with OnPlayerStateChange) you can check if oldstate is PLAYER_STATE_PASSENGER and if their previous vehicle was train/tram.

NexiusTailer commented 3 months ago

In case if samp server behaviour is different, I think it possibly may be because of validation checks. If open.mp server now checks vehicleid if it's streamed in for player inside EnterVehicle and ExitVehicle events, there may be an issue with trains as they are not considered "streamed in" like other cars. That's just my assumption as I didn't check the current validations in the source files yet.

DobbysGamertag commented 3 months ago

Simply use OnPlayerStateChange and store the players vehicle ID when they enter a vehicle, then (again with OnPlayerStateChange) you can check if oldstate is PLAYER_STATE_PASSENGER and if their previous vehicle was train/tram.

Seen it done with KEY_SECONDARY_ATTACK check in OnPlayerKeyStateChange also.

BeckzyBoi commented 3 months ago

Simply use OnPlayerStateChange and store the players vehicle ID when they enter a vehicle, then (again with OnPlayerStateChange) you can check if oldstate is PLAYER_STATE_PASSENGER and if their previous vehicle was train/tram.

Seen it done with KEY_SECONDARY_ATTACK check in OnPlayerKeyStateChange also.

If the train/tram is moving at a certain speed you can't always exit it no matter how much you spam the key.

AmyrAhmady commented 3 months ago

Does this work in samp?

LDami commented 3 months ago

It's the same behaviour in SA-MP.

NexiusTailer commented 3 months ago

Just tested it too, samp server doesn't call it as well (so it's not called from the client itself).

AmyrAhmady commented 3 months ago

Then it's a client issue, closing this