Command
#1

Код:
car[0] = AddStaticVehicleEx(470,-710.1328,2324.4019,127.4047,307.9189,43,0 ,100); // 21
car[1] = AddStaticVehicleEx(468,-514.6782,2550.9993,53.1297,86.4095,6,6,100); // 1
car[2] = AddStaticVehicleEx(468,-514.6990,2552.4338,53.0843,87.9950,3,3,100); // 2
car[3] = AddStaticVehicleEx(468,-514.5493,2554.2017,53.0745,83.8978,46,46,100); // 3
car[4] = AddStaticVehicleEx(471,-514.0535,2557.2751,52.9037,92.5018,120,114,100); // 4
car[5] = AddStaticVehicleEx(471,-514.1407,2560.0361,52.8431,90.7432,74,91,100); // 5
car[6] = AddStaticVehicleEx(470,-548.2491,2557.2463,53.4923,267.9488,43,0,100); // 6
car[7] = AddStaticVehicleEx(568,-513.3019,2643.8662,53.4073,359.9999,33,0,100); // 7
car[8] = AddStaticVehicleEx(424,-517.7118,2644.7217,53.2876,359.2311,6,16,100); // 8
car[9] = AddStaticVehicleEx(470,-529.0178,2644.1995,53.5186,358.1688,43,0,100); // 9
car[10] = AddStaticVehicleEx(470,-533.1437,2644.1384,53.5594,0.0402,43,0,100); // 10
car[11] = AddStaticVehicleEx(470,-716.0922,2380.1680,127.7841,159.0945,43,0,100); // 11
car[12] = AddStaticVehicleEx(468,-711.8572,2365.8040,127.3024,57.7228,6,6,100); // 12
car[13] = AddStaticVehicleEx(468,-712.7996,2364.3955,127.1897,58.0552,3,3,100); // 13
car[14] = AddStaticVehicleEx(468,-713.6177,2362.9871,127.1410,57.8943,53,53,100); // 14
car[15] = AddStaticVehicleEx(471,-715.2697,2360.2341,126.6977,59.6976,74,83,100); // 15
car[16] = AddStaticVehicleEx(471,-716.6490,2357.8938,126.6158,60.0105,120,112,100); // 16
car[17] = AddStaticVehicleEx(424,-719.7819,2353.3308,126.7038,51.2771,15,30,100); // 17
car[18] = AddStaticVehicleEx(568,-721.5780,2337.8853,126.1084,304.6407,41,29,100); // 18
car[19] = AddStaticVehicleEx(568,-719.7067,2335.3057,126.2486,302.9700,37,0,100); // 19
car[20] = AddStaticVehicleEx(470,-713.0833,2327.7578,127.1815,309.0127,43,0,100); // 20
car[21] = AddStaticVehicleEx(444,-409.5646,2205.2302,42.7816,7.9773,32,53,100);
car[22] = AddStaticVehicleEx(444,-404.7762,2205.7185,42.7873,7.8851,32,42,100);
How can I make a command that destroy all unused vehicles of these that I added?
Reply
#2

Loop from 0 to 23 (because if you loop to 22 the last car wont be deleted)
then use (IsVehicleOccuiped) function if no one is in the car then DestroyVehicle()

I'll post an example later since I'm on phone right now.
Reply
#3

Quote:
Originally Posted by DaniceMcHarley
Посмотреть сообщение
Loop from 0 to 23 (because if you loop to 22 the last car wont be deleted)
then use (IsVehicleOccuiped) function if no one is in the car then DestroyVehicle()

I'll post an example later since I'm on phone right now.
Here's an example:
pawn Код:
// Somewhere in your code (A command for example)
for (new i = 0; i < 23; i++)
{
    if (!IsVehicleOccupied(car[i])) DestroyVehicle(car[i]); // Use SetVehicleToRespawn(car[i]); if you want them to respawn instead of getting destroyed.
}
Here's the IsVehicleOccupied function.
pawn Код:
stock IsVehicleOccupied(vehid)
{
    for( new all = 0; all < MAX_PLAYERS; all++)
    {
        if (IsPlayerInVehicle(all, vehid))
        {
            return 1;
        }
    }
    return 0;
}
Should work.
Reply
#4

Quote:
Originally Posted by Stinged
Посмотреть сообщение
Here's an example:
pawn Код:
// Somewhere in your code (A command for example)
for (new i = 0; i < 23; i++)
{
    if (!IsVehicleOccupied(car[i])) DestroyVehicle(car[i]); // Use SetVehicleToRespawn(car[i]); if you want them to respawn instead of getting destroyed.
}
Here's the IsVehicleOccupied function.
pawn Код:
stock IsVehicleOccupied(vehid)
{
    for( new all = 0; all < MAX_PLAYERS; all++)
    {
        if (IsPlayerInVehicle(all, vehid))
        {
            return 1;
        }
    }
    return 0;
}
Should work.
It works,thanks a lot.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)