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



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

Code:
new value;
0.4 * inputtext = value; // ERROR
GivePlayerMoney(playerid, value);



AW: error 033: array must be indexed (variable "inputtext") - Kaliber - 06.03.2015

Write it like this:

Code:
new value = 0.4 * strval(inputtext); // ERROR
GivePlayerMoney(playerid, value);
Greekz


Re: error 033: array must be indexed (variable "inputtext") - dan40o - 06.03.2015

Tag mistmatch
Code:
new value = 0.4 * strval(inputtext);



Re: error 033: array must be indexed (variable "inputtext") - HY - 06.03.2015

pawn Code:
new value;
value = 0.4 * strval(inputtext);



Re: error 033: array must be indexed (variable "inputtext") - dan40o - 06.03.2015

Thanks all REP++


Re: error 033: array must be indexed (variable "inputtext") - dan40o - 06.03.2015

hm.. It doesn't work. If i type 6 it shows 12904821094 and give me 1293031 money

Code:
new hh[128], value;
value = strval(inputtext) * 0.4;   <=== TAG MISMATCH
GivePlayerMoney(playerid, value);
Still tag mismatch.


Re: error 033: array must be indexed (variable "inputtext") - Threshold - 06.03.2015

pawn Code:
new Float:value = strval(inputtext) * 0.4;
    GivePlayerMoney(playerid, floatround(value, floatround_round));
References:
https://sampwiki.blast.hk/wiki/Floatround
https://sampwiki.blast.hk/wiki/Floats

EDIT:

I would also recommend that you set a limit on what a player can enter. To make sure they don't enter negative or very high positive values such as -194581371489144 and 19478189587175 for instance.
Example:
pawn Code:
if(!(1 <= strval(inputtext) <= 999999999)) return SendClientMessage(playerid, -1, "You must put a value between 1 and 999999999.");



Re: error 033: array must be indexed (variable "inputtext") - dan40o - 06.03.2015

I've already have limit:

Code:
if(strval(inputtext) >= 100 || strval(inputtext) <= 700)



Re: error 033: array must be indexed (variable "inputtext") - dan40o - 06.03.2015

Yep. Now i fixed it and working. Thanks again REP++.