Making this code faster
#1

Hi guys,
Is there any way this loop can be made more efficient?
It's only called in OnFilterScriptInit, but it takes 23 seconds to complete.
There are roughly 680 cars. MAX_CARS is 700.
pawn Код:
cars=0;
new vehid;
new ownedcars,freecars;
new str[128];
new str1[5];
new idx;
new Float:info[4],model;
for(new id;id<MAX_CARS;id++)
{
    format(str,128,"");
    format(str1,5,"%i",id);
    idx=0;
    model=0;
    if(!dini_Isset(CARLIST,str1)) continue;
    str = dini_SGet(CARLIST,str1);
    model = strval(Sstrtok(str,idx));
    info[0] = floatstr(Sstrtok(str,idx));
    info[1] = floatstr(Sstrtok(str,idx));
    info[2] = floatstr(Sstrtok(str,idx));
    info[3] = floatstr(Sstrtok(str,idx));
    vehid = CreateVehicle(model,info[0],info[1],info[2],info[3],-1,-1,360000);
    Vcolour1[vehid] = -1;
    Vcolour2[vehid] = -1;
    SetColour(vehid);
    if(dini_Isset(MODFILE,valtostr(vehid))) LoadMods(vehid,dini_SGet(MODFILE,valtostr(vehid)));
    if(!dini_Isset("carsys/carowners.txt",str1))
    {
        carowner[id] = "No Owner";
        freecars++;
    }
    else
    {
        str = dini_SGet("carsys/carowners.txt",str1);
        format(carowner[id],MAX_PLAYER_NAME,str);
        ownedcars++;
    }
    if(model==509 || model==481 || model==510) EngineOn[vehid] = 1;
    cars++;
    }
Any custom functions are already very efficient. It's just this bit I want to fix up!

P.S. I don't want answers like "Get a streamer". There's no challenge in that!
Reply
#2

OMFG, 23 seconds? This can not be true... I can't help you, I don't know DINI...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)