21.11.2012, 16:06
Okay, well I have made a login system which works on my local host but on my server you can type in any password and it works.
Код:
ShowMainMenuDialog(playerid, frame)
{
new titlestring[64];
new string[256];
switch(frame)
{
case 1:
{
new ip[32];
GetPlayerIp(playerid, ip, 32);
format(titlestring, sizeof(titlestring), "Login - %s", GetPlayerNameEx(playerid));
format(string, sizeof(string), "Welcome to High Street's Roleplay, %s.\n\nThis Account Is Registred Please Fill In Your Password To Login In", GetPlayerNameEx(playerid), ip);
ShowPlayerDialog(playerid,MAINMENU,DIALOG_STYLE_INPUT,titlestring,string,"Login","Exit");
}
case 2:
{
new ip[32];
GetPlayerIp(playerid, ip, 32);
format(titlestring, sizeof(titlestring), "Register - %s", GetPlayerNameEx(playerid));
format(string, sizeof(string), "Welcome to High Street's Roleplay, %s.\n\nYou Have Not Yet Registerd Please Do And Fill Out The Password.", GetPlayerNameEx(playerid), ip);
ShowPlayerDialog(playerid,MAINMENU2,DIALOG_STYLE_INPUT,titlestring,string,"Register","Exit");
}
case 3:
{
new ip[32];
GetPlayerIp(playerid, ip, 32);
format(titlestring, sizeof(titlestring), "Login - %s", GetPlayerNameEx(playerid));
format(string, sizeof(string), "Invalid Password!\n\nWelcome to High Street's Roleplay, %s.\n\nThis Account Is Registred Please Fill In Your Password To Login In", GetPlayerNameEx(playerid), ip);
ShowPlayerDialog(playerid,MAINMENU,DIALOG_STYLE_INPUT,titlestring,string,"Login","Exit");
}
}
}
public SafeLogin(playerid)
{
// Main Menu Features.
ShowMainMenuGUI(playerid);
SetPlayerJoinCamera(playerid);
ClearChatbox(playerid);
SetPlayerVirtualWorld(playerid, 0);
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
if(doesAccountExist(playername))
{
gPlayerAccount[playerid] = 1;
ShowMainMenuDialog(playerid, 1);
return 1;
}
else
{
if( strfind( playername, "_", true) == -1 )
{
SendClientMessageEx( playerid, COLOR_WHITE, "Connection rejected. Please get a name in the correct format like: James_Bob." );
}
else
{
gPlayerAccount[playerid] = 0;
ShowMainMenuDialog(playerid, 2);
}
return 1;
}
}
Код:
if(dialogid == MAINMENU || dialogid == MAINMENU2)
{
if(dialogid == MAINMENU)
{
if( response == 0 )
{
SendClientMessageEx(playerid, COLOR_RED, "SERVER: You have been kicked out automatically.");
Kick(playerid);
}
else
{
if(strlen(inputtext))
{
new tmppass[64];
strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
Encrypt(tmppass);
OnPlayerLogin(playerid,tmppass);
}
else
{
new loginname[64];
GetPlayerName(playerid,loginname,sizeof(loginname));
ShowPlayerDialog(playerid,MAINMENU,DIALOG_STYLE_INPUT,"Login","Incorrect password. \n \nThat name is registered, you may now enter your password.","Login","Exit");
gPlayerLogTries[playerid] += 1;
if(gPlayerLogTries[playerid] == 2) { SendClientMessageEx(playerid, COLOR_RED, "SERVER: Wrong password, you have been kicked out automatically."); Kick(playerid); }
}
}
}
if(dialogid == MAINMENU2)
{
if(strlen(inputtext))
{
GetPlayerName(playerid, sendername, sizeof(sendername));
if(doesAccountExist(sendername))
{
SendClientMessageEx(playerid, COLOR_YELLOW, "That username is already taken, please choose a different one.");
return 1;
}
new tmppass[64];
strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
Encrypt(tmppass);
OnPlayerRegister(playerid,tmppass);
}
}
}


