error 033: array must be indexed (variable "inputtext") -
Lexus95 - 31.07.2014
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 ?
Re: error 033: array must be indexed (variable "inputtext") -
McBan - 31.07.2014
http://lmgtfy.com/?q=samp+how+to+index+an+array
Re: error 033: array must be indexed (variable "inputtext") -
Stinged - 31.07.2014
Inputtext is a string, not an int/float.
McBan, your answer has nothing to do with this.
Re: error 033: array must be indexed (variable "inputtext") -
BlackM - 31.07.2014
Код:
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;
}
Re : error 033: array must be indexed (variable "inputtext") -
Lexus95 - 31.07.2014
Oh alright thank you Stinged for this information

and thanks BlackM as well. it's fixed now, +REP both of you
Re : error 033: array must be indexed (variable "inputtext") -
Lexus95 - 31.07.2014
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

?
Re: error 033: array must be indexed (variable "inputtext") -
BlackM - 31.07.2014
Код:
new str[256], Float:ammount;
Re : error 033: array must be indexed (variable "inputtext") -
Lexus95 - 31.07.2014
Still the same problem, nothing changed at all :/
Re: error 033: array must be indexed (variable "inputtext") -
BlackM - 31.07.2014
Does the client message show "inputtext" correctly?
Re : error 033: array must be indexed (variable "inputtext") -
Lexus95 - 31.07.2014
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;
Re: error 033: array must be indexed (variable "inputtext") -
BlackM - 31.07.2014
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;
}
Re : error 033: array must be indexed (variable "inputtext") -
Lexus95 - 31.07.2014
Nope, it's the same problem aswell.. i am really confused i don't know what's seems to be the problem
Re: error 033: array must be indexed (variable "inputtext") -
Basssiiie - 01.08.2014
Make sure "ammount" is not a float anymore. Furthermore, the code BlackM posted looks fine and should work properly.