17.10.2011, 13:11
This is an example
I used this thing in my login and register script.
pawn Код:
{
gPlayerLogged[playerid] = 0;
new name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
{
if(!dini_Exists(file))
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Hi your not registered", "Welcome, your not a member,Input your PW below","Register","Kick Me");
}
if(fexist(file))
{
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your registered", "Welcome, your a member,Input your PW below","Register","Kick Me");
}
}
return 1;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 1)
{
new name[MAX_PLAYER_NAME], file[256], string[128];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
if(!strlen(inputtext)) return
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Hi your not registered", "Welcome, your not a member,Input your PW below","Register","Kick Me");
dini_Create(file);
dini_IntSet(file, "Password", udb_hash(inputtext));
dini_IntSet(file, "Score", PInfo[playerid][pScore]);
dini_IntSet(file, "Cash", PInfo[playerid][pCash]);
dini_IntSet(file, "AdminLevel", PInfo[playerid][pAdminLevel]);
format(string, 128, "[SYSTEM]: You succesfully registered the nickname %s with password %s, you have been auto logged in.", name, inputtext);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
gPlayerLogged[playerid] = 1;
}
if(dialogid == 2)
{
new name[MAX_PLAYER_NAME], file[256], string[128];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), SERVER_USER_FILE, name);
if(!response) return Kick(playerid);
if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your registered,Welcome, your a member","Input your PW below","Register","Kick Me");
new tmp;
tmp = dini_Int(file, "Password");
if(udb_hash(inputtext) !=tmp)
{
SendClientMessage(playerid, COLOR_RED, "Wrong PW dude");
ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Hi your registered", "Welcome, your not member,Input your PW below","Register","Kick Me");
}
else
{
gPlayerLogged[playerid] = 1;
PInfo[playerid][pAdminLevel] = dini_Int(file, "AdminLevel");
SetPlayerScore(playerid, dini_Int(file, "Score"));
SendClientMessage(playerid,COLOR_RED, "[SYSTEM]: Successfully logged in!");
}
}
return 1;
}