Hanging on a boat cannot be detected with GetPlayerSurfingVehicleID
#1

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.
Reply
#2

Forbid mods then.
Reply
#3

^^ ..
Reply
#4

Hello! I have the same problem. Does any update for this issue?
Reply
#5

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.
Reply
#6

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;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)