Stopping player fom exiting car
#9

Try getting the nearest vehicle ID, I'll find you the stock...

pawn Code:
stock GetNearestVehicle(playerid, Float:dis)
{
    new Float:X, Float:Y, Float:Z;
    if(GetPlayerPos(playerid, X, Y, Z))
    {
        new vehicleid = INVALID_VEHICLE_ID;
        for(new v, Float:temp, Float:VX, Float:VY, Float:VZ; v != MAX_VEHICLES; v++)
        {
            if(GetVehiclePos(v, VX, VY, VZ))
            {
                VX -= X, VY -= Y, VZ -= Z;
                temp = VX * VX + VY * VY + VZ * VZ;
                if(temp < dis) dis = temp, vehicleid = v;
            }
        }
        dis = floatpower(dis, 0.5);
        return vehicleid;
    }
    return INVALID_VEHICLE_ID;
}
Paste that on the bottom of your code... Then change the code to
pawn Code:
if ( (newkeys & KEY_SECONDARY_ATTACK) && IsPlayerInAnyVehicle(playerid) )
    {
        new nearest = GetNearestVehicle(playerid, 5.0);
        PutPlayerInVehicle(playerid, nearest, GetPlayerSeat(playerid));
    }
The seat however, I don't know how to get out of it...
Reply


Messages In This Thread
Stopping player fom exiting car - by AlExAlExAlEx - 04.02.2011, 06:02
Re: Stopping player fom exiting car - by Krx17 - 04.02.2011, 06:04
Re: Stopping player fom exiting car - by AlExAlExAlEx - 04.02.2011, 06:10
Re: Stopping player fom exiting car - by Krx17 - 04.02.2011, 06:10
Re: Stopping player fom exiting car - by AlExAlExAlEx - 04.02.2011, 06:16
Re: Stopping player fom exiting car - by Kwarde - 04.02.2011, 06:18
Re: Stopping player fom exiting car - by AlExAlExAlEx - 04.02.2011, 06:38
Re: Stopping player fom exiting car - by AlExAlExAlEx - 04.02.2011, 06:57
Re: Stopping player fom exiting car - by Kyle_Olsen - 04.02.2011, 07:02
Re: Stopping player fom exiting car - by MrDeath537 - 04.02.2011, 07:36

Forum Jump:


Users browsing this thread: 2 Guest(s)