Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

kalixis
Copy link

@kalixis kalixis commented Nov 27, 2023

No description provided.

@CLAassistant
Copy link

CLAassistant commented Nov 27, 2023

CLA assistant check
All committers have signed the CLA.

@Hual
Copy link
Collaborator

Hual commented Nov 27, 2023

What does this fix exactly?

@kalixis
Copy link
Author

kalixis commented Nov 27, 2023

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?

@BeckzyBoi
Copy link

BeckzyBoi commented Nov 27, 2023

I could've sworn Amir fixed this earlier this year, but at another glance it seems to still be the same:

50876f9

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.

@mysy00
Copy link

mysy00 commented Nov 27, 2023

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.

@AmyrAhmady
Copy link
Member

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;
Copy link
Collaborator

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

Copy link
Author

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.

@kalixis kalixis closed this by deleting the head repository Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants