Make this line work?
#1

if(inputtext == AccountInfo[playerid][Password])

error 033: array must be indexed (variable "inputtext")

OR if its not possible:

Код:
if(dialogid == 2)
{
  if(response) {
    new string[128];
 		if(AccountInfo[playerid][Logged] == 1) return SendClientMessage(playerid, RED, "You are already logged in.");
 		new plname[MAX_PLAYER_NAME];
  		GetPlayerName(playerid, plname, sizeof(plname));
		format(string, sizeof(string), "/sAccounts/%s.seifadmin", plname);
		if(!fexist(string))
		{
		ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Please register your account.", "Please input the password you want to register with", "Register", "Cancel");
	 	return SendClientMessage(playerid, RED, "That account isn't registered! Please register: /register [password]");
		}
		if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Please login to your account.", "Please input the password to your account", "Login", "Cancel");
		OnPlayerLogin(playerid,inputtext);
		}
}
return 0;
}
Make that so it doesnt log you in if you type any old crap in.

Thanks,
Cozza
Reply
#2

use strcmp and could you stop creating for each problem a new topic use the search function or pawn-lang.pdf
Reply
#3

yeah, good idea... use strcmp for a dialog...
Reply
#4

Quote:
Originally Posted by XxCozzaxX
yeah, good idea... use strcmp for a dialog...
you asked "Make this line work" ( if(inputtext == AccountInfo[playerid][Password]) )

pawn Код:
if(strcmp(inputtext, AccountInfo[playerid][Password], false) == 0)
and the "OR if its not possible:" I ignored because its possible

So I dont see the problem
Reply
#5

that line is part of the dialog :l but i will try it.
Reply
#6

Quote:
Originally Posted by ♣ Joker ♠
Quote:
Originally Posted by XxCozzaxX
yeah, good idea... use strcmp for a dialog...
you asked "Make this line work" ( if(inputtext == AccountInfo[playerid][Password]) )

pawn Код:
if(strcmp(inputtext, AccountInfo[playerid][Password], false) == 0)
and the "OR if its not possible:" I ignored because its possible

So I dont see the problem
My bad - didnt know strcmp works outside of onplayercommandtext!
Reply
#7

now, it says incorrect password to everything:

Код:
if(strcmp(inputtext, AccountInfo[playerid][Password], false) == 0)
    {
		OnPlayerLogin(playerid,inputtext);
 		}
		else
		{
		SendClientMessage(playerid, RED, "Incorrect Password.");
		ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Please login to your account.", "Please input the password to your account", "Login", "Cancel");
		return 1;
Reply
#8

the code is absolutly correct, did you load the password from a file ? did you deleted the /r/n at the end ?
best solution print inputtext and AccountInfo[playerid][Password] and check whats different
Reply
#9

how to open the file?

The OnPlayerLogin(playerid) looks like this:

pawn Код:
public OnPlayerLogin(playerid, password[])
{
  new name[MAX_PLAYER_NAME], str[128];
  GetPlayerName(playerid, name, sizeof name);
    format(str, sizeof str, "/sAccounts/%s.seifadmin", name);
    new File:account = fopen(str, io_read);
    if (account)
    {
      new pass[256];
      new passres[128], value[128];
      fread(account, pass, sizeof pass);
      passres = GetFileString(pass);
      if (!strcmp("Password", passres))
        {
            value = GetFileValue(pass);
            strmid(AccountInfo[playerid][Password], value, 0, strlen(value)-1, 128);
        }
        if (!strcmp(AccountInfo[playerid][Password], password, true))
        {
          while (fread(account, pass, 256))
            {
                passres = GetFileString(pass);
                if (strfind(passres, "AdminLevel") != -1)
                {
                    value = GetFileValue(pass);
                    AccountInfo[playerid][AdminLevel] = strval(value);
                }
                if (strfind(passres, "Cash") != -1)
                {
                    value = GetFileValue(pass);
                    AccountInfo[playerid][Cash] = strval(value);
                }
        if (strfind(passres, "Warnings") != -1)
                {
                    value = GetFileValue(pass);
                    AccountInfo[playerid][Warns] = strval(value);
                }
                if (strfind(passres, "WarnReason1") != -1)
                {
                    value = GetFileValue(pass);
                    strmid(AccountInfo[playerid][WarnReason1], value, 0, strlen(value)-1, 128);
                }
                if (strfind(passres, "WarnReason2") != -1)
                {
                    value = GetFileValue(pass);
                    strmid(AccountInfo[playerid][WarnReason2], value, 0, strlen(value)-1, 128);
                }
                if (strfind(passres, "WarnReason3") != -1)
                {
                    value = GetFileValue(pass);
                    strmid(AccountInfo[playerid][WarnReason3], value, 0, strlen(value)-1, 128);
                }
            }
            fclose(account);
      AccountInfo[playerid][Logged] = 1;
        }
        else
        {
            SendClientMessage(playerid, RED, "Incorrect Password.");
            ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Please login to your account.", "Please input the password to your account", "Login", "Cancel");
        fclose(account);
        return 1;
        }
        GivePlayerMoney(playerid, AccountInfo[playerid][Cash]);
        format(str, sizeof str, "|- You have successfully logged in as %s -|", name);
        SendClientMessage(playerid, GREEN, str);
        printf("%s has logged in", name);
        if (AccountInfo[playerid][AdminLevel] > 0)
        {
        format(str, sizeof str, "|» You are now logged in as a level %d admin «|", AccountInfo[playerid][AdminLevel]);
            SendClientMessage(playerid, LIGHTGREEN, str);
            ViewCmds[playerid] = 0;
        }
    }
    return 1;
}
And what im trying to do:

pawn Код:
if(dialogid == 2)
{
  if(response) {
    new string[128];
        if(AccountInfo[playerid][Logged] == 1) return SendClientMessage(playerid, RED, "You are already logged in.");
        new plname[MAX_PLAYER_NAME];
        GetPlayerName(playerid, plname, sizeof(plname));
        format(string, sizeof(string), "/sAccounts/%s.seifadmin", plname);
        if(!fexist(string))
        {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Please register your account.", "Please input the password you want to register with", "Register", "Cancel");
        return SendClientMessage(playerid, RED, "That account isn't registered! Please register: /register [password]");
        }
        if(fexist(string))
        {
        if(!strlen(inputtext)) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Please login to your account.", "Please input the password to your account", "Login", "Cancel");
    if(strcmp(inputtext, AccountInfo[playerid][Password], false) == 0)
    {
        OnPlayerLogin(playerid,inputtext);
        }
        else
        {
        SendClientMessage(playerid, RED, "Incorrect Password.");
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Please login to your account.", "Please input the password to your account", "Login", "Cancel");
        return 1;
        }
        }
        }
}
return 0;
}
^ i think thats completely wrong. Compiles though.. thats a start.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)