-
Notifications
You must be signed in to change notification settings - Fork 98
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
Fixed GetPlayerVehicleID returning INVALID_VEHICLE_ID. #788
Conversation
What does this fix exactly? |
On the server, GetPlayerVehicleID returns INVALID_VEHICLE_ID, although on the website https://www.open.mp/docs/scripting/functions/GetPlayerVehicleID, it is stated to return 'ID of the vehicle or 0 if not in a vehicle.' Or is it not fixed this way? |
I could've sworn Amir fixed this earlier this year, but at another glance it seems to still be the same: However I use GetPlayerVehicleID a lot and check if it equals, or doesn't equal, zero and I've had no issues at all. Strange.. Edit: Never mind, I still have it patched with GetPlayerVehicleID2:
So yeah I guess this fix is actually relevant. |
I'm pretty sure it makes more sense to return |
This break a lot of scripts depending on it, while it's good to stay consistent, we still try to stay as compatible as possible to 20 years oof samp scripts Also documentation is wrong (or not complete to be precise). If playerid is not valid, it must return 0, and if player's vehicle is not valid, it must return INVALID_VEHICLE_ID. So you just have to reverse how original returns worked. |
{ | ||
IVehicle* vehicle = data.getVehicle(); | ||
if (vehicle) | ||
{ | ||
return vehicle->getID(); | ||
} | ||
return 0; | ||
return FailRet; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return INVALID_VEHICLE_ID here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's strange, but if you input an invalid player ID (a player who is not on the server) into GetPlayerVehicleID, it will return 65535 (INVALID_PLAYER_ID).
And if no player is in the vehicle, it will return 0.
No description provided.