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

i've made a dialog but when i compile it i get that error

Код:
C:\Documents and Settings\Propriйtaire\Bureau\San Andreas Miultiplayer Folders\LASF- Roleplay\gamemodes\bc.pwn(4467) : error 033: array must be indexed (variable "inputtext")
C:\Documents and Settings\Propriйtaire\Bureau\San Andreas Miultiplayer Folders\LASF-Roleplay\gamemodes\bc.pwn(4468) : error 033: array must be indexed (variable "inputtext")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
This is the script

Код:
    if(dialogid == 8)
    {
		 if(response)
		 switch(listitem)
		 {
		   case 0: //bait
		   {
			   if(PlayerInfo[playerid][Money] <= 250) return SCM(playerid, COLOR_GREY,"You dont have enough money on you");
	           ShowPlayerDialog(playerid, 14,DIALOG_STYLE_INPUT,"Ammount","How much bait you want to buy(1-20 max)","Select","Return");
		   }
		   case 1: //Fishing Rod
		   {
			  if(PlayerInfo[playerid][Money] <= 500) return SCM(playerid, COLOR_GREY,"You dont have enough money on you");
			  GivePlayerMoney(playerid, -500);
			  PlayerInfo[playerid][Money] -= 500;
			  SendClientMessage(playerid,COLOR_YELLOW,"You have bought a fishing rod.");
			  PlayerInfo[playerid][FishingRod] ++;
		   }
	     }
    }
    if(dialogid == 14)
    {
	  if(!response) return   ShowPlayerDialog(playerid, 8, DIALOG_STYLE_LIST,"{FEFEFE}Fishing Store","Bait                       $250\nFishing Rod                $500","Select","Cancel");
      if(response)
	  {
			 new str[256],ammount;
			 format(str,sizeof(str),"You have bought %i from the fishing store", inputtext);
			 SendClientMessage(playerid,COLOR_YELLOW,str);
			 PlayerInfo[playerid][Bait] == inputtext; //<---- in this line
			 ammount = inputtext * 12.5;  // <----------- and this line too
			 GivePlayerMoney(playerid, -ammount);
			 PlayerInfo[playerid][Money] -= ammount;

      }
    }
    return 1;
}
any idea what does that mean ?
Reply
#2

http://lmgtfy.com/?q=samp+how+to+index+an+array
Reply
#3

Inputtext is a string, not an int/float.

McBan, your answer has nothing to do with this.
Reply
#4

Код:
    if(dialogid == 14)
    {
	  if(!response) return   ShowPlayerDialog(playerid, 8, DIALOG_STYLE_LIST,"{FEFEFE}Fishing Store","Bait                       $250\nFishing Rod                $500","Select","Cancel");
          if(response)
	  {
                         new str[256],ammount;
			 format(str,sizeof(str),"You have bought %s from the fishing store", inputtext);
			 SendClientMessage(playerid,COLOR_YELLOW,str);
			 PlayerInfo[playerid][Bait] = strval(inputtext); //<---- line fix
			 ammount = strval(inputtext) * 12.5;  // <----------- line fix
			 GivePlayerMoney(playerid, -ammount);
			 PlayerInfo[playerid][Money] -= ammount;
          }
Reply
#5

Oh alright thank you Stinged for this information and thanks BlackM as well. it's fixed now, +REP both of you
Reply
#6

Oh, it's compiled but strval(inputtext) dosent give me the exact number that i insert in the dialog, i mean when i try to buy 1 ammount of bait it should cost 12.5 but IG i got -15646545615465 ?
Reply
#7

Код:
new str[256], Float:ammount;
Reply
#8

Still the same problem, nothing changed at all :/
Reply
#9

Does the client message show "inputtext" correctly?
Reply
#10

No, it dosent, when i type "2" it becomes "50"
Not sure if this is related to the problem, but when i compile it i get this warning
Код:
(4469) : warning 213: tag mismatch
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase
In this line:
Код:
	                 new str[256],Float:ammount;
			 format(str,sizeof(str),"You have bought %i from the fishing store", inputtext);
			 SendClientMessage(playerid,COLOR_YELLOW,str);
			 PlayerInfo[playerid][Bait] = strval(inputtext);
			 ammount = strval(inputtext) * 12.5;
			 GivePlayerMoney(playerid, - ammount); <---- this one
			 PlayerInfo[playerid][Money] -= ammount;
Reply
#11

Well try this code: (Note: due to possible tag mismatching I changed "12.5" to "12". I advise u to do so)
Код:
    if(dialogid == 14)
    {
	  if(!response) return   ShowPlayerDialog(playerid, 8, DIALOG_STYLE_LIST,"{FEFEFE}Fishing Store","Bait                       $250\nFishing Rod                $500","Select","Cancel");
          if(response)
	  {
                         new str[256],ammount;
                         new inputvalue = strval(inputtext);
			 format(str,sizeof(str),"You have bought %d from the fishing store", inputvalue);
			 SendClientMessage(playerid,COLOR_YELLOW,str);
			 PlayerInfo[playerid][Bait] = inputvalue; 
			 ammount = inputvalue * 12;  
			 GivePlayerMoney(playerid, -ammount);
			 PlayerInfo[playerid][Money] -= ammount;
          }
Reply
#12

Nope, it's the same problem aswell.. i am really confused i don't know what's seems to be the problem
Reply
#13

Make sure "ammount" is not a float anymore. Furthermore, the code BlackM posted looks fine and should work properly.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)