Raised This Month: $ Target: $400
 0% 

Error: Must be assigned to an array?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sleepwalker
Member
Join Date: Dec 2006
Old 01-26-2009 , 12:48   Error: Must be assigned to an array?
Reply With Quote #1

Why doesn't this code work?
Code:
    new data[11];
    data[0] = id;
    data[1] = name;
    data[2] = authid;
    data[3] = ip;
    data[4] = alive;
    data[5] = TEAMNAME[_:team];
    data[6] = datestr;
    data[7] = timestr;
    data[8] = message;
    data[9] = cmd;
    data[10] = mapname;
Ex. on code before:
Code:
    new CsTeams:team = cs_get_user_team(id);
    get_user_name(id,name,31);
Sleepwalker is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 01-26-2009 , 14:33   Re: Error: Must be assigned to an array?
Reply With Quote #2

Quote:
Originally Posted by Sleepwalker View Post
Code:
data[1] = name;
data[2] = authid;
data[8] = message;
data[10] = mapname;
There's some pawn tutorials you should read.
You can't put 31 chars long name to one.
There's some examples:
new int = 11;
new int[1]; int[0] = 11;
new name[32];
name[0] = "N";
get_user_name(index, name, 31);
Just watch that the arrays' chars fit.

Last edited by SnoW; 01-26-2009 at 14:35.
SnoW is offline
Send a message via MSN to SnoW
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-26-2009 , 14:55   Re: Error: Must be assigned to an array?
Reply With Quote #3

PHP Code:
enum DataField {
    
Did,
    
Dname[32],
    
Dauthid[32],
    
Dip[22],
    
Dalive,
    
CsTeams:Dteam// not sure what you want here
    
etc...
}

new 
data[33][DataField];


    
get_user_name(iddata[id][Dname], 31
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 01-26-2009 , 15:50   Re: Error: Must be assigned to an array?
Reply With Quote #4

Quote:
Originally Posted by ConnorMcLeod View Post
PHP Code:
enum DataField {
    
Did,
    
Dname[32],
    
Dauthid[32],
    
Dip[22],
    
Dalive,
    
CsTeams:Dteam// not sure what you want here
    
etc...
}

new 
data[33][DataField];


    
get_user_name(iddata[id][Dname], 31
Aren't enumerated variables considered as constants?
__________________
O o
/Ż________________________
| IMMA FIRIN' MAH LAZOR!!!
\_ŻŻŻ
Dores is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 01-26-2009 , 15:56   Re: Error: Must be assigned to an array?
Reply With Quote #5

Quote:
Originally Posted by Dores View Post
Aren't enumerated variables considered as constants?
Something like this.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-26-2009 , 19:36   Re: Error: Must be assigned to an array?
Reply With Quote #6

Quote:
Originally Posted by ConnorMcLeod View Post
PHP Code:
enum DataField {
    
Did,
    
Dname[32],
    
Dauthid[32],
    
Dip[22],
    
Dalive,
    
CsTeams:Dteam// not sure what you want here
    
etc...
}

new 
data[33][DataField];


    
get_user_name(iddata[id][Dname], 31
arkshine told me that you couldn't use arrays in enum{}.
He told me that you have to use EngFunc_AllocString when setting it, then use glb_EncodeText (or whatever it is) after you retrieve it to get it to a string.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Sleepwalker
Member
Join Date: Dec 2006
Old 01-26-2009 , 15:56   Re: Error: Must be assigned to an array?
Reply With Quote #7

I'm trying to make a array with data.
But however I try, it does not work.
Sleepwalker is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-27-2009 , 01:12   Re: Error: Must be assigned to an array?
Reply With Quote #8

I never said that. oO

I have several plugins where I'm using array in enum, you know. I don't see why I would say something like. And if you search in scripting section you will find old posts where I give such example. You confuse with something else.

Last edited by Arkshine; 01-27-2009 at 01:21.
Arkshine is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 01:41.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode