20.12.2010, 19:06
Код:
///----------------------------------------------------------------------------- public LoadCars() { new carrCoords[16][64]; new strFromFile2[256]; new File: file = fopen("vehicles/spawns.cfg", io_read); if (file) { new idx; new total_car = 0; fread(file, strFromFile2); split(strFromFile2, carrCoords, '|'); while (idx < sizeof(carrCoords)) { new modelid, Float:x,Float:y,Float:z,Float:angle,color1,color2,respawn_delay,use_random_colors; modelid = strval(carrCoords[0]); x = floatstr(carrCoords[1]); y = floatstr(carrCoords[2]); z = floatstr(carrCoords[3]); angle = floatstr(carrCoords[4]); color1 = strval(carrCoords[5]); color2 = strval(carrCoords[6]); respawn_delay = strval(carrCoords[7]); use_random_colors = strval(carrCoords[8]); if (use_random_colors == 1) { color1 = random(255); color2 = random(255); } if (LastCarID == 0) { LastCarID = CreateVehicle(modelid ,x,y,z,angle,color1,color2,respawn_delay); if(total_car == 0) { total_car = 1; } else if (total_car > 0) { total_car++; } } else { new Float:XLastVehicle; new Float:YLastVehicle; new Float:ZLastVehicle; GetVehiclePos(LastCarID, XLastVehicle,YLastVehicle,ZLastVehicle); if (floatcmp(x,XLastVehicle) == 1 && floatcmp(y,YLastVehicle) == 1 && floatcmp(z,ZLastVehicle) == 1) { LastCarID = CreateVehicle(modelid ,x,y,z,angle,color1,color2,respawn_delay); if(total_car == 0) { total_car = 1; } else if (total_car > 0) { total_car++; } } } idx++; } fclose(file); new string[128]; format(string, sizeof(string), "Foram Carregados: %i", total_car); print(string); return 1; } return 0; } //------------------------------------------------------------------------------ public split(const strsrc[], strdest[][], delimiter) { new i, li; new aNum; new len; while(i <= strlen(strsrc)){ if(strsrc[i]==delimiter || i==strlen(strsrc)){ len = strmid(strdest[aNum], strsrc, li, i, 128); strdest[aNum][len] = 0; li = i+1; aNum++; } i++; } return 1; }