24.12.2018, 04:36
Estou com um problema no meu gm. Ele salva as senhas dos players, mas depois some, fica em branco e qualquer um pode entrar na conta. Como resolver isso? Uso a include DOF2 no gm.
PlayerFile_Create(playerid)
{
new file[100], File:PFile, Name[24], LineForFile[100];
format(Name, sizeof(Name), APlayerData[playerid][PlayerName]); // Get the playername
format(file, sizeof(file), PlayerFile, Name); // Construct the complete filename for this player's account
PFile = fopen(file, io_write); // Open the playerfile for writing
format(LineForFile, 100, "Senha %s\r\n", APlayerData[playerid][PlayerPassword]); // Construct the line: "Password <playerpassword>"
fwrite(PFile, LineForFile); // And save it to the file
//format(LineForFile, 100, "Level %i\r\n", 0); // Construct the line: "Level <playerlevel>"
//fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "VIP %i\r\n", 0); // Construct the line: "Level <playerlevel>"
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Jailed %i\r\n", 0); // Construct the line: "Jailed <playerjailed>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "Wanted %i\r\n", 0); // Construct the line: "Wanted <wantedlevel>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "Bans %i\r\n", 0); // Construct the line: "Bans <NumberOfBans>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "BanTime %i\r\n", 0); // Construct the line: "BanTime <TimeToUnban>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "TempoVIP %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "StatusMedico %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "StatusBombeiro %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "StatusExercito %i\r\n", 0); // Construct the line: "StatsTruckerJobs <StatsTruckerJobs>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatusAdvogado %i\r\n", 0); // Construct the line: "StatsTruckerJobs <StatsTruckerJobs>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "PontosCarteira %i\r\n", 0); //
fwrite(PFile, LineForFile);
format(LineForFile, 100, "PontosCarteiraTruck %i\r\n", 0); //
fwrite(PFile, LineForFile);
format(LineForFile, 100, "PontosCarteiraCarro %i\r\n", 0); //
fwrite(PFile, LineForFile);
format(LineForFile, 100, "PontosCarteiraMafia %i\r\n", 0); //
fwrite(PFile, LineForFile);
format(LineForFile, 100, "PontosCarteiraPiloto %i\r\n", 0); //
fwrite(PFile, LineForFile);
format(LineForFile, 100, "PontosCarteiraOnibus %i\r\n", 0); //
fwrite(PFile, LineForFile);
format(LineForFile, 100, "EvitouRoubo %i\r\n", 0); //
fwrite(PFile, LineForFile);
format(LineForFile, 100, "RoubosRealizados %i\r\n", 0); //
fwrite(PFile, LineForFile);
format(LineForFile, 100, "BonusCompletas %i\r\n", 0); //
fwrite(PFile, LineForFile);
format(LineForFile, 100, "PosX %f\r\n", 0); // Construct the line: "VehicleVentLeft <VehicleVentLeft>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "PosY %f\r\n", 0); // Construct the line: "VehicleVentLeft <VehicleVentLeft>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "PosZ %f\r\n", 0); // Construct the line: "VehicleVentLeft <VehicleVentLeft>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "Nascer %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "GanhouCorridas %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Cabeca %s\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "UsarSkin %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "PegarSkin %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "MatouEvento %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Velha %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Frase %s\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Bangu %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "VaiPreso %i\r\n", 0); //
fwrite(PFile, LineForFile);
format(LineForFile, 100, "TruckerLicense %i\r\n", 0); // Construct the line: "TruckerLicense <playertruckerlicense>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "CarroLicense %i\r\n", 0); // Construct the line: "TruckerLicense <playertruckerlicense>"
fwrite(PFile, LineForFile);
format(LineForFile, 100, "BusLicense %i\r\n", 0); // Construct the line: "BusLicense <playerbuslicense>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "MafiaLicense %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "PilotLicense %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "StatsMetersDriven %f\r\n", 0.0); // Construct the line: "StatsMetersDriven <StatsMetersDriven>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatsTruckerJobs %i\r\n", 0); // Construct the line: "StatsTruckerJobs <StatsTruckerJobs>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatsConvoyJobs %i\r\n", 0); // Construct the line: "StatsConvoyJobs <StatsConvoyJobs>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatsBusDriverJobs %i\r\n", 0); // Construct the line: "StatsBusDriverJobs <StatsBusDriverJobs>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatsPilotJobs %i\r\n", 0); // Construct the line: "StatsPilotJobs <StatsPilotJobs>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatsAeroConvoyJobs %i\r\n", 0); // Construct the line: "StatsConvoyJobs <StatsConvoyJobs>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatsMafiaJobs %i\r\n", 0); // Construct the line: "StatsMafiaJobs <StatsMafiaJobs>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatsQuadrilhaJobs %i\r\n", 0); // Construct the line: "StatsConvoyJobs <StatsConvoyJobs>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatsMafiaStolen %i\r\n", 0); // Construct the line: "StatsMafiaStolen <StatsMafiaStolen>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatsPoliceFined %i\r\n", 0); // Construct the line: "StatsPoliceFined <StatsPoliceFined>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatsPoliceJailed %i\r\n", 0); // Construct the line: "StatsPoliceJailed <StatsPoliceJailed>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatusLixeiro %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "StatsAssistance %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Money %i\r\n", 0); // Construct the line: "Money <playermoney>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "Score %i\r\n", 0); // Construct the line: "Score <playerscore>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "Cash %i\r\n", 0); // Construct the line: "Score <playerscore>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "Ouro %i\r\n", 0); // Construct the line: "Score <playerscore>"
fwrite(PFile, LineForFile);
format(LineForFile, 100, "AvisoAdm %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "CreditoAdm %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Linha1 %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Linha2 %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Linha3 %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Linha4 %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Linha5 %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Linha6 %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Linha7 %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Linha8 %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "PlanoSaude %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "X1Ganhos %i\r\n", 0);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "UltimoLogin %s\r\n", 0); // Ultimo Login
fwrite(PFile, LineForFile); // Ultimo Login
format(LineForFile, 100, "TempoTotalConectado %i\r\n", 0); // Tempo Total Conectado
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Presidente %i\r\n", 0); // presidente
fwrite(PFile, LineForFile);
format(LineForFile, 100, "RecebeuBF %i\r\n", 0); // Bolsa Familia
fwrite(PFile, LineForFile);
format(LineForFile, 100, "SemParar %i\r\n", 0); //
fwrite(PFile, LineForFile);
format(LineForFile, 100, "CarteiraTrabalho %i\r\n", 0); //
fwrite(PFile, LineForFile);
fclose(PFile); // Close the file;
return 1;
}
PlayerFile_Load(playerid)
{
// Setup local variables
new file[100], File:PFile, Name[24], LineFromFile[100], ParameterName[50], ParameterValue[50], HouseIndex, BusIndex;
format(Name, sizeof(Name), APlayerData[playerid][PlayerName]); // Get the playername
format(file, sizeof(file), PlayerFile, Name); // Construct the complete filename for this player's account
// Check if the player's datafile exists
if (fexist(file))
{
PFile = fopen(file, io_read); // Open the playerfile for reading
fread(PFile, LineFromFile); // Read the first line of the file
// Keep reading until the end of the file is found (no more data)
while (strlen(LineFromFile) > 0)
{
StripNewLine(LineFromFile); // Strip any newline characters from the LineFromFile
sscanf(LineFromFile, "s[50]s[50]", ParameterName, ParameterValue); // Extract parametername and parametervalue
// Store the proper value in the proper place
if (strcmp(ParameterName, "Senha", false) == 0) // If the parametername is correct ("Password")
format(APlayerData[playerid][PlayerPassword], 50, ParameterValue); // Store the password
//if (strcmp(ParameterName, "Level", false) == 0) // If the parametername is correct ("Level")
//APlayerData[playerid][PlayerLevel] = strval(ParameterValue); // Store the playerlevel
if (strcmp(ParameterName, "VIP", false) == 0) // If the parametername is correct ("Level")
APlayerData[playerid][VIPLevel] = strval(ParameterValue); // Store the playerlevel
if (strcmp(ParameterName, "Jailed", false) == 0) // If the parametername is correct ("Jailed")
APlayerData[playerid][PlayerJailed] = strval(ParameterValue); // Store the jailed-status
if (strcmp(ParameterName, "Wanted", false) == 0) // If the parametername is correct ("Wanted")
SetPlayerWantedLevel(playerid, strval(ParameterValue)); // Set the wanted-status
if (strcmp(ParameterName, "Bans", false) == 0) // If the parametername is correct ("Bans")
APlayerData[playerid][Bans] = strval(ParameterValue); // Store the bans
if (strcmp(ParameterName, "BanTime", false) == 0) // If the parametername is correct ("BanTime")
APlayerData[playerid][BanTime] = strval(ParameterValue); // Store the bantime
if (strcmp(ParameterName, "TempoVIP", false) == 0)
APlayerData[playerid][TempoVIP] = strval(ParameterValue);
if (strcmp(ParameterName, "StatusMedico", false) == 0)
APlayerData[playerid][StatsMedic] = strval(ParameterValue);
if (strcmp(ParameterName, "StatusBombeiro", false) == 0)
APlayerData[playerid][StatusBombeiro] = strval(ParameterValue);
if (strcmp(ParameterName, "StatusExercito", false) == 0)
APlayerData[playerid][StatusExercito] = strval(ParameterValue);
if (strcmp(ParameterName, "StatusAdvogado", false) == 0)
APlayerData[playerid][StatusAdvogado] = strval(ParameterValue);
if (strcmp(ParameterName, "PontosCarteira", false) == 0)
APlayerData[playerid][PontosCarteira] = strval(ParameterValue);
if (strcmp(ParameterName, "PontosCarteiraTruck", false) == 0)
APlayerData[playerid][PontosCarteiraTruck] = strval(ParameterValue);
if (strcmp(ParameterName, "PontosCarteiraCarro", false) == 0)
APlayerData[playerid][PontosCarteiraCarro] = strval(ParameterValue);
if (strcmp(ParameterName, "PontosCarteiraMafia", false) == 0)
APlayerData[playerid][PontosCarteiraMafia] = strval(ParameterValue);
if (strcmp(ParameterName, "PontosCarteiraPiloto", false) == 0)
APlayerData[playerid][PontosCarteiraPiloto] = strval(ParameterValue);
if (strcmp(ParameterName, "PontosCarteiraOnibus", false) == 0)
APlayerData[playerid][PontosCarteiraOnibus] = strval(ParameterValue);
if (strcmp(ParameterName, "EvitouRoubo", false) == 0)
APlayerData[playerid][StatsEvitouRoubo] = strval(ParameterValue);
if (strcmp(ParameterName, "RoubosRealizados", false) == 0)
APlayerData[playerid][RoubosRealizados] = strval(ParameterValue);
if (strcmp(ParameterName, "BonusCompletas", false) == 0)
APlayerData[playerid][BonusCompletas] = strval(ParameterValue);
if (strcmp(ParameterName, "PosX", false) == 0)
APlayerData[playerid][PosX] = strval(ParameterValue);
if (strcmp(ParameterName, "PosY", false) == 0)
APlayerData[playerid][PosY] = strval(ParameterValue);
if (strcmp(ParameterName, "PosZ", false) == 0)
APlayerData[playerid][PosZ] = strval(ParameterValue);
if (strcmp(ParameterName, "Nascer", false) == 0)
APlayerData[playerid][Nascer] = strval(ParameterValue);
if (strcmp(ParameterName, "GanhouCorridas", false) == 0)
APlayerData[playerid][GanhouCorridas] = strval(ParameterValue);
if (strcmp(ParameterName, "Cabeca", false) == 0)
format(APlayerData[playerid][Cabeca], 500, ParameterValue);
if (strcmp(ParameterName, "UsarSkin", false) == 0)
APlayerData[playerid][UsarSkin] = strval(ParameterValue);
if (strcmp(ParameterName, "PegarSkin", false) == 0)
APlayerData[playerid][PSkin] = strval(ParameterValue);
if (strcmp(ParameterName, "MatouEvento", false) == 0)
APlayerData[playerid][MatouEvento] = strval(ParameterValue);
if (strcmp(ParameterName, "Velha", false) == 0)
APlayerData[playerid][Velha] = strval(ParameterValue);
if (strcmp(ParameterName, "Frase", false) == 0)
format(APlayerData[playerid][Frase], 80, ParameterValue);
if (strcmp(ParameterName, "Bangu", false) == 0)
APlayerData[playerid][Bangu] = strval(ParameterValue);
if (strcmp(ParameterName, "VaiPreso", false) == 0)
APlayerData[playerid][VaiPreso] = strval(ParameterValue);
if (strcmp(ParameterName, "TruckerLicense", false) == 0) // If the parametername is correct ("TruckerLicense")
APlayerData[playerid][TruckerLicense] = strval(ParameterValue); // Store the TruckerLicense
if (strcmp(ParameterName, "CarroLicense", false) == 0) // If the parametername is correct ("TruckerLicense")
APlayerData[playerid][CarroLicense] = strval(ParameterValue); // Store the TruckerLicense
if (strcmp(ParameterName, "BusLicense", false) == 0) // If the parametername is correct ("BusLicense")
APlayerData[playerid][BusLicense] = strval(ParameterValue); // Store the BusLicense
if (strcmp(ParameterName, "MafiaLicense", false) == 0)
APlayerData[playerid][MafiaLicense] = strval(ParameterValue);
if (strcmp(ParameterName, "PilotLicense", false) == 0)
APlayerData[playerid][PilotLicense] = strval(ParameterValue);
if (strcmp(ParameterName, "Muted", false) == 0) // If the parametername is correct ("Muted")
{
if (strcmp(ParameterValue, "Yes", false) == 0) // If the value "Yes" was read
APlayerData[playerid][Muted] = true; // Player is muted
else
APlayerData[playerid][Muted] = false; // Player is not muted
}
if (strcmp(ParameterName, "RulesRead", false) == 0) // If the parametername is correct ("RulesRead")
{
if (strcmp(ParameterValue, "Yes", false) == 0) // If the value "Yes" was read
APlayerData[playerid][RulesRead] = true; // Player has accepted the rules
else
APlayerData[playerid][RulesRead] = false; // Player hasn't accepted the rules yet
}
if (strcmp(ParameterName, "StatsMetersDriven", false) == 0) // If the parametername is correct ("StatsMetersDriven")
APlayerData[playerid][StatsMetersDriven] = floatstr(ParameterValue); // Store the StatsMetersDriven
if (strcmp(ParameterName, "StatsTruckerJobs", false) == 0) // If the parametername is correct ("StatsTruckerJobs")
APlayerData[playerid][StatsTruckerJobs] = strval(ParameterValue); // Store the StatsTruckerJobs
if (strcmp(ParameterName, "StatsConvoyJobs", false) == 0) // If the parametername is correct ("StatsConvoyJobs")
APlayerData[playerid][StatsConvoyJobs] = strval(ParameterValue); // Store the StatsConvoyJobs
if (strcmp(ParameterName, "StatsBusDriverJobs", false) == 0) // If the parametername is correct ("StatsBusDriverJobs")
APlayerData[playerid][StatsBusDriverJobs] = strval(ParameterValue); // Store the StatsBusDriverJobs
if (strcmp(ParameterName, "StatsPilotJobs", false) == 0) // If the parametername is correct ("StatsPilotJobs")
APlayerData[playerid][StatsPilotJobs] = strval(ParameterValue); // Store the StatsPilotJobs
if (strcmp(ParameterName, "StatsAeroConvoyJobs", false) == 0)
APlayerData[playerid][StatsAeroConvoyJobs] = strval(ParameterValue);
if (strcmp(ParameterName, "StatsMafiaJobs", false) == 0) // If the parametername is correct ("StatsMafiaJobs")
APlayerData[playerid][StatsMafiaJobs] = strval(ParameterValue); // Store the StatsMafiaJobs
if (strcmp(ParameterName, "StatsQuadrilhaJobs", false) == 0)
APlayerData[playerid][StatsQuadrilhaJobs] = strval(ParameterValue);
if (strcmp(ParameterName, "StatsMafiaStolen", false) == 0) // If the parametername is correct ("StatsMafiaStolen")
APlayerData[playerid][StatsMafiaStolen] = strval(ParameterValue); // Store the StatsMafiaStolen
if (strcmp(ParameterName, "StatsPoliceFined", false) == 0) // If the parametername is correct ("StatsPoliceFined")
APlayerData[playerid][StatsPoliceFined] = strval(ParameterValue); // Store the StatsPoliceFined
if (strcmp(ParameterName, "StatsPoliceJailed", false) == 0) // If the parametername is correct ("StatsPoliceJailed")
APlayerData[playerid][StatsPoliceJailed] = strval(ParameterValue); // Store the StatsPoliceJailed
if (strcmp(ParameterName, "StatusLixeiro", false) == 0) // If the parametername is correct ("StatsPoliceJailed")
APlayerData[playerid][StatsLixeiroJobs] = strval(ParameterValue); // Store the StatsPoliceJailed
if (strcmp(ParameterName, "StatsAssistance", false) == 0) // If the parametername is correct ("StatsAssistance")
APlayerData[playerid][StatsAssistance] = strval(ParameterValue); // Store the StatsAssistance
if (strcmp(ParameterName, "StatsCourierJobs", false) == 0) // If the parametername is correct ("StatsCourierJobs")
APlayerData[playerid][StatsCourierJobs] = strval(ParameterValue); // Store the StatsCourierJobs
if (strcmp(ParameterName, "StatsRoadworkerJobs", false) == 0) // If the parametername is correct ("StatsRoadworkerJobs")
APlayerData[playerid][StatsRoadworkerJobs] = strval(ParameterValue); // Store the StatsRoadworkerJobs
if (strcmp(ParameterName, "House", false) == 0) // If the parametername is correct ("House")
{
APlayerData[playerid][Houses][HouseIndex] = strval(ParameterValue); // Store the HouseID at the selected slot
HouseIndex++; // Select the next house-slot in case another house-id is found
}
if (strcmp(ParameterName, "Business", false) == 0) // If the parametername is correct ("Business")
{
if (strcmp(ABusinessData[strval(ParameterValue)][Owner], Name, false) == 0) // Check if the player is the true owner of the business
{
APlayerData[playerid][Business][BusIndex] = strval(ParameterValue); // Store the BusinessID at the selected slot
BusIndex++; // Select the next business-slot in case another business-id is found
}
}
if (strcmp(ParameterName, "Money", false) == 0) // If the parametername is correct ("Money")
RewardPlayer(playerid, strval(ParameterValue), 0); // Store the money
if (strcmp(ParameterName, "Score", false) == 0) // If the parametername is correct ("Score")
RewardPlayer(playerid, 0, strval(ParameterValue)); // Store the score
if (strcmp(ParameterName, "Cash", false) == 0) // If the parametername is correct ("StatsRoadworkerJobs")
APlayerData[playerid][PlayerCash] = strval(ParameterValue);
if (strcmp(ParameterName, "Ouro", false) == 0) // If the parametername is correct ("StatsRoadworkerJobs")
APlayerData[playerid][PlayerOuro] = strval(ParameterValue);
if (strcmp(ParameterName, "AvisoAdm", false) == 0) // If the parametername is correct ("StatsRoadworkerJobs")
APlayerData[playerid][AvisoAdministrativo] = strval(ParameterValue);
if (strcmp(ParameterName, "CreditoAdm", false) == 0) // If the parametername is correct ("StatsRoadworkerJobs")
APlayerData[playerid][CreditoAdm] = strval(ParameterValue);
if (strcmp(ParameterName, "Linha1", false) == 0) // If the parametername is correct ("StatsRoadworkerJobs")
APlayerData[playerid][Linha1] = strval(ParameterValue);
if (strcmp(ParameterName, "Linha2", false) == 0) // If the parametername is correct ("StatsRoadworkerJobs")
APlayerData[playerid][Linha2] = strval(ParameterValue);
if (strcmp(ParameterName, "Linha3", false) == 0) // If the parametername is correct ("StatsRoadworkerJobs")
APlayerData[playerid][Linha3] = strval(ParameterValue);
if (strcmp(ParameterName, "Linha4", false) == 0) // If the parametername is correct ("StatsRoadworkerJobs")
APlayerData[playerid][Linha4] = strval(ParameterValue);
if (strcmp(ParameterName, "Linha5", false) == 0) // If the parametername is correct ("StatsRoadworkerJobs")
APlayerData[playerid][Linha5] = strval(ParameterValue);
if (strcmp(ParameterName, "Linha6", false) == 0)
APlayerData[playerid][Linha6] = strval(ParameterValue);
if (strcmp(ParameterName, "Linha7", false) == 0)
APlayerData[playerid][Linha7] = strval(ParameterValue);
if (strcmp(ParameterName, "Linha8", false) == 0)
APlayerData[playerid][Linha8] = strval(ParameterValue);
if (strcmp(ParameterName, "PlanoSaude", false) == 0) // If the parametername is correct ("StatsRoadworkerJobs")
APlayerData[playerid][PlanoSaude] = strval(ParameterValue);
if (strcmp(ParameterName, "X1Ganhos", false) == 0)
wDuelos[playerid] = strval(ParameterValue);
if (strcmp(ParameterName, "UltimoLogin", false) == 0) // Ultimo Login
format(APlayerData[playerid][UltimoLogin], 30, ParameterValue); // Ultimo Login
if (strcmp(ParameterName, "TempoTotalConectado", false) == 0)
APlayerData[playerid][TempoTotalConectado] = strval(ParameterValue);
if (strcmp(ParameterName, "Presidente", false) == 0)
APlayerData[playerid][Presidente] = strval(ParameterValue);
if (strcmp(ParameterName, "RecebeuBF", false) == 0)
APlayerData[playerid][RecebeuBF] = strval(ParameterValue);
if (strcmp(ParameterName, "SemParar", false) == 0)
APlayerData[playerid][ViaFacil] = strval(ParameterValue);
if (strcmp(ParameterName, "CarteiraTrabalho", false) == 0)
APlayerData[playerid][CTPS] = strval(ParameterValue);
fread(PFile, LineFromFile);
}
fclose(PFile); // Close the file
return 1; // Return if the file was read correctly
}
else
return 0; // Return 0 if the file couldn't be read (doesn't exist)
}
// This function will save all player-data (used when the player disconnects from the server)
PlayerFile_Save(playerid)
{
new file[100], File:PFile, Name[24], LineForFile[100];
format(Name, sizeof(Name), APlayerData[playerid][PlayerName]); // Get the playername
format(file, sizeof(file), PlayerFile, Name); // Construct the complete filename for this player's account
PFile = fopen(file, io_write); // Open the playerfile for writing
format(LineForFile, 100, "Senha %s\r\n", APlayerData[playerid][PlayerPassword]); // Construct the line: "Password <playerpassword>"
fwrite(PFile, LineForFile); // And save it to the file
//format(LineForFile, 100, "Level %i\r\n", APlayerData[playerid][PlayerLevel]); // Construct the line: "Level <playerlevel>"
//fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "VIP %i\r\n", APlayerData[playerid][VIPLevel]); // Construct the line: "Level <playerlevel>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "Jailed %i\r\n", APlayerData[playerid][PlayerJailed]); // Construct the line: "Jailed <playerjailed>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "Wanted %i\r\n", GetPlayerWantedLevel(playerid)); // Construct the line: "Wanted <wantedlevel>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "Bans %i\r\n", APlayerData[playerid][Bans]); // Construct the line: "Bans <NumberOfBans>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "BanTime %i\r\n", APlayerData[playerid][BanTime]); // Construct the line: "BanTime <TimeToUnban>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "TempoVIP %i\r\n", APlayerData[playerid][TempoVIP]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "StatusMedico %i\r\n", APlayerData[playerid][StatsMedic]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "StatusBombeiro %i\r\n", APlayerData[playerid][StatusBombeiro]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "StatusExercito %i\r\n", APlayerData[playerid][StatusExercito]); // Construct the line: "StatsTruckerJobs <StatsTruckerJobs>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatusAdvogado %i\r\n", APlayerData[playerid][StatusAdvogado]); // Construct the line: "StatsTruckerJobs <StatsTruckerJobs>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "PontosCarteira %i\r\n", APlayerData[playerid][PontosCarteira]); // Construct the line: "StatsRoadworkerJobs <StatsRoadworkerJobs>"
fwrite(PFile, LineForFile);
format(LineForFile, 100, "PontosCarteiraTruck %i\r\n", APlayerData[playerid][PontosCarteiraTruck]); // Construct the line: "StatsRoadworkerJobs <StatsRoadworkerJobs>"
fwrite(PFile, LineForFile);
format(LineForFile, 100, "PontosCarteiraCarro %i\r\n", APlayerData[playerid][PontosCarteiraCarro]); // Construct the line: "StatsRoadworkerJobs <StatsRoadworkerJobs>"
fwrite(PFile, LineForFile);
format(LineForFile, 100, "PontosCarteiraMafia %i\r\n", APlayerData[playerid][PontosCarteiraMafia]); // Construct the line: "StatsRoadworkerJobs <StatsRoadworkerJobs>"
fwrite(PFile, LineForFile);
format(LineForFile, 100, "PontosCarteiraPiloto %i\r\n", APlayerData[playerid][PontosCarteiraPiloto]); // Construct the line: "StatsRoadworkerJobs <StatsRoadworkerJobs>"
fwrite(PFile, LineForFile);
format(LineForFile, 100, "PontosCarteiraOnibus %i\r\n", APlayerData[playerid][PontosCarteiraOnibus]); // Construct the line: "StatsRoadworkerJobs <StatsRoadworkerJobs>"
fwrite(PFile, LineForFile);
format(LineForFile, 100, "EvitouRoubo %i\r\n", APlayerData[playerid][StatsEvitouRoubo]); // Construct the line: "StatsRoadworkerJobs <StatsRoadworkerJobs>"
fwrite(PFile, LineForFile);
format(LineForFile, 100, "RoubosRealizados %i\r\n", APlayerData[playerid][RoubosRealizados]); // Construct the line: "StatsRoadworkerJobs <StatsRoadworkerJobs>"
fwrite(PFile, LineForFile);
format(LineForFile, 100, "BonusCompletas %i\r\n", APlayerData[playerid][BonusCompletas]); // Construct the line: "StatsRoadworkerJobs <StatsRoadworkerJobs>"
fwrite(PFile, LineForFile);
format(LineForFile, 100, "PosX %f\r\n", APlayerData[playerid][PosX]); // Construct the line: "VehicleVentLeft <VehicleVentLeft>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "PosY %f\r\n", APlayerData[playerid][PosY]); // Construct the line: "VehicleVentLeft <VehicleVentLeft>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "PosZ %f\r\n", APlayerData[playerid][PosZ]); // Construct the line: "VehicleVentLeft <VehicleVentLeft>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "Nascer %i\r\n", APlayerData[playerid][Nascer]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "GanhouCorridas %i\r\n", APlayerData[playerid][GanhouCorridas]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Cabeca %s\r\n", APlayerData[playerid][Cabeca]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "UsarSkin %i\r\n", APlayerData[playerid][UsarSkin]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "PegarSkin %i\r\n", APlayerData[playerid][PSkin]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "MatouEvento %i\r\n", APlayerData[playerid][MatouEvento]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Velha %i\r\n", APlayerData[playerid][Velha]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Frase %s\r\n", APlayerData[playerid][Frase]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Bangu %i\r\n", APlayerData[playerid][Bangu]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "VaiPreso %i\r\n", APlayerData[playerid][VaiPreso]); // Construct the line: "HouseName <HouseName>"
fwrite(PFile, LineForFile);
format(LineForFile, 100, "TruckerLicense %i\r\n", APlayerData[playerid][TruckerLicense]); // Construct the line: "TruckerLicense <playertruckerlicense>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "CarroLicense %i\r\n", APlayerData[playerid][CarroLicense]); // Construct the line: "TruckerLicense <playertruckerlicense>"
fwrite(PFile, LineForFile);
format(LineForFile, 100, "BusLicense %i\r\n", APlayerData[playerid][BusLicense]); // Construct the line: "BusLicense <playerbuslicense>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "MafiaLicense %i\r\n", APlayerData[playerid][MafiaLicense]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "PilotLicense %i\r\n", APlayerData[playerid][PilotLicense]);
fwrite(PFile, LineForFile);
if (APlayerData[playerid][Muted] == true) // Check if the player is muted
format(LineForFile, 100, "Muted Yes\r\n"); // Construct the line: "Muted <Yes>"
else
format(LineForFile, 100, "Muted No\r\n"); // Construct the line: "Muted <No>"
fwrite(PFile, LineForFile); // And save it to the file
if (APlayerData[playerid][RulesRead] == true) // Check if the player has accepted the rules
format(LineForFile, 100, "RulesRead Yes\r\n"); // Construct the line: "RulesRead <Yes>"
else
format(LineForFile, 100, "RulesRead No\r\n"); // Construct the line: "RulesRead <No>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatsMetersDriven %f\r\n", APlayerData[playerid][StatsMetersDriven]); // Construct the line: "StatsMetersDriven <StatsMetersDriven>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatsTruckerJobs %i\r\n", APlayerData[playerid][StatsTruckerJobs]); // Construct the line: "StatsTruckerJobs <StatsTruckerJobs>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatsConvoyJobs %i\r\n", APlayerData[playerid][StatsConvoyJobs]); // Construct the line: "StatsConvoyJobs <StatsConvoyJobs>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatsBusDriverJobs %i\r\n", APlayerData[playerid][StatsBusDriverJobs]); // Construct the line: "StatsBusDriverJobs <StatsBusDriverJobs>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatsPilotJobs %i\r\n", APlayerData[playerid][StatsPilotJobs]); // Construct the line: "StatsPilotJobs <StatsPilotJobs>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatsAeroConvoyJobs %i\r\n", APlayerData[playerid][StatsAeroConvoyJobs]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "StatsMafiaJobs %i\r\n", APlayerData[playerid][StatsMafiaJobs]); // Construct the line: "StatsMafiaJobs <StatsMafiaJobs>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatsQuadrilhaJobs %i\r\n", APlayerData[playerid][StatsQuadrilhaJobs]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "StatsMafiaStolen %i\r\n", APlayerData[playerid][StatsMafiaStolen]); // Construct the line: "StatsMafiaStolen <StatsMafiaStolen>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatsPoliceFined %i\r\n", APlayerData[playerid][StatsPoliceFined]); // Construct the line: "StatsPoliceFined <StatsPoliceFined>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatsPoliceJailed %i\r\n", APlayerData[playerid][StatsPoliceJailed]); // Construct the line: "StatsPoliceJailed <StatsPoliceJailed>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatusLixeiro %i\r\n", APlayerData[playerid][StatsLixeiroJobs]); // Construct the line: "StatsPoliceJailed <StatsPoliceJailed>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatsAssistance %i\r\n", APlayerData[playerid][StatsAssistance]); // Construct the line: "StatsAssistance <StatsAssistance>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatsCourierJobs %i\r\n", APlayerData[playerid][StatsCourierJobs]); // Construct the line: "StatsCourierJobs <StatsCourierJobs>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "StatsRoadworkerJobs %i\r\n", APlayerData[playerid][StatsRoadworkerJobs]); // Construct the line: "StatsRoadworkerJobs <StatsRoadworkerJobs>"
fwrite(PFile, LineForFile); // And save it to the file
for (new i; i < MAX_HOUSESPERPLAYER; i++)
{
if (APlayerData[playerid][Houses][i] != 0)
{
format(LineForFile, 100, "House %i\r\n", APlayerData[playerid][Houses][i]); // Construct the line: "House <HouseID>"
fwrite(PFile, LineForFile); // And save it to the file
}
}
for (new i; i < MAX_BUSINESSPERPLAYER; i++)
{
if (APlayerData[playerid][Business][i] != 0)
{
format(LineForFile, 100, "Business %i\r\n", APlayerData[playerid][Business][i]); // Construct the line: "Business <BusinessID>"
fwrite(PFile, LineForFile); // And save it to the file
}
}
format(LineForFile, 100, "Money %i\r\n", APlayerData[playerid][PlayerMoney]); // Construct the line: "Money <playermoney>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "Score %i\r\n", APlayerData[playerid][PlayerScore]); // Construct the line: "Score <playerscore>"
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "Cash %i\r\n", APlayerData[playerid][PlayerCash]);
fwrite(PFile, LineForFile); // And save it to the file
format(LineForFile, 100, "Ouro %i\r\n", APlayerData[playerid][PlayerOuro]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "AvisoAdm %i\r\n", APlayerData[playerid][AvisoAdministrativo]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "CreditoAdm %i\r\n", APlayerData[playerid][CreditoAdm]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Linha1 %i\r\n", APlayerData[playerid][Linha1]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Linha2 %i\r\n", APlayerData[playerid][Linha2]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Linha3 %i\r\n", APlayerData[playerid][Linha3]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Linha4 %i\r\n", APlayerData[playerid][Linha4]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Linha5 %i\r\n", APlayerData[playerid][Linha5]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Linha6 %i\r\n", APlayerData[playerid][Linha6]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Linha7 %i\r\n", APlayerData[playerid][Linha7]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Linha8 %i\r\n", APlayerData[playerid][Linha8]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "PlanoSaude %i\r\n", APlayerData[playerid][PlanoSaude]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "X1Ganhos %i\r\n", wDuelos[playerid]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "UltimoLogin %s\r\n", APlayerData[playerid][UltimoLogin]); // Ultimo Login
fwrite(PFile, LineForFile); // Ultimo Login
format(LineForFile, 100, "TempoTotalConectado %i\r\n", APlayerData[playerid][TempoTotalConectado]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "Presidente %i\r\n", APlayerData[playerid][Presidente]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "RecebeuBF %i\r\n", APlayerData[playerid][RecebeuBF]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "SemParar %i\r\n", APlayerData[playerid][ViaFacil]);
fwrite(PFile, LineForFile);
format(LineForFile, 100, "CarteiraTrabalho %i\r\n", APlayerData[playerid][CTPS]);
fwrite(PFile, LineForFile);
for (new i; i < MAX_HOUSESPERPLAYER; i++)
{
if (APlayerData[playerid][Houses][i] != 0)
{
HouseFile_Save(APlayerData[playerid][Houses][i]);
}
}
for (new i; i < MAX_BUSINESSPERPLAYER; i++)
{
if (APlayerData[playerid][Business][i] != 0)
{
BusinessFile_Save(APlayerData[playerid][Business][i]);
}
}
fclose(PFile); // Close the file
return 1;
}
PlayerFile_Save(playerid)