20.07.2011, 16:44
I took from the moderntopia with the r6 plugin the login, register and update system. It doesn't load the data from the database and doesn't save it when i close.
When i close the server i get the "don't send" error.
When i close the server i get the "don't send" error.
pawn Код:
public OnPlayerLogin(playerid,password[])
{
MySQLCheckConnection();
new tmp2[256];
new string2[64];
new playername2[MAX_PLAYER_NAME];
new playernamesplit[3][MAX_PLAYER_NAME];
GetPlayerName(playerid, playername2, sizeof(playername2));
split(playername2, playernamesplit, '_');
MySQLFetchAcctSingle(PlayerInfo[playerid][pSQLID], "Password", PlayerInfo[playerid][pPass]);
if(strcmp(PlayerInfo[playerid][pPass],password, true ) == 0 )
{
mysql_query("SELECT * FROM `users`");
mysql_store_result();
if (mysql_num_rows())
{
new field[64], data[256];
mysql_fetch_row(data);
mysql_fetch_field_row(field, "Level");
PlayerInfo[playerid][pLevel] = strval(field);
mysql_fetch_row(data);
mysql_fetch_field_row(field, "Money");
PlayerInfo[playerid][pMoney] = strval(field);
mysql_fetch_row(data);
mysql_fetch_field_row(field, "Admin");
PlayerInfo[playerid][pAdmin] = strval(field);
mysql_fetch_row(data);
mysql_fetch_field_row(field, "Vip");
PlayerInfo[playerid][pVip] = strval(field);
mysql_fetch_row(data);
mysql_fetch_field_row(field, "Pos_x");
PlayerInfo[playerid][pPos_x] = strval(field);
mysql_fetch_row(data);
mysql_fetch_field_row(field, "Pos_y");
PlayerInfo[playerid][pPos_y] = strval(field);
.
.
.
.
}
mysql_free_result();
}
pawn Код:
public SaveAccount(playerid)
{
if(IsPlayerConnected(playerid))
{
if(gPlayerLogged[playerid])
{
MySQLCheckConnection();
new query[MAX_STRING];
format(query, MAX_STRING, "UPDATE players SET ");
MySQLUpdatePlayerStr(query, PlayerInfo[playerid][pSQLID], "Password", PlayerInfo[playerid][pPass]);
PlayerInfo[playerid][pMoney] = GetPlayerMoney(playerid);
MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Level", PlayerInfo[playerid][pLevel]);
MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Money", PlayerInfo[playerid][pMoney]);
MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Admin", PlayerInfo[playerid][pAdmin]);
MySQLUpdatePlayerInt(query, PlayerInfo[playerid][pSQLID], "Vip", PlayerInfo[playerid][pVip]);
.
.
.
.
MySQLUpdateFinish(query, PlayerInfo[playerid][pSQLID]);
}
}
return 1;
}]