AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Error: Must be assigned to an array? (https://forums.alliedmods.net/showthread.php?t=84465)

Sleepwalker 01-26-2009 12:48

Error: Must be assigned to an array?
 
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);


SnoW 01-26-2009 14:33

Re: Error: Must be assigned to an array?
 
Quote:

Originally Posted by Sleepwalker (Post 750518)
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.

ConnorMcLeod 01-26-2009 14:55

Re: Error: Must be assigned to an array?
 
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


Dores 01-26-2009 15:50

Re: Error: Must be assigned to an array?
 
Quote:

Originally Posted by ConnorMcLeod (Post 750592)
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? :shock:

Sleepwalker 01-26-2009 15:56

Re: Error: Must be assigned to an array?
 
I'm trying to make a array with data.
But however I try, it does not work.

ConnorMcLeod 01-26-2009 15:56

Re: Error: Must be assigned to an array?
 
Quote:

Originally Posted by Dores (Post 750644)
Aren't enumerated variables considered as constants? :shock:

Something like this.

Exolent[jNr] 01-26-2009 19:36

Re: Error: Must be assigned to an array?
 
Quote:

Originally Posted by ConnorMcLeod (Post 750592)
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.

Arkshine 01-27-2009 01:12

Re: Error: Must be assigned to an array?
 
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.


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

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