30.12.2015, 14:47
PHP код:
stock num_hash(buf[])
{
new length = strlen(buf),s1 = 1,s2 = 0,n;
for(n = 0; n < length; n++)
{
s1 = (s1 + buf[n]) % 65521;
s2 = (s2 + s1) % 65521;
}
return (s2 << 16) + s1;
}
case DIALOG_REGISTER:
{
if (!response) return Kick(playerid);
if(response)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, "Registering...","You have entered an invalid password.\nType your password below to register a new account.","Register","Quit");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteString(File, "Password", num_hash(inputtext));
INI_WriteInt(File,"Cash",0);
INI_WriteInt(File,"Admin",0);
INI_WriteInt(File,"Sex",0);
INI_WriteInt(File,"Age",0);
INI_WriteFloat(File,"Pos_x",1654.0);
INI_WriteFloat(File,"Pos_y",-2330.3);
INI_WriteFloat(File,"Pos_z",13.5);
INI_WriteInt(File,"Skin",0);
INI_WriteInt(File,"Team",0);
INI_WriteInt(File,"Accent",0);
INI_WriteInt(File,"Member",0);
INI_Close(File);
}
}
case DIALOG_LOGIN:
{
//if ( !response ) return Kick ( playerid ); done :D
if( response )
{
if(num_hash(inputtext) == PlayerInfo[ playerid ][ pPassword ] ) )
{
INI_ParseFile(UserPath ( playerid ), "load_user_%s", .bExtra = true, .extra = playerid);
SetSpawnInfo(playerid, PlayerInfo[playerid][pTeam], PlayerInfo[playerid][pSkin], PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z], 1.0, -1, -1, -1, -1, -1, -1);
GivePlayerMoney( playerid, PlayerInfo[ playerid ][ pCash ] );
// so this is done (thanks i pissed and chosen to come and fix :D) man not fixed trust me JUST WATCH
}
else
{
ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"{97F2FD}Account: Login","{FF2020}You have entered an incorrect password\n\n{FFFFFF}Please type your password to login","Login","Quit");
}
return 1;
}
else
{
Kick(playerid);
//ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"Login","Please enter a password to proceed further.","Login","Quit");
}
}
}