SA-MP Forums Archive
Scripting Help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Scripting Help (/showthread.php?tid=525907)



Scripting Help - kirostar - 14.07.2014

I discovered a very horrible problem at my server.
When you login to the server you have to type the password, but when i click login or click enter. it log in

So, i added this code :

PHP код:
if (isnull(inputtext)) return SendClientMessage(playerid, -1""RED"ERROR: "GREY"You have not specified any password."); 
But it still not working.

Here's the code :

PHP код:
ShowPlayerDialog(playeridLOGINDIALOG_STYLE_PASSWORD""RED">> "PREMIUM"Account Login"""WHITE"Welcome back to "RED"Extreme Street Fighters"WHITE"!\n"WHITE"This account is "GREEN"registered"WHITE".\n\n"YELLOW"» Please enter your password below to login.""Login""Quit");
PlayerInfo[playerid][LoginFail]++;
if (
isnull(inputtext)) return SendClientMessage(playerid, -1""RED"ERROR: "GREY"You have not specified any password"); // This code
switch (PlayerInfo[playerid][LoginFail])
                {
case 
1SendClientMessage(playerid, -1""RED":: "GREY"You have entered an incorrect password! (1/3)");
case 
2SendClientMessage(playerid, -1""RED"::  "GREY"You have entered an incorrect password! (2/3)");
case 
3:
                    {
                        
SendClientMessage(playerid, -1""RED":: "GREY"You have reached your maximum login attempts! (3/3)");
                        
SetTimerEx("KickOnFail"500false"i"playerid);
                       }
                }
                return 
1
Help


Re: Scripting Help - hardcode - 14.07.2014

Try strlen:

pawn Код:
if(!strlen(inputtext))



Re: Scripting Help - kirostar - 14.07.2014

Tried it, didn't work


Re: Scripting Help - BroZeus - 14.07.2014

show us more of the code
whole code of dialog login


Re: Scripting Help - kirostar - 14.07.2014

PHP код:
    if (dialogid == LOGIN)
    {
        if (!
response) return Kick(playerid);
        if (
response)
        {
           if(!
strcmpPlayerInfo[playerid][Password],inputtextfalse))
           {
                new 
str[250], AdminRank[50], msg[128], str2[128];
                
INI_ParseFile(UserPath(playerid), "loadaccount_%s", .bExtra true, .extra playerid);
                
SetPlayerScore(playeridPlayerInfo[playerid][Score]);
                
GivePlayerMoney(playeridPlayerInfo[playerid][Cash]);
                
SetPlayerColor(playeridPlayerInfo[playerid][Color]);
                switch(
PlayerInfo[playerid][Admin])
                {
                    case 
1AdminRank "Moderator";
                    case 
2AdminRank "Administrator";
                    case 
3AdminRank "Head Administrator";
                    case 
4AdminRank "Server Owner";
                }
                if (
PlayerInfo[playerid][VIP] >= && isnull(PlayerInfo[playerid][AltName]))
                {
                    
format(msgsizeof(msg), "{FFD700}[EsF] {87F5EA}VIP {%06x}%s(%d) {A1D4CF}{87F5EA}has logged in.", (GetPlayerColor(playerid) >>> 8), GetName(playerid), playerid);
                    
SendClientMessageToAll(-1msg);
                }
                   else if (
PlayerInfo[playerid][VIP] >= 1)
                {
                    
format(msgsizeof(msg), "{FFD700}[EsF] {87F5EA}VIP {%06x}%s(%d) {A1D4CF}(%s) {87F5EA}has logged in.", (GetPlayerColor(playerid) >>> 8), GetName(playerid), playeridPlayerInfo[playerid][AltName]);
                       
SendClientMessageToAll(-1msg);
                }
                if (
PlayerInfo[playerid][Admin] >= 1)
                {
                    
format(msgsizeof(msg), "{FFD700}[EsF] {DEF968}%s {%06x}%s(%d) {DEF968}has logged in."AdminRank, (GetPlayerColor(playerid) >>> 8), GetName(playerid), playerid);
                    
SendClientMessageToAll(-1msg);
                }
                
format(strsizeof(str), "** Welcome back, %s! You were last online on {CB6CE6}%s{FFB6C1}!"GetName(playerid), lastactive[playerid]);
                
SendClientMessage(playeridCOLOR_PINKstr);
                
format(str2sizeof(str2), "** You have been online for %i hours and %i minutes in total."PlayerInfo[playerid][Hours], PlayerInfo[playerid][Minutes]);
                
SendClientMessage(playerid0xFFD70075str2);
                
TD_MSG(playerid3000"~b~~h~Welcome back!~n~~b~~h~You have successfully logged in!");
                
SpawnPlayer(playerid);
                
gOnlineTime SetTimerEx("TimeOnServer"60000true"i"playerid);
                
PlayerInfo[playerid][Spawned] = 1;
                
PlayerInfo[playerid][LoggedIn] = 1;
           }
           else
           {
                
ShowPlayerDialog(playeridLOGINDIALOG_STYLE_PASSWORD""RED">> "PREMIUM"Account Login"""WHITE"Welcome back to "RED"Extreme Street Fighters"WHITE"!\n"WHITE"This account is "GREEN"registered"WHITE".\n\n"YELLOW"» Please enter your password below to login.""Login""Quit");
                
PlayerInfo[playerid][LoginFail]++;
                if (
strlen(inputtext)) return SendClientMessage(playerid, -1""RED"ERROR: "GREY"You have not specified any password");
                switch (
PlayerInfo[playerid][LoginFail])
                {
                    case 
1SendClientMessage(playerid, -1""RED":: "GREY"You have entered an incorrect password! (1/3)");
                    case 
2SendClientMessage(playerid, -1""RED"::  "GREY"You have entered an incorrect password! (2/3)");
                    case 
3:
                    {
                        
SendClientMessage(playerid, -1""RED":: "GREY"You have reached your maximum login attempts! (3/3)");
                        
SetTimerEx("KickOnFail"500false"i"playerid);
                       }
                }
                return 
1



Re: Scripting Help - kirostar - 14.07.2014

Tried the both, not working.


Re: Scripting Help - hardcode - 14.07.2014

Quote:
Originally Posted by Ralfie
Посмотреть сообщение
Its

if(!strlen(inputtext))

Not

if (strlen(inputtext))
He/she wants to check if the inputtext is null. If there is no string length, it is null.


Re: Scripting Help - kirostar - 14.07.2014

You mean i will paste the whole LOGIN Code?


Re: Scripting Help - BroZeus - 14.07.2014

try this
pawn Код:
if (dialogid == LOGIN)
    {
        if (!response) return Kick(playerid);
        if (response)
        {
          if (isnull(inputtext) || !strlen(inputtext)) //added this and its bottm thingy
      {
 ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD, ""RED">> "PREMIUM"Account Login", ""WHITE"Welcome back to "RED"Extreme Street Fighters"WHITE"!\n"WHITE"This account is "GREEN"registered"WHITE".\n\n"YELLOW"» Please enter your password below to login.", "Login", "Quit");
 SendClientMessage(playerid, -1, ""RED"ERROR: "GREY"You have not specified any password");
return 1;
}


           if(!strcmp( PlayerInfo[playerid][Password],inputtext, false))
           {
                new str[250], AdminRank[50], msg[128], str2[128];
                INI_ParseFile(UserPath(playerid), "loadaccount_%s", .bExtra = true, .extra = playerid);
                SetPlayerScore(playerid, PlayerInfo[playerid][Score]);
                GivePlayerMoney(playerid, PlayerInfo[playerid][Cash]);
                SetPlayerColor(playerid, PlayerInfo[playerid][Color]);
                switch(PlayerInfo[playerid][Admin])
                {
                    case 1: AdminRank = "Moderator";
                    case 2: AdminRank = "Administrator";
                    case 3: AdminRank = "Head Administrator";
                    case 4: AdminRank = "Server Owner";
                }
                if (PlayerInfo[playerid][VIP] >= 1 && isnull(PlayerInfo[playerid][AltName]))
                {
                    format(msg, sizeof(msg), "{FFD700}[EsF] {87F5EA}VIP {%06x}%s(%d) {A1D4CF}{87F5EA}has logged in.", (GetPlayerColor(playerid) >>> 8), GetName(playerid), playerid);
                    SendClientMessageToAll(-1, msg);
                }
                   else if (PlayerInfo[playerid][VIP] >= 1)
                {
                    format(msg, sizeof(msg), "{FFD700}[EsF] {87F5EA}VIP {%06x}%s(%d) {A1D4CF}(%s) {87F5EA}has logged in.", (GetPlayerColor(playerid) >>> 8), GetName(playerid), playerid, PlayerInfo[playerid][AltName]);
                       SendClientMessageToAll(-1, msg);

                }
                if (PlayerInfo[playerid][Admin] >= 1)
                {
                    format(msg, sizeof(msg), "{FFD700}[EsF] {DEF968}%s {%06x}%s(%d) {DEF968}has logged in.", AdminRank, (GetPlayerColor(playerid) >>> 8), GetName(playerid), playerid);
                    SendClientMessageToAll(-1, msg);
                }
                format(str, sizeof(str), "** Welcome back, %s! You were last online on {CB6CE6}%s{FFB6C1}!", GetName(playerid), lastactive[playerid]);
                SendClientMessage(playerid, COLOR_PINK, str);
                format(str2, sizeof(str2), "** You have been online for %i hours and %i minutes in total.", PlayerInfo[playerid][Hours], PlayerInfo[playerid][Minutes]);
                SendClientMessage(playerid, 0xFFD70075, str2);
                TD_MSG(playerid, 3000, "~b~~h~Welcome back!~n~~b~~h~You have successfully logged in!");
                SpawnPlayer(playerid);
                gOnlineTime = SetTimerEx("TimeOnServer", 60000, true, "i", playerid);
                PlayerInfo[playerid][Spawned] = 1;
                PlayerInfo[playerid][LoggedIn] = 1;
           }
           else
           {
                ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_PASSWORD, ""RED">> "PREMIUM"Account Login", ""WHITE"Welcome back to "RED"Extreme Street Fighters"WHITE"!\n"WHITE"This account is "GREEN"registered"WHITE".\n\n"YELLOW"» Please enter your password below to login.", "Login", "Quit");
SendClientMessage(playerid, -1, "Wrong Message");
                PlayerInfo[playerid][LoginFail]++;
               
                switch (PlayerInfo[playerid][LoginFail])
                {
                    case 1: SendClientMessage(playerid, -1, ""RED":: "GREY"You have entered an incorrect password! (1/3)");
                    case 2: SendClientMessage(playerid, -1, ""RED"::  "GREY"You have entered an incorrect password! (2/3)");
                    case 3:
                    {
                        SendClientMessage(playerid, -1, ""RED":: "GREY"You have reached your maximum login attempts! (3/3)");
                        SetTimerEx("KickOnFail", 500, false, "i", playerid);
                       }
                }
                return 1;



Re: Scripting Help - kirostar - 14.07.2014

@BroZeus it worked