28.09.2010, 20:52
Hey I got this code:
I want to switch these to a command like /login [password] and /register [password]
Can anyone help me out PS: I tried it but I failed
Код:
if(dialogid == 201)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid,201,DIALOG_STYLE_INPUT,"Registration","ERROR: You did not enter a password.\nPlease enter a password to register this account!","Register","Cancel");
new playerfile[128], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(playerfile, sizeof(playerfile), "EAdmin/Users/%s.ini",pname);
if(dini_Exists(playerfile)) return SendClientMessage(playerid, red, "You are already registered!");
new playerip[20];
GetPlayerIp(playerid, playerip, sizeof(playerip));
dini_Create(playerfile);
dini_IntSet(playerfile, "Password", udb_hash(inputtext));
dini_Set(playerfile, "Ip", playerip);
dini_IntSet(playerfile, "Level", 0);
dini_IntSet(playerfile, "Cash", 0);
dini_IntSet(playerfile, "Score", 0);
logged[playerid] = 1;
SendClientMessage(playerid, yellow, "You have registered your account! You have also been logged in.");
}
if(dialogid == 200)
{
if(!strlen(inputtext)) return ShowPlayerDialog(playerid,200,DIALOG_STYLE_INPUT,"Login","ERROR: You did not enter a password.\nPlease enter a password to login to this account!","Login","Cancel");
new playerfile[100], pname[MAX_PLAYER_NAME];
GetPlayerName(playerid, pname, sizeof(pname));
format(playerfile, sizeof(playerfile), "EAdmin/Users/%s.ini",pname);
if(!dini_Exists(playerfile)) return SendClientMessage(playerid, red, "This account is not yet registered, please type /register.");
new tmp[256];
tmp = dini_Get(playerfile, "Password");
if(udb_hash(inputtext) == strval(tmp))
{
new playerip[20];
GetPlayerIp(playerid, playerip, sizeof(playerip));
level[playerid] = dini_Int(playerfile, "Level");
logged[playerid] = 1;
dini_Set(playerfile, "Ip", playerip);
GivePlayerMoney(playerid, dini_Int(playerfile, "Cash"));
SetPlayerScore(playerid, dini_Int(playerfile, "Score"));
logged[playerid] = 1;
SendClientMessage(playerid, yellow, "You have logged in!");
} else return ShowPlayerDialog(playerid,200,DIALOG_STYLE_INPUT,"Login","ERROR: Invalid Password.\nPlease enter a password to login to this account!","Login","Cancel");
}
Can anyone help me out PS: I tried it but I failed
