29.01.2013, 10:24
Here you go:
Example:
pawn Код:
// A function to get the ID of a nearby AT400
stock GetNearbyAT400ID(playerid, Float:distance)
{
new RETURN = INVALID_VEHICLE_ID;
for(new i = 0; i < MAX_VEHICLES; i ++)
{
if(GetVehicleModel(i) == 577)
{
new Float:X, Float:Y, Float:Z;
GetVehiclePos(i, X, Y, Z);
if(GetPlayerDistanceFromPoint(playerid, X, Y, Z) <= distance)
{
RETURN = i;
break;
}
}
}
return RETURN;
}
pawn Код:
// How to use
new AT400ID = GetNearbyAT400ID(playerid, 3.0);
if(AT400ID == INVALID_VEHICLE_ID)
{
SendClientMessage(playerid, -1, "Error: No aeroplanes around!");
}
else
{
// Teleport them to interior
// And store the ID:
Entered_AT400_ID[playerid] = AT400ID;
}