22.01.2017, 01:36
When i created my account. It don't call "OnAccountLoad" Or "OnAccountRegister".
It calls 'OnAccountCheck". When i join the server i register put in my password. then again i joined the server it still saids i need to register. what the problem can be?
my server log saids:
Passed to connect to database! (so it is connected to mysql).
On Top Gamemode:
OnPlayerConnect:
OnPlayerDisconnect:
Database Screenshot:
It calls 'OnAccountCheck". When i join the server i register put in my password. then again i joined the server it still saids i need to register. what the problem can be?
Код:
enum pInfo { pAdmin, pWork, StartingPoint, EndingPoint, pVIP, pConvoy, MissionID, ID, Password[129], VIP, Score, Money, } new PlayerInfo[MAX_PLAYERS][pInfo];
Passed to connect to database! (so it is connected to mysql).
On Top Gamemode:
Код:
static Name[MAX_PLAYERS][24];
Код:
new query[128]; mysql_format(mysql, query, sizeof(query), "SELECT `Password`, `ID` FROM `accounts` WHERE `Name` = '%e' LIMIT 1", Name[playerid]); mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);
Код:
new query[128], pname[MAX_PLAYER_NAME], string[39 + MAX_PLAYER_NAME]; mysql_format(mysql, query, sizeof(query), "UPDATE `accounts` SET `Score`= %i WHERE `ID` = '%d'", GetPlayerScore(playerid), PlayerInfo[playerid][ID]); mysql_tquery(mysql, query, "", "");
Код:
public OnAccountCheck(playerid) { new rows; //a variable that will be used to retrieve rows and fields in the database. cache_get_row_count(rows);//let's get the rows and fields from the database. if(rows) //if there is row {//then cache_get_value_name(0, "Password", PlayerInfo[playerid][Password], 129); //we will load player's password into pInfo[playerid][Password] to be used in logging in cache_get_value_name_int(0, "ID", PlayerInfo[playerid][ID]); //now let's load player's ID into pInfo[playerid][ID] so we can use it later printf("%s", PlayerInfo[playerid][Password]); //OPTIONAL: Just for debugging. If it didn't show your password, then there must be something wrong while getting player's password ShowPlayerDialog(playerid, dlogin, DIALOG_STYLE_INPUT, "Login", "In order to play, you need to login", "Login", "Quit"); //And since we found a result from the database, which means, there is an account; we will show a login dialog } else //if we didn't find any rows from the database, that means, no accounts were found { ShowPlayerDialog(playerid, dregister, DIALOG_STYLE_INPUT, "TruckingWorld: {FFFF00}Register", "In order to play, you need to register.", "Register", "Quit"); //So we show them a dialog register } return 1; } forward OnAccountLoad(playerid); public OnAccountLoad(playerid) { cache_get_value_name_int(0, "Admin", PlayerInfo[playerid][pAdmin]); cache_get_value_name_int(0, "VIP", PlayerInfo[playerid][pVIP]); cache_get_value_name_int(0, "Score", PlayerInfo[playerid][Score]); cache_get_value_name_int(0, "Money", PlayerInfo[playerid][Money]); GivePlayerMoney(playerid, PlayerInfo[playerid][Money]); SendClientMessage(playerid, -1, "You have successfully logged in."); return true; } forward OnAccountRegister(playerid); public OnAccountRegister(playerid) { PlayerInfo[playerid][ID] = cache_insert_id(); //loads the ID of the player in the variable once they registered. printf("TW Account ID: %d", PlayerInfo[playerid][ID]); //just for debugging. return 1; }