// 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;
}
new LoginAttemps[MAX_PLAYERS];
forward public KickPlayer(playerid);
public KickPlayer(playerid) return Kick(playerid);
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);
}
}
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;
}
LoginAttempts[playerid]=0;
I defined: TO TOP.
new LoginAttemps[MAX_PLAYERS]; forward public KickPlayer(playerid); public KickPlayer(playerid) return Kick(playerid); |
new LoginAttemps[MAX_PLAYERS];
new LoginAttempts[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
LoginAttempts[playerid] = 0;
return 1;
}