14.07.2010, 21:02
first. my dialog
then
ingore the above textdraws
when onplayerrequestspawn HITS i could login the password i reged with and any other word i type in logs me in D:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(response)
{
if(dialogid == 1 || dialogid == 12347)
{
if(strlen(inputtext))
{
new ppw[20], str[128];
format(pfile, sizeof(pfile), pfile_path, Playername(playerid));
if(IsLogged[playerid] == 1) return 0;
else if(!dini_Exists(pfile)) return SendMsg(playerid, RED, "*Error: No account with that username is registered, please register");
else
{
format(pfile, sizeof(pfile), pfile_path, Playername(playerid));
new playerpw[256];
playerpw = dini_Get(pfile, "Password");
if(strcmp(playerpw, ppw, true) == 0)
{
format(str, sizeof(str), "*Success: You have Successfully Logged In %s", Playername(playerid), dini_Int(pfile, "AdminLevel"));
SendMsg(playerid, LIME, str);
LoadPlayer(playerid);
IsLogged[playerid] = 1;
SetTimerEx("TimePlayerLogged", 1000, true, "i", playerid);
}
else
{
SendMsg(playerid, RED, "*Error: Wrong Password. Password Did Not Match With The One You Have Register With.");
}
}
}
else
{
new loginstring[128];
new loginname[64];
GetPlayerName(playerid,loginname,sizeof(loginname));
format(loginstring,sizeof(loginstring),"ERROR: Incorrect password!\n \nPlease enter the correct password:",loginname);
ShowPlayerDialog(playerid,12347,DIALOG_STYLE_INPUT,"Login",loginstring,"Login","Cancel");
gPlayerLogTries[playerid] += 1;
if(gPlayerLogTries[playerid] == 3) { Kick(playerid); }
}
}
if(dialogid == 2 || dialogid == 12345)
{
if(strlen(inputtext))
{
new ppw[20], str[128];
format(pfile, sizeof(pfile), pfile_path, Playername(playerid));
if(dini_Exists(pfile)) return SendMsg(playerid, RED, "*Error: This Username Is Already Registered In Our Database Please Login! Or Create A Different Account");
else
{
format(pfile, sizeof(pfile), pfile_path, Playername(playerid));
dini_Create(pfile);
dini_Set(pfile, "Password", ppw);
dini_IntSet(pfile, "Score", 0);
dini_IntSet(pfile, "Money", 0);
dini_IntSet(pfile, "AdminLevel", 0);
dini_IntSet(pfile, "Hourslogged", 0);
dini_IntSet(pfile, "MinutesLogged", 0);
dini_IntSet(pfile, "SecondsLogged", 0);
dini_IntSet(pfile, "WantedLevel", 0);
format(str, sizeof(str), "*Success: You Has Successfully Registered %s And With The Password Of %s", Playername(playerid), ppw);
SendMsg(playerid, GREEN, str);
}
}
else
{
new regstring[128];
new regname[64];
GetPlayerName(playerid,regname,sizeof(regname));
format(regstring,sizeof(regstring),"Welcome, %s\nYou dont have an account.\nPlease register:",regname);
ShowPlayerDialog(playerid,12345,DIALOG_STYLE_INPUT,"Register",regstring,"Register","Cancel");
}
}
}
return 1;
}
pawn Код:
public OnPlayerRequestSpawn(playerid)
{
if(gTeam[playerid] == TEAM_COPS)
{
TextDrawShowForPlayer(playerid, COPBOX);
TextDrawShowForPlayer(playerid, text5);
TextDrawShowForPlayer(playerid, text6);
TextDrawShowForPlayer(playerid, text7);
TextDrawShowForPlayer(playerid, text8);
}
else if(gTeam[playerid] == TEAM_CIVILIAN)
{
TextDrawShowForPlayer(playerid, CIVBOX);
TextDrawShowForPlayer(playerid, text1);
TextDrawShowForPlayer(playerid, text2);
TextDrawShowForPlayer(playerid, text3);
TextDrawShowForPlayer(playerid, text4);
}
else if(gTeam[playerid] == TEAM_MEDIC)
{
TextDrawShowForPlayer(playerid, MDCBOX);
TextDrawShowForPlayer(playerid, text9);
TextDrawShowForPlayer(playerid, text10);
TextDrawShowForPlayer(playerid, text11);
TextDrawShowForPlayer(playerid, text12);
}
new string[128];
format(pfile, sizeof(pfile), pfile_path, Playername(playerid));
if(!dini_Exists(pfile))
{
format(string,sizeof(string),"Welcome to New York City Life Cops And Robbers. \n \nYour name is Not registered.\nPlease enter your password & Register A New Account below:",Playername(playerid));
ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Login",string,"Register","Cancel");
return 0;
}
else if(IsLogged[playerid] == 0)
{
format(string,sizeof(string),"Welcome Back %s to New York City Life Cops And Robbers. \n \nYour name is registered.\nPlease enter your password below:",Playername(playerid));
ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Login",string,"Login","Cancel");
return 0;
}
return 1;
}
pawn Код:
CMD:login(playerid, params[])
{
new ppw[20], str[128];
format(pfile, sizeof(pfile), pfile_path, Playername(playerid));
if(sscanf(params, "s", ppw)) return SendMsg(playerid, RED, "*USAGE: /login [password]");
else if(strlen(ppw) < 3) return SendMsg(playerid, RED, "*Error: Password is too short to be correct");
else if(strlen(ppw) > 20) return SendMsg(playerid, RED, "*Error: Password is too long to be correct");
else if(IsLogged[playerid] == 1) return SendMsg(playerid, RED, "*Error: You are already logged in");
else if(!dini_Exists(pfile)) return SendMsg(playerid, RED, "*Error: No account with that username is registered, please register");
else
{
format(pfile, sizeof(pfile), pfile_path, Playername(playerid));
new playerpw[256];
playerpw = dini_Get(pfile, "Password");
if(strcmp(playerpw, ppw, true) == 0)
{
format(str, sizeof(str), "*Success: You have Successfully Logged In %s", Playername(playerid), dini_Int(pfile, "AdminLevel"));
SendMsg(playerid, LIME, str);
LoadPlayer(playerid);
IsLogged[playerid] = 1;
SetTimerEx("TimePlayerLogged", 1000, true, "i", playerid);
}
else
{
SendMsg(playerid, RED, "*Error: Wrong Password. Password Did Not Match With The One You Have Register With.");
}
}
return 1;
}
CMD:register(playerid, params[])
{
new ppw[20], str[128];
format(pfile, sizeof(pfile), pfile_path, Playername(playerid));
if(sscanf(params, "s", ppw)) return SendMsg(playerid, RED, "*USAGE: /register [password] - Max length is 20 & minium is 3");
else if(strlen(ppw) < 3) return SendMsg(playerid, RED, "*Error: Password Is Under The Limit Sorry");
else if(strlen(ppw) > 20) return SendMsg(playerid, RED, "*Error: Password Is Over The Limit Sorry");
else if(IsLogged[playerid] == 1) return SendMsg(playerid, RED, "*Error: You Are Logged In | No Need To Register Again!");
else if(dini_Exists(pfile)) return SendMsg(playerid, RED, "*Error: This Username Is Already Registered In Our Database Please Login! Or Create A Different Account");
else
{
format(pfile, sizeof(pfile), pfile_path, Playername(playerid));
dini_Create(pfile);
dini_Set(pfile, "Password", ppw);
dini_IntSet(pfile, "Score", 0);
dini_IntSet(pfile, "Money", 0);
dini_IntSet(pfile, "AdminLevel", 0);
dini_IntSet(pfile, "Hourslogged", 0);
dini_IntSet(pfile, "MinutesLogged", 0);
dini_IntSet(pfile, "SecondsLogged", 0);
dini_IntSet(pfile, "WantedLevel", 0);
format(str, sizeof(str), "*Success: You Has Successfully Registered %s And With The Password Of %s", Playername(playerid), ppw);
SendMsg(playerid, GREEN, str);
}
return 1;
}