AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   problem with the array in if (https://forums.alliedmods.net/showthread.php?t=117865)

SylvertCs 02-05-2010 13:01

problem with the array in if
 
PHP Code:

// Class List
 
for (class = 0; class < g_zclass_i; class++)
 {
  
// Retrieve name and info
  
ArrayGetString(g_zclass_name, class, buffercharsmax(buffer))
  
ArrayGetString(g_zclass_info, class, buffer2charsmax(buffer2))
  
ArrayGetString(g_zclass_lvl, class, buffer3charsmax(buffer3))
  
  
// Add to menu
  
if(Lvl[id] >= g_zclass_lvl[class])//line  3425
  
{
   if (class == 
g_zombieclassnext[id])
    
formatex(menucharsmax(menu), "\d%s %sr(\yLvl:\w%d\r)"bufferbuffer2,buffer3)
   else
    
formatex(menucharsmax(menu), "%s \y%sr(\yLvl:\w%d\r)"bufferbuffer2,buffer3)
  }
  else
   
formatex(menucharsmax(menu), "%s \y%s\r(\yLvl:\w%d\r)"bufferbuffer2,buffer3)
  
  
buffer[0] = class
  
buffer[1] = 0
  buffer
[3] = class
  
menu_additem(menuidmenubuffer)
 } 

PHP Code:

Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c1997-2006 ITB CompuPhaseAMX Mod X Team
Error
Invalid subscript (not an array or too many subscripts): "g_zclass_lvl" on line 3425
Warning
Expression has no effect on line 3425
Error
Expected token";"but found "]" on line 3425
Error
Invalid expressionassumed zero on line 3425
Error
Too many error messages on one line on line 3425
Compilation aborted
.
4 Errors.
Could not locate output file C:\Documents and Settings\Administrador\Escritorio\zp_nuevo.amx (compile failed). 


Bugsy 02-05-2010 13:36

Re: problem with the array in if
 
show declaration for g_zclass_lvl

SylvertCs 02-05-2010 15:28

Re: problem with the array in if
 
new Array:g_zclass_lvl
in plugin_init
g_zclass_lvl = ArrayCreate(1, 1)

fysiks 02-05-2010 18:32

Re: problem with the array in if
 
PHP Code:

if(Lvl[id] >= str_to_num(buffer2)) 

g_zclass_lvl is an integer; pointer.

SylvertCs 02-05-2010 21:57

Re: problem with the array in if
 
the right way is...
PHP Code:

if(Lvl[id] >= ArrayGetCell(g_zclass_lvl,class))
  {
   if (class == 
g_zombieclassnext[id])
    
formatex(menucharsmax(menu), "\d%s %s\r(\wLvl:\y%d\r)"bufferbuffer2,buffer3)
   else
    
formatex(menucharsmax(menu), "%s \y%s\r(\wLvl:\y%d\r)"bufferbuffer2,buffer3)
  }
  else
  {
   
formatex(menucharsmax(menu), "\d%s \y%s\r(\wLvl:\y%d\r)"bufferbuffer2,buffer3)
  } 


ConnorMcLeod 02-05-2010 22:57

Re: problem with the array in if
 
You vould consider using a structure like :

Code:

enum _:ClassDatas {
        ClassName[MAX_CLASSNAME_LENGTH],
        ClassInfo[MAX_CLASSINFO_LENGTH],
        ClassLevel
}

Then you would do :

Code:

new Datas[ClassDatas]
ArrayGetArray(g_class, class, Datas)
formatex(menu, charsmax(menu), "\d%s %sr(\yLvl:\w%d\r)", Datas[ClassName], Datas[ClassInfo], Datas[ClassLevel])

See hlmp for a more implemented example.



Else, i think the problem in your code is that you pass %d for level but it match with a buffer and not an integer.


All times are GMT -4. The time now is 07:20.

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