open.mp icon indicating copy to clipboard operation
open.mp copied to clipboard

Fixed GetPlayerVehicleID returning INVALID_VEHICLE_ID.

Open kalixis opened this issue 1 year ago • 6 comments

kalixis avatar Nov 27 '23 00:11 kalixis

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Nov 27 '23 00:11 CLAassistant

What does this fix exactly?

Hual avatar Nov 27 '23 08:11 Hual

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?

kalixis avatar Nov 27 '23 10:11 kalixis

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.

BeckzyBoi avatar Nov 27 '23 11:11 BeckzyBoi

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.

mysy00 avatar Nov 27 '23 11:11 mysy00

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.

AmyrAhmady avatar Nov 27 '23 12:11 AmyrAhmady