open.mp
open.mp copied to clipboard
Fixed GetPlayerVehicleID returning INVALID_VEHICLE_ID.
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:
https://github.com/openmultiplayer/open.mp/commit/50876f92be7c418ff0eaa70cde6b49ea96502774
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:
GetPlayerVehicleID2(playerid) { new vid = GetPlayerVehicleID(playerid); if (vid == INVALID_VEHICLE_ID) return 0; return vid; }
So yeah I guess this fix is actually relevant.
I'm pretty sure it makes more sense to return INVALID_VEHICLE_ID
instead of 0
.
If samp used to return the value 0, it's definitely a mistake and the difference between samp and open.mp should be noted in the wiki whilst keeping the existing behavior here.
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.