forward PlayerFile_Create(playerid);
public PlayerFile_Create(playerid)
{
APlayerData[playerid][CompteID] = cache_insert_id();
printf("ETAT DU SERVEUR: ENREGISTREMENT D'UN COMPTE ID : %d", APlayerData[playerid][CompteID]);
return 1;
}
forward PlayerFile_Save(playerid);
public PlayerFile_Save(playerid)
{
new query[1024];
format(query, sizeof(query), "UPDATE `users` SET `Level` = %d,", APlayerData[playerid][PlayerLevel]);
format(query, sizeof(query), "%s `VIP` = %d, `Jailed` = %d, `Wanted` = %d,", query, APlayerData[playerid][VIPLevel], APlayerData[playerid][PlayerJailed], GetPlayerWantedLevel(playerid));
format(query, sizeof(query), "%s `Bans` = %d, `BanTime` = %d, `TruckerLicense` = %d,", query, APlayerData[playerid][Bans], APlayerData[playerid][BanTime], APlayerData[playerid][TruckerLicense]);
format(query, sizeof(query), "%s `BusLicense` = %d, `PilotLicense` = %d,", query, APlayerData[playerid][BusLicense], APlayerData[playerid][PilotLicense]);
format(query, sizeof(query), "%s `MafiaLicense` = %d, `Muted` = %d,", query, APlayerData[playerid][MafiaLicense], APlayerData[playerid][Muted]);
format(query, sizeof(query), "%s `RulesRead` = %d, `StatsMetersDriven` = %d, `LastLoggin` = %d,", query, APlayerData[playerid][RulesRead], APlayerData[playerid][StatsMetersDriven], ReturnDate());
format(query, sizeof(query), "%s `StatsTruckerJobs` = %d, `StatsConvoyJobs` = %d,", query, APlayerData[playerid][StatsTruckerJobs], APlayerData[playerid][StatsConvoyJobs]);
format(query, sizeof(query), "%s `StatsBusDriverJobs` = %d, `StatsPilotJobs` = %d,", query, APlayerData[playerid][StatsBusDriverJobs], APlayerData[playerid][StatsPilotJobs]);
format(query, sizeof(query), "%s `StatsMafiaJobs` = %d, `StatsMafiaStolen` = %d,", query, APlayerData[playerid][StatsMafiaJobs], APlayerData[playerid][StatsMafiaStolen]);
format(query, sizeof(query), "%s `StatsPoliceFined` = %d, `StatsPoliceJailed` = %d,", query, APlayerData[playerid][StatsPoliceFined], APlayerData[playerid][StatsPoliceJailed]);
format(query, sizeof(query), "%s `StatsCourierJobs` = %d, `StatsRoadworkerJobs` = %d,", query, APlayerData[playerid][StatsCourierJobs], APlayerData[playerid][StatsRoadworkerJobs]);
format(query, sizeof(query), "%s `StatsAssistance` = %d, `Team` = %d, `Leader` = %d,", query, APlayerData[playerid][StatsAssistance], APlayerData[playerid][Team], APlayerData[playerid][Leader]);
format(query, sizeof(query), "%s `Heuresjouer` = %d, `Minutesjouer` = %d,", query, APlayerData[playerid][pHeures], APlayerData[playerid][pMinutes]);
format(query, sizeof(query), "%s `Money` = %d, `Score` = %d WHERE `ID` = %d", query, APlayerData[playerid][PlayerMoney], APlayerData[playerid][PlayerScore], APlayerData[playerid][CompteID]);
mysql_format(g_iHandle, query, sizeof(query), "%s", query);
mysql_tquery(g_iHandle, query);
printf("STATS DU SERVEUR | ENREGISTREMENT MYSQL : %s", query);
return 1;
}
CREATE TABLE IF NOT EXISTS `users` (
`ID` int(12) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`ID`)
I can only think of 2 things (not sure about the second one though):
- In INSERT query, ID is given a value instead of being NULL. - Multiply connections have different connection handle so using "1" as default might conflict. |
Dialog_Register(playerid, response, passwordtext[])
{
new file[100], Name[MAX_PLAYER_NAME]; // Setup local variables
GetPlayerName(playerid, Name, sizeof(Name)); // Get the playername
format(file, sizeof(file), PlayerFile, Name); // Construct the complete filename for this player's account
switch (response) // Check which button was clicked
{
case 1: // Player clicked "Register"
{
// Check if the player entered a password
if(strlen(passwordtext) > 0)
{
new query[300];
// mysql_format(g_iHandle, query, sizeof(query), "INSERT INTO `users` (`PlayerName`, `Password`) VALUES ('%e', '%s')", GetPlayerNameEx(playerid), passwordtext);
mysql_format(g_iHandle, query, sizeof(query), "INSERT INTO `users` (`PlayerName`, `Password`, `email`) VALUES ('%e', '%s', '%s')", GetPlayerNameEx(playerid), passwordtext, APlayerData[playerid][Email]);
mysql_tquery(g_iHandle, query, "", "i", playerid);
// Send a message to the client to inform him that his account has been registered
SendClientMessage(playerid, 0xFFFFFFFF, TXT_AccountRegistered);
APlayerData[playerid][LoggedIn] = true; // The player has logged in properly
}
else
{
SendClientMessage(playerid, 0xFFFFFFFF, TXT_WrongPassword);
KickEx(playerid);
}
}
case 0: // Player clicked "Cancel"
{
// Show a message that the player must be registered to play on this server
SendClientMessage(playerid, 0xFFFFFFFF, TXT_PlayerMustRegister);
// Kick the player
KickEx(playerid);
}
}
return 1;
}
mysql_tquery(g_iHandle, query, "PlayerFile_Create", "i", playerid);