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=93707)

alan_el_more 06-01-2009 06:14

Error: Must be assigned to an array
 
PHP Code:

new const WEAPONLVLS[][] = { """""""4""""10""""1""5",
            
"""""""2""""6""6",
            
"""""""3""",
            
"8""9)""1""""""",
            
"4""9""""7" }

//...
static lvls
lvls 
WEAPONLVLS[ArrayGetCell(g_primary_weaponidsweap)]
        
if(
g_playerlevel[id] == lvls || g_playerlevel[id] >= lvls)
       
len += formatex(menu[len], charsmax(menu) - len"\r%d.\r %s \y(Nivel %d)^n"weap-WPN_STARTID+1WEAPONNAMES[ArrayGetCell(g_primary_weaponidsweap)], WEAPONLVLS[ArrayGetCell(g_primary_weaponidsweap)])
else
       
len += formatex(menu[len], charsmax(menu) - len"\r%d.\d %s (Nivel %d)^n"weap-WPN_STARTID+1WEAPONNAMES[ArrayGetCell(g_primary_weaponidsweap)], WEAPONLVLS[ArrayGetCell(g_primary_weaponidsweap)]) 

Error: Must be assigned to an array on line 3248

what is the problem?

Hunter-Digital 06-01-2009 07:07

Re: Error: Must be assigned to an array
 
weapon lvls are strings...

Code:

static lvls[2]
lvls = WEAPONLVLS[ArrayGetCell(g_primary_weaponids, weap)]

also, replace %d with %s

or remove the "" and one [] from the initial array and place 0 where you don't want a level

alan_el_more 06-01-2009 07:38

Re: Error: Must be assigned to an array
 
PHP Code:

new const WEAPONLVLS[] = { "0""0""0""4""0""10""0""1""5",
            
"0""0""0""2""0""6""6",
            
"""0""0""3""0",
            
"8""9""1""0""0""0",
            
"4""9""0""7" }

//...

static lvls[2]
lvls[2] = WEAPONLVLS[ArrayGetCell(g_primary_weaponidsweap)]
        
if(
g_playerlevel[id] == lvls || g_playerlevel[id] >= lvls)
       
len += formatex(menu[len], charsmax(menu) - len"\r%d.\r %s \y(Nivel %d)^n"weap-WPN_STARTID+1WEAPONNAMES[ArrayGetCell(g_primary_weaponidsweap)], WEAPONLVLS[ArrayGetCell(g_primary_weaponidsweap)])
else
        
len += formatex(menu[len], charsmax(menu) - len"\r%d.\d %s (Nivel %d)^n"weap-WPN_STARTID+1WEAPONNAMES[ArrayGetCell(g_primary_weaponidsweap)], WEAPONLVLS[ArrayGetCell(g_primary_weaponidsweap)]) 

Is that correct?

crazyeffect 06-01-2009 08:09

Re: Error: Must be assigned to an array
 
Try it out :D

Bugsy 06-01-2009 08:55

Re: Error: Must be assigned to an array
 
Why use a string to store integers?

Hunter-Digital 06-01-2009 10:25

Re: Error: Must be assigned to an array
 
no, the const in your first post with the rest of the code in your later post will work, but those are strings, you should do it like this:
PHP Code:

new const WEAPONLVLS[] = {0004010015,
            
0002066,
            
00030,
            
891000,
            
4907}
 
//...
 
static lvls
lvls 
WEAPONLVLS[ArrayGetCell(g_primary_weaponidsweap)]
 
if(
g_playerlevel[id] == lvls || g_playerlevel[id] >= lvls)
       
len += formatex(menu[len], charsmax(menu) - len"\r%d.\r %d \y(Nivel %d)^n"weap-WPN_STARTID+1WEAPONNAMES[ArrayGetCell(g_primary_weaponidsweap)], WEAPONLVLS[ArrayGetCell(g_primary_weaponidsweap)])
else
        
len += formatex(menu[len], charsmax(menu) - len"\r%d.\d %d (Nivel %d)^n"weap-WPN_STARTID+1WEAPONNAMES[ArrayGetCell(g_primary_weaponidsweap)], WEAPONLVLS[ArrayGetCell(g_primary_weaponidsweap)]) 


alan_el_more 06-02-2009 09:18

Re: Error: Must be assigned to an array
 
thanks Hunter-Digital for the help, works great!!!


All times are GMT -4. The time now is 13:57.

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