Hallo,
ich habe ein Problem mit der Löschfunktion, genauer damit, dass die Fahrzeuge die Reloadet werden falsche IDs haben.
Hier der Code:
if(dialogid == Dialog_DeleteAhCar)
{
mysql_query("SELECT * FROM Autohaus");
mysql_store_result();
if(!strval(inputtext) || strval(inputtext) == 0 || strval(inputtext) > mysql_num_rows())
{
SendClientMessage(playerid,rot,"Kein Text, nicht 0 oder keine existierende ID!");
return ShowPlayerDialog(playerid,Dialog_DeleteAhCar,1,"Deleting - Autohaus Fahrzeug","{FF0000}ID eingeben bitte","Weiter","Zurück");
}
DeleteAhID[playerid] = strval(inputtext);
ShowPlayerDialog(playerid,Dialog_DeleteAhCarBestätigung,0,"Bestätigung","{FFFFFF}Bist du sicher, das du das Autohaus Fahrzeug {FF0000}löschen {FFFFFF}möchtest?","Löschen","Abbrechen");
}
if(dialogid == Dialog_DeleteAhCarBestätigung)
{
new query[150];
format(query,sizeof query,"DELETE FROM Autohaus WHERE id = %d",AhCars[DeleteAhID[playerid]][mysqlID]);
mysql_query(query);
mysql_free_result();
DestroyVehicle(AhCars[DeleteAhID[playerid]][vID]);
Delete3DTextLabel(AhCars[DeleteAhID[playerid]][vAhCarText]);
AhCars[DeleteAhID[playerid]][mysqlID] = 0;
AhCars[DeleteAhID[playerid]][Modell] = 0;
AhCars[DeleteAhID[playerid]][Kaufpreis] = 0;
AhCars[DeleteAhID[playerid]][Verkaufspreis] = 0;
AhCars[DeleteAhID[playerid]][Repairpreis] = 0;
AhCars[DeleteAhID[playerid]][PosX] = 0;
AhCars[DeleteAhID[playerid]][PosY] = 0;
AhCars[DeleteAhID[playerid]][PosZ] = 0;
AhCars[DeleteAhID[playerid]][Rotation] = 0;
AhCars[DeleteAhID[playerid]][vID] = 0;
//Ab hier war eigentlich gar nichts, ich hab ein wenig ausprobiert.
//ReloadAhCars();
new i = 1,string1[128],string2[128],col = random(126);
format(query,sizeof query,"SELECT * FROM Autohaus");
mysql_query(query);
mysql_store_result();
while(mysql_fetch_row_format(query))
{
DestroyVehicle(AhCars[i][vID]);
Delete3DTextLabel(AhCars[i][vAhCarText]);
sscanf(query,"e<p<|>dddddffff",AhCars[i]);
AhCars[i][vID] = AddStaticVehicleEx(AhCars[i][Modell],AhCars[i][PosX],AhCars[i][PosY],AhCars[i][PosZ],AhCars[i][Rotation],col,col,3600000);
format(string2,sizeof string2,"Modell: {FF0000}%s\n{00A0FF}Kaufpreis: %d€\nVerkaufspreis: %d€\nRepairpreis: %d€\nID: %d",Carname[AhCars[i][Modell]-400],AhCars[i][Kaufpreis],AhCars[i][Verkaufspreis],AhCars[i][Repairpreis],i);
AhCars[i][vAhCarText] = Create3DTextLabel(string2,hellblau,AhCars[i][PosX],AhCars[i][PosY],AhCars[i][PosZ],15,0);
Attach3DTextLabelToVehicle(AhCars[i][vAhCarText],AhCars[i][vID],0,0,0.75);
SetVehicleParamsEx(AhCars[i][vID],0,0,0,1,0,0,0);
format(string1,sizeof string1,"Autohaus %d",i);
SetVehicleNumberPlate(AhCars[i][vID],string1);
i++;
}
}
Bei der Bestätigung war eigentlich ReloadAhCars(); (Mit der Kennzeichnung)
Leider lief das schief...
Hier noch die Codes von LoadAhVehicles(); und ReloadAhCars();
ReloadAhCars()
{
new i = 1,query[128];
format(query,sizeof query,"SELECT * FROM Autohaus");
mysql_query(query);
mysql_store_result();
while(mysql_fetch_row_format(query))
{
DestroyVehicle(AhCars[i][vID]);
Delete3DTextLabel(AhCars[i][vAhCarText]);
printf("successful %d",i);
i++;
}
LoadAhVehicles();
}
LoadAhVehicles() //Ist vielleicht wichtig ;)
{
new col = 0 + random(126);
new str[128],string1[128],string2[128],i = 1;
format(str,sizeof str,"SELECT * FROM Autohaus");
mysql_query(str);
mysql_store_result();
while(mysql_fetch_row_format(str))
{
sscanf(str,"e<p<|>dddddffff>",AhCars[i]);
AhCars[i][vID] = AddStaticVehicleEx(AhCars[i][Modell],AhCars[i][PosX],AhCars[i][PosY],AhCars[i][PosZ],AhCars[i][Rotation],col,col,3600000);
format(string2,sizeof string2,"Modell: {FF0000}%s\n{00A0FF}Kaufpreis: %d€\nVerkaufspreis: %d€\nRepairpreis: %d€\nID: %d",Carname[AhCars[i][Modell]-400],AhCars[i][Kaufpreis],AhCars[i][Verkaufspreis],AhCars[i][Repairpreis],i);
AhCars[i][vAhCarText] = Create3DTextLabel(string2,hellblau,AhCars[i][PosX],AhCars[i][PosY],AhCars[i][PosZ],15,0);
Attach3DTextLabelToVehicle(AhCars[i][vAhCarText],AhCars[i][vID],0,0,0.75);
SetVehicleParamsEx(AhCars[i][vID],0,0,0,1,0,0,0);
format(string1,sizeof string1,"Autohaus %d",i);
SetVehicleNumberPlate(AhCars[i][vID],string1);
i++;
}
}
Danke schonmal