SA-MP Forums Archive
Hanging on a boat cannot be detected with GetPlayerSurfingVehicleID - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP (https://sampforum.blast.hk/forumdisplay.php?fid=3)
+--- Forum: Bug Reports (https://sampforum.blast.hk/forumdisplay.php?fid=20)
+--- Thread: Hanging on a boat cannot be detected with GetPlayerSurfingVehicleID (/showthread.php?tid=358992)



Hanging on a boat cannot be detected with GetPlayerSurfingVehicleID - leong124 - 12.07.2012

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.


Re: Hanging on a boat cannot be detected with GetPlayerSurfingVehicleID - MP2 - 12.07.2012

Forbid mods then.


Re: Hanging on a boat cannot be detected with GetPlayerSurfingVehicleID - YoungKris - 12.07.2012

^^ ..


Re: Hanging on a boat cannot be detected with GetPlayerSurfingVehicleID - diclofoss - 22.09.2017

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


Re: Hanging on a boat cannot be detected with GetPlayerSurfingVehicleID - NaS - 24.09.2017

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.


Re: Hanging on a boat cannot be detected with GetPlayerSurfingVehicleID - Kar - 24.09.2017

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