Hallo
Mein Script brauch aus unerklärlichen Gründen fast 2 Sekunden um eine For-Schleife mit 2000 Durchgängen ( MAX_VEHICLES ) durchlaufen zu lassen.
Die Schleife:
for(new i = 0; i<MAX_VEHICLES; i++)
{
LoadCar(i);
VehInfo[i][Motor] = 0;
}
Und die Funktion LoadCar: [ Dateien haben sich seit es so lange braucht nicht verändert! ]
public LoadCar(i)
{
new path[128], str[30];
format(path, sizeof path, "/Cars/%d.ini", i);
if(fexist(path))
{
if(INI_Open(path))
{
PlayerCar[i][px] = INI_ReadFloat("px");
PlayerCar[i][py] = INI_ReadFloat("py");
PlayerCar[i][pz] = INI_ReadFloat("pz");
PlayerCar[i][pa] = INI_ReadFloat("pa");
PlayerCar[i][model] = INI_ReadInt("model");
PlayerCar[i][c1] = INI_ReadInt("c1");
PlayerCar[i][c2] = INI_ReadInt("c2");
PlayerCar[i][Lock] = INI_ReadInt("Lock");
PlayerCar[i][BuyPrice] = INI_ReadInt("BuyPrice");
PlayerCar[i][Fuel] = INI_ReadInt("Fuel");
PlayerCar[i][NSID] = INI_ReadInt("NSID");
PlayerCar[i][Nitro] = INI_ReadInt("Nitro");
PlayerCar[i][Hyd] = INI_ReadInt("Hyd");
PlayerCar[i][Wheel] = INI_ReadInt("Wheel");
PlayerCar[i][Auspuff] = INI_ReadInt("Auspuff");
PlayerCar[i][SeiteL] = INI_ReadInt("SeiteL");
PlayerCar[i][SeiteR] = INI_ReadInt("SeiteR");
PlayerCar[i][FB] = INI_ReadInt("FB");
PlayerCar[i][RB] = INI_ReadInt("RB");
PlayerCar[i][Spoiler] = INI_ReadInt("Spoiler");
PlayerCar[i][Roof] = INI_ReadInt("Roof");
PlayerCar[i][Hood] = INI_ReadInt("Hood");
PlayerCar[i][Vent] = INI_ReadInt("Vent");
PlayerCar[i][Lamp] = INI_ReadInt("Lamp");
PlayerCar[i][vid] = CreateVehicle(PlayerCar[i][model], PlayerCar[i][px], PlayerCar[i][py], PlayerCar[i][pz], PlayerCar[i][pa], PlayerCar[i][c1], PlayerCar[i][c2], -1);
PlayerCar[i][Distanz] = INI_ReadInt("Distanz");
PlayerCar[i][Paintjob] = INI_ReadInt("Paintjob");
PlayerCar[i][JobCar] = INI_ReadInt("JobCar");
PlayerCar[i][FrakCar] = INI_ReadInt("FrakCar");
PlayerCar[i][Job] = INI_ReadInt("Job");
PlayerCar[i][Frak] = INI_ReadInt("Frak");
INI_ReadString(PlayerCar[i][ABC], "ABC", 11);
INI_ReadString(PlayerCar[i][Key], "Key", MAX_PLAYER_NAME);
INI_Close();
if(PlayerCar[i][model] < 400 || PlayerCar[i][model] > 611)
{
new string[128];
format(string, sizeof string, "Car ID %d ", i);
printf("Car ID %d ist fehlerhaft!", i);
if(INI_Open("Cars.txt"))
{
INI_WriteString(string, " fehlerhaft!");
INI_Save();
INI_Close();
}
return 1;
}
//printf("Fahrzeug %d geladen & erstellt! [BESITZER: %s] [NUMMERNSCHILD: %s-%d]", i, PlayerCar[i][Key], PlayerCar[i][ABC], PlayerCar[i][NSID]);
//Attach3DTextLabelToVehicle(PlayerCar[i][NS], PlayerCar[i][vid], 0.0, 0.0, NSHoehe);
if(PlayerCar[i][JobCar] || PlayerCar[i][FrakCar]) SetVehicleNumberPlate(PlayerCar[i][vid], PlayerCar[i][ABC]);
else if(!PlayerCar[i][JobCar] && !PlayerCar[i][FrakCar] && strcmp(PlayerCar[i][Key], "Staat", false)) SetVehicleNumberPlate(PlayerCar[i][vid], PlayerCar[i][Key]);
SetVehicleToRespawn(PlayerCar[i][vid]);
if(!PlayerCar[i][JobCar] && !PlayerCar[i][FrakCar]) AddComponents(i);
if(i < 10 && i > 0) format(str, sizeof str, "%s-000%d", PlayerCar[i][ABC], i);
else if(i < 100 && i >= 10) format(str, sizeof str, "%s-00%d", PlayerCar[i][ABC], i);
else if(i < 1000 && i >= 100) format(str, sizeof str, "%s-0%d", PlayerCar[i][ABC], i);
else format(str, sizeof str, "%s-%d", PlayerCar[i][ABC], i);
PlayerCar[i][NS] = CreateDynamic3DTextLabel(str, COLOR_NS, 0.0, 0.0, NSHoehe, 50, INVALID_PLAYER_ID, PlayerCar[i][vid]);
}
}
return 1;
}
Auch in dieser Funktion hat sich nichts geändert.
Woran kann es bloß liegen?
Aber an meinem PC geht es noch relativ schnell, habe es mal jemandem mit langsameren Prozessor geschickt, bei dem hats 30 Sekunden [!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!] gedauert und das für eine einfach for schleife die normal 20 milisekunden dauert.
Pls helft mir!
LG
Evil