24.10.2013, 13:37
Hello, I got some problems with the mysql on my script. It wont save/load the data.
This is the debug:
No idea whats wrong. My skin,money or position wont save/load.
This is the debug:
Код:
[17:45:55] >> mysql_query( Connection handle: 1 ) [17:45:55] CMySQLHandler::Query(UPDATE `playerinfo` SET `level` = 0, `Skin` = 288, `money` = 0, `Admin` = 6, `Last Pos X` = 91.929710, `Last Pos Y` = 205.167037, `Last Pos Z` = -46.045261, `Interior` = 0, `Dlic` = 0, `Wlic` = 0 WHERE `user` = 'Dean_Summers') - Successfully executed. [17:45:55] >> mysql_free_result( Connection handle: 1 ) [17:45:55] CMySQLHandler::FreeResult() - The result is already empty.
pawn Код:
stock SavePInfo(playerid)
{
if(GetPVarInt(playerid, "LoggedIN") == 1)
{
GetPlayerPos(playerid, PVar[playerid][pPos_x], PVar[playerid][pPos_y], PVar[playerid][pPos_z]);
PVar[playerid][pSkin] = GetPlayerSkin(playerid);
PVar[playerid][pMoney] = GetPlayerMoney(playerid);
new
Query[1000];
format(Query, sizeof(Query), "UPDATE `playerinfo` SET `level` = %d, `Skin` = %d, `money` = %d, `Admin` = %d, `Last Pos X` = %f, `Last Pos Y` = %f, `Last Pos Z` = %f, `Interior` = %d, `Dlic` = %d, `Wlic` = %d WHERE `user` = '%s'", // Also remember to update this...
PVar[playerid][pLevel],
PVar[playerid][pSkin],
GetPlayerMoney(playerid),
PVar[playerid][pAdmin],
PVar[playerid][pPos_x],
PVar[playerid][pPos_y],
PVar[playerid][pPos_z],
GetPlayerInterior(playerid),
PVar[playerid][pDlic],
PVar[playerid][pWlic],
pName(playerid));
mysql_query(Query);
mysql_free_result();
return 1;
}
else return 0;
}
pawn Код:
case LOGIN:
{
if(!response)
{
format(Msg, sizeof(Msg), ""#CBLUE"Player: "#CORANGE"%s(%d) "#CBLUE"has been kicked - Reason: Not loggin in!", pName(playerid), playerid);
SendClientMessageToAll(COLOR_GREY, Msg);
Kick(playerid);
}
else
{
if(!strlen(inputtext)) DialogInput(playerid, LOGIN, ""#CCADET"Account Login", ""#CYELLOW"You must enter a password below to continue!", "Login", "Leave");
new
EscPass[38],
Query[128];
mysql_real_escape_string(inputtext, EscPass);
format(Query, sizeof(Query), "SELECT * FROM `playerinfo` WHERE `user` = '%s' AND `password` = md5('%s')", pName(playerid), EscPass);
mysql_query(Query);
mysql_store_result();
if(mysql_num_rows() > 0)
{
LoadPlayerInfo(playerid);
SetPVarInt(playerid, "LoggedIN", 1);
SpawnPlayer(playerid);
SendClientMessage(playerid, COLOR_CADETBLUE, "You have been logged in");
}
else
{
SendClientMessage(playerid, COLOR_RED, "You have entered an incorrect password, try again!");
DialogInput(playerid, LOGIN, ""#CCADET"Account Login", ""#CYELLOW"You have 3 chances to enter a correct password..", "Login", "Leave");
}
}
}
}
return 1;
}
pawn Код:
stock LoadStats(playerid)
{
SetPlayerPos(playerid, PVar[playerid][pPos_x], PVar[playerid][pPos_y], PVar[playerid][pPos_z]);
SetPlayerInterior(playerid, PVar[playerid][pInt]);
SetPlayerScore(playerid, PVar[playerid][pLevel]);
SetPlayerSkin(playerid, PVar[playerid][pSkin]);
GivePlayerMoney(playerid, PVar[playerid][pMoney]);
SetPlayerColor(playerid, COLOR_WHITE);
return 1;
}