mysql mixes variables
#1

Basicly my MYSQL is mixing up variables. e.g:
Adminlevel 0, money: 500.
After logout: adminlevel 500, money: 0 (and not, nothing changed IG with a command or what so ever)
This happens to all of the variables.

Accounts saving (update)

Код:
    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',Spawn2='%f',Spawn3='%f',Spawn4='%f',Spawn5=%i,Reg=%i,Sex=%i,Wallet=%i,Renting=%i,Products=%i,PhoneNumber=%i,Minutes=%i,Spawn6=%i,Arrested=%i,Prisoned=%i,Jailed=%i,JailTime=%i, \
	Cell=%i,Towe=%i,License=%i,Linked=%i,ForumName='%s',ForumPassword='%s',wLicense=%i,Job=%i,Donator=%i,CarParts=%i,PlayingTime=%i,FightingStyle=%i 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],AccountData[playerid][Spawn][2],AccountData[playerid][Spawn][3],
	AccountData[playerid][InteriorSpawn],AccountData[playerid][Reg],AccountData[playerid][Sex],GetPlayerWalletCash(playerid),AccountData[playerid][Renting],AccountData[playerid][Products],
	AccountData[playerid][PhoneNumber],AccountData[playerid][Minutes],AccountData[playerid][WorldSpawn],AccountData[playerid][Arrested],AccountData[playerid][Prisoned],AccountData[playerid][Jailed],
	AccountData[playerid][JailTime],AccountData[playerid][Cell],AccountData[playerid][Towe],AccountData[playerid][License], 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);
Account adding:

Код:
	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);
Everything is good, so says the mysql log (succesfully executed). But still he switches all variables.

MYSQL Log: Creating account:
Код:
[21:00:36] CMySQLHandler::ProcessQueryThread(UPDATE Accounts SET AdminLevel=0,Money=500,Bank=500,Faction=500,Rank=999,HouseKey=999,BizKey=999,Skin=101,Spawn1='0.000000',Spawn2='0.000000',Spawn3='0.000000',Spawn4='0.000000',Spawn5=0,Reg=1,Sex=1,Wallet=200,Renting=0,Products=0,PhoneNumber=1,Minutes=999,Spawn6=0,Arrested=0,Prisoned=0,Jailed=0,JailTime=0, Cell=0,Towe=0,License=0,Linked=0,ForumName='',ForumPassword='',wLicense=0,Job=0,Donator=0,CarParts=0,PlayingTime=0,FightingStyle=0 WHERE Name = 'Charles Luton') - Data is getting passed to OnQueryFinish() - (Threadsafe: Yes)
Re-logging

Код:
[21:04:16] CMySQLHandler::ProcessQueryThread(UPDATE Accounts SET AdminLevel=1,Money=0,Bank=400,Faction=500,Rank=500,HouseKey=999,BizKey=999,Skin=101,Spawn1='1975.704589',Spawn2='-1965.959838',Spawn3='15.785546',Spawn4='206.144805',Spawn5=0,Reg=1,Sex=300,Wallet=0,Renting=1,Products=999,PhoneNumber=0,Minutes=999,Spawn6=0,Arrested=0,Prisoned=0,Jailed=0,JailTime=0, Cell=0,Towe=0,License=0,Linked=0,ForumName='',ForumPassword='',wLicense=0,Job=0,Donator=0,CarParts=0,PlayingTime=1,FightingStyle=0 WHERE Name = 'Charles Luton') - Data is getting passed to OnQueryFinish() - (Threadsafe: Yes)
Voor logging in he takes the variables of the last log out ofc.
Reply
#2

Show the loading part.
Reply
#3

Код:
function SetPlayerVariables(playerid) {
	format(string, sizeof(string), "SELECT * FROM Accounts WHERE Name = '%s'", GetUserName(playerid));
	mysql_query(string);
	mysql_store_result();
	new data[40][128];
 	mysql_fetch_row_format(string, "|");
 	explode(data, string, "|");
	AccountData[playerid][AdminLevel] = strval(data[2]);
	AccountData[playerid][Money] = strval(data[3]);
	AccountData[playerid][Bank] = strval(data[4]);
	AccountData[playerid][Faction] = strval(data[5]);
	AccountData[playerid][Rank] = strval(data[6]);
	AccountData[playerid][HouseKey] = strval(data[7]);
	AccountData[playerid][BizKey] = strval(data[8]);
	AccountData[playerid][Skin] = strval(data[9]);
	AccountData[playerid][Spawn][0] = floatstr(data[10]);
	AccountData[playerid][Spawn][1] = floatstr(data[11]);
	AccountData[playerid][Spawn][2] = floatstr(data[12]);
	AccountData[playerid][Spawn][3] = floatstr(data[13]);
	AccountData[playerid][InteriorSpawn] = strval(data[14]);
	AccountData[playerid][Reg] = strval(data[15]);
	AccountData[playerid][Sex] = strval(data[16]);
	AccountData[playerid][Wallet] = strval(data[17]);
	AccountData[playerid][Renting] = strval(data[18]);
	AccountData[playerid][Products] = strval(data[19]);
	AccountData[playerid][PhoneNumber] = strval(data[20]);
	AccountData[playerid][Minutes] = strval(data[21]);
	AccountData[playerid][WorldSpawn] = strval(data[22]);
	AccountData[playerid][Arrested] = strval(data[23]);
	AccountData[playerid][Prisoned] = strval(data[24]);
	AccountData[playerid][Jailed] = strval(data[25]);
	AccountData[playerid][JailTime] = strval(data[26]);
	AccountData[playerid][Cell] = strval(data[27]);
	AccountData[playerid][Towe] = strval(data[28]);
	AccountData[playerid][License] = strval(data[29]);
	AccountData[playerid][Linked] = strval(data[30]);
	strmid(AccountData[playerid][ForumName], data[31], 0, strlen(data[31]), 255);
	strmid(AccountData[playerid][ForumPassword], data[32], 0, strlen(data[32]), 255);
	AccountData[playerid][wLicense] = strval(data[33]);
	AccountData[playerid][pJob] = strval(data[34]);
	AccountData[playerid][Donator] = strval(data[35]);
	AccountData[playerid][CarParts] = strval(data[36]);
	AccountData[playerid][PlayingTime] = strval(data[37]);
	AccountData[playerid][FightingStyle] = strval(data[38]);
	AccountData[playerid][Materials] = strval(data[39]);
}
Reply
#4

That happened me long time ago, the only way you can fix it is to look good at your LOAD / SAVE functions and to see that everything is written right.
In mine I had few problems as yours, It's something in one of those functions or check your MySQL database and see If you have the same vars as in your LOAD / SAVE functions.
Reply
#5

But the problem occurs when logging out, and it appears that there is no wrong-written things in the saving parts..
Reply
#6

Show me your OnPlayerDisconnect callback.
Reply
#7

public OnPlayerDisconnect(playerid)
{
if(IsPlayerLoggedIn(playerid)) {
SaveAccount(playerid);
}
}
Reply
#8

It looks fine, you even used If logged in or not, the only problem is in SaveAccount function;
I had a porblem as this, fixed it as I told you.
Reply
#9

The thing is, I can't find the problem in the SaveAccount function
Reply
#10

Think I found the problem!

EDIT::

Nevermind.. False alarm, still not working.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)