pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
new string[128];
new tmp2[128];
GetPlayerName(playerid, playername, sizeof(playername));
switch(dialogid)
{
case 1:
{
if (dini_Exists(udb_encode(playername)))
{
tmp2 = dini_Get(udb_encode(playername), "password");
if (udb_hash(inputtext) != strval(tmp2))
{
SendClientMessage(playerid, COLOR_RED, "Wrong password");
}
else
{
logged[playerid] = 1;
money[playerid] = dini_Int(udb_encode(playername), "money");
score[playerid] = dini_Int(udb_encode(playername), "score");
registered[playerid] = dini_Int(udb_encode(playername), "registerd");
adminlevel[playerid] = dini_Int(udb_encode(playername), "adminlevel");
format(string, sizeof(string), "%s, You are now logged in. Your adminlevel is %d, Your money is %d, and your score is %d.", playername, adminlevel[playerid], money[playerid], score[playerid]);
SendClientMessage(playerid, COLOR_GREEN, string);
GivePlayerMoney(playerid, money[playerid]);
SetPlayerScore(playerid, score[playerid]);
printf("%s has logged in",playername);
return 1;
}
}
else
{
format(string, sizeof(string), "The account %s does not exist yet. Type /register [password] to make an account.", playername);
SendClientMessage(playerid, COLOR_RED, string);
return 1;
}
}
case 2:
{
if (!dini_Exists(udb_encode(playername)))
{
dini_Create(udb_encode(playername));
dini_IntSet(udb_encode(playername), "password", udb_hash(inputtext));
dini_IntSet(udb_encode(playername), "adminlevel", 0);
dini_IntSet(udb_encode(playername), "money", 0);
dini_IntSet(udb_encode(playername), "score", 0);
dini_IntSet(udb_encode(playername), "registered", 0);
format(string, sizeof(string), "Account %s has been made!", playername, inputtext);
SendClientMessage(playerid, COLOR_GREEN, string);
printf("%s has registered",playername);
registered[playerid] = 1;
}
return 1;
}
}
return 0;
}