I don't know why but I just loved the way you asked for help and I'll try to make this a little tutorial as much as I can, and hope It helps you
Okay, one by one.
MySQL has a default parameter you could set, this is (in my opinion) better, as you don't have to even insert the value or have to define a default for it in the script, you just insert everything except it and it automatically takes the default value in the database, so, how do you do this ?
Also, MySQL has a great few hashing methods, so you don't have to actually use Whirpool, I think the most popular one is SHA256, but that's just if you want
Quote:
Originally Posted by Jay_
These are SA-MP gamemodes, not banks. Stating that "Whirlpool is a more secure hash" may not necessarily be incorrect, however, for the data that is stored by a SA-MP server, a salted SHA-256 encryption is more than enough.
|
And about the skin saving, I just edited the two queries in here and noted what I changed
pawn Код:
#define DEFAULT_SKIN (26)
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case LoginDialog:
{
if(!response) Kick(playerid);
new
hashpass[129],
query[100],
playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
WP_Hash(hashpass, sizeof(hashpass), inputtext);
if(!strcmp(hashpass, Player[playerid][Password]))
{
mysql_format(mysql, query, sizeof(query), "SELECT * FROM `accounts` WHERE `Name` = '%e' LIMIT 1", playername);
mysql_tquery(mysql, query, "OnAccountLoad", "i", playerid);
}
else
{
SendClientMessage(playerid, -1, "Incorrect Password, try again.");
ShowPlayerDialog(playerid, LoginDialog, DIALOG_STYLE_PASSWORD, "Sign in", "You seem to have an account on our server. \nPlease, type your password to log in:", "Login", "Quit");
}
}
case RegisterDialog:
{
if(!response) return Kick(playerid);
if(strlen(inputtext) < 5)
{
SendClientMessage(playerid, -1, "Your password needs to have more than 4 characters.");
return ShowPlayerDialog(playerid, RegisterDialog, DIALOG_STYLE_PASSWORD, "Sign up", "Mmm.. seems like you don't have an account. \nPlease, type a password:", "Next", "Quit");
}
new
query[512],
playername[MAX_PLAYER_NAME],
playerip[16];
GetPlayerName(playerid, playername, sizeof(playername));
GetPlayerIp(playerid, playerip, sizeof(playerip));
WP_Hash(Player[playerid][Password], 129, inputtext);
mysql_format(mysql, query, sizeof(query), "INSERT INTO `accounts` (`Name`, `Password`, `IP`, `Admin`, `VIP`, `Money`, `PosX`, `PosY`, `PosZ`, `PosA`, `SkinID`) VALUES ('%e', '%e', '%e', 0, 0, 0, %f, %f, %f, %f, %d)", playername, Player[playerid][Password], playerip, SPAWN_X, SPAWN_Y, SPAWN_Z, SPAWN_A, DEFAULT_SKIN);//Added "`SkinID`", "%d" and "DEFAULT_SKIN"
mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid);
}
}
return 0;
}
public OnPlayerDisconnect(playerid, reason)
{
new
query[128],
Float:Pos[4];
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
GetPlayerFacingAngle(playerid, Pos[3]);
mysql_format(mysql, query, sizeof(query), "UPDATE `accounts` SET `Money` = %d, `PosX` = %f, `PosY` = %f, `PosZ` = %f, `PosA` = %f, `SkinID` = %d WHERE `ID` = %d",
GetPlayerMoney(playerid), Pos[0], Pos[1], Pos[2], Pos[3], GetPlayerSkin(playerid), Player[playerid][ID]);//Added "`SkinID` = %d" and "GetPlayerSkin(playerid)" which returns the skin id
mysql_tquery(mysql, query, "", "");
return 1;
}
One step messing though, which is actually setting the skin to the player, using "SetPlayerSkin(playerid, skinid);" under "OnAccountLoad" but you didn't post this function and I think you can do it.
Don't forget to add the "SkinID" to the database manually and to the creation query(If you got one) in the script.