SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 11/08/2011, 04:23 AM   #1
iGetty
High-roller
 
iGetty's Avatar
 
Join Date: Sep 2010
Location: Falkirk, Scotland
Posts: 1,753
Reputation: 224
Default Error 006: Must be assigned to an array.

pawn Code:
new amount = inputtext;

I don't understand the error "Must be assigned to an array."

Please help.
iGetty is offline  
Old 11/08/2011, 04:33 AM   #2
Backwardsman97
High-roller
 
Backwardsman97's Avatar
 
Join Date: Nov 2007
Posts: 1,501
Reputation: 36
Default Re: Error 006: Must be assigned to an array.

You need an array to store strings.

pawn Code:
new amount[128] = inputtext;
Backwardsman97 is offline  
Old 11/08/2011, 04:34 AM   #3
iGetty
High-roller
 
iGetty's Avatar
 
Join Date: Sep 2010
Location: Falkirk, Scotland
Posts: 1,753
Reputation: 224
Default Re: Error 006: Must be assigned to an array.

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 ^.
iGetty is offline  
Old 11/08/2011, 04:48 AM   #4
Backwardsman97
High-roller
 
Backwardsman97's Avatar
 
Join Date: Nov 2007
Posts: 1,501
Reputation: 36
Default Re: Error 006: Must be assigned to an array.

Show the other code
Backwardsman97 is offline  
Old 11/08/2011, 04:58 AM   #5
iGetty
High-roller
 
iGetty's Avatar
 
Join Date: Sep 2010
Location: Falkirk, Scotland
Posts: 1,753
Reputation: 224
Default Re: Error 006: Must be assigned to an array.

Quote:
Originally Posted by Backwardsman97 View Post
Show the other code
I'll show the full dialog code, I have currently commented them off at the minte:

pawn Code:
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;
      }
}
iGetty is offline  
Old 11/08/2011, 05:00 AM   #6
JaTochNietDan
High-roller
 
JaTochNietDan's Avatar
 
Join Date: Apr 2007
Location: Republic of Ireland
Posts: 2,502
Reputation: 363
Default Re: Error 006: Must be assigned to an array.

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 Code:
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.
__________________
Releases:
[Includes]: [jBan] | [jBanLite]
[Plugins]: [FileManager] | [Execute]
[Applications]: [Remote Administrator *NEW] | [Script King] | [RCON GUI]
JaTochNietDan is offline  
Old 11/08/2011, 05:02 AM   #7
iGetty
High-roller
 
iGetty's Avatar
 
Join Date: Sep 2010
Location: Falkirk, Scotland
Posts: 1,753
Reputation: 224
Default

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 Code:
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.
iGetty is offline  
Old 11/08/2011, 05:10 AM   #8
JaTochNietDan
High-roller
 
JaTochNietDan's Avatar
 
Join Date: Apr 2007
Location: Republic of Ireland
Posts: 2,502
Reputation: 363
Default Re: Error 006: Must be assigned to an array.

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 Code:
format(tmp, sizeof(tmp), "{FFFFFF}Account: %s\n[B]{FFFFFF}New Balance: {254C01}$%d[/B]", RemoveUnderScore(playerid), Player[playerid][BankMoney]);

I suggest you read the PAWN documentation over at CompuPhase's website.
__________________
Releases:
[Includes]: [jBan] | [jBanLite]
[Plugins]: [FileManager] | [Execute]
[Applications]: [Remote Administrator *NEW] | [Script King] | [RCON GUI]
JaTochNietDan is offline  
Old 11/08/2011, 05:18 AM   #9
iGetty
High-roller
 
iGetty's Avatar
 
Join Date: Sep 2010
Location: Falkirk, Scotland
Posts: 1,753
Reputation: 224
Default Re: Error 006: Must be assigned to an array.

Thank you, compiling it now :3.
iGetty is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
error 006: must be assigned to an array ruarai Help Archive 5 28/09/2009 10:33 AM
error 006: must be assigned to an array loleteviejo Help Archive 7 04/05/2009 05:09 PM
error 006: must be assigned to an array Manuel4 Help Archive 1 10/04/2009 04:09 PM
error 006: must be assigned to an array Celson Help Archive 3 13/02/2009 03:04 PM


All times are GMT. The time now is 04:00 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.