SA-MP Forums Archive
error 033: array must be indexed (variable "tmp") - 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: error 033: array must be indexed (variable "tmp") (/showthread.php?tid=341172)



error 033: array must be indexed (variable "tmp") - adampoconnor - 09.05.2012

pawn Код:
//475   if(dialogid == DIALOG_LOGIN)
//476   {
//477       if(!response)
//478       {
//479            SendClientMessage(playerid, COLOR_RED,"You have been kicked as you have selected 'Quit'.");
//480            Kick(playerid);
//481       }
//482       else if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"This Account Is Registered","Please Login","Submit","Quit");
//483       new tmp[50];
//484           format(Query, sizeof(Query), "SELECT * FROM SAMPplayers WHERE name='%s'", name);
//485       mysql_query(Query);
//486       mysql_store_result();
//487       tmp = mysql_fetch_field_row(tmp,"Password");
//488       if(udb_hash(inputtext) != tmp) {
//489            SendClientMessage(playerid, COLOR_RED," Invalid Password");
//490            ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,"This Account Is Registered","Please Login","Submit","Quit");
//491       }
//492       else
//493       {
//494            format(string,sizeof(string),"Welcome back %s! Spawning where you last quit...",name);
//495            SendClientMessage(playerid,COLOR_JOIN,string);
//496            SetPlayerInterior(playerid,0);
//497            SetTimerEx("SpawnLastSaved",1000,false,"i",playerid);
//498       }
//499   }
//500   mysql_free_result();
//501   return 1;
//502 }
Errors:
pawn Код:
TEST.pwn(487) : error 033: array must be indexed (variable "tmp")
TEST.pwn(488) : error 033: array must be indexed (variable "tmp")



Re: error 033: array must be indexed (variable "tmp") - Jonny5 - 09.05.2012

pawn Код:
mysql_fetch_field_row(tmp,"Password");
if(strcmp(udb_hash(inputtext) ,true, tmp));
you can't use strings like that, they are just arrays of chars
the first line is passing the var into it so no need for tmp=

and the second youll need to use strcmp like i showed,
you cant do
if(string==otherstring)

EDIT:

ops!
Vince is correct, I dont use this hash as its to weak

new code

pawn Код:
mysql_fetch_field_row(tmp,"Password");
if (udb_hash(inputtext) != strval(tmp))
this should work..
not sure if its better to convert to integer or to format the pass into a string.


Re: error 033: array must be indexed (variable "tmp") - Vince - 09.05.2012

udb_hash generates an integer, actually. But then again, you would be comparing an integer with a string which obviously isn't going to work out either.


Re: error 033: array must be indexed (variable "tmp") - adampoconnor - 09.05.2012

Thanks Jonny it worked.