Posts: 1,496
Threads: 78
Joined: Jun 2008
Reputation:
0
I got a problem that when you hanging on a boat, or climbing on it, GetPlayerSurfingVehicleID still returns INVALID_VEHICLE_ID.
Checking the player's animation and the distance between the boat and him won't work, because the player can install a mod to make the ship to be large. He can then climb on the boat on a further distance, which can escape from the distance check.
Posts: 30
Threads: 5
Joined: Apr 2013
Reputation:
0
Hello! I have the same problem. Does any update for this issue?
Posts: 1,801
Threads: 21
Joined: Mar 2008
Reputation:
0
Wouldn't say this is a bug, because you cannot surf on unoccupied vehicles. Only on vehicles with a player (or NPC) in it.
You could of course argue that it should be added, but I really don't see a point in it. Especially because most unoccupied vehicles aren't really synced anyway.
Posts: 2,938
Threads: 162
Joined: May 2010
I use this code.
pawn Code:
playerGetSurfingBoatFromLastVeh(playerid, Float:playerZ)
{
if(isPlayerSwimming(playerid) || IsPlayerInAnyVehicle(playerid)) return INVALID_VEHICLE_ID;
new vehicleID = INVALID_VEHICLE_ID;
if(playerData[playerid][pCurrentVehicleID] != INVALID_VEHICLE_ID && GetPlayerDistanceFromVehicle(playerid, playerData[playerid][pCurrentVehicleID]) <= 10.0) {
vehicleID = playerData[playerid][pCurrentVehicleID];
}
if(vehicleID == INVALID_VEHICLE_ID) {
vehicleID = getClosestVehicle(playerid);
if(!IsValidVehicle(vehicleID) || GetPlayerDistanceFromVehicle(playerid, vehicleID) > 10.0) {
vehicleID = INVALID_VEHICLE_ID;
}
}
if(vehicleID != INVALID_VEHICLE_ID) {
new vehicleType = GetVehicleType(GetVehicleModel(vehicleID));
if(vehicleType == VEHICLE_BOAT || vehicleType == VEHICLE_VORTEX) {
new Float:vX, Float:vY, Float:vZ;
GetVehiclePos(vehicleID, vX, vY, vZ);
if(playerZ > vZ && (playerZ - vZ) <= 4.0 && GetPlayerDistanceFromPoint(playerid, vX, vY, vZ) <= 10.0) { // surfing
return vehicleID;
}
}
}
return INVALID_VEHICLE_ID;
}
isPlayerSurfingBoat(playerid)
{
if(IsPlayerInAnyVehicle(playerid)) return 0;
new surfingVehicle = GetPlayerSurfingVehicleIDEx(playerid), vehicleType;
vehicleType = GetVehicleType(GetVehicleModel(surfingVehicle));
return surfingVehicle != INVALID_VEHICLE_ID && (vehicleType == VEHICLE_BOAT || vehicleType == VEHICLE_VORTEX);
}
GetPlayerSurfingVehicleIDEx(playerid)
{
new surfingVehicle = GetPlayerSurfingVehicleID(playerid);
if(surfingVehicle == INVALID_VEHICLE_ID) {
new Float:z;
GetPlayerPos(playerid, z, z, z);
surfingVehicle = playerGetSurfingBoatFromLastVeh(playerid, z);
}
return surfingVehicle;
}