Need help with vehicle scripting please
#4

Here you go:

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

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


Messages In This Thread
Need help with vehicle scripting please - by iSkull - 29.01.2013, 09:10
Re: Need help with vehicle scripting please - by [KHK]Khalid - 29.01.2013, 09:44
Re: Need help with vehicle scripting please - by iSkull - 29.01.2013, 09:50
Re: Need help with vehicle scripting please - by [KHK]Khalid - 29.01.2013, 10:24
Re: Need help with vehicle scripting please - by iSkull - 29.01.2013, 11:39

Forum Jump:


Users browsing this thread: 1 Guest(s)