Advertisement
Guest User

Untitled

a guest
May 16th, 2012
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.67 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <YSI\y_ini> // Y_LESS
  4.  
  5. #define PATH "vehicle/%s.ini"
  6.  
  7. forward LoadUser_data(playerid,name[],value[]);
  8.  
  9. public OnFilterScriptInit()
  10. {
  11. print("\n--------------------------------------");
  12. print(" LOADED SAVING CARs");
  13. print("--------------------------------------\n");
  14. return 1;
  15. }
  16.  
  17. enum cInfo
  18. {
  19. Model,
  20. Float:cX,
  21. Float:cY,
  22. Float:cZ,
  23. Lock,
  24. Alarm,
  25. }
  26. new CarInformation[MAX_PLAYERS][cInfo];
  27.  
  28. COMMAND:savec(playerid, params[])
  29. {
  30. if(IsPlayerInAnyVehicle(playerid))
  31. {
  32. new INI:File = INI_Open(UserPath(playerid));
  33. new vozidloID[MAX_PLAYERS];
  34. vozidloID[playerid] = GetPlayerVehicleID(playerid);
  35. //
  36. CarInformation[playerid][Model] = GetVehicleModel(vozidloID[playerid]);
  37. //
  38. GetVehiclePos(vozidloID[playerid], CarInformation[playerid][cX], CarInformation[playerid][cY], CarInformation[playerid][cZ]);
  39. new engine, lights, bonnet, boot, objective;
  40. GetVehicleParamsEx(vozidloID[playerid], engine, lights, CarInformation[playerid][Alarm], CarInformation[playerid][Lock], bonnet, boot, objective);
  41. //
  42. INI_SetTag(File,"Auto");
  43. INI_WriteInt(File,"Model",CarInformation[playerid][Model]);
  44. INI_WriteFloat(File,"PosX",CarInformation[playerid][cX]);
  45. INI_WriteFloat(File,"PosY",CarInformation[playerid][cY]);
  46. INI_WriteFloat(File,"PosZ",CarInformation[playerid][cZ]);
  47. INI_WriteInt(File,"Alarm",CarInformation[playerid][Alarm]);
  48. INI_WriteInt(File,"Lock",CarInformation[playerid][Lock]);
  49. INI_Close(File);
  50. }
  51. return 1;
  52. }
  53. COMMAND:loadc(playerid, params[])
  54. {
  55. if(fexist(UserPath(playerid)))
  56. {
  57. INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
  58. AddStaticVehicle(CarInformation[playerid][Model] , CarInformation[playerid][cX], CarInformation[playerid][cY], CarInformation[playerid][cZ], 0, random(250), random(250));
  59. printf("%d %d %d %d Here is pos and modelid",CarInformation[playerid][Model] , CarInformation[playerid][cX], CarInformation[playerid][cY], CarInformation[playerid][cZ]);
  60. }
  61. return 1;
  62. }
  63. public LoadUser_data(playerid,name[],value[])
  64. {
  65. INI_Int("Model",CarInformation[playerid][Model]);
  66. INI_Float("PoziceX",CarInformation[playerid][cX]);
  67. INI_Float("PoziceY",CarInformation[playerid][cY]);
  68. INI_Float("PoziceZ",CarInformation[playerid][cZ]);
  69. INI_Int("Lock",CarInformation[playerid][Lock]);
  70. INI_Int("Alarm",CarInformation[playerid][Alarm]);
  71. return 1;
  72. }
  73. stock UserPath(playerid)
  74. {
  75. new string[128],playername[MAX_PLAYER_NAME];
  76. GetPlayerName(playerid,playername,sizeof(playername));
  77. format(string,sizeof(string),PATH,playername);
  78. return string;
  79. }
  80.  
  81. public OnPlayerDisconnect(playerid, reason)
  82. {
  83. new INI:File = INI_Open(UserPath(playerid));
  84. new vozidloID[MAX_PLAYERS];
  85. vozidloID[playerid] = GetPlayerVehicleID(playerid);
  86. //
  87. CarInformation[playerid][Model] = GetVehicleModel(vozidloID[playerid]);
  88. //
  89. GetVehiclePos(vozidloID[playerid], CarInformation[playerid][cX], CarInformation[playerid][cY], CarInformation[playerid][cZ]);
  90. new engine, lights, bonnet, boot, objective;
  91. GetVehicleParamsEx(vozidloID[playerid], engine, lights, CarInformation[playerid][Alarm], CarInformation[playerid][Lock], bonnet, boot, objective);
  92. //
  93. INI_SetTag(File,"Auto");
  94. INI_WriteInt(File,"Model",CarInformation[playerid][Model]);
  95. INI_WriteFloat(File,"PosX",CarInformation[playerid][cX]);
  96. INI_WriteFloat(File,"PosY",CarInformation[playerid][cY]);
  97. INI_WriteFloat(File,"PosZ",CarInformation[playerid][cZ]);
  98. INI_WriteInt(File,"Alarm",CarInformation[playerid][Alarm]);
  99. INI_WriteInt(File,"Lock",CarInformation[playerid][Lock]);
  100. INI_Close(File);
  101. return 1;
  102. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement