25.01.2017, 22:27
Olб, eu estou mudando o salvamento do gamemode pcc_truking para SQlite, porem estou com uma duvida nб parte que carrega o jogador!
Como posso mudar isso para SQl?
(nгo tem somente essa linha, tem varias, calback abaixo!)
Alguem poderia me ajudar nessa parte? realmente fiquei em duvida de como Mudar essa parte...
Caso alguem puder me ajudar, agradecerei!
Como posso mudar isso para SQl?
Код:
if (strcmp(ParameterName, "Password", false) == 0) // If the parametername is correct ("Password") format(APlayerData[playerid][PlayerPassword], 50, ParameterValue); // Store the password
PHP код:
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, "Password", 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, "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, "TruckerLicense", false) == 0) // If the parametername is correct ("TruckerLicense")
APlayerData[playerid][TruckerLicense] = 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, "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, "StatsMafiaJobs", false) == 0) // If the parametername is correct ("StatsMafiaJobs")
APlayerData[playerid][StatsMafiaJobs] = strval(ParameterValue); // Store the StatsMafiaJobs
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, "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
fread(PFile, LineFromFile); // Read the next line of the file
}
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)
}
Caso alguem puder me ajudar, agradecerei!