Add seat parameter to setPedEnterVehicle#4573
Conversation
|
This is really cool. Great pull request description too. What do you think about just letting an int be provided as the third argument? I think this would be cleaner and remove the need for a dummy/unused argument. You should be able to use a mtasa-blue/Server/mods/deathmatch/logic/luadefs/CLuaColShapeDefs.cpp Lines 825 to 843 in 3d02b86 |
| // Explicit seat specified - validate it (reuse validation logic from warpPedIntoVehicle) | ||
| uiSeat = optSeat.value(); | ||
| const unsigned char ucMaxPassengers = CClientVehicleManager::GetMaxPassengerCount(pVehicle->GetModel()); | ||
|
|
||
| if (uiSeat > ucMaxPassengers) | ||
| return false; | ||
|
|
||
| if (uiSeat > 0 && ucMaxPassengers == 255) | ||
| return false; |
There was a problem hiding this comment.
If this is copied from the warpPedIntoVehicle method, then I think it'd make sense to extract to a function that can be used by both. E.g. IsValidSeat
qaisjp
left a comment
There was a problem hiding this comment.
Great job, thanks for contributing this.
| // Camper only has 3 seats (0-2) | ||
| if (static_cast<VehicleType>(ulModel) == VehicleType::VT_CAMPER && ucSeat > 2) | ||
| return false; |
There was a problem hiding this comment.
I wonder why this is a special case not accounted for by GetMaxPassengerCount but I won't argue with it since it was there before 😆
|
I'm moderately confident in this change, so I'm going to let this merge into 1.7 despite the feature freeze. |
|
Thanks for sending this patch @MohabCodeX, you're churning out lots of great code! |
This PR adds an optional seat parameter to
setPedEnterVehicle.The implementation reuses the existing seat validation logic from
warpPedIntoVehicle.When a seat is specified, it validates that:
Syntax:
Optional Arguments:
Note
The seat parameter takes priority over the passenger parameter.
Examples:
2025-11-23.15-13-33.2.mp4
Testing
hit.zip