Password to MySQL
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
The size of "Password" in players table is 29 instead of 129. You may as well change it to CHAR(12 as it's a fixed-length string.

---

About the script:

- In "PlayerData" enum, you have to make "Name" and "Password" strings as you currently have them as an integers:
pawn Код:
// in the enumerator:
Name[MAX_PLAYER_NAME],
Password[129],
Since you have "Name", you can get the player's name once on connect so you won't need to keep calling GetPlayerName with a local string.

pawn Код:
// OnPlayerConnect:
GetPlayerName(playerid, PlayerInfo[playerid][Name], MAX_PLAYER_NAME);

// you can use "PlayerInfo[playerid][Name]" as argument in format/mysql_format now.
- Reset player-arrays on connect.

- You don't have the login part correct yet but you are trying to load them in the same callback that is used to retrieve the the unique ID. In "RegisterAccount", you only need:
pawn Код:
PlayerInfo[playerid][ID] = cache_insert_id();
Time to login the player. First of all, you are selecting the "ID" and "Name" from the database when it should have been the "ID" and "Password" instead. In "CheckAccount", you need to store the ID and the password to the variables and compare the passwords in OnDialogResponse. If they do match, execute a query that selects all the data and retrieve the data to store them to variables.

However, I recommend to load the data once (if there are not many columns). A good example that also uses race condition check can be found here: https://raw.githubusercontent.com/pB...stem-cache.pwn
Thank you so much. +rep
Reply


Messages In This Thread
Password to MySQL - by Allura - 02.08.2016, 11:56
Re: Password to MySQL - by Konstantinos - 02.08.2016, 12:12
Re: Password to MySQL - by Allura - 02.08.2016, 12:34
Re: Password to MySQL - by Konstantinos - 02.08.2016, 12:58
Re: Password to MySQL - by Allura - 02.08.2016, 13:37

Forum Jump:


Users browsing this thread: 1 Guest(s)