29.08.2012, 23:08
Ok so here is my problem... I am trying to make a MySQL system but I am a newbie at MySQL and so I don't know how to get around that well... At first the script worked fine, it was saving accounts in the database etc. But i added 3 new parameters (organisation, leader, and rank) and then it just wouldn't save anymore ... I think the problem is in the query's (from what i know they are in charge of writing/reading the database...).
At first I thought that the string size wasn't big enough (it was 200) so I made it 1600 just to check and still nothing ... here are all the querys I have in the gamemode, and i would be greatfull if someone could find the problem and tell me how to solve it...
This is on OnGameModeInit (checks if there is a table present and if not creates it (thats what i read in the tut )
I believe that this one is for checking the last IP (for the auto-login)
This one is for updating the database (i guess)
This one is in the DialogResponse for the login dialog
This one is in the register stock
And this one is in the login stock
thats all the querys in the mod...
Thanks in advance
At first I thought that the string size wasn't big enough (it was 200) so I made it 1600 just to check and still nothing ... here are all the querys I have in the gamemode, and i would be greatfull if someone could find the problem and tell me how to solve it...
This is on OnGameModeInit (checks if there is a table present and if not creates it (thats what i read in the tut )
Код:
mysql_query("CREATE TABLE IF NOT EXISTS playerdata(user VARCHAR(24), password VARCHAR(41), level INT(20), money INT(20), admin INT(5), skin INT(3), org INT(2), lider INT(2), rank INT(2), IP VARCHAR(16) )");
Код:
new query[1600], pname[24]; GetPlayerName(playerid, pname, 24); format(query, sizeof(query), "SELECT IP FROM `playerdata` WHERE user = '%s' LIMIT 1", pname); mysql_query(query);
Код:
new level = GetPlayerScore(playerid); new money = GetPVarInt(playerid, "Novac"); new admin = GetPVarInt(playerid, "Admin"); new skin = GetPVarInt(playerid, "Skin"); new org = GetPVarInt(playerid, "Org"); new lider = GetPVarInt(playerid, "Lider"); new rank = GetPVarInt(playerid, "Rank"); new query[1600], pname[24]; GetPlayerName(playerid, pname, 24); format(query, sizeof(query), "UPDATE playerdata SET level=%d, money=%d, admin=%d, skin=%d, org=%d, lider=%d, rank=%d WHERE user='%s'", level, money, admin, skin, org, lider, rank, pname); mysql_query(query);
Код:
format(query, sizeof(query), "SELECT `user` FROM playerdata WHERE user = '%s' AND password = SHA1('%s')", pname, escapepass); mysql_query(query);
Код:
format(query, sizeof(query), "INSERT INTO playerdata (user, password, level, money, admin, skin, org, lider, rank, IP) VALUES('%s', SHA1('%s'), 1, 5000, 0, 1, 0, 0, 0, '%s')", pname, passwordstring, IP); mysql_query(query);
Код:
format(query, sizeof(query), "SELECT * FROM playerdata WHERE user = '%s'", pname); mysql_query(query);
Thanks in advance