MySQL refuse to load position & skin -
BizzyD - 10.08.2014
Hello, got a problem with my reg & login system. It refuses to load the stats. You spawn where the camera is. And your skin is cj. It saves fine, but when I login. It changes the stats for some reason. No errors in mysql.log.
This is the saveplayer code:
Код:
public SavePlayer(playerid) //
{
new IP[20];
new Float: X, Float: Y, Float: Z;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerIp(playerid, IP, 20);
PlayerInfo[playerid][pSkin] = GetPlayerSkin(playerid);
new Query[500];
new QueryFinal[1500] = "UPDATE `playerdata` SET ";
format(Query, sizeof(Query), "`username`='%s',`Admin`=%d,`Level`=%d, `Hours`=%d, `Skin`=%d, `Sex`=%d, `Talent`=%d, `Pos_x`='%f',`Pos_y`='%f',`Pos_z`='%f', `IP`='%s' WHERE `Username`='%s'",
ReturnPlayerName(playerid),
PlayerInfo[playerid][pAdmin],
PlayerInfo[playerid][pLevel],
PlayerInfo[playerid][pPlayTime],
PlayerInfo[playerid][pSkin],
PlayerInfo[playerid][pSex],
PlayerInfo[playerid][pTalent],
X, Y, Z,
IP, ReturnPlayerName(playerid)); strcat(QueryFinal, Query);
mysql_function_query(conn, QueryFinal, false, "OnQuerySend", "");
return 1;
}
OnPlayerDisconnect
Код:
public OnPlayerDisconnect(playerid, reason)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid,x,y,z);
SavePlayer(playerid);
gPlayerLogged[playerid] = 0;
And the login parts:
Код:
LoginPlayer(playerid, password[]) // Custom
{
new Query[128];
format(Query, sizeof(Query), "SELECT * FROM `playerdata` WHERE username='%s' AND password=MD5('%s')", ReturnPlayerName(playerid), password);
mysql_function_query(conn, Query, true, "LoginPlayerProcessed", "is", playerid, password);
return 1;
}
public LoginPlayerProcessed(playerid, password[]) // Custom
{
new rows, fields;
cache_get_data(rows, fields, conn);
if(!rows)
{
SendClientMessage(playerid, COLOR_RED, "Your password is incorrect. Please try again. Multiple wrong attempts could have you banned.");
ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD, "Welcome back!", "Welcome back!\n\nType in your password below to login", "Login", "Leave");
return 1;
}
if(rows)
{
PlayerInfo[playerid][pAdmin] = cache_get_field_content_int(0, "Admin", conn);
PlayerInfo[playerid][pLevel] = cache_get_field_content_int(0, "Level", conn);
PlayerInfo[playerid][pPlayTime] = cache_get_field_content_int(0, "Hours", conn);
PlayerInfo[playerid][pSkin] = cache_get_field_content_int(0, "Skin", conn);
PlayerInfo[playerid][pSex] = cache_get_field_content_int(0, "Sex", conn);
PlayerInfo[playerid][pTalent] = cache_get_field_content_int(0, "Talent", conn);
PlayerInfo[playerid][pPos_x] = cache_get_field_content_float(0, "Pos_x", conn);
PlayerInfo[playerid][pPos_y] = cache_get_field_content_float(0, "Pos_y", conn);
PlayerInfo[playerid][pPos_z] = cache_get_field_content_float(0, "Pos_z", conn);
SendClientMessage(playerid, RED, "Please wait... Initilising your connection..");
SendClientMessage(playerid, COLOR_WHITE, "You have successfully logged in and your stats have been loaded.");
SetTimerEx("login_wait", 3000, 0, "i", playerid);
}
return 1;
}
forward login_wait(playerid);
public login_wait(playerid)
{
SetSpawnInfo(playerid, 0, PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z], 0.0, 0, 0,0, 0, 0, 0);
SpawnPlayer(playerid);
return 1;
}
It seems like it refuses to load the stats for some reason. As I said, no errors in mysql.log. Using BlueGs R33 plugin.
any help is appreciated!
thanks.
Re: MySQL refuse to load position & skin -
Kaperstone - 10.08.2014
Did you check if the data in the database change ?
Re: MySQL refuse to load position & skin -
BizzyD - 10.08.2014
Yea it does. But when i login it sets my skin & pos in database to 0 and position where the camera is.
Re: MySQL refuse to load position & skin -
iryston - 10.08.2014
When you logout, save data correct? u Check in database?
and when you login LoadData correct, but same time, just Skin and Position X Y Z, set 0 in database?
Re: MySQL refuse to load position & skin -
BizzyD - 10.08.2014
Yea it saves correctly. But when I login it changes to 0 and the position.
Re: MySQL refuse to load position & skin -
BizzyD - 10.08.2014
Fixed it!