PDA

View Full Version : Help with login with 3 warnings.


NixsaHD
16/01/2018, 08:05 PM
Hello, when players come to server and login when is password wrong players will be kicked. Now how to add 3-more warn?. When on 3.rd players type wrong password , player will be kicked. Sry for my English.
// Process the login-dialog
Dialog_Login(playerid, response, inputtext[])
{
switch (response) // Check which button was clicked
{
case 1: // Player clicked "Login"
{
// Check if the player entered a password
if (strlen(inputtext) > 0)
{
// Check if the entered password is the same as the password saved in the player's account
if (strcmp(APlayerData[playerid][PlayerPassword], inputtext, false) == 0)
{
APlayerData[playerid][LoggedIn] = true; // The player has logged in properly
BankFile_Load(playerid); // Load your bank account (if it exists, the player will be notified about this)
SendClientMessage(playerid, 0xFFFFFFFF, TXT_LoggedIn); // Send a message to the client to inform him that he logged in properley
}
else
{
SendClientMessage(playerid, 0xFFFFFFFF, TXT_WrongPassword);
// Kick(playerid);
}
}
else
{
SendClientMessage(playerid, 0xFFFFFFFF, TXT_WrongPassword);
Kick(playerid);
}
}
case 0: // Player clicked "Cancel"
{
// Show a message that the player must be logged in to play on this server
SendClientMessage(playerid, 0xFFFFFFFF, TXT_PlayerMustLogin);
// Kick the player
Kick(playerid);
}
}

return 1;
}

NixsaHD
16/01/2018, 08:28 PM
Some one?

Lucases
16/01/2018, 08:38 PM
At the top of your script


new LoginAttemps[MAX_PLAYERS];

forward public KickPlayer(playerid);
public KickPlayer(playerid) return Kick(playerid);



Then edit your code in this part



if (strcmp(APlayerData[playerid][PlayerPassword], inputtext, false) == 0)
{
APlayerData[playerid][LoggedIn] = true; // The player has logged in properly
BankFile_Load(playerid); // Load your bank account (if it exists, the player will be notified about this)
SendClientMessage(playerid, 0xFFFFFFFF, TXT_LoggedIn); // Send a message to the client to inform him that he logged in properley
}
else
{
LoginAttempts[playerid]++;
if(LoginAttempts[playerid] >= 3) {
SetTimerEx("KickPlayer", 200, false, "i" playerid);
SendClientMessage(playerid, 0xFFFFFFFF, TXT_WrongPassword);
}
}

NixsaHD
16/01/2018, 08:53 PM
I getting error:
Dialogs.inc(67) : error 017: undefined symbol "LoginAttempts"
Dialogs.inc(67) : warning 215: expression has no effect
Dialogs.inc(67) : error 001: expected token: ";", but found "]"
Dialogs.inc(67) : error 029: invalid expression, assumed zero
Dialogs.inc(67) : fatal error 107: too many error messages on one line


Dialog_Login(playerid, response, inputtext[])
{

switch (response) // Check which button was clicked
{
case 1: // Player clicked "Login"
{
// Check if the player entered a password
if (strlen(inputtext) > 0)
{
// Check if the entered password is the same as the password saved in the player's account
if (strcmp(APlayerData[playerid][PlayerPassword], inputtext, false) == 0)
{
APlayerData[playerid][LoggedIn] = true; // The player has logged in properly
BankFile_Load(playerid); // Load your bank account (if it exists, the player will be notified about this)
SendClientMessage(playerid, 0xFFFFFFFF, TXT_LoggedIn); // Send a message to the client to inform him that he logged in properley
}
else
{
LoginAttempts[playerid]++;
if(LoginAttempts[playerid] >= 3) {
SetTimerEx("KickPlayer", 200, false, "i" playerid);
SendClientMessage(playerid, 0xFFFFFFFF, TXT_WrongPassword);
}
}
case 0: // Player clicked "Cancel"
{
// Show a message that the player must be logged in to play on this server
SendClientMessage(playerid, 0xFFFFFFFF, TXT_PlayerMustLogin);
// Kick the player
Kick(playerid);
}
}

return 1;
}

Where i faill?

Lucases
16/01/2018, 08:54 PM
Did you add the variable at the top of your script like I have said?

Also remember to add


LoginAttempts[playerid]=0;

Under OnPlayerConnect

NixsaHD
16/01/2018, 08:55 PM
I defined: TO TOP.

new LoginAttemps[MAX_PLAYERS];
forward public KickPlayer(playerid);
public KickPlayer(playerid) return Kick(playerid);

Lucases
16/01/2018, 08:57 PM
I defined: TO TOP.

new LoginAttemps[MAX_PLAYERS];
forward public KickPlayer(playerid);
public KickPlayer(playerid) return Kick(playerid);

Sorry my bad

Change


new LoginAttemps[MAX_PLAYERS];


To


new LoginAttempts[MAX_PLAYERS];




Also



public OnPlayerConnect(playerid)
{
LoginAttempts[playerid] = 0;
return 1;
}

NixsaHD
16/01/2018, 09:02 PM
This is clear error, but he shows news error -_-

Dialogs.inc(4) : error 021: symbol already defined: "KickPlayer"
Dialogs.inc(73) : error 001: expected token: "-string end-", but found "-identifier-"
Dialogs.inc(73) : warning 215: expression has no effect
Dialogs.inc(73) : error 001: expected token: ";", but found ")"
Dialogs.inc(73) : error 029: invalid expression, assumed zero
Dialogs.inc(73) : fatal error 107: too many error messages on one line

73-76.
{
LoginAttempts[playerid]++;
if(LoginAttempts[playerid] >= 3) {
SetTimerEx("KickPlayer", 200, false, "i" playerid);
SendClientMessage(playerid, 0xFFFFFFFF, TXT_WrongPassword);
}
}

Lucases
16/01/2018, 09:05 PM
You have already defined KickPlayer

Replace KickPlayer in my code with something else, like AttemptsKick

NixsaHD
16/01/2018, 09:16 PM
I rename KickPlayer on top to AttemptsLick, thats works, now i have other error:
Dialogs.inc(74) : error 001: expected token: "-string end-", but found "-identifier-"
Dialogs.inc(74) : warning 215: expression has no effect
Dialogs.inc(74) : error 001: expected token: ";", but found ")"
Dialogs.inc(74) : error 029: invalid expression, assumed zero
Dialogs.inc(74) : fatal error 107: too many error messages on one line

70-77line
else
{
LoginAttempts[playerid]++;
if(LoginAttempts[playerid] >= 3) {
SetTimerEx("AttemptsKick", 200, false, "i" playerid);
SendClientMessage(playerid, 0xFFFFFFFF, TXT_WrongPassword);
}
}

NixsaHD
16/01/2018, 09:36 PM
Idk what can be wrong here

NixsaHD
17/01/2018, 02:45 PM
You have already defined KickPlayer

Replace KickPlayer in my code with something else, like AttemptsKick

that works, but i have new error.

Lucases
17/01/2018, 04:27 PM
that works, but i have new error.


Post it here

NixsaHD
17/01/2018, 04:38 PM
Post it here

Dialog_Login(playerid, response, inputtext[])
{

switch (response) // Check which button was clicked
{
case 1: // Player clicked "Login"
{
// Check if the player entered a password
if (strlen(inputtext) > 0)
{
// Check if the entered password is the same as the password saved in the player's account
if (strcmp(APlayerData[playerid][PlayerPassword], inputtext, false) == 0)
{
APlayerData[playerid][LoggedIn] = true; // The player has logged in properly
BankFile_Load(playerid); // Load your bank account (if it exists, the player will be notified about this)
SendClientMessage(playerid, 0xFFFFFFFF, TXT_LoggedIn); // Send a message to the client to inform him that he logged in properley
}
else
{
LoginAttempts[playerid]++;
if(LoginAttempts[playerid] >= 3){
SetTimerEx("AttemptsKick", 2000, false, "i", playerid);
SendClientMessage(playerid, 0xFFFFFFFF, TXT_WrongPassword);
}
}
}
}
case 0: // Player clicked "Cancel"
{
// Show a message that the player must be logged in to play on this server
SendClientMessage(playerid, 0xFFFFFFFF, TXT_PlayerMustLogin);
// Kick the player
Kick(playerid);
}
}

return 1;
}
Error on script: pwn(2805) : warning 203: symbol is never used: "LoginAttemps"


On top script i define:
new LoginAttemps[MAX_PLAYERS];

Public OnPlayerConnect(playerid)
{
LoginAttempts[playerid] = 0;
return 1;
}

NixsaHD
17/01/2018, 05:07 PM
Post it here

Im define 2x time: new LoginAttemps[MAX_PLAYERS];
i remove one, that remove error, and working, but when i faill password on login server kick me, i dont get 3 attempts. Why? code is up.

Lucases
17/01/2018, 05:09 PM
Im define 2x time: new LoginAttemps[MAX_PLAYERS];
i remove one, that remove error, and working, but when i faill password on login server kick me, i dont get 3 attempts. Why? code is up.

Do you reset the variable under OnPlayerConnect?

NixsaHD
18/01/2018, 03:03 PM
Do you reset the variable under OnPlayerConnect?
In OnPlayerConnect has nothing to do with login or the like, just it: new LoginAttemps[MAX_PLAYERS];

Lucases
18/01/2018, 03:44 PM
It's not LoginAttemps, delete that, it's LoginAttempts.

You need to create that variable at the top of your script, under color defines.etc.

You need to reset the variable under OnPlayerConnect or you will always get kicked

NixsaHD
18/01/2018, 07:49 PM
It's not LoginAttemps, delete that, it's LoginAttempts.

You need to create that variable at the top of your script, under color defines.etc.

You need to reset the variable under OnPlayerConnect or you will always get kicked

Okay, yeah im so bored -_-.

I dont have error, but i have kick on login when faill password.

Im define it on top script:
forward public AttemptsKick(playerid);
public AttemptsKick(playerid) return Kick(playerid);
new LoginAttempts[MAX_PLAYERS];

This in OnPlayerConnect
LoginAttempts[playerid] = 0;

Thats is full dialog login:
Dialog_Login(playerid, response, inputtext[])
{

switch (response) // Check which button was clicked
{
case 1: // Player clicked "Login"
{
// Check if the player entered a password
if (strlen(inputtext) > 0)
{
// Check if the entered password is the same as the password saved in the player's account
if (strcmp(APlayerData[playerid][PlayerPassword], inputtext, false) == 0)
{
APlayerData[playerid][LoggedIn] = true; // The player has logged in properly
BankFile_Load(playerid); // Load your bank account (if it exists, the player will be notified about this)
SpawnPlayer(playerid);
SetPlayerColor(playerid, COLOR_WHITE);
SendClientMessage(playerid, 0xFFFFFFFF, TXT_LoggedIn); // Send a message to the client to inform him that he logged in properly
}
else
{
LoginAttempts[playerid]++;
if(LoginAttempts[playerid] >= 3){
SetTimerEx("AttemptsKick", 2000, false, "i", playerid);
SendClientMessage(playerid, 0xFFFFFFFF, TXT_WrongPassword);
}
}
}
}
case 0: // Player clicked "Cancel"
{
// Show a message that the player must be logged in to play on this server
SendClientMessage(playerid, 0xFFFFFFFF, TXT_PlayerMustLogin);
// Kick the player
Kick(playerid);
}
}

return 1;
}

Lucases
18/01/2018, 08:01 PM
First you don't show the dialog again after the player types a wrong password, second you put 2000 in the timer, it's a lot, make it 300.

NixsaHD
18/01/2018, 08:10 PM
First you don't show the dialog again after the player types a wrong password, second you put 2000 in the timer, it's a lot, make it 300.

How u thinks show dialog?
When i come to server, i get dialog for login, i type faill password to test, but server spawn me and kick, thats all in 3sc
Im change it, from 2000 to 300. But nothing i have kick