stock SaveAccount(playerid)
{
if(LoggingIn[playerid] == 1) return 0;
new query[300], Float:pos[3], Float:Angle;
GetPlayerPos(playerid, pos[0],pos[1],pos[2]);
GetPlayerFacingAngle(playerid, Angle);
format(query, sizeof(query), "UPDATE `accounts` SET Admin='%d', Sex='%d', Skin='%d', Age='%d', PosX='%.2f', PosY='%.2f' ,PosZ='%.2f', FaceA='%.2f', Interior='%d',VirtualWorld='%d', CellNum='%d', Job='%d', Accent='%d', Faction='%d', Hospital='%d', Insurance='%d', WHERE `Name`='%s'",PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pSex], PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pAge], pos[0],pos[1],pos[2], Angle, GetPlayerInterior(playerid),GetPlayerVirtualWorld(playerid),PlayerInfo[playerid][Name]);
mysql_function_query(handle, query, false, "SendQuery", "");
return 1;
}
B:\Development\SAMP\Blank Gamemode\gamemodes\crp.pwn(1271) : error 075: input line too long (after substitutions)
B:\Development\SAMP\Blank Gamemode\gamemodes\crp.pwn(1272) : error 017: undefined symbol "N"
B:\Development\SAMP\Blank Gamemode\gamemodes\crp.pwn(1273) : warning 217: loose indentation
B:\Development\SAMP\Blank Gamemode\gamemodes\crp.pwn(1273) : error 017: undefined symbol "ame"
B:\Development\SAMP\Blank Gamemode\gamemodes\crp.pwn(1273) : error 029: invalid expression, assumed zero
B:\Development\SAMP\Blank Gamemode\gamemodes\crp.pwn(1273) : error 029: invalid expression, assumed zero
B:\Development\SAMP\Blank Gamemode\gamemodes\crp.pwn(1273) : fatal error 107: too many error messages on one line
stock SaveAccount(playerid)
{
if(LoggingIn[playerid] == 1) return 0;
new query[300], Float:pos[3], Float:Angle;
GetPlayerPos(playerid, pos[0],pos[1],pos[2]);
GetPlayerFacingAngle(playerid, Angle);
format(query, sizeof(query),
"UPDATE `accounts` SET Admin='%d', Sex='%d', Skin='%d', Age='%d', PosX='%.2f', PosY='%.2f' ,PosZ='%.2f', FaceA='%.2f', Interior='%d',VirtualWorld='%d', CellNum='%d', Job='%d', Accent='%d', Faction='%d', Hospital='%d', Insurance='%d', WHERE `Name`='%s'",
PlayerInfo[playerid][pAdmin], PlayerInfo[playerid][pSex], PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pAge], pos[0],pos[1],pos[2], Angle, GetPlayerInterior(playerid),GetPlayerVirtualWorld(playerid),PlayerInfo[playerid][Name]);
mysql_function_query(handle, query, false, "SendQuery", "");
return 1;
}
|
The line is too long so separate its arguments:
pawn Код:
|
new myString[32] = "This \
is \
continuation. "
;
case DIALOG_LOGIN:
{
if (!response) return Kick (playerid);
if(response)
{
new query[128];
if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login:","{FFFFFF}Please Enter your password below to login. \n\nCannot be blank!","Login","Exit");
format(query, sizeof(query), "SELECT * FROM `accounts` WHERE `Name`='%s' AND `Pass`=md5('%s')", PlayerInfo[playerid][Name], PlayerInfo[playerid][pPass]);
mysql_function_query(handle, query, true, "OnAccountLoad", "d", playerid);
/*if(inputtext == PlayerInfo[playerid][pPass]) //How Would I compare inputtext with Password stored?
{
LoadAccount(playerid);
}
else
{
if(LogginAttempts[playerid] == 2)
{
LogginAttempts[playerid] = 0;
Kick(playerid);
}
else
{
LogginAttempts[playerid]++;
new str[1024], string[256];
format(string, sizeof(string), "{FF4000}Incorrect Password Attempts: %d\n", LogginAttempts[playerid]);
strcat(str, string);
format(string, sizeof(string), "{FFFFFF}You will be kicked after 3 attempts.\n");
strcat(str, string);
format(string, sizeof(string), "{FFFFFF}Please type your password below to login.\n");
strcat(str, string);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login:", str, "Login", "Exit");
}
}*/
}
}
forward OnAccountLoad(playerid);
public OnAccountLoad(playerid)
{
SetCameraBehindPlayer(playerid);
PlayerInfo[playerid][pCash] = cache_get_row_int(0,3,handle),
PlayerInfo[playerid][pAdmin] = cache_get_row_int(0,4,handle),
PlayerInfo[playerid][pSex] = cache_get_row_int(0,5,handle),
PlayerInfo[playerid][pSkin] = cache_get_row_int(0,6,handle),
PlayerInfo[playerid][pAge] = cache_get_row_int(0,7,handle),
PlayerInfo[playerid][PosX] = cache_get_row_float(0,8,handle),
PlayerInfo[playerid][PosY] = cache_get_row_float(0,9,handle),
PlayerInfo[playerid][PosZ] = cache_get_row_float(0,10,handle),
PlayerInfo[playerid][FaceA] = cache_get_row_float(0,11,handle),
PlayerInfo[playerid][Interior] = cache_get_row_int(0,12,handle),
PlayerInfo[playerid][VirtualWorld] = cache_get_row_int(0,13,handle),
PlayerInfo[playerid][CellNum] = cache_get_row_int(0,14,handle),
PlayerInfo[playerid][Job] = cache_get_row_int(0,15,handle),
PlayerInfo[playerid][Accent] = cache_get_row_int(0,16,handle),
PlayerInfo[playerid][Faction] = cache_get_row_int(0,17,handle),
PlayerInfo[playerid][Hospital] = cache_get_row_int(0,18,handle),
PlayerInfo[playerid][Insurance] = cache_get_row_int(0,19,handle);
LoggingIn[playerid] = 1;
return 1;
}
stock CreateAccount(playerid,pass[])
{
new query[240], name[24];
GetPlayerName(playerid, name, sizeof(name));
format(query, sizeof(query), "INSERT INTO `accounts` (Name,Pass) VALUES (\'%s\', \'md5('%s')\')", name, pass);
mysql_function_query(handle, query, false, "SendQuery", "");
}
stock LoadAccount(playerid)
{
new query[128];
format(query, sizeof(query), "SELECT * FROM `accounts` WHERE `Name`='%s'", PlayerInfo[playerid][Name]);
mysql_function_query(handle, query, true, "OnAccountLoad", "d", playerid);
}
if(!strcmp(md5(inputtext), retrievedPass))
{
// log him in
}
|
Suggestions on which encryption to use?
Whirlpool or something else like the Encrypt plugin? Thanks for help btw. EDIT: I'm not asking how, I have that done (I think) just comparing strings & storing/reading them as encrypted strings. |
case DIALOG_LOGIN:
{
if (!response) return Kick (playerid);
if(response)
{
new buf[129];
if(!strlen(inputtext)) return ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login:","{FFFFFF}Please Enter your password below to login. \n\nCannot be blank!","Login","Exit");
WP_Hash(buf, sizeof(buf), inputtext);
if(strcmp(buf, PlayerInfo[playerid][pPass]))
{
if(LogginAttempts[playerid] == 2)
{
LogginAttempts[playerid] = 0;
Kick(playerid);
}
else
{
LogginAttempts[playerid]++;
new str[1024], string[256];
format(string, sizeof(string), "{FF4000}Incorrect Password Attempts: %d\n", LogginAttempts[playerid]);
strcat(str, string);
format(string, sizeof(string), "{FFFFFF}You will be kicked after 3 attempts.\n");
strcat(str, string);
format(string, sizeof(string), "{FFFFFF}Please type your password below to login.\n");
strcat(str, string);
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login:", str, "Login", "Exit");
}
}
else
{
LoadAccount(playerid);
}
}
}
stock CheckAccount(playerid)
{
new query[82];
format(query, sizeof(query), "SELECT * FROM `accounts` WHERE `Name` = '%s'", PlayerInfo[playerid][Name]);
mysql_function_query(handle, query, true, "OnAccountCheck", "d", playerid);
return 1;
}
forward OnAccountCheck(playerid);
public OnAccountCheck(playerid)
{
if(playerid != INVALID_PLAYER_ID)
{
new rows, fields;
cache_get_data(rows, fields, handle);
if(rows)
{
//cache_get_row(0,1,PlayerInfo[playerid][pPass],handle, 64);
cache_get_field_content(0, "Pass", PlayerInfo[playerid][pPass], handle, 129);
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_PASSWORD,"Login:","Please Enter your password below to login.","Login","Exit");
}
else
{
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register:","Please Enter a password below to register.","Register","Exit");
}
}
return 1;
}
|
https://sampforum.blast.hk/showthread.php?tid=496953
This plugin works quite well, you can use whatever you like from the 'Hash functions' list. (whirlpool is usually the one to go for, but others are equally as safe) |
|
Don't really know why you would use a entire extra plugin for one function you'd maybe use twice. MySQL supports sha1 and sha2 (the latter from 5.5 onwards) which, in combination with a salt, should be sufficient.
|