Advertisement
Guest User

Untitled

a guest
Oct 10th, 2012
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.20 KB | None | 0 0
  1.  
  2. LoadGarages() {
  3.  
  4. if(!fexist("Garages/garages.cfg")) return 1;
  5.  
  6. new
  7. szFileStr[1024],
  8. File: iFileHandle = fopen("Garages/garages.cfg", io_read),
  9. iIndex;
  10.  
  11. while(iIndex < MAX_GARAGES && fread(iFileHandle, szFileStr)) {
  12. if(!sscanf(szFileStr, "p<|>is[24]ffffffffiiii",
  13. arrGarage[iIndex][b_iInteriorID],
  14. arrGarage[iIndex][b_szOwner],
  15. arrGarage[iIndex][b_fExteriorPos][0],
  16. arrGarage[iIndex][b_fExteriorPos][1],
  17. arrGarage[iIndex][b_fExteriorPos][2],
  18. arrGarage[iIndex][b_fExteriorPos][3],
  19. arrGarage[iIndex][b_fInteriorPos][0],
  20. arrGarage[iIndex][b_fInteriorPos][1],
  21. arrGarage[iIndex][b_fInteriorPos][2],
  22. arrGarage[iIndex][b_fInteriorPos][3],
  23. arrGarage[iIndex][b_iValue],
  24. arrGarage[iIndex][b_iFee],
  25. arrGarage[iIndex][b_iSafeMoney],
  26. arrGarage[iIndex][b_iLocked])) {
  27.  
  28. if(!isnull(arrGarage[iIndex][b_szOwner])) format(szFileStr, sizeof(szFileStr), "Garage\n%s\nOwned by %s\nID: %d", ((arrGarage[iIndex][b_iLocked]) ? ("{FF0000}Closed{33AA33}") : ("{E8A831}Open{33AA33}")), arrGarage[iIndex][b_szOwner], iIndex);
  29. else format(szFileStr, sizeof(szFileStr), "{E8A831}This garage is for sale for $%d!\n{33AA33}/buygarage to purchase.\nID: %d", arrGarage[iIndex][b_iValue], iIndex);
  30. if(arrGarage[iIndex][b_iFee] > 0)
  31. {
  32. if(!isnull(arrGarage[iIndex][b_szOwner])) format(szFileStr, sizeof(szFileStr), "Garage\n%s\nEntrance fee: $%i\nOwned by %s\nID: %d", ((arrGarage[iIndex][b_iLocked]) ? ("{FF0000}Closed{33AA33}") : ("{E8A831}Open{33AA33}")), arrGarage[iIndex][b_iFee], arrGarage[iIndex][b_szOwner], iIndex);
  33. }
  34. arrGarage[iIndex][b_iPickupID] = CreateDynamicPickup(1239, 23, arrGarage[iIndex][b_fExteriorPos][0], arrGarage[iIndex][b_fExteriorPos][1], arrGarage[iIndex][b_fExteriorPos][2], .worldid = 0, .interiorid = 0);
  35. arrGarage[iIndex][b_tLabelID] = CreateDynamic3DTextLabel(szFileStr, COLOR_GREEN, arrGarage[iIndex][b_fExteriorPos][0], arrGarage[iIndex][b_fExteriorPos][1], arrGarage[iIndex][b_fExteriorPos][2] + 0.5,30.0, .testlos = 1, .streamdistance = 30.0, .worldid = 0, .interiorid = 0);
  36. ++iIndex;
  37. }
  38. }
  39. return fclose(iFileHandle);
  40. }
  41.  
  42.  
  43. SaveGarages() {
  44.  
  45. new
  46. szFileStr[1024],
  47. File: fHandle = fopen("Garages/garages.cfg", io_write);
  48.  
  49. for(new iIndex; iIndex < MAX_GARAGES; iIndex++) {
  50. format(szFileStr, sizeof(szFileStr),"%s|%i|%.2f|%.2f|%.2f|%.2f|%.2f|%.2f|%.2f|%.2f|%i|$%i|%i|%i\r\n",
  51. arrGarage[iIndex][b_szOwner],
  52. arrGarage[iIndex][b_iInteriorID],
  53. arrGarage[iIndex][b_fExteriorPos][0],
  54. arrGarage[iIndex][b_fExteriorPos][1],
  55. arrGarage[iIndex][b_fExteriorPos][2],
  56. arrGarage[iIndex][b_fExteriorPos][3],
  57. arrGarage[iIndex][b_fInteriorPos][0],
  58. arrGarage[iIndex][b_fInteriorPos][1],
  59. arrGarage[iIndex][b_fInteriorPos][2],
  60. arrGarage[iIndex][b_fInteriorPos][3],
  61. arrGarage[iIndex][b_iValue],
  62. arrGarage[iIndex][b_iFee],
  63. arrGarage[iIndex][b_iSafeMoney],
  64. arrGarage[iIndex][b_iLocked]
  65. );
  66. fwrite(fHandle, szFileStr);
  67. }
  68. fclose(fHandle);
  69. return 1;
  70. }
  71.  
  72. enum eGarageData {
  73. b_iInteriorID,
  74. b_szOwner[MAX_PLAYER_NAME],
  75. Float: b_fExteriorPos[4],
  76. Float: b_fInteriorPos[4],
  77. Text3D: b_tLabelID,
  78. b_iValue,
  79. b_iSafeMoney,
  80. b_iPickupID,
  81. b_iFee,
  82. b_iLocked
  83. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement