new RandomRegularVehicle[][3] =
{
// Positions, (model, low price, high price)
{400, 20000, 21000},
{401, 18000, 19000},
{404, 18000, 19000},
{405, 19000, 20000},
{410, 16000, 17000},
{412, 21000, 22000},
{418, 14000, 15000},
{419, 15000, 16000},
{421, 17000, 18000},
{422, 22000, 23000},
{426, 20000, 21000},
{436, 16000, 17000},
{439, 21000, 22000},
{445, 19000, 20000},
{458, 21000, 22000},
{466, 23000, 24000},
{467, 23000, 24000},
{474, 25000, 26000},
{475, 21000, 22000},
{479, 19000, 20000},
{489, 23000, 24000},
{491, 17000, 18000},
{492, 18000, 19000},
{500, 24000, 26000},
{505, 22000, 24000},
{507, 18000, 21000},
{516, 19000, 22000},
{517, 16000, 20000},
{518, 17000, 21000},
{526, 20000, 24000},
{527, 20000, 24000},
{529, 18000, 22000},
{533, 24000, 27000},
{534, 19000, 23000},
{535, 25000, 32000},
{536, 24000, 31000},
{540, 19000, 22000},
{542, 16000, 21000},
{543, 20000, 24000},
{545, 24000, 30000},
{546, 19000, 22000},
{547, 19000, 22000},
{549, 17000, 22000},
{550, 23000, 26000},
{551, 21000, 26000},
{554, 25000, 34000},
{558, 24000, 26000},
{560, 28000, 37000},
{561, 23000, 35000},
{562, 27000, 35000},
{565, 32000, 37000},
{566, 19000, 24000},
{567, 24000, 32000},
{575, 22000, 26000},
{576, 21000, 24000},
{579, 26000, 33000},
{580, 21000, 24000},
{585, 21000, 26000},
{587, 32000, 43000},
{589, 27000, 35000},
{600, 23000, 31000},
{602, 32000, 42000}
};
if(CarInfo[idx][cModel] != RandomRegularVehicle[][0]) return SendClientMessage(playerid, COLOR_RED, "You cannot sell this type of vehicle here");
|
Code:
if(CarInfo[idx][cModel] != RandomRegularVehicle[][0]) return SendClientMessage(playerid, COLOR_RED, "You cannot sell this type of vehicle here"); |
for (new i = 0; i < sizeof(RandomRegularVehicle); i++)
if(CarInfo[idx][cModel] != RandomRegularVehicle[i][0]) return SendClientMessage(playerid, COLOR_RED, "You cannot sell this type of vehicle here");
|
That is incorrect. If the first vehicle doesn't match, it will return the error without even checking the rest of the array. Never return inside a loop unless you explicitly want to break it.
|
new i;
for (i = 0; i < sizeof(RandomRegularVehicle); i++)
if(CarInfo[idx][cModel] == RandomRegularVehicle[i][0]) break;
if (i == sizeof(RandomRegularVehicle))
return SendClientMessage(playerid, COLOR_RED, "You cannot sell this type of vehicle here");
bool:IncorrectModel(modelid)
{
for(new i=0; i != sizeof(RandomRegularVehicle); i++)
if(RandomRegularVehicle[i][0] == modelid)
return true;
return false;
}
if(!IncorrectModel(CarInfo[idx][cModel])) return SendClientMessage(playerid, COLOR_RED, "You cannot sell this type of vehicle here");
new bool:modelfound = false;
for(new i = 0; i < sizeof(RandomRegularVehicle); i++)
{
if(CarInfo[idx][cModel] != RandomRegularVehicle[i][0]) continue;
modelfound = true;
break;
}
if(!modelfound) return SendClientMessage(playerid, COLOR_RED, "You cannot sell this type of vehicle here");