How to make this into a dialog login? -
Robert_Crawford - 12.01.2011
How could i make this to where it uses login?
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
if (PlayerInfo[playerid][pDeath] == 1) return SpawnPlayer(playerid);
if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, RED, ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::");
new File:welcome = fopen("WelcomeMessage.txt",io_read);
if (welcome)
{
new lines;
new message[500];
while (fread(welcome,message))
{
lines++;
SendClientMessage(playerid,COLOR_WHITE,message);
}
}
SendClientMessage(playerid, RED, ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::");
if(PlayerInfo[playerid][pSQLId] != INVALID_SQL_ID)
{
new nick[128];
format(nick,sizeof(nick),"Hello %s, type /login <password> to proceed",PlayerInfo[playerid][pName]);
SendClientMessage(playerid, COLOR_WHITE, nick);
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "Your account isn't registered. You may use /register <password> ");
SendClientMessage(playerid, COLOR_WHITE, "Please make the effort to ensure your name is properly capitalized or you may be requested to change it");
}
}
return 0;
}
Re: How to make this into a dialog login? -
Kyosaur - 12.01.2011
https://sampwiki.blast.hk/wiki/ShowPlayerDialog
https://sampwiki.blast.hk/wiki/OnDialogResponse
You gotta at least try to do it yourself if you expect any assistance. Not a whole lot of people are willing to do the work for you, but rather HELP you.
Re: How to make this into a dialog login? -
Robert_Crawford - 12.01.2011
I know how to inert the showplayer dialog. Ive never succeed at doing this. this is what i have
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
if (PlayerInfo[playerid][pDeath] == 1) return SpawnPlayer(playerid);
if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, RED, ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::");
new File:welcome = fopen("WelcomeMessage.txt",io_read);
if (welcome)
{
new lines;
new message[500];
while (fread(welcome,message))
{
lines++;
SendClientMessage(playerid,COLOR_WHITE,message);
}
}
SendClientMessage(playerid, RED, ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::");
if(PlayerInfo[playerid][pSQLId] != INVALID_SQL_ID)
{
ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"Login","Enter your password below:","Login","Cancel");
}
else
{
ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"Register,"Enter your password below:","Login","Cancel");
}
}
return 0;
}
And then like i know my register command is this
pawn Код:
// ************************************** REGISTER COMMAND ********************************//
else if (strcmp(cmd, "/register", true) ==0 )
{
//if (Admins < 1) return SendClientMessage(playerid, ADMIN_RED, "Please register at 'www.register.sincityrp.com'. Thank you for joining!");
if(gPlayerLogged[playerid] == 1)
{
SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are already logged in.");
return 1;
}
if(PlayerInfo[playerid][pSQLId] != 0)
{
SendClientMessage(playerid, COLOR_YELLOW, "This Username is already taken, please choose a different one.");
return 1;
}
if(strcount(cmdtext, ' ') != 2)
{
SendClientMessage(playerid, COLOR_GRAD1, "USAGE: /register [password]");
return 1;
}
new tmppass[34];
tmppass = strtok(cmdtext, idx);
AddPlayer(playerid,tmppass);
LoadPlayer(playerid);
SendClientMessage(playerid, COLOR_YELLOW, "Account registered, you can login now ( /login [password] ).");
SendClientMessage(playerid, COLOR_YELLOW, "Once you are logged in, you may type /clothes to change your skin.");
return 1;
}
else if(gPlayerLogged[playerid] == 0)
{
SendClientMessage(playerid, COLOR_LIGHTRED, "You are required to login BEFORE you can use commands.");
return 1;
}
My login command now how would i intergrate this into the ondialogresponse?
pawn Код:
// ************************************** LOGIN COMMAND ********************************//
if (strcmp("/login", cmd, true) == 0)
{
if(RestartTimer != DONT_RESTART)
{
format(string, sizeof(string), "The Server will be restarting, untill then login has been disabled.");
SendClientMessage(playerid, COLOR_LIGHTRED, string);
return 1;
}
if(gPlayerLogged[playerid] == 1)
{
SendClientMessage(playerid, COLOR_WHITE, "SERVER: You are already logged in.");
return 1;
}
if(strcount(cmdtext, ' ') != 2)
{
SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /login [password]");
return 1;
}
if(PlayerInfo[playerid][pSQLId] == INVALID_SQL_ID)
{
SendClientMessage(playerid, COLOR_YELLOW, "You dont have an account. Please register by using /register [password]");
return 1;
}
new inputhash[50];
new checkhash[33];
new rawcheckhash[99];
inputhash = MD5_Hash(strtok(cmdtext, idx));
strmid(checkhash,PlayerInfo[playerid][pPassword],0,strlen(PlayerInfo[playerid][pPassword]),sizeof(checkhash));
strmid(rawcheckhash,PlayerInfo[playerid][pPassword],0,strlen(PlayerInfo[playerid][pPassword]),sizeof(checkhash));
printf("RAW CHECK HASH: %s",rawcheckhash);
printf("CHECK HASH: %s",checkhash);
printf("INPUT HASH: %s",inputhash);
if (strfind(checkhash, inputhash, true) != -1)
{
gPlayerLogged[playerid] = 1;
printf("%s has entered his password",PlayerInfo[playerid][pName]);
SendClientMessage(playerid, COLOR_WHITE,"Please hold while we log you in...");
// new timer for login -> spawn
SetTimerEx("SpawnPlayerEx",5000,0,"i",playerid);
}
else
{
SendClientMessage(playerid, COLOR_RED, "ERROR: Password does not match your name.");
}
return 1;
}