Error 006: Must be assigned to an array. -
iGetty - 11.08.2011
I don't understand the error "Must be assigned to an array."
Please help.
Re: Error 006: Must be assigned to an array. -
Backwardsman97 - 11.08.2011
You need an array to store strings.
pawn Код:
new amount[128] = inputtext;
Re: Error 006: Must be assigned to an array. -
iGetty - 11.08.2011
Testing it now, will return here, with an edit of result:
(475
: error 008: must be a constant expression; assumed zero
(4759) : error 033: array must be indexed (variable "amount")
(4766) : error 033: array must be indexed (variable "amount")
There's the edit ^.
Re: Error 006: Must be assigned to an array. -
Backwardsman97 - 11.08.2011
Show the other code
Re: Error 006: Must be assigned to an array. -
iGetty - 11.08.2011
Quote:
Originally Posted by Backwardsman97
Show the other code
|
I'll show the full dialog code, I have currently commented them off at the minte:
pawn Код:
case 1336:
{
//new amount[128] = inputtext;
//if(Player[playerid][Money] >= amount)
//{
// SendClientMessage(playerid, WHITE, "You don't have that much cash on you.");
//}
//else
{
new tmp[256], JFS[256];
//Player[playerid][BankMoney] += amount;
format(tmp, sizeof(tmp), "{FFFFFF}Account: %s", RemoveUnderScore(playerid));
format(tmp, sizeof(tmp), "{FFFFFF}New Balance: {254C01}$%s", Player[playerid][BankMoney]);
strins(JFS, tmp, strlen(JFS));
ShowPlayerDialog(playerid, 1245, DIALOG_STYLE_MSGBOX, "Southern Life - New Balance.", tmp, "OK", "");
return 1;
}
}
Re: Error 006: Must be assigned to an array. -
JaTochNietDan - 11.08.2011
I assume that Player[playerid][Money] is an integer? and so is the BankMoney enumeration? You cannot compare an integer to a string like that, nor increment it like that, nor would you really want to, instead I suggest doing this:
pawn Код:
new amount = strval(inputtext);
That will get the integer value of the inputtext and store it in amount as an integer, so therefore the rest of your code should function as intended.
-
iGetty - 11.08.2011
I'm testing that now, JaTochNietDan
, Thank you.
Again, I will edit this post:
Worked!
, THANK YOU! +1 reputation for the both of you, +1 the the other guy for attempting, and +1 for you helping
.
pawn Код:
format(tmp, sizeof(tmp), "{FFFFFF}Account: %s", RemoveUnderScore(playerid));
format(tmp, sizeof(tmp), "{FFFFFF}New Balance: {254C01}$%s", Player[playerid][BankMoney]);
strins(JFS, tmp, strlen(JFS));
How comes that these lines don't show in the dialog? Just the bottom line.
EDIT: Sorry, this was meant to be an edit.
Re: Error 006: Must be assigned to an array. -
JaTochNietDan - 11.08.2011
Because you're formatting tmp twice and the old value is over-written the second time, why are you even using two formats? This can easily be achieved with a single one. Additionally you're inserting the value as a string when it is an integer in the second format, you need to use %d for integers, for example:
pawn Код:
format(tmp, sizeof(tmp), "{FFFFFF}Account: %s\n{FFFFFF}New Balance: {254C01}$%d", RemoveUnderScore(playerid), Player[playerid][BankMoney]);
I suggest you read the PAWN documentation over at CompuPhase's website.
Re: Error 006: Must be assigned to an array. -
iGetty - 11.08.2011
Thank you, compiling it now :3.