stock SavePlayerAccount(playerid)
{
if(IsPlayerConnected(playerid))
{
new EscapedName[MAX_PLAYER_NAME];
mysql_real_escape_string(GetName(playerid), EscapedName);
//UpdatePlayerVariables(playerid);
if(CheckExist(playerid) == 0)
{
format(query, sizeof(query), "INSERT INTO `Accounts` (Username, Password) VALUES('%s', '%s')",EscapedName, Player[playerid][pPassword]);
mysql_query(query);
}
format(query, sizeof(query), "UPDATE Accounts SET AccountID=%d, Username='%s', Password='%s', Money=%d, Level=%d, Skin=%d, Health=%f, Armour=%f, PosX=%f, PosY=%f, PosZ=%f, Angle=%f, Ethnicity=%d, Gender=%d, Age=%d, DefaultSpawn=%d, PhoneType=%d, PhoneNumber=%d, World=%d, Interior=%d, VehSlots=%d, Admin=%d WHERE playerid=%d",
Player[playerid][pAccountID],Player[playerid][pUsername],Player[playerid][pPassword],Player[playerid][pMoney],Player[playerid][pLevel],Player[playerid][pSkin],Player[playerid][pHealth],Player[playerid][pArmour],
Player[playerid][pPosX],Player[playerid][pPosY],Player[playerid][pPosZ],Player[playerid][pAngle],Player[playerid][pEthnicity],Player[playerid][pGender],Player[playerid][pAge],Player[playerid][pDefaultSpawn],Player[playerid][pPhoneType],
Player[playerid][pPhoneNumber],Player[playerid][pWorld], Player[playerid][pInterior],Player[playerid][pVehSlots],Player[playerid][pAdmin],Player[playerid][pAccountID]);
mysql_query(query);
SaveContacts(playerid);
}
}
format(query, sizeof(query), "UPDATE `Accounts` SET `Username` = '%s', `Password` = '%s', `Money` = '%d', `Level` = '%d', `Skin` = '%d' WHERE `AccountID` = '%d'", Player[playerid][pUsername], Player[playerid][pPassword], Player[playerid][pMoney], Player[playerid][pLevel], Player[playerid][pSkin], Player[playerid][pAccountID]);
mysql_query(query);
format(query,sizeof(query), "UPDATE `Accounts` SET `Health` = '%f', `Armour` = '%f', `PositionX` = '%f', `PositionY` = '%f', `PositionZ` = '%f', `Angle` = '%f' WHERE `AccountID` = '%d'", Player[playerid][pHealth],Player[playerid][pArmour],Player[playerid][pPosX],Player[playerid][pPosY],Player[playerid][pPosZ],Player[playerid][pAngle],Player[playerid][pAccountID]);
mysql_query(query);
format(query,sizeof(query), "UPDATE `Accounts` SET `Ethnicity` = '%d', `Gender` = '%d', `Age` = '%d', `Locked` = '%d', `DefaultSpawn` = '%d', `PhoneType` = '%d', `PhoneNumber` = '%d' WHERE `AccountID` = '%d'", Player[playerid][pEthnicity],Player[playerid][pEthnicity],Player[playerid][pAge],Player[playerid][pDefaultSpawn],Player[playerid][pPhoneType],Player[playerid][pPhoneNumber],Player[playerid][pAccountID]);
mysql_query(query);
format(query,sizeof(query), "UPDATE `Accounts` SET `World` = '%d', `Interior` = '%d', `VehSlots` = '%d', `Admin` = '%d', `AdminDuty` = '%d', WHERE `AccountID` = '%d'", Player[playerid][pWorld],Player[playerid][pInterior],Player[playerid][pVehSlots],Player[playerid][pAdmin],Player[playerid][pAdminDuty],Player[playerid][pAccountID]);
mysql_query(query);
SaveContacts(playerid);
enum PlayerData
{
pAccountID,
pUsername[23],
pPassword[146],
pMoney,
pLevel,
pSkin,
Float:pHealth,
Float:pArmour,
Float:pPosX,
Float:pPosY,
Float:pPosZ,
Float:pAngle,
pEthnicity,
pGender,
pAge,
pDefaultSpawn,
pPhoneType,
pPhoneNumber,
pWorld,
pInterior,
pVehSlots,
pAdmin,
pAdminDuty,
pJob,
pFaction
};
Originally Posted by mkr
It seems to me that the problem is you aren't updating pAccountID with the ID that they're assigned in the database.
|
Originally Posted by mkr
AccountID needs to be the primary key in your table
|
Originally Posted by mkr
and after your insert statement you should set Player[playerid][pAccountID] to mysql_insert_row()
|
Originally Posted by mkr
each one of those queries is trying to update WHERE AccountID = 0, which isn't going to do anything.
|
stock SavePlayerAccount(playerid)
{
if(IsPlayerConnected(playerid))
{
new x;
new EscapedName[MAX_PLAYER_NAME];
mysql_real_escape_string(GetName(playerid), EscapedName);
//UpdatePlayerVariables(playerid);
while(mysql_retrieve_row())
{
mysql_get_field("AccountID", DataResult);
x = strval(DataResult);
}
if(CheckExist(playerid) == 0)
{
format(query, sizeof(query), "INSERT INTO `Accounts` (Username, Password) VALUES('%s', '%s')",EscapedName, Player[playerid][pPassword]);
mysql_query(query);
}
format(query, sizeof(query), "UPDATE Accounts SET AccountID=%d, Username='%s', Password='%s', Money=%d, Level=%d, Skin=%d, Health=%f, Armour=%f, PosX=%f, PosY=%f, PosZ=%f, Angle=%f, Ethnicity=%d, Gender=%d, Age=%d, DefaultSpawn=%d, PhoneType=%d, PhoneNumber=%d, World=%d, Interior=%d, VehSlots=%d, Admin=%d WHERE AccountID=%d",
Player[playerid][pAccountID],Player[playerid][pUsername],Player[playerid][pPassword],Player[playerid][pMoney],Player[playerid][pLevel],Player[playerid][pSkin],Player[playerid][pHealth],Player[playerid][pArmour],
Player[playerid][pPosX],Player[playerid][pPosY],Player[playerid][pPosZ],Player[playerid][pAngle],Player[playerid][pEthnicity],Player[playerid][pGender],Player[playerid][pAge],Player[playerid][pDefaultSpawn],Player[playerid][pPhoneType],
Player[playerid][pPhoneNumber],Player[playerid][pWorld], Player[playerid][pInterior],Player[playerid][pVehSlots],Player[playerid][pAdmin],x);
mysql_query(query);
SaveContacts(playerid);
}
}
Originally Posted by mkr
You should echo those queries to the console just to be sure. Having phpmyadmin is nice because you can just feed them into it and it'll cough out any error messages that the queries generate.
|
stock SavePlayerAccount(playerid)
{
if(IsPlayerConnected(playerid))
{
new EscapedName[MAX_PLAYER_NAME];
mysql_real_escape_string(GetName(playerid), EscapedName);
//UpdatePlayerVariables(playerid);
if(CheckExist(playerid) == 0)
{
format(query, sizeof(query), "INSERT INTO `Accounts` (Username, Password) VALUES('%s', '%s')",EscapedName, Player[playerid][pPassword]);
mysql_query(query);
Player[playerid][pAccountID] = mysql_insert_id();
}
format(query, sizeof(query), "UPDATE Accounts SET AccountID=%d, Username='%s', Password='%s', Money=%d, Level=%d, Skin=%d, Health=%f, Armour=%f, PosX=%f, PosY=%f, PosZ=%f, Angle=%f, Ethnicity=%d, Gender=%d, Age=%d, DefaultSpawn=%d, PhoneType=%d, PhoneNumber=%d, World=%d, Interior=%d, VehSlots=%d, Admin=%d WHERE AccountID=%d",
Player[playerid][pAccountID],Player[playerid][pUsername],Player[playerid][pPassword],Player[playerid][pMoney],Player[playerid][pLevel],Player[playerid][pSkin],Player[playerid][pHealth],Player[playerid][pArmour],
Player[playerid][pPosX],Player[playerid][pPosY],Player[playerid][pPosZ],Player[playerid][pAngle],Player[playerid][pEthnicity],Player[playerid][pGender],Player[playerid][pAge],Player[playerid][pDefaultSpawn],Player[playerid][pPhoneType],
Player[playerid][pPhoneNumber],Player[playerid][pWorld], Player[playerid][pInterior],Player[playerid][pVehSlots],Player[playerid][pAdmin],Player[playerid][pAccountID]);
mysql_query(query);
SaveContacts(playerid);
}
}
tail -f server_log.txt
Player[playerid][pAccountID] = mysql_insert_id();
stock SavePlayerAccount(playerid)
{
if(IsPlayerConnected(playerid))
{
new EscapedName[MAX_PLAYER_NAME];
mysql_real_escape_string(GetName(playerid), EscapedName);
//UpdatePlayerVariables(playerid);
if(CheckExist(playerid) == 0)
{
format(query, sizeof(query), "INSERT INTO `Accounts` (Username, Password) VALUES('%s', '%s')",EscapedName, Player[playerid][pPassword]);
mysql_query(query);
Player[playerid][pAccountID] = mysql_insert_id();
}
format(query, sizeof(query), "UPDATE Accounts SET AccountID=%d, Username='%s', Password='%s', Money=%d, Level=%d, Skin=%d, Health=%f, Armour=%f, PosX=%f, PosY=%f, PosZ=%f, Angle=%f, Ethnicity=%d, Gender=%d, Age=%d, DefaultSpawn=%d, PhoneType=%d, PhoneNumber=%d, World=%d, Interior=%d, VehSlots=%d, Admin=%d WHERE AccountID=%d",
Player[playerid][pAccountID],Player[playerid][pUsername],Player[playerid][pPassword],Player[playerid][pMoney],Player[playerid][pLevel],Player[playerid][pSkin],Player[playerid][pHealth],Player[playerid][pArmour],
Player[playerid][pPosX],Player[playerid][pPosY],Player[playerid][pPosZ],Player[playerid][pAngle],Player[playerid][pEthnicity],Player[playerid][pGender],Player[playerid][pAge],Player[playerid][pDefaultSpawn],Player[playerid][pPhoneType],
Player[playerid][pPhoneNumber],Player[playerid][pWorld], Player[playerid][pInterior],Player[playerid][pVehSlots],Player[playerid][pAdmin],Player[playerid][pAccountID]);
mysql_query(query);
SaveContacts(playerid);
}
return 1;
}
stock SavePlayerAccount(playerid)
{
if(IsPlayerConnected(playerid))
{
new EscapedName[MAX_PLAYER_NAME];
mysql_real_escape_string(GetName(playerid), EscapedName);
//UpdatePlayerVariables(playerid);
if(CheckExist(playerid) == 0)
{
format(query, sizeof(query), "INSERT INTO `Accounts` (Username, Password) VALUES('%s', '%s')",EscapedName, Player[playerid][pPassword]);
mysql_query(query);
Player[playerid][pAccountID] = mysql_insert_id();
}
format(query, sizeof(query), "UPDATE Accounts SET AccountID=%d, Username='%s', Password='%s', Money=%d, Level=%d, Skin=%d, Health=%f, Armour=%f, PosX=%f, PosY=%f, PosZ=%f, Angle=%f, Ethnicity=%d, Gender=%d, Age=%d, DefaultSpawn=%d, PhoneType=%d, PhoneNumber=%d, World=%d, Interior=%d, VehSlots=%d, Admin=%d WHERE AccountID=%d",
Player[playerid][pAccountID],Player[playerid][pUsername],Player[playerid][pPassword],Player[playerid][pMoney],Player[playerid][pLevel],Player[playerid][pSkin],Player[playerid][pHealth],Player[playerid][pArmour],
Player[playerid][pPosX],Player[playerid][pPosY],Player[playerid][pPosZ],Player[playerid][pAngle],Player[playerid][pEthnicity],Player[playerid][pGender],Player[playerid][pAge],Player[playerid][pDefaultSpawn],Player[playerid][pPhoneType],
Player[playerid][pPhoneNumber],Player[playerid][pWorld], Player[playerid][pInterior],Player[playerid][pVehSlots],Player[playerid][pAdmin],Player[playerid][pAccountID]);
mysql_query(query);
Player[playerid][pAccountID] = mysql_insert_id();
SaveContacts(playerid);
}
return 1;
}
stock SavePlayerAccount(playerid)
{
if(IsPlayerConnected(playerid))
{
new EscapedName[MAX_PLAYER_NAME];
mysql_real_escape_string(GetName(playerid), EscapedName);
//UpdatePlayerVariables(playerid);
if(CheckExist(playerid) == 0)
{
format(query, sizeof(query), "INSERT INTO `Accounts` (Username, Password) VALUES('%s', '%s')",EscapedName, Player[playerid][pPassword]);
mysql_query(query);
Player[playerid][pAccountID] = mysql_insert_id();
}
mysql_query("SELECT AccountID FROM Accounts where Username = '%s'", EscapedName);
mysql_store_result();
Player[playerid][pAccountID] = mysql_fetch_int();
format(query, sizeof(query), "UPDATE Accounts SET AccountID=%d, Username='%s', Password='%s', Money=%d, Level=%d, Skin=%d, Health=%f, Armour=%f, PosX=%f, PosY=%f, PosZ=%f, Angle=%f, Ethnicity=%d, Gender=%d, Age=%d, DefaultSpawn=%d, PhoneType=%d, PhoneNumber=%d, World=%d, Interior=%d, VehSlots=%d, Admin=%d WHERE AccountID=%d",
Player[playerid][pAccountID],Player[playerid][pUsername],Player[playerid][pPassword],Player[playerid][pMoney],Player[playerid][pLevel],Player[playerid][pSkin],Player[playerid][pHealth],Player[playerid][pArmour],
Player[playerid][pPosX],Player[playerid][pPosY],Player[playerid][pPosZ],Player[playerid][pAngle],Player[playerid][pEthnicity],Player[playerid][pGender],Player[playerid][pAge],Player[playerid][pDefaultSpawn],Player[playerid][pPhoneType],
Player[playerid][pPhoneNumber],Player[playerid][pWorld], Player[playerid][pInterior],Player[playerid][pVehSlots],Player[playerid][pAdmin],Player[playerid][pAccountID]);
mysql_query(query);
mysql_free_result();
SaveContacts(playerid);
}
return 1;
}
stock SavePlayerAccount(playerid)
{
if(IsPlayerConnected(playerid))
{
new EscapedName[MAX_PLAYER_NAME];
mysql_real_escape_string(GetName(playerid), EscapedName);
//UpdatePlayerVariables(playerid);
if(CheckExist(playerid) == 0)
{
format(query, sizeof(query), "INSERT INTO `Accounts` (Username, Password) VALUES('%s', '%s')",EscapedName, Player[playerid][pPassword]);
mysql_query(query);
Player[playerid][pAccountID] = mysql_insert_id();
}
if (Player[playerid][pAccountID] == 0) // don't do an extra query if you don't have to
{
mysql_query("SELECT AccountID FROM Accounts where Username = '%s'", EscapedName);
mysql_store_result();
Player[playerid][pAccountID] = mysql_fetch_int();
}
format(query, sizeof(query), "UPDATE Accounts SET AccountID=%d, Username='%s', Password='%s', Money=%d, Level=%d, Skin=%d, Health=%f, Armour=%f, PosX=%f, PosY=%f, PosZ=%f, Angle=%f, Ethnicity=%d, Gender=%d, Age=%d, DefaultSpawn=%d, PhoneType=%d, PhoneNumber=%d, World=%d, Interior=%d, VehSlots=%d, Admin=%d WHERE AccountID=%d",
Player[playerid][pAccountID],Player[playerid][pUsername],Player[playerid][pPassword],Player[playerid][pMoney],Player[playerid][pLevel],Player[playerid][pSkin],Player[playerid][pHealth],Player[playerid][pArmour],
Player[playerid][pPosX],Player[playerid][pPosY],Player[playerid][pPosZ],Player[playerid][pAngle],Player[playerid][pEthnicity],Player[playerid][pGender],Player[playerid][pAge],Player[playerid][pDefaultSpawn],Player[playerid][pPhoneType],
Player[playerid][pPhoneNumber],Player[playerid][pWorld], Player[playerid][pInterior],Player[playerid][pVehSlots],Player[playerid][pAdmin],Player[playerid][pAccountID]);
mysql_query(query);
mysql_free_result();
SaveContacts(playerid);
}
return 1;
}