Guten Morgen,
Beim laden des Fahrzeuges wird nur das erste fahrzeug in der Datenbank geladen und ich kann den fehler nicht finden.
Hier mein Code:
stock OnLoadAllCars() {
new Cache:Temp = mysql_query(handle,"SELECT `Owner`, `SlotId` FROM `playervehicles` ORDER BY `ID`");
if(cache_get_row_count(handle) != 0)
{
new idx = 0, lastid = 0, sql[258];
format(sql,sizeof(sql),"SELECT `Owner`, `SlotId`, `ID` FROM `playervehicles` WHERE `ID` > '%d' ORDER BY `ID` LIMIT 1",lastid);
new Cache:Temp1 = mysql_query(handle, sql);
new rows = cache_get_row_count(handle);
while (idx < rows) {
new Name[40];
cache_get_field_content(idx, "Owner", Name, handle, MAX_PLAYER_NAME);
new slotid = cache_get_field_content_int(idx, "SlotId", handle);
lastid = cache_get_field_content_int(idx, "ID", handle);
LoadPlayerVehicle(Name, slotid);
idx++;
}
cache_delete(Temp1);
}
cache_delete(Temp);
}
stock LoadPlayerVehicle(PlayerName[], Slot) {
printf("Owner: %s | Slot: %i", PlayerName,Slot);
new sql[258];
format(sql,sizeof(sql),"SELECT * FROM `playervehicles` WHERE `Owner` = '%s' AND `SlotId` = '%d' ORDER BY `ID` DESC LIMIT 1",PlayerName,Slot);
new Cache:Temp = mysql_query(handle,sql),
rows = cache_get_row_count(handle),
id, idx = 0;
while (idx < rows) {
for(new i= 0; i < MAX_VEHICLES; i++) {
if(pVInfo[i][pV_CarID] < 1) {
id = i;
break;
}
}
pVInfo[idx][pV_SQLid] = cache_get_field_content_int(idx, "ID", handle);
cache_get_field_content(idx, "Owner", pVInfo[id][pV_Owner], handle, MAX_PLAYER_NAME);
pVInfo[id][pV_SlotID] = cache_get_field_content_int(idx, "SlotId", handle);
pVInfo[id][pV_ModelID] = cache_get_field_content_int(idx, "ModelID", handle);
pVInfo[id][pV_Pos][0] = cache_get_field_content_float(idx, "X", handle);
pVInfo[id][pV_Pos][1] = cache_get_field_content_float(idx, "Y", handle);
pVInfo[id][pV_Pos][2] = cache_get_field_content_float(idx, "Z", handle);
pVInfo[id][pV_Pos][3] = cache_get_field_content_float(idx, "A", handle);
pVInfo[id][pV_Color][0] = cache_get_field_content_int(idx, "Color1", handle);
pVInfo[id][pV_Color][1] = cache_get_field_content_int(idx, "Color2", handle);
pVInfo[id][pV_CarID] = CreateVehicle(pVInfo[id][pV_ModelID], pVInfo[id][pV_Pos][0], pVInfo[id][pV_Pos][1], pVInfo[id][pV_Pos][2], pVInfo[id][pV_Pos][3], pVInfo[id][pV_Color][0], pVInfo[id][pV_Color][1], -1);
printf("VehID: %i | Owner: %s | SlotID: %i", pVInfo[id][pV_CarID], pVInfo[id][pV_Owner], pVInfo[id][pV_SlotID]);
idx++;
}
cache_delete(Temp);
return 1;
}
Bitte um hilfe.