new v_prioid;
new filename[MAX_STRING];
new linecount = 0;
new prio_count;
format(filename, sizeof (filename), "%sGTO.vehiclespawns.txt",VehicleDB);
new idx;
new temp[256];
new File:fhandle;
fhandle = fopen(filename,io_read);
while (fread(fhandle,temp,sizeof(temp))) {
linecount++;
temp = strrest(temp,0);
v_prioid = strval(strcharsplit(temp, idx,strchar(",")));
new string[256];
format(string, sizeof(string), "%d",v_prioid);
printf(string);
if(v_prioid == 1)
{
prio_count++;
PriorityCars[prio_count] = linecount;
}
}
fclose(fhandle);
These are the functions used;
public strcharsplit(string[], &index,seperator)
{
new result[MAX_STRING];
new idxpos = index;
for (new i=index;i<strlen(string);i++)
{
index++;
if (string[i] == seperator) break;
if (string[i] == 0) break;
result[i-idxpos] = string[i];
}
return result;
}
public strchar(string[2])
{
return string[0];
}
this is how the file content looks like
-1,443,-1540.2059,-2747.823,49.172,170.2765,20,1,300000
-1,463,-1555.4904,-2743.136,48.0808,334.7023,11,11,300000
-1,468,-1557.7052,-2741.2961,48.2089,337.581,53,53,300000
-1,470,-1609.6151,-2718.1558,48.5342,231.5696,43,0,300000
-1,593,1960.2064,-2647.5012,14.0086,0.6559,-1,-1,300000
1,476,1718.2184,-2625.3433,13.3286,352.5374,-1,-1,300000
1,476,1860.7959,-2623.4519,13.3287,3.9905,-1,-1,300000
1,553,1482.4989,-2620.6145,13.3287,266.7185,-1,-1,300000
-1,565,2489.3066,-2605.5688,13.3711,0.4802,-1,-1,300000
1,411,-2119.7756,-2513.2112,31.1944,324.9478,43,0,300000
-1,579,2763.6816,-2510.6714,13.6339,0.0716,-1,-1,300000
1,519,1421.8922,-2491.6023,13.386,271.9363,13,13,300000