stock loadplayervehicles(iPlayer)
{
for(new i=0; i<4; i++)
{
DestroyVehicle(ownedvehicle[iPlayer][i]);
ResetVVar(ownedvehicle[iPlayer][i]); // Restores all vehicle relative variables to their default
ownedvehicle[iPlayer][i] = 0; // This basically makes the player own "0" cars when they log out
}
new Query[700];
format(Query, sizeof(Query), "SELECT * FROM `vehicleinfo` WHERE `vowner` = '%s'", pName(iPlayer));
mysql_query(Query);
mysql_store_result();
new nextveh;
ownedveh[iPlayer] = 0;
if(mysql_num_rows()) // I did have a for loop in here to add all 3 vehicles but it didn't work at all.
{
mysql_fetch_row_format(Query, "|");
for(new i=0; i<MAX_VEHICLES; i++)
{
if(!IsValidVehicle(i)) // Adds the vehicle into a free vehicle slot
{
nextveh = i;
sscanf(Query, "p<|>e<s[32]ds[32]ds[7]ddffffddfddddddddddddddddddddddddddd>", VVar[vehicle[nextveh]]);
ownedvehicle[iPlayer][ownedveh[iPlayer]] = vehicle[nextveh];
new plate[7];
format(plate,sizeof(plate), VVar[vehicle[nextveh]][vplate]);
SetVehicleNumberPlate(vehicle[nextveh], plate);
vehicle[nextveh] = CreateVehicle(VVar[vehicle[nextveh]][vmodel], VVar[vehicle[nextveh]][vx], VVar[vehicle[nextveh]][vy], VVar[vehicle[nextveh]][vz], VVar[vehicle[nextveh]][vangle], VVar[vehicle[nextveh]][vcolour1], VVar[vehicle[nextveh]][vcolour2], 0); // Adds the vehicle data into the respective variables.
ownedveh[iPlayer]++;
break;
}
}
}
ownedveh[iPlayer] = 0;
return 1;
}
The break statement in the loop cancels it. Simple as that.
Also, why are you looping through the vehicles? Loop through the results that your query gives you. |