GetClosestVehicle problem
#5

Try this:

pawn Код:
GetClosestVehicleForPlayer(playerid)
{
    new vehicleid = INVALID_VEHICLE_ID;
    new Float:distance = 99999.0;
    new Float:X, Float:Y, Float:Z;
    GetPlayerPos(playerid, X, Y, Z);
    for(i = 0; i < MAX_VEHICLES; i++)
    {
        if(GetVehicleDistanceFromPoint(i, X, Y, Z) < distance && distance < 8.0) //you can change this value
        {
            vehicleid = i;
            distance = GetVehicleDistanceFromPoint(i, X, Y, Z);
        }
    }
    return vehicleid;
}
pawn Код:
COMMAND:takekey(playerid, params[])
{
     
        new carid = GetClosestVehicleForPlayer(playerid);
        if(carid == 583)
        {
            SendClientMessage(playerid, 0x80FF00FF, "You take the key of the vehicle.");
        }
        else
        {
            SendClientMessage(playerid, 0x80FF00FF, "You are not enough close to the vehicle.");
        }
        return 1;
}
Reply


Messages In This Thread
GetClosestVehicle problem - by Vukilore - 04.11.2011, 08:35
Re: GetClosestVehicle problem - by [MG]Dimi - 04.11.2011, 08:52
Re : GetClosestVehicle problem - by Vukilore - 04.11.2011, 08:55
Re: GetClosestVehicle problem - by [MG]Dimi - 04.11.2011, 09:34
Re: GetClosestVehicle problem - by RazR_ - 04.11.2011, 09:47
Re : GetClosestVehicle problem - by Vukilore - 04.11.2011, 13:50
Re: GetClosestVehicle problem - by SuperViper - 04.11.2011, 14:28
Re : GetClosestVehicle problem - by Vukilore - 04.11.2011, 16:40
Re : GetClosestVehicle problem - by Vukilore - 04.11.2011, 16:49
Re : GetClosestVehicle problem - by Vukilore - 05.11.2011, 10:30

Forum Jump:


Users browsing this thread: 1 Guest(s)