[help]Mysql login problem
#1

Hello, I have a problem, in the database do i make changes and saved, when he entered the game changes have not been applied. thank you.

stock MySQL_Login(playerid)
{
new query[300], pname[24], savingstring[256];
GetPlayerName(playerid, pname, 24);
format(query, sizeof(query), "SELECT * FROM playerdata WHERE user = '%s'", pname);
mysql_query(query);
mysql_store_result();

mysql_fetch_field_row(savingstring, "scores"); SetPlayerScore(playerid, strval(savingstring));
mysql_fetch_field_row(savingstring, "money"); GivePlayerMoney(playerid, strval(savingstring));
mysql_fetch_field_row(savingstring, "adminlevel"); PlayerInfo[playerid][pAdmin] = strval(savingstring);
mysql_fetch_field_row(savingstring, "helperlevel"); PlayerInfo[playerid][pHelper] = strval(savingstring);
mysql_fetch_field_row(savingstring, "kills"); PlayerInfo[playerid][pKills] = strval(savingstring);
mysql_fetch_field_row(savingstring, "deaths"); PlayerInfo[playerid][pDeaths] = strval(savingstring);

mysql_free_result();
MySQL_vLogin(playerid); //vip log in
PlayerInfo[playerid][pLogged] = 1;
return 1;
}
Reply
#2

Are you saving the results? The stock MySQL_Login(playerid) is designed to fetch the table information from MYSQL, however are you saving the tables properly? If so please show us the lines in that area.
Reply
#3

Quote:
Originally Posted by Phaze
Посмотреть сообщение
Are you saving the results? The stock MySQL_Login(playerid) is designed to fetch the table information from MYSQL, however are you saving the tables properly? If so please show us the lines in that area.
mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_DB, MYSQL_PASS);
mysql_query("CREATE TABLE IF NOT EXISTS playerdata(user VARCHAR(24), password VARCHAR(40), IP VARCHAR(16), money INT(20), scores INT(30), adminlevel INT(10), helperlevel INT(10), kills INT(20), deaths INT(20), viplevel INT(10))");
mysql_query("CREATE TABLE IF NOT EXISTS bandata(admin VARCHAR(20), player VARCHAR(20), reason VARCHAR(50), IP VARCHAR(16), banned INT(10))");
mysql_query("CREATE TABLE IF NOT EXISTS vipdata(player VARCHAR(20), viplevel INT(10))");
mysql_debug();
CreateConfig();

Reply
#4

You are getting those lines from the database file, I'm talking about the actual script.
Reply
#5

Quote:
Originally Posted by Phaze
Посмотреть сообщение
You are getting those lines from the database file, I'm talking about the actual script.
stock MySQL_Login(playerid)
{
new query[300], pname[24], savingstring[256];
GetPlayerName(playerid, pname, 24);
format(query, sizeof(query), "SELECT * FROM playerdata WHERE user = '%s'", pname);
mysql_query(query);
mysql_store_result();

mysql_fetch_field_row(savingstring, "scores"); SetPlayerScore(playerid, strval(savingstring));
mysql_fetch_field_row(savingstring, "money"); GivePlayerMoney(playerid, strval(savingstring));
mysql_fetch_field_row(savingstring, "adminlevel"); PlayerInfo[playerid][pAdmin] = strval(savingstring);
mysql_fetch_field_row(savingstring, "helperlevel"); PlayerInfo[playerid][pHelper] = strval(savingstring);
mysql_fetch_field_row(savingstring, "kills"); PlayerInfo[playerid][pKills] = strval(savingstring);
mysql_fetch_field_row(savingstring, "deaths"); PlayerInfo[playerid][pDeaths] = strval(savingstring);

mysql_free_result();
MySQL_vLogin(playerid); //vip log in
PlayerInfo[playerid][pLogged] = 1;
return 1;
}

stock MySQL_vLogin(playerid)
{
new query[300], pname[24], savingstring[20];
GetPlayerName(playerid, pname, 24);
format(query, sizeof(query), "SELECT * FROM vipdata WHERE player = '%s'", pname);
mysql_query(query);
mysql_store_result();
while(mysql_fetch_row_format(query,"|"))
{
mysql_fetch_field_row(savingstring, "viplevel"); PlayerInfo[playerid][pVIP] = strval(savingstring);
}
mysql_free_result();
return 1;
}

stock MySQL_Save(playerid)
{
if(PlayerInfo[playerid][pLogged] == 1)
{
if(PlayerInfo[playerid][pVIP] >= 1)
{
new query[200], viplevel = PlayerInfo[playerid][pVIP];
format(query, sizeof(query),"UPDATE `vipdata` SET `viplevel`='%d' WHERE `player`='%s'", viplevel, PlayerName(playerid));
mysql_query(query);
}
new query[200], scores = GetPlayerScore(playerid), money = GetPlayerMoney(playerid), level = PlayerInfo[playerid][pAdmin], helper = PlayerInfo[playerid][pHelper], kills = PlayerInfo[playerid][pKills], deaths = PlayerInfo[playerid][pDeaths];
format(query, sizeof(query),"UPDATE `playerdata` SET `scores`='%d', `kills`='%d' ,`deaths`='%d' ,`money`='%d' ,`adminlevel`='%d' , `helperlevel`='%d' WHERE `user`='%s'",scores, kills, deaths, money, level, helper, PlayerName(playerid));
mysql_query(query);
}
return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)