11.01.2016, 02:04
I've been looking at this code for a while now but couldn't make sense of it.
^ Cut out the loop for clarity.
What's the loop for? Does it check for the created cars and the invalid vehicle id's? I am really not sure what's that loop supposed to do.
PS: This is a command to destroy a spawned vehicle.
Код:
new CreatedCars[MAX_VEHICLES] = {INVALID_VEHICLE_ID, ...};
new currentVehicle = GetPlayerVehicleID(playerid);
if(currentVehicle == 0) return SendClientMessage(playerid,COLOR_GREY, "You must be in a vehicle to destroy it.");
new check;
for(new i = 0; i < sizeof(CreatedCars); i++)
{
if(CreatedCars[i] == currentVehicle)
{
check = 1;
CreatedCars[i] = INVALID_VEHICLE_ID;
break;
}
}
if(!check) return SendClientMessage(playerid, COLOR_GRAD1, "You may only destroy a vehicle that was created with /veh.");
gDestroyVehicle[currentVehicle] = 1;
SetVehicleToRespawn(currentVehicle);
return 1;
}
Код:
new CreatedCars[MAX_VEHICLES] = {INVALID_VEHICLE_ID, ...};
new check;
for(new i = 0; i < sizeof(CreatedCars); i++)
{
if(CreatedCars[i] == currentVehicle)
{
check = 1;
CreatedCars[i] = INVALID_VEHICLE_ID;
break;
}
}
What's the loop for? Does it check for the created cars and the invalid vehicle id's? I am really not sure what's that loop supposed to do.
PS: This is a command to destroy a spawned vehicle.



