Raised This Month: $ Target: $400
 0% 

problem with the array in if


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SylvertCs
BANNED
Join Date: Sep 2009
Location: San Nicolas-Buenos Aires
Old 02-05-2010 , 13:01   problem with the array in if
Reply With Quote #1

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). 
SylvertCs is offline
Send a message via MSN to SylvertCs
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-05-2010 , 13:36   Re: problem with the array in if
Reply With Quote #2

show declaration for g_zclass_lvl
__________________
Bugsy is offline
SylvertCs
BANNED
Join Date: Sep 2009
Location: San Nicolas-Buenos Aires
Old 02-05-2010 , 15:28   Re: problem with the array in if
Reply With Quote #3

new Array:g_zclass_lvl
in plugin_init
g_zclass_lvl = ArrayCreate(1, 1)
SylvertCs is offline
Send a message via MSN to SylvertCs
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 02-05-2010 , 18:32   Re: problem with the array in if
Reply With Quote #4

PHP Code:
if(Lvl[id] >= str_to_num(buffer2)) 
g_zclass_lvl is an integer; pointer.
__________________
fysiks is offline
Old 02-05-2010, 21:46
SylvertCs
This message has been deleted by SylvertCs.
SylvertCs
BANNED
Join Date: Sep 2009
Location: San Nicolas-Buenos Aires
Old 02-05-2010 , 21:57   Re: problem with the array in if
Reply With Quote #5

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)
  } 

Last edited by SylvertCs; 02-05-2010 at 22:30.
SylvertCs is offline
Send a message via MSN to SylvertCs
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-05-2010 , 22:57   Re: problem with the array in if
Reply With Quote #6

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.
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 02-05-2010 at 22:59.
ConnorMcLeod 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 07:20.


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