Register dialog showing when player already registered -
Eminem 2ka9 - 26.03.2013
I'm using LuxAdmin, when i restart the server (My host control panel) then the register dialog appears, even when the player is already registered, and this dialog doesn't work anyway.
But, if i just /q, or if i was a new player, then it would Login/register fine.
This is my code in OnPlayerConnect.
pawn Код:
public OnPlayerConnect(playerid)
{
//==============================================================================
// Request Register
//==============================================================================
if(AccInfo[playerid][Registered] == 0 && ServerInfo[MustRegister] == 1)
{
#if USE_DIALOGS == true
new rstring[256];
format(rstring,256,"{15FF00}Welcome to {FF0000}%s\n{15FF00}\n{15FF00}Account '%s' is not registred!\n{FFFFFF}\n{FFFFFF}Enter the password to Register your Account:",GetServerHostName(),pName(playerid));
ShowPlayerDialog(playerid,DIALOGID+66,DIALOG_STYLE_INPUT,"Register Account",rstring,"Register","Quit");
#endif
return 1;
}
//==============================================================================
// Request Login
//==============================================================================
if(ServerInfo[MustLogin] == 1 && AccInfo[playerid][Registered] == 1 && AccInfo[playerid][LoggedIn] == 0)
{
#if USE_DIALOGS == true
new lstring[256];
format(lstring,green,"{15FF00}That account '%s 'is Registered!\n{15FF00}\n{FFFFFF} Login to access your Account:",pName(playerid));
ShowPlayerDialog(playerid,DIALOGID+67,DIALOG_STYLE_INPUT, "Login Account",lstring,"Login","Quit");
#endif
return 1;
}
This is how they register/login.
pawn Код:
if(strlen(dini_Get("LuxAdmin/Config/aka.txt", tmp3)) == 0)
dini_Set("LuxAdmin/Config/aka.txt", tmp3, PlayerName);
else
{
if( strfind( dini_Get("LuxAdmin/Config/aka.txt", tmp3), PlayerName, true) == -1 )
{
format(string,sizeof(string),"%s,%s", dini_Get("LuxAdmin/Config/aka.txt",tmp3), PlayerName);
dini_Set("LuxAdmin/Config/aka.txt", tmp3, string);
}
}
if(!udb_Exists(PlayerName2(playerid)))
SendClientMessage(playerid,orange, "SERVER: Your account isn't registered. Please register (/"#RegisterCommand")");
else
{
AccInfo[playerid][Registered] = 1;
format(file,sizeof(file),"/LuxAdmin/Accounts/%s.sav",udb_encode(PlayerName));
new tmp2[256]; tmp2 = dini_Get(file,"Ip");
if( (!strcmp(tmp3,tmp2,true)) && (ServerInfo[AutoLogin] == 1))
{
LoginPlayer(playerid);
if(AccInfo[playerid][Level] > 0)
{
switch(AccInfo[playerid][Level])
{
case 1: AdmRank = "Starter Administrator";
case 2: AdmRank = "Junior Administrator";
case 3: AdmRank = "Intermediate Administrator";
case 4: AdmRank = "Head Administrator";
case 5: AdmRank = "Executive Admin";
case 6: AdmRank = "Co-Owner";
case 7: AdmRank = "Owner";
}
if(AccInfo[playerid][Level] > 6)
{
AdmRank = "Co-Owner";
}
if(AccInfo[playerid][Level] > 7)
{
AdmRank = "Server Owner";
}
Re: Register dialog showing when player already registered -
LeeXian99 - 26.03.2013
I've this bug too!
Re: Register dialog showing when player already registered -
Eminem 2ka9 - 26.03.2013
Yes, it ONLY happens if i restart my server in my host control panel.
Re: Register dialog showing when player already registered -
Gamer_007 - 26.03.2013
This isnt a bug.This is because u must change all ur return 1; to return 0; except at the last of ondialog response.Replace all return 1; to return 0; in Ondialogresponse except at the last one.
Re: Register dialog showing when player already registered -
Eminem 2ka9 - 26.03.2013
Oh ok. So, tell me how i should put this (I'll let you handle it, it seems you know better than me.
These are in my OnDialogResponse.
pawn Код:
if (dialogid == DIALOGID+66)
{
if(response == 0 && ServerInfo[MustRegister] == 1)
{
Kick(playerid);
}
if(response)
{
if (strlen(inputtext) < 4 || strlen(inputtext) > 20)
{
new rstring[256];
format(rstring,256,"Sorry %s\n\nThe length of your password should contain more \nthan 3 characters and less than 20 characters! \n\n Please, re-enter the Password:",pName(playerid));
return ShowPlayerDialog(playerid,DIALOGID+68,DIALOG_STYLE_INPUT,"Register Error!",rstring,"Register","Quit");
}
if (udb_Create(PlayerName2(playerid)))
{
ShowPlayerDialog(playerid,DIALOG_TYPE_QUESTION,DIALOG_STYLE_INPUT,"LuxAdmin - Account Safety Question","Type a security question, for when you forget\n your password, you just answer this Question.","Next","End");
new file[256],name[MAX_PLAYER_NAME], buf[145],tmp3[100];
new strdate[20], year,month,day;
getdate(year, month, day);
WP_Hash(buf, sizeof(buf), inputtext);
GetPlayerName(playerid,name,sizeof(name));
format(file,sizeof(file),"/LuxAdmin/Accounts/%s.sav",udb_encode(name));
GetPlayerIp(playerid,tmp3,100);
dini_Set(file,"Password",buf);
dini_Set(file,"Ip",tmp3);
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)).("AccountType",0);
dUserSetINT(PlayerName2(playerid)).("LastOn",0);
dUserSetINT(PlayerName2(playerid)).("Money",0);
dUserSetINT(PlayerName2(playerid)).("Kills",0);
dUserSetINT(PlayerName2(playerid)).("Deaths",0);
dUserSetINT(PlayerName2(playerid)).("WantedLevel",0);
#if SaveScore == true
dUserSetINT(PlayerName2(playerid)).("Score",0);
#endif
dUserSetINT(PlayerName2(playerid)).("Hours",0);
dUserSetINT(PlayerName2(playerid)).("Minutes",0);
dUserSetINT(PlayerName2(playerid)).("Seconds",0);
AccInfo[playerid][LoggedIn] = 1;
AccInfo[playerid][Registered] = 1;
SendClientMessage(playerid, green, "|- You are now Registered, and have been automaticaly Logged in! -|");
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
return 1;
}
}
return 1;
}
//==============================================================================
//---------------
// Dialog - LOGIN
//---------------
//==============================================================================
if (dialogid == DIALOGID+67)
{
if(response == 0 && ServerInfo[MustLogin] == 1)
{
Kick(playerid);
}
if(response)
{
new lstring[256];
new file[128], Pass[256];
format(file,sizeof(file),"/LuxAdmin/Accounts/%s.sav",udb_encode(PlayerName2(playerid)));
Pass = dini_Get(file, "Password");
new buf[145];
WP_Hash(buf, sizeof(buf), inputtext);
AccInfo[playerid][NoQuestion] = dUserINT(PlayerName2(playerid)).("NoQuestion");
if(strcmp(Pass, buf, false) == 0)
{
new tmp3[100], string[128];
format(file,sizeof(file),"/LuxAdmin/Accounts/%s.sav",udb_encode(PlayerName2(playerid)));
GetPlayerIp(playerid,tmp3,100);
dini_Set(file,"Ip",tmp3);
LoginPlayer(playerid);
PlayerPlaySound(playerid,1057,0.0,0.0,0.0);
if(AccInfo[playerid][Level] > 0)
{
switch(AccInfo[playerid][Level])
{
case 1: AdmRank = "Starter Administrator";
case 2: AdmRank = "Junior Administrator";
case 3: AdmRank = "Intermediate Administrator";
case 4: AdmRank = "Head Administrator";
case 5: AdmRank = "Executive Admin";
case 6: AdmRank = "Co-Owner";
case 7: AdmRank = "Owner";
}
if(AccInfo[playerid][Level] > 7)
{
AdmRank = "Owner";
}
if(AccInfo[playerid][pVip] > 0)
{
switch(AccInfo[playerid][pVip])
{
case 1: AccType = "Silver";
case 2: AccType = "Gold";
case 3: AccType = "Premium";
}
format(string,sizeof(string),"|- You have Successfully Logged! | Account: %s | Level %d - %s -|", AccType, AccInfo[playerid][Level], AdmRank);
return SendClientMessage(playerid,0x00C378AA,string);
}
else
{
format(string,sizeof(string),"|- You have Successfully Logged! | Level %d - %s -|", AccInfo[playerid][Level], AdmRank);
return SendClientMessage(playerid,green,string);
}
}
else
{
if(AccInfo[playerid][pVip] > 0)
{
switch(AccInfo[playerid][pVip])
{
case 1: AccType = "Silver";
case 2: AccType = "Gold";
case 3: AccType = "Premium";
}
format(string,sizeof(string),"|- You have Successfully logged! | Account: %s -|", AccType);
return SendClientMessage(playerid,0x00C896AA,string);
}
else return SendClientMessage(playerid,green,"|- You have Successfully logged! -|");
}
}
else
{
AccInfo[playerid][FailLogin]++;
printf("LOGIN: Failed Login: %s. Wrong password (%s) (%d)", PlayerName2(playerid), inputtext, AccInfo[playerid][FailLogin] );
if(AccInfo[playerid][FailLogin] == MAX_FAIL_LOGINS)
{
new string[128]; format(string, sizeof(string), "|- Player %s has been automatically kicked (Reason: Many attempts Incorrect Passwords) -|", PlayerName2(playerid) );
SendClientMessageToAll(red, string);
print(string);
Kick(playerid);
}
if(AccInfo[playerid][NoQuestion] == 1)
{
format(lstring,256,"Sorry '%s'\n\nYour entered password is Incorrect!\nPlease, re-enter the Correct Password:",pName(playerid));
return ShowPlayerDialog(playerid,DIALOGID+69,DIALOG_STYLE_INPUT,"Login Error",lstring,"Login","Quit");
}
if(AccInfo[playerid][NoQuestion] == 0)
{
format(lstring,256,"Sorry '%s'\n\nYour entered password is Incorrect!\nPlease, re-enter the Correct Password:\n\nOr type the response of your security question:\n\n \"%s\"",pName(playerid),dini_Get(file, "Question"));
return ShowPlayerDialog(playerid,DIALOGID+69,DIALOG_STYLE_INPUT,"Login Error",lstring,"Login","Quit");
}
}
}
}
Re: Register dialog showing when player already registered -
Eminem 2ka9 - 26.03.2013
Ok i added a return 0; to the only return there.. still nothing!
Re: Register dialog showing when player already registered -
Eminem 2ka9 - 26.03.2013
This has always been a hard topic... only 1 legit answer
Re: Register dialog showing when player already registered -
Guest123 - 13.05.2013
i have bug too but it sloved with my work

,
pawn Код:
public OnPlayerConnect(playerid)
{
new name[MAX_PLAYER_NAME]; // the name and the file
GetPlayerName(playerid, name, MAX_PLAYER_NAME); // getting client's name
format(file,sizeof(file),"/LuxAdmin/Accounts/%s.sav",udb_encode(PlayerName2(playerid)) );
if(!fexist(file)) { // if the file does not exists
new rstring[256];
format(rstring,256,"Welcome %s\n\nEnter You Password To Connect To This Server:\n[0.3x]Freeroam+Advance[0.3x]",pName(playerid));
ShowPlayerDialog(playerid,DIALOGID+66,DIALOG_STYLE_INPUT,"Register Account",rstring,"Register","Quit");
}
else {
new LOL[256];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
format(LOL,256,"Welcome Back %s\n\nEnter You Password To Connect To This Server:\n[0.3x]Freeroam+Advance[0.3x]",pName(playerid));
ShowPlayerDialog(playerid,DIALOGID+67,DIALOG_STYLE_PASSWORD,"Login Account",LOL,"Login","Quit");
}
return 1;
}
rep me if i helped you
Re: Register dialog showing when player already registered -
Calabresi - 13.05.2013
Do you say that only happens to first player that connects (ID: 0) after you restart your gamemode?