22.06.2012, 09:48
how to load car's in cars.cfg

i am a newbie

i am a newbie
411,2248.7592,-1653.7923,15.2370,77.8130 404,1057.8303,-1239.1422,15.8217,4.0920 421,1565.2381,-1713.0145,5.7960,240.0299 474,1588.3597,-1681.5926,5.7371,47.1082 482,1534.3208,-1664.0897,6.0624,11.2734 596,1366.6151,-1343.1114,13.2292,321.9594 596,1862.9022,-1624.7380,13.1891,221.4700 596,1905.9127,-1794.8537,13.2180,129.5675 492,2511.9128,-1675.5234,13.3339,265.8019 605,2265.0649,-1177.3547,25.4319,61.6267 554,2140.2673,-1478.6140,24.4899,269.1665 478,1131.4676,-1563.6695,13.2777,117.3684 470,767.0205,-1374.6064,13.5509,332.4468 470,770.9467,-1313.1103,13.4785,236.8058 470,1991.3922,-1622.7154,13.7376,179.8538 416,1276.8160,-1385.9272,13.5045,89.5615 433,2498.3972,-1656.8647,13.8934,102.7611 475,2341.4177,-1198.0008,27.7709,42.9351 543,1784.0069,-1929.7269,13.2089,96.5996 442,1010.9500,-1359.9200,13.1990,300.8020 475,974.1707,-1290.4687,13.3760,110.1266 400,819.5186,-1647.7154,13.5951,201.6994 426,620.8861,-1512.0080,14.6892,181.2187 410,1194.9298,-1292.6451,13.0600,196.6502 408,844.5678,-1414.5450,14.0298,106.0979 475,1707.2213,-1558.1346,13.8549,91.6050 420,1348.6770,-1756.9217,13.2559,139.1757 475,1707.2213,-1558.1346,13.8816,91.5464 574,1905.3166,-1388.3359,10.1812,69.5484 463,2086.8295,-1183.1477,25.2465,311.9219 400,1845.3863,-1883.7950,13.5226,269.0480 433,2734.5839,-1082.5194,69.8615,57.4272 409,2716.7912,-1065.5793,69.2321,87.7276 420,1775.4073,-1898.3763,13.2047,328.9674 405,744.2340,-1660.6319,4.1922,161.2539 540,2110.4135,-1342.1595,23.8444,238.4237 596,2662.4843,-1853.6599,10.6365,271.5252 470,367.8410,-2044.0714,7.6711,0.9243 470,372.8666,-2044.7147,7.6676,357.7654 470,2715.3715,-1117.0393,69.5149,111.3178 507,748.4389,-1340.9914,13.3072,154.5384
#include "../include/gl_common.inc"
//----------------------------------------------------------
//
// GRAND LARCENY common functions include.
//
//----------------------------------------------------------
stock LoadStaticVehiclesFromFile(const filename[])
{
new File:file_ptr;
new line[256];
new var_from_line[64];
new vehicletype;
new Float:SpawnX;
new Float:SpawnY;
new Float:SpawnZ;
new Float:SpawnRot;
new Color1, Color2;
new index;
new vehicles_loaded;
file_ptr = fopen(filename,filemode:io_read);
if(!file_ptr) return 0;
vehicles_loaded = 0;
while(fread(file_ptr,line,256) > 0)
{
index = 0;
// Read type
index = token_by_delim(line,var_from_line,',',index);
if(index == (-1)) continue;
vehicletype = strval(var_from_line);
if(vehicletype < 400 || vehicletype > 611) continue;
// Read X, Y, Z, Rotation
index = token_by_delim(line,var_from_line,',',index+1);
if(index == (-1)) continue;
SpawnX = floatstr(var_from_line);
index = token_by_delim(line,var_from_line,',',index+1);
if(index == (-1)) continue;
SpawnY = floatstr(var_from_line);
index = token_by_delim(line,var_from_line,',',index+1);
if(index == (-1)) continue;
SpawnZ = floatstr(var_from_line);
index = token_by_delim(line,var_from_line,',',index+1);
if(index == (-1)) continue;
SpawnRot = floatstr(var_from_line);
// Read Color1, Color2
index = token_by_delim(line,var_from_line,',',index+1);
if(index == (-1)) continue;
Color1 = strval(var_from_line);
index = token_by_delim(line,var_from_line,';',index+1);
Color2 = strval(var_from_line);
//printf("%d,%.2f,%.2f,%.2f,%.4f,%d,%d",vehicletype,SpawnX,SpawnY,SpawnZ,SpawnRot,Color1,Color2);
AddStaticVehicleEx(vehicletype,SpawnX,SpawnY,SpawnZ,SpawnRot,Color1,Color2,(30*60)); // respawn 30 minutes
/*new numplate_test[32+1];
format(numplate_test,32,"GRLC{44AA33}%d",vid);
SetVehicleNumberPlate(vid, numplate_test);*/
vehicles_loaded++;
}
fclose(file_ptr);
printf("Loaded %d vehicles from: %s",vehicles_loaded,filename);
return vehicles_loaded;
}
stock token_by_delim(const string[], return_str[], delim, start_index)
{
new x=0;
while(string[start_index] != EOS && string[start_index] != delim) {
return_str[x] = string[start_index];
x++;
start_index++;
}
return_str[x] = EOS;
if(string[start_index] == EOS) start_index = (-1);
return start_index;
}
LoadStaticVehiclesFromFile("fileloc/filename.txt"); //replace the location and name with your own obvi.
At the top of your script put this:
pawn Код:
pawn Код:
pawn Код:
|