Variables mix up
#1

Hey guys,

My MYSQL db is working all fine.
Well, almost. Basicly when a player registers it creates variables (and with /stats it shows the right variables).
Altough when the player relogs (log out and back in by quitting the game) the /stats variables mix up.
Sometimes 0 replaces them!
But when I take a look at my MYSQL columns and check a player's variable it shows me the correct numbers!

Here's the function that makes a mysql column after a player registered.

Код:
function AddAccount(name[],password[]) {
	mysql_real_escape_string(password, SQLEscape[Escape][0]);
	format(string,sizeof(string), "INSERT INTO `Accounts` (`Name`, `Password`, `AdminLevel`, `Money`, `Bank`, `Faction`, `Rank`, `HouseKey`, `BizKey`, `Skin`, `Spawn1`, `Spawn2`, `Spawn3`, `Spawn4`, `Spawn5`, `Reg`, `Sex`, `Wallet`, `Renting`, `PhoneNumber`, `Minutes`, `Cell`) VALUES('%s',md5('%s'), 0,500,500,999,999,999,999,101, 1981.7389,-1962.9572,16.6941, 359.3499, 0,0, 300, 500,200,0, 0, 1)",
	name, SQLEscape[Escape][0]);
	mysql_query(string);
    format(string,sizeof(string), "INSERT INTO `Weapons` (`Name`) VALUES('%s')", name);
	mysql_query(string);
	
	format(string,sizeof(string), "INSERT INTO `WeaponsAmmo` (`Name`) VALUES('%s')", name);
	mysql_query(string);
	
	format(string,sizeof(string), "INSERT INTO `Drugs` (`Name`) VALUES('%s')", name);
	mysql_query(string);
	
	for(new i = 0; i < 10; i ++ ) {
        format(string,sizeof(string), "INSERT INTO `phone_contacts` (`Name`) VALUES('%s')", name);
		mysql_query(string);
	}
	
	format(string,sizeof(string), "INSERT INTO `scholarships` (`Name`) VALUES('%s')", name);
	mysql_query(string);
}
This is the function that will be called when a player logs out and whenever a variable changes;

Код:
function SaveAccount(playerid) {
    GetPlayerPos(playerid, AccountData[playerid][Spawn][0],AccountData[playerid][Spawn][1],AccountData[playerid][Spawn][2]);
    GetPlayerFacingAngle(playerid, AccountData[playerid][Spawn][3]);
    AccountData[playerid][InteriorSpawn] = GetPlayerInterior(playerid);
    AccountData[playerid][WorldSpawn] = GetPlayerVirtualWorld(playerid);
    format(string,sizeof(string), "UPDATE `Accounts` SET `AdminLevel` = %i,`Money` = %i, `Bank` = %i, `Faction` = %i, `Rank` = %i, `HouseKey` = %i, `BizKey` = %i, `Skin` = %i, `Spawn1` = '%f', WHERE `Name` = '%s'",
    AccountData[playerid][AdminLevel],GetPlayerCash(playerid),AccountData[playerid][Bank],
	AccountData[playerid][Faction],AccountData[playerid][Rank],AccountData[playerid][HouseKey],
	AccountData[playerid][BizKey],GetPlayerSkin(playerid),AccountData[playerid][Spawn][0],AccountData[playerid][Spawn][1],GetUserName(playerid));
	mysql_query(string, MYSQL_SAVE_USERS);
	
	format(string,sizeof(string), "UPDATE `Accounts` SET `Spawn2` = '%f', `Spawn3` = '%f', `Spawn4` = '%f', `Spawn5` = %i, `Reg` = %i, `Sex` = %i, `Wallet` = %i, `Renting` = %i, WHERE `Name` = '%s'",
	AccountData[playerid][Spawn][2],AccountData[playerid][Spawn][3],
	AccountData[playerid][InteriorSpawn],AccountData[playerid][Reg],AccountData[playerid][Sex],GetPlayerWalletCash(playerid),AccountData[playerid][Renting],GetUserName(playerid));
	mysql_query(string, MYSQL_SAVE_USERS);
	
	format(string,sizeof(string), "UPDATE `Accounts` SET `Products` = %i, `PhoneNumber` = %i, `Minutes` = %i, `Spawn6` = %i, `Arrested` = %i, `Prisoned` = %i, WHERE `Name` = '%s'",
	AccountData[playerid][Products],
	AccountData[playerid][PhoneNumber],AccountData[playerid][Minutes],AccountData[playerid][WorldSpawn],AccountData[playerid][Arrested],AccountData[playerid][Prisoned],GetUserName(playerid));
	mysql_query(string, MYSQL_SAVE_USERS);
	
	format(string,sizeof(string), "UPDATE `Accounts` SET `Jailed` = %i, `JailTime` = %i, `Cell` = %i, `Towe` = %i, `License` = %i, WHERE `Name` = '%s'",
	AccountData[playerid][Jailed],
	AccountData[playerid][JailTime],AccountData[playerid][Cell],AccountData[playerid][Towe],AccountData[playerid][License],GetUserName(playerid));
	mysql_query(string, MYSQL_SAVE_USERS);
	
	format(string,sizeof(string), "UPDATE `Accounts` SET `Linked` = %i, `ForumName` = '%s', `ForumPassword` = '%s', `wLicense` = %i, `Job` = %i, `Donator` = %i, `CarParts` = %i, `PlayingTime` = %i, `FightingStyle` = %i, WHERE `Name` = '%s'",
	AccountData[playerid][Linked], AccountData[playerid][ForumName],
	AccountData[playerid][ForumPassword],AccountData[playerid][wLicense],AccountData[playerid][pJob], AccountData[playerid][Donator], AccountData[playerid][CarParts], AccountData[playerid][PlayingTime],
	AccountData[playerid][FightingStyle],GetUserName(playerid));
	mysql_query(string, MYSQL_SAVE_USERS);
	
	format(string,sizeof(string), "UPDATE `Accounts` SET `Materials` = %i WHERE `Name` = '%s'",
    AccountData[playerid][Materials],GetUserName(playerid));
	mysql_query(string, MYSQL_SAVE_USERS);
	
	format(string, sizeof(string), "UPDATE `enrolled` SET `Classes` = %i WHERE `Name` = '%s'", AccountData[playerid][Classes],
	GetUserName(playerid));
	mysql_query(string);
	
	format(string, sizeof(string), "UPDATE `scholarships` SET `Psychology` = %i,`Criminal_Justice` = %i,`Medicine` = %i WHERE `Name` = '%s'", UniversityData[playerid][Psychology], UniversityData[playerid][Criminal_Justice],
	UniversityData[playerid][Medicine],GetUserName(playerid));
	mysql_query(string);
	
	format(string, sizeof(string), "UPDATE `drugs` SET `Cocaine` = %d,`Crack` = %d,`Heroin` = %d,`Hydrocodone` = %d,\
	`Inhalants` = %d,`LSD` = %d,`Marijuana` = %d,`MDMA` = %d,`Methamphetamine` = %d,`Anabolic_Steroids` = %d,`Needles` = %d,`Blunts` = %d WHERE `Name` = '%s'",
	PlayerDrugData[playerid][Cocaine],PlayerDrugData[playerid][Crack],PlayerDrugData[playerid][Heroin],PlayerDrugData[playerid][Hydrocodone],
	PlayerDrugData[playerid][Inhalants],PlayerDrugData[playerid][LSD],PlayerDrugData[playerid][Marijuana],PlayerDrugData[playerid][MDMA],
	PlayerDrugData[playerid][Methamphetamine],PlayerDrugData[playerid][Anabolic_Steroids],PlayerDrugData[playerid][Needles],PlayerDrugData[playerid][Blunts],GetUserName(playerid));
	mysql_query(string);
	
	format(string, sizeof(string), "UPDATE `Settings` SET `Turfs` = %i,`SAN` = %i,`Phone` = %i,`Room` = %i WHERE `Name` = '%s'", PlayerSettingsData[playerid][TurfTog], PlayerSettingsData[playerid][SANTog],
	PlayerSettingsData[playerid][PhoneTog], PlayerSettingsData[playerid][RoomTog],GetUserName(playerid));
	mysql_query(string);
	
 	SavePlayerWeapons(playerid);
	SavePlayerWeaponsAmmo(playerid);
}
Any ideas?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)