PDA

View Full Version : Stupid mysql problem.


MythicalMarauder
08/01/2015, 06:34 AM
I've been struggling with this bug for weeks.. Can't find any solution to it.

http://i.imgur.com/Y5TDKLr.png?1

It sets either random values or it copies this from another account, for example, my account is admin 4 and 50 kills with 17 death, when someone registers, it takes my data and inserts it into his account?! I fixed this by using WHERE uid=%d instead of WHERE user='%s'. But now it saves data for the previous account.. Can someone please help me? This is my SavePlayer function:


stock SavePlayer(playerid)
{
if(Logged[playerid] == 1)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
new query[300];
format(query, sizeof(query), "UPDATE playerdata SET `score`='%d', `money`='%d', `level`='%d', `kills`='%d', `deaths`='%d', `vip`='%d', `clan`='%d', `clanposition`='%d', `logins`='%d',`banned`='%d' WHERE user='%s'",
pInfo[playerid][pScore],
GetPlayerMoney(playerid),
pInfo[playerid][pAdmin],
pInfo[playerid][pKills],
pInfo[playerid][pDeaths],
pInfo[playerid][pVIP],
pInfo[playerid][pClan],
pInfo[playerid][pClanP],
pInfo[playerid][pLogins],
pInfo[playerid][pBanned],
name);
mysql_query(query);
Logged[playerid] = 0;
printf("%s", query);
}
}

Thewin
08/01/2015, 06:52 AM
You have a function that cleans all variables player that connects?

MythicalMarauder
08/01/2015, 06:57 AM
You have a function that cleans all variables player that connects?

Nope I don't.

Thewin
08/01/2015, 06:58 AM
Make this and try.

MythicalMarauder
08/01/2015, 07:02 AM
Make this and try.

Alright done that. Now I have to wait for more players to register to ensure it works.

Thewin
08/01/2015, 07:08 AM
Okay, remember to clean all the variables that you are implementing in the future.