21.11.2011, 18:41
Ok i have a problem where everytime a player logs on it resets it therestats but i can fix this but i need to know how to load the saved info from the database but im not sure how to any help would be great.
This is how the players info is saved think u might need this.
Many thanks.
Код:
public OnPlayerConnect(playerid) { new lStr[70]; format(lStr, sizeof(lStr), ""#CBLUE"Player: "#CDGREEN"%s(%d) "#CBLUE"has joined the server!", pName(playerid), playerid); SendClientMessageToAll(-1, lStr); ResetPVars(playerid); InitConnection(playerid); return 1; } public OnPlayerDisconnect(playerid, reason) { new dStr[70]; format(dStr, sizeof(dStr), ""#CBLUE"Player: "#CDGREEN"%s(%d) "#CBLUE"has left the server!", pName(playerid), playerid); SendClientMessageToAll(-1, dStr); GetPlayerPos(playerid, PVar[playerid][pLastX], PVar[playerid][pLastY], PVar[playerid][pLastZ]); SavePInfo(playerid); return 1; }
Код:
stock SavePInfo(playerid) { if(GetPVarInt(playerid, "LoggedIN") == 1) { new Query[600]; format(Query, sizeof(Query), "UPDATE `playerinfo` SET `kills` = %d, `deaths` = %d, `money` = %d, `Level` = %d, `Last Pos X` = %f, `Last Pos Y` = %f, `Last Pos Z` = %f, `Interior` = %d, `score` = %d WHERE `user` = '%s'", // Also remember to update this... PVar[playerid][pKills], PVar[playerid][pDeaths], GetPlayerMoney(playerid), PVar[playerid][pLevel], PVar[playerid][pLastX], PVar[playerid][pLastY], PVar[playerid][pLastZ], GetPlayerInterior(playerid), PVar[playerid][pScore], pName(playerid)); mysql_query(Query); mysql_free_result(); return 1; } else return 0; }