Advertisement
Guest User

Untitled

a guest
Dec 9th, 2016
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.77 KB | None | 0 0
  1. PlayerFile_Load(playerid)
  2. {
  3. // Setup local variables
  4. new file[100], File:PFile, Name[24], LineFromFile[100], ParameterName[50], ParameterValue[50], HouseIndex, BusIndex;
  5.  
  6. format(Name, sizeof(Name), APlayerData[playerid][PlayerName]); // Get the playername
  7. format(file, sizeof(file), PlayerFile, Name); // Construct the complete filename for this player's account
  8.  
  9. // Check if the player's datafile exists
  10. if (fexist(file))
  11. {
  12. PFile = fopen(file, io_read); // Open the playerfile for reading
  13.  
  14. fread(PFile, LineFromFile); // Read the first line of the file
  15.  
  16. // Keep reading until the end of the file is found (no more data)
  17. while (strlen(LineFromFile) > 0)
  18. {
  19. StripNewLine(LineFromFile); // Strip any newline characters from the LineFromFile
  20. sscanf(LineFromFile, "s[50]s[50]", ParameterName, ParameterValue); // Extract parametername and parametervalue
  21.  
  22. // Store the proper value in the proper place
  23. if (strcmp(ParameterName, "Senha", false) == 0) // If the parametername is correct ("Password")
  24. format(APlayerData[playerid][PlayerPassword], 50, ParameterValue); // Store the password
  25. //if (strcmp(ParameterName, "Level", false) == 0) // If the parametername is correct ("Level")
  26. //APlayerData[playerid][PlayerLevel] = strval(ParameterValue); // Store the playerlevel
  27. if (strcmp(ParameterName, "VIP", false) == 0) // If the parametername is correct ("Level")
  28. APlayerData[playerid][VIPLevel] = strval(ParameterValue); // Store the playerlevel
  29. if (strcmp(ParameterName, "Jailed", false) == 0) // If the parametername is correct ("Jailed")
  30. APlayerData[playerid][PlayerJailed] = strval(ParameterValue); // Store the jailed-status
  31. if (strcmp(ParameterName, "Wanted", false) == 0) // If the parametername is correct ("Wanted")
  32. SetPlayerWantedLevel(playerid, strval(ParameterValue)); // Set the wanted-status
  33. if (strcmp(ParameterName, "Bans", false) == 0) // If the parametername is correct ("Bans")
  34. APlayerData[playerid][Bans] = strval(ParameterValue); // Store the bans
  35. if (strcmp(ParameterName, "BanTime", false) == 0) // If the parametername is correct ("BanTime")
  36. APlayerData[playerid][BanTime] = strval(ParameterValue); // Store the bantime
  37. if (strcmp(ParameterName, "TempoVIP", false) == 0)
  38. APlayerData[playerid][TempoVIP] = strval(ParameterValue);
  39. if (strcmp(ParameterName, "StatusMedico", false) == 0)
  40. APlayerData[playerid][StatsMedic] = strval(ParameterValue);
  41. if (strcmp(ParameterName, "StatusExercito", false) == 0)
  42. APlayerData[playerid][StatusExercito] = strval(ParameterValue);
  43. if (strcmp(ParameterName, "StatusAdvogado", false) == 0)
  44. APlayerData[playerid][StatusAdvogado] = strval(ParameterValue);
  45. if (strcmp(ParameterName, "PontosCarteira", false) == 0)
  46. APlayerData[playerid][PontosCarteira] = strval(ParameterValue);
  47. if (strcmp(ParameterName, "EvitouRoubo", false) == 0)
  48. APlayerData[playerid][StatsEvitouRoubo] = strval(ParameterValue);
  49. if (strcmp(ParameterName, "RoubosRealizados", false) == 0)
  50. APlayerData[playerid][RoubosRealizados] = strval(ParameterValue);
  51. if (strcmp(ParameterName, "BonusCompletas", false) == 0)
  52. APlayerData[playerid][BonusCompletas] = strval(ParameterValue);
  53. if (strcmp(ParameterName, "PosX", false) == 0)
  54. APlayerData[playerid][PosX] = strval(ParameterValue);
  55. if (strcmp(ParameterName, "PosY", false) == 0)
  56. APlayerData[playerid][PosY] = strval(ParameterValue);
  57. if (strcmp(ParameterName, "PosZ", false) == 0)
  58. APlayerData[playerid][PosZ] = strval(ParameterValue);
  59. if (strcmp(ParameterName, "Nascer", false) == 0)
  60. APlayerData[playerid][Nascer] = strval(ParameterValue);
  61. if (strcmp(ParameterName, "GanhouCorridas", false) == 0)
  62. APlayerData[playerid][GanhouCorridas] = strval(ParameterValue);
  63. if (strcmp(ParameterName, "Cabeca", false) == 0)
  64. format(APlayerData[playerid][Cabeca], 500, ParameterValue);
  65. if (strcmp(ParameterName, "UsarSkin", false) == 0)
  66. APlayerData[playerid][UsarSkin] = strval(ParameterValue);
  67. if (strcmp(ParameterName, "PegarSkin", false) == 0)
  68. APlayerData[playerid][PSkin] = strval(ParameterValue);
  69. if (strcmp(ParameterName, "MatouEvento", false) == 0)
  70. APlayerData[playerid][MatouEvento] = strval(ParameterValue);
  71. if (strcmp(ParameterName, "Velha", false) == 0)
  72. APlayerData[playerid][Velha] = strval(ParameterValue);
  73. if (strcmp(ParameterName, "Frase", false) == 0)
  74. format(APlayerData[playerid][Frase], 80, ParameterValue);
  75. if (strcmp(ParameterName, "Bangu", false) == 0)
  76. APlayerData[playerid][Bangu] = strval(ParameterValue);
  77. if (strcmp(ParameterName, "VaiPreso", false) == 0)
  78. APlayerData[playerid][VaiPreso] = strval(ParameterValue);
  79. if (strcmp(ParameterName, "TruckerLicense", false) == 0) // If the parametername is correct ("TruckerLicense")
  80. APlayerData[playerid][TruckerLicense] = strval(ParameterValue); // Store the TruckerLicense
  81. if (strcmp(ParameterName, "BusLicense", false) == 0) // If the parametername is correct ("BusLicense")
  82. APlayerData[playerid][BusLicense] = strval(ParameterValue); // Store the BusLicense
  83. if (strcmp(ParameterName, "MafiaLicense", false) == 0)
  84. APlayerData[playerid][MafiaLicense] = strval(ParameterValue);
  85. if (strcmp(ParameterName, "PilotLicense", false) == 0)
  86. APlayerData[playerid][PilotLicense] = strval(ParameterValue);
  87.  
  88. if (strcmp(ParameterName, "Muted", false) == 0) // If the parametername is correct ("Muted")
  89. {
  90. if (strcmp(ParameterValue, "Yes", false) == 0) // If the value "Yes" was read
  91. APlayerData[playerid][Muted] = true; // Player is muted
  92. else
  93. APlayerData[playerid][Muted] = false; // Player is not muted
  94. }
  95. if (strcmp(ParameterName, "RulesRead", false) == 0) // If the parametername is correct ("RulesRead")
  96. {
  97. if (strcmp(ParameterValue, "Yes", false) == 0) // If the value "Yes" was read
  98. APlayerData[playerid][RulesRead] = true; // Player has accepted the rules
  99. else
  100. APlayerData[playerid][RulesRead] = false; // Player hasn't accepted the rules yet
  101. }
  102.  
  103. if (strcmp(ParameterName, "StatsMetersDriven", false) == 0) // If the parametername is correct ("StatsMetersDriven")
  104. APlayerData[playerid][StatsMetersDriven] = floatstr(ParameterValue); // Store the StatsMetersDriven
  105. if (strcmp(ParameterName, "StatsTruckerJobs", false) == 0) // If the parametername is correct ("StatsTruckerJobs")
  106. APlayerData[playerid][StatsTruckerJobs] = strval(ParameterValue); // Store the StatsTruckerJobs
  107. if (strcmp(ParameterName, "StatsConvoyJobs", false) == 0) // If the parametername is correct ("StatsConvoyJobs")
  108. APlayerData[playerid][StatsConvoyJobs] = strval(ParameterValue); // Store the StatsConvoyJobs
  109. if (strcmp(ParameterName, "StatsBusDriverJobs", false) == 0) // If the parametername is correct ("StatsBusDriverJobs")
  110. APlayerData[playerid][StatsBusDriverJobs] = strval(ParameterValue); // Store the StatsBusDriverJobs
  111. if (strcmp(ParameterName, "StatsPilotJobs", false) == 0) // If the parametername is correct ("StatsPilotJobs")
  112. APlayerData[playerid][StatsPilotJobs] = strval(ParameterValue); // Store the StatsPilotJobs
  113. if (strcmp(ParameterName, "StatsAeroConvoyJobs", false) == 0)
  114. APlayerData[playerid][StatsAeroConvoyJobs] = strval(ParameterValue);
  115. if (strcmp(ParameterName, "StatsMafiaJobs", false) == 0) // If the parametername is correct ("StatsMafiaJobs")
  116. APlayerData[playerid][StatsMafiaJobs] = strval(ParameterValue); // Store the StatsMafiaJobs
  117. if (strcmp(ParameterName, "StatsQuadrilhaJobs", false) == 0)
  118. APlayerData[playerid][StatsQuadrilhaJobs] = strval(ParameterValue);
  119. if (strcmp(ParameterName, "StatsMafiaStolen", false) == 0) // If the parametername is correct ("StatsMafiaStolen")
  120. APlayerData[playerid][StatsMafiaStolen] = strval(ParameterValue); // Store the StatsMafiaStolen
  121. if (strcmp(ParameterName, "StatsPoliceFined", false) == 0) // If the parametername is correct ("StatsPoliceFined")
  122. APlayerData[playerid][StatsPoliceFined] = strval(ParameterValue); // Store the StatsPoliceFined
  123. if (strcmp(ParameterName, "StatsPoliceJailed", false) == 0) // If the parametername is correct ("StatsPoliceJailed")
  124. APlayerData[playerid][StatsPoliceJailed] = strval(ParameterValue); // Store the StatsPoliceJailed
  125. if (strcmp(ParameterName, "StatusLixeiro", false) == 0) // If the parametername is correct ("StatsPoliceJailed")
  126. APlayerData[playerid][StatsLixeiroJobs] = strval(ParameterValue); // Store the StatsPoliceJailed
  127. if (strcmp(ParameterName, "StatsAssistance", false) == 0) // If the parametername is correct ("StatsAssistance")
  128. APlayerData[playerid][StatsAssistance] = strval(ParameterValue); // Store the StatsAssistance
  129. if (strcmp(ParameterName, "StatsCourierJobs", false) == 0) // If the parametername is correct ("StatsCourierJobs")
  130. APlayerData[playerid][StatsCourierJobs] = strval(ParameterValue); // Store the StatsCourierJobs
  131. if (strcmp(ParameterName, "StatsRoadworkerJobs", false) == 0) // If the parametername is correct ("StatsRoadworkerJobs")
  132. APlayerData[playerid][StatsRoadworkerJobs] = strval(ParameterValue); // Store the StatsRoadworkerJobs
  133.  
  134.  
  135. if (strcmp(ParameterName, "House", false) == 0) // If the parametername is correct ("House")
  136. {
  137. APlayerData[playerid][Houses][HouseIndex] = strval(ParameterValue); // Store the HouseID at the selected slot
  138. HouseIndex++; // Select the next house-slot in case another house-id is found
  139. }
  140. if (strcmp(ParameterName, "Business", false) == 0) // If the parametername is correct ("Business")
  141. {
  142. if (strcmp(ABusinessData[strval(ParameterValue)][Owner], Name, false) == 0) // Check if the player is the true owner of the business
  143. {
  144. APlayerData[playerid][Business][BusIndex] = strval(ParameterValue); // Store the BusinessID at the selected slot
  145. BusIndex++; // Select the next business-slot in case another business-id is found
  146. }
  147. }
  148.  
  149. if (strcmp(ParameterName, "Money", false) == 0) // If the parametername is correct ("Money")
  150. RewardPlayer(playerid, strval(ParameterValue), 0); // Store the money
  151. if (strcmp(ParameterName, "Score", false) == 0) // If the parametername is correct ("Score")
  152. RewardPlayer(playerid, 0, strval(ParameterValue)); // Store the score
  153. if (strcmp(ParameterName, "Cash", false) == 0) // If the parametername is correct ("StatsRoadworkerJobs")
  154. APlayerData[playerid][PlayerCash] = strval(ParameterValue);
  155. if (strcmp(ParameterName, "AvisoAdm", false) == 0) // If the parametername is correct ("StatsRoadworkerJobs")
  156. APlayerData[playerid][AvisoAdministrativo] = strval(ParameterValue);
  157. if (strcmp(ParameterName, "CreditoAdm", false) == 0) // If the parametername is correct ("StatsRoadworkerJobs")
  158. APlayerData[playerid][CreditoAdm] = strval(ParameterValue);
  159. if (strcmp(ParameterName, "Linha1", false) == 0) // If the parametername is correct ("StatsRoadworkerJobs")
  160. APlayerData[playerid][Linha1] = strval(ParameterValue);
  161. if (strcmp(ParameterName, "Linha2", false) == 0) // If the parametername is correct ("StatsRoadworkerJobs")
  162. APlayerData[playerid][Linha2] = strval(ParameterValue);
  163. if (strcmp(ParameterName, "Linha3", false) == 0) // If the parametername is correct ("StatsRoadworkerJobs")
  164. APlayerData[playerid][Linha3] = strval(ParameterValue);
  165. if (strcmp(ParameterName, "Linha4", false) == 0) // If the parametername is correct ("StatsRoadworkerJobs")
  166. APlayerData[playerid][Linha4] = strval(ParameterValue);
  167. if (strcmp(ParameterName, "PlanoSaude", false) == 0) // If the parametername is correct ("StatsRoadworkerJobs")
  168. APlayerData[playerid][PlanoSaude] = strval(ParameterValue);
  169. if (strcmp(ParameterName, "UltimoLogin", false) == 0) // Ultimo Login
  170. format(APlayerData[playerid][UltimoLogin], 30, ParameterValue); // Ultimo Login
  171. if (strcmp(ParameterName, "TempoTotalConectado", false) == 0)
  172. APlayerData[playerid][TempoTotalConectado] = strval(ParameterValue);
  173. if (strcmp(ParameterName, "Presidente", false) == 0)
  174. APlayerData[playerid][Presidente] = strval(ParameterValue);
  175. if (strcmp(ParameterName, "RecebeuBF", false) == 0)
  176. APlayerData[playerid][RecebeuBF] = strval(ParameterValue);
  177. if (strcmp(ParameterName, "SemParar", false) == 0)
  178. APlayerData[playerid][ViaFacil] = strval(ParameterValue);
  179. fread(PFile, LineFromFile);
  180. }
  181. fclose(PFile); // Close the file
  182.  
  183. return 1; // Return if the file was read correctly
  184. }
  185. else
  186. return 0; // Return 0 if the file couldn't be read (doesn't exist)
  187. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement