SA-MP Forums Archive
PlayerBehindVehicle - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: PlayerBehindVehicle (/showthread.php?tid=427869)



PlayerBehindVehicle - PaulDinam - 03.04.2013

Hey, is there any stock for this?


Re: PlayerBehindVehicle - Ayumi - 03.04.2013

Not that I know of...

If you're thinking of doing something along the lines of a trunk system, in which you have to be close to a vehicle to open the trunk or the hood of the car, I suggest using ' GetVehiclePos ' and ' IsPlayerInRangeOfPoint ' together.


Re: PlayerBehindVehicle - PaulDinam - 04.04.2013

I tried to do something like that:
pawn Код:
stock PlayerBehindVehicle(playerid)
{
    new Float:vX, Float:vY, Float:vZ, Float:vA;
    for(new i = 0; i < MAX_VEHICLES; i++)
    {
        if(VehicleInfo[i][carOwned] == 1)
        {
            GetVehiclePos(i, vX, vY, vZ);
            GetVehicleZAngle(i, vA);
            if(vA >= 270 && vA <= 360 && IsPlayerInRangeOfPoint(playerid, 2.0, vX-3.0, vY, vZ))
                return i;
            if(vA >= 180 && vA <= 270 && IsPlayerInRangeOfPoint(playerid, 2.0, vX, vY-3.0, vZ))
                return i;
            if(vA >= 90 && vA <= 180 && IsPlayerInRangeOfPoint(playerid, 2.0, vX+3.0, vY, vZ))
                return i;
            if(vA >= 0 && vA <= 90 && IsPlayerInRangeOfPoint(playerid, 2.0, vX, vY-3.0, vZ))
                return i;
        }
    }
    return INVALID_VEHICLE_ID;
}
It works on some positions. but I can't calculate all of them.... can someone help me?


Re: PlayerBehindVehicle - InfiniTy. - 04.04.2013

https://sampforum.blast.hk/showthread.php?tid=348044


Re: PlayerBehindVehicle - PaulDinam - 04.04.2013

The stock there doesn't even works...


Re: PlayerBehindVehicle - MP2 - 04.04.2013

You're not making yourself clear. Do you want a function that PUTS a player behind a vehicle, or a function that DETECTS when a player is behind a vehicle?


Re: PlayerBehindVehicle - PaulDinam - 04.04.2013

DETECTS.!


Re: PlayerBehindVehicle - InfiniTy. - 04.04.2013

Nevermind.Sorry.