new dialogstr[256]; new pame[MAX_PLAYER_NAME]; GetPlayerName(playerid, pame, sizeof(pame)); if(!udb_Exists(PlayerName2(playerid))) format(dialogstr,sizeof(dialogstr),"{FFFFFF}%s your nickname isn't registered please choose a password:", pame); else { PlayerInfo[playerid][Registered] = 1; format(file,sizeof(file),"/ladmin/users/%s.sav",udb_encode(PlayerName)); new tmp2[256]; tmp2 = dini_Get(file,"ip"); if( (!strcmp(tmp3,tmp2,true)) && (ServerInfo[AutoLogin] == 1) ) { LoginPlayer(playerid); LoadPlayer(playerid); if(PlayerInfo[playerid][Level] > 0) { format(string,sizeof(string),"ACCOUNT: You have been automatically logged in. (Level %d)", PlayerInfo[playerid][Level] ); SendClientMessage(playerid,green,string); } else SendClientMessage(playerid,green,"ACCOUNT: You have been automatically logged in."); } else format(dialogstr,sizeof(dialogstr),"{00FF00}%s {FF0000}This Name is registered please login:", pame), ShowPlayerDialog(playerid, 9048, DIALOG_STYLE_INPUT, "{FF0000}Login", dialogstr, "Login", "Cancel"); } |
//==========================On Dialog Response==================================
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
new idx;
new string[128];
new params[128];
// new cmd[256];
new moneys[MAX_PLAYERS];
new giveplayer[128];
new giveplayerid;
new sendername[MAX_PLAYER_NAME];
new playermoney[MAX_PLAYERS];
new iparam1;
new adminname[MAX_PLAYER_NAME], playername[MAX_PLAYER_NAME];
new player1,colour1, colour2;
if(dialogid == 9048 && response)
{
new dialogstr[256];
new pame[MAX_PLAYER_NAME];
GetPlayerName(playerid, pame, sizeof(pame));
if (PlayerInfo[playerid][LoggedIn] == 1) return SendClientMessage(playerid,red,"ACCOUNT: You are already logged in.");
if (!udb_Exists(PlayerName2(playerid))) return SendClientMessage(playerid,red,"ACCOUNT: Account doesn't exist, please use '/register [password]'.");
if (strlen(inputtext)==0) return format(dialogstr,sizeof(dialogstr),"{FFFFFF}%s This Name is registered please login:", pame), ShowPlayerDialog(playerid, 9048, DIALOG_STYLE_INPUT, "{FF0000}Login", dialogstr, "Aceptar", "Cancelar");
if (udb_CheckLogin(PlayerName2(playerid),inputtext))
{
new file[256], tmp3[100];
format(file,sizeof(file),"/ladmin/users/%s.sav",udb_encode(PlayerName2(playerid)) );
GetPlayerIp(playerid,tmp3,100);
dini_Set(file,"ip",tmp3);
LoginPlayer(playerid);
LoadPlayer(playerid);
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
if(PlayerInfo[playerid][Level] > 0) {
format(string,sizeof(string),"ACCOUNT: Successfully Logged In. (Level %d)", PlayerInfo[playerid][Level] );
return SendClientMessage(playerid,green,string);
} else return SendClientMessage(playerid,green,"ACCOUNT: Successfully Logged In");
}
else {
Kick(playerid);
PlayerInfo[playerid][FailLogin]++;
printf("LOGIN: %s has failed to login, Wrong password (%s) Attempt (%d)", PlayerName2(playerid), inputtext, PlayerInfo[playerid][FailLogin] );
if(PlayerInfo[playerid][FailLogin] == MAX_FAIL_LOGINS)
{
format(string, sizeof(string), "%s has been kicked (Failed Logins)", PlayerName2(playerid) );
SendClientMessageToAll(grey, string);
print(string);
Kick(playerid);
}
return SendClientMessage(playerid,red,"ACCOUNT: Login failed! Incorrect Password");
}
}
if(dialogid == 9049 && response)
{
new dialogstr[256];
new pame[MAX_PLAYER_NAME];
GetPlayerName(playerid, pame, sizeof(pame));
if (PlayerInfo[playerid][LoggedIn] == 1) return SendClientMessage(playerid,red,"ACCOUNT: You are already registered and logged in.");
if (udb_Exists(PlayerName2(playerid))) return SendClientMessage(playerid,GREEN,"ACCOUNT: This account already exists, please use '/login [password]'.");
if (strlen(inputtext) == 0) return format(dialogstr,sizeof(dialogstr),"{FFFFFF}%s your nickname isn't registed please choose a password:", pame), ShowPlayerDialog(playerid, 9049, DIALOG_STYLE_INPUT, "{FF0000}Register", dialogstr, "Aceptar", "Cancelar");
if (strlen(inputtext) < 4 || strlen(inputtext) > 20) return format(dialogstr,sizeof(dialogstr),"{FFFFFF}%s your nickname isn't registed please choose a password:", pame), ShowPlayerDialog(playerid, 9049, DIALOG_STYLE_INPUT, "{FF0000}Register", dialogstr, "Aceptar", "Cancelar");
if (udb_Create(PlayerName2(playerid),inputtext))
{
new file[256], tmp3[100];
new strdate[20], year,month,day; getdate(year, month, day);
GetPlayerName(playerid,pame,sizeof(pame)); format(file,sizeof(file),"/ladmin/users/%s.sav",udb_encode(pame));
GetPlayerIp(playerid,tmp3,100); dini_Set(file,"ip",tmp3);
// dini_Set(file,"password",params);
dUserSetINT(PlayerName2(playerid)).("registered",1);
format(strdate, sizeof(strdate), "%d/%d/%d",day,month,year);
GetPlayerIp(playerid,tmp3,100);
dini_Set(file,"ip",tmp3);
// dini_Set(file,"password",params);
dUserSetINT(PlayerName2(playerid)).("registered",1);
format(strdate, sizeof(strdate), "%d/%d/%d",day,month,year);
dini_Set(file,"RegisteredDate",strdate);
dUserSetINT(PlayerName2(playerid)).("loggedin",1);
dUserSetINT(PlayerName2(playerid)).("banned",0);
dUserSetINT(PlayerName2(playerid)).("level",0);
dUserSetINT(PlayerName2(playerid)).("LastOn",0);
dUserSetINT(PlayerName2(playerid)).("money",0);
dUserSetINT(PlayerName2(playerid)).("kills",0);
dUserSetINT(PlayerName2(playerid)).("deaths",0);
dUserSetINT(PlayerName2(playerid)).("Bank",PlayerInfo[playerid][bank]);
dUserSetINT(PlayerName2(playerid)).("weed",PlayerInfo[playerid][weed]);
dUserSetINT(PlayerName2(playerid)).("Gang",PlayerInfo[playerid][gang]);
dUserSetINT(PlayerName2(playerid)).("Condoms",PlayerInfo[playerid][condoms]);
dUserSetINT(PlayerName2(playerid)).("inalcatraz",PlayerInfo[playerid][inalcatraz]);
PlayerInfo[playerid][LoggedIn] = 1;
PlayerInfo[playerid][Registered] = 1;
SavePlayer(playerid);
dUserSetINT(PlayerName2(playerid)).("bowner",0);
dUserSetINT(PlayerName2(playerid)).("bowned",0);
dUserSetINT(PlayerName2(playerid)).("vowned",0);
dUserSetINT(PlayerName2(playerid)).("vowner",0);
dUserSetINT(PlayerName2(playerid)).("vowned2",0);
dUserSetINT(PlayerName2(playerid)).("vowner2",0);
dUserSetINT(PlayerName2(playerid)).("vowned3",0);
dUserSetINT(PlayerName2(playerid)).("vowner3",0);
dUserSetINT(PlayerName2(playerid)).("vowned4",0);
dUserSetINT(PlayerName2(playerid)).("vowner4",0);
dUserSetINT(PlayerName2(playerid)).("vowned5",0);
dUserSetINT(PlayerName2(playerid)).("vowner5",0);
dUserSetINT(PlayerName2(playerid)).("vowned6",0);
dUserSetINT(PlayerName2(playerid)).("vowner6",0);
dUserSetINT(PlayerName2(playerid)).("vowned7",0);
dUserSetINT(PlayerName2(playerid)).("vowner7",0);
dUserSetINT(PlayerName2(playerid)).("vowned8",0);
dUserSetINT(PlayerName2(playerid)).("vowner8",0);
dUserSetINT(PlayerName2(playerid)).("vowned9",0);
dUserSetINT(PlayerName2(playerid)).("vowner9",0);
dUserSetINT(PlayerName2(playerid)).("vowned10",0);
dUserSetINT(PlayerName2(playerid)).("vowner10",0);
dUserSetINT(PlayerName2(playerid)).("Houseid", -255);
dUserSetINT(PlayerName2(playerid)).("Rentid", -255);
dUserSetINT(PlayerName2(playerid)).("SpawnX", 0);
dUserSetINT(PlayerName2(playerid)).("SpawnY", 0);
dUserSetINT(PlayerName2(playerid)).("SpawnZ", 0);
dUserSetINT(PlayerName2(playerid)).("SpawnInt", 0);
LoginPlayer(playerid);
LoadPlayer(playerid);
SendClientMessage(playerid, green, "ACCOUNT: You are now registered, and have been automaticaly logged in");
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
return 1;
}
return 1;
}
else
{
PlayerInfo[playerid][FailLogin]++;
SendClientMessage(playerid,red,"ACCOUNT: Login failed! Incorrect Password");
printf("LOGIN: %s has failed to login, Wrong password (%s) Attempt (%d)", PlayerName2(playerid), inputtext, PlayerInfo[playerid][FailLogin] );
if(PlayerInfo[playerid][FailLogin] == MAX_FAIL_LOGINS)
{
format(string, sizeof(string), "%s has been kicked (Failed Logins)", PlayerName2(playerid) );
SendClientMessageToAll(grey, string);
print(string);
Kick(playerid);
}
// here you can re-show your dialog if they typed wrong
}
Change your code where it starts with ELSE with this
pawn Код:
|
Change your code where it starts with ELSE with this
pawn Код:
|
else
{
PlayerInfo[playerid][FailLogin]++;
SendClientMessage(playerid,red,"ACCOUNT: Login failed! Incorrect Password");
printf("LOGIN: %s has failed to login, Wrong password (%s) Attempt (%d)", PlayerName2(playerid), inputtext, PlayerInfo[playerid][FailLogin] );
if(PlayerInfo[playerid][FailLogin] == MAX_FAIL_LOGINS)
{
format(string, sizeof(string), "%s has been kicked (Failed Logins)", PlayerName2(playerid) );
SendClientMessageToAll(grey, string);
print(string);
Kick(playerid);
}
return ShowPlayerDialog(playerid, 9048, DIALOG_STYLE_INPUT, "{FF0000}Login", dialogstr, "Login", "Cancel");
}
}
else
{
PlayerInfo[playerid][FailLogin]++;
SendClientMessage(playerid,red,"ACCOUNT: Login failed! Incorrect Password");
printf("LOGIN: %s has failed to login, Wrong password (%s) Attempt (%d)", PlayerName2(playerid), inputtext, PlayerInfo[playerid][FailLogin] );
if(PlayerInfo[playerid][FailLogin] == MAX_FAIL_LOGINS)
{
format(string, sizeof(string), "%s has been kicked (Failed Logins)", PlayerName2(playerid) );
SendClientMessageToAll(grey, string);
print(string);
Kick(playerid);
}
else
{
ShowPlayerDialog(playerid, 9048, DIALOG_STYLE_INPUT, "{FF0000}Login", dialogstr, "Login", "Cancel");
}
}
} else { ShowPlayerDialog(playerid, 9048, DIALOG_STYLE_INPUT, "{FF0000}Login", dialogstr, "Login", "Cancel"); } } |