Guest User

Untitled

a guest
Jul 26th, 2012
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.24 KB | None | 0 0
  1. enum cInfo
  2. {
  3. cModel,
  4. Float:cLocationx,
  5. Float:cLocationy,
  6. Float:cLocationz,
  7. Float:cAngle,
  8. cColorOne,
  9. cColorTwo,
  10. cOwner[MAX_PLAYER_NAME],
  11. cDescription[MAX_PLAYER_NAME],
  12. cValue,
  13. cLicense,
  14. cRegistration,
  15. cOwned,
  16. cLock
  17. };
  18. new CarInfo[430][cInfo]; // broj vozila za poslove,org(346 + 84 vozila koji se nalaze u cars.cfg)
  19.  
  20.  
  21. forward LoadCar();
  22. public LoadCar()
  23. {
  24. new arrCoords[13][256];
  25. new strFromFile2[256];
  26. new File: file = fopen("cfg/cars.cfg", io_read);
  27. if (file)
  28. {
  29. new idx = 346; // odavde krecu vozila,ovo unazad su od org,poslova....
  30. while (idx < sizeof(CarInfo))
  31. {
  32. fread(file, strFromFile2);
  33. split(strFromFile2, arrCoords, ',');
  34. CarInfo[idx][cModel] = strval(arrCoords[0]);
  35. CarInfo[idx][cLocationx] = floatstr(arrCoords[1]);
  36. CarInfo[idx][cLocationy] = floatstr(arrCoords[2]);
  37. CarInfo[idx][cLocationz] = floatstr(arrCoords[3]);
  38. CarInfo[idx][cAngle] = floatstr(arrCoords[4]);
  39. CarInfo[idx][cColorOne] = strval(arrCoords[5]);
  40. CarInfo[idx][cColorTwo] = strval(arrCoords[6]);
  41. strmid(CarInfo[idx][cOwner], arrCoords[7], 0, strlen(arrCoords[7]), 255);
  42. strmid(CarInfo[idx][cDescription], arrCoords[8], 0, strlen(arrCoords[8]), 255);
  43. CarInfo[idx][cValue] = strval(arrCoords[9]);
  44. CarInfo[idx][cLicense] = strval(arrCoords[10]);
  45. CarInfo[idx][cOwned] = strval(arrCoords[11]);
  46. CarInfo[idx][cLock] = strval(arrCoords[12]);
  47. printf("ID: %d || Vlasnik: %d",idx,CarInfo[idx][cOwner]);
  48. idx++;
  49. }
  50. }
  51. return 1;
  52. }
  53.  
  54. // public OnPropUpdate
  55.  
  56. idx = 346;
  57. while (idx < sizeof(CarInfo))
  58. {
  59. new coordsstring[256];
  60. format(coordsstring, sizeof(coordsstring), "%d,%f,%f,%f,%f,%d,%d,%s,%s,%d,%s,%d,%d\n",
  61. CarInfo[idx][cModel],//
  62. CarInfo[idx][cLocationx],//
  63. CarInfo[idx][cLocationy],//
  64. CarInfo[idx][cLocationz],//
  65. CarInfo[idx][cAngle],//
  66. CarInfo[idx][cColorOne],//
  67. CarInfo[idx][cColorTwo],//
  68. CarInfo[idx][cOwner],//
  69. CarInfo[idx][cDescription],//
  70. CarInfo[idx][cValue],//
  71. CarInfo[idx][cLicense],//
  72. CarInfo[idx][cOwned],//
  73. CarInfo[idx][cLock]);
  74. if(idx == 346)
  75. {
  76. file2 = fopen("cfg/cars.cfg", io_write);
  77. }
  78. else
  79. {
  80. file2 = fopen("cfg/cars.cfg", io_append);
  81. }
  82. fwrite(file2, coordsstring);
  83. idx++;
  84. fclose(file2);
  85. }
Advertisement
Add Comment
Please, Sign In to add comment