Raised This Month: $ Target: $400
 0% 

error 008: must be a constant expression


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
l4ulwtlln
Member
Join Date: Aug 2007
Old 08-26-2007 , 01:51   error 008: must be a constant expression
Reply With Quote #1

wats wrong with this? basically i want to have it be dynamic thats why i wont have it as a global

this is just a small portion of the actually thing but it shows basically what i want

/home/groups/amxmodx/tmp3/textyYESGo.sma(14 -- 15) : error 008: must be a constant expression; assumed zero

1 Error.
Could not locate output file /home/groups/amxmodx/public_html/websc3/textyYESGo.amx (compile failed).
PHP Code:
#include <amxmodx>

#define MAX_ALLOWED 64

new const Sound_Test[4][MAX_ALLOWED][64]

new 
SoundNumber

public plugin_precache() {
    
register_plugin("","","")

    
SoundNumber 4

    Sound_Test
[SoundNumber] = {
        
"csound/1.wav"
        
"csound/2.wav"
        
"csound/3.wav"
        
"csound/4.wav"
    
}


l4ulwtlln is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 08-26-2007 , 03:41   Re: error 008: must be a constant expression
Reply With Quote #2

Oh no. >.> ?!

1.register_plugin(....) should be in plugin_init()
2.3D array :S...why ?!
3.Code should look like this :

Code:
#include <amxmodx>
 
#define PLUGIN "New Plugin"
#define VERSION "1.0"
#define AUTHOR "Author"
 
#define SOUNDS_NUMBER 4
 
stock const sound_test[SOUNDS_NUMBER][/*max len*/] = {
 
 "csound/1.wav",
 "csound/2.wav",
 "csound/3.wav",
 "csound/4.wav"
}
 
public plugin_init() {
 
 register_plugin(PLUGIN, VERSION, AUTHOR);
}
 
public plugin_precache()
{
 for(new z = 0 ; z < sizeof sound_test ; z++)
 {
  precache_sound(sound_test[z]);
 }
}
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
l4ulwtlln
Member
Join Date: Aug 2007
Old 08-26-2007 , 04:00   Re: error 008: must be a constant expression
Reply With Quote #3

1. dont have to be, it works in plugin_precache if ur only registering the plugin
2. cuz i want it to be dynamic, so when i change SoundNumber to another number, it will be another set of sounds
3. that wouldnt make it dynamic anymore
l4ulwtlln is offline
Drak
Veteran Member
Join Date: Jul 2005
Old 08-26-2007 , 07:48   Re: error 008: must be a constant expression
Reply With Quote #4

Quote:
Originally Posted by l4ulwtlln View Post
1. dont have to be, it works in plugin_precache if ur only registering the plugin
2. cuz i want it to be dynamic, so when i change SoundNumber to another number, it will be another set of sounds
3. that wouldnt make it dynamic anymore
You can't do it the way you want to.

Example:
Code:
new SoundNumber = 4; #define MAX_ALLOWED 64 new Sound_Test[SoundNumber][MAX_ALLOWED] = { "csound/1.wav","csound/2.wav","csound/3.wav","csound/4.wav" }

Would NOT work, you would get "Must be a constant expression" error.

This would work:
Code:
new Sound_Test[4][64] = { "csound/1.wav","csound/2.wav","csound/3.wav","csound/4.wav" }

You can't use variables and such, like you where.
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 08-26-2007 , 07:55   Re: error 008: must be a constant expression
Reply With Quote #5

Also 64 is the len of array!
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
l4ulwtlln
Member
Join Date: Aug 2007
Old 08-26-2007 , 13:23   Re: error 008: must be a constant expression
Reply With Quote #6

so then there is no possible way for this to work?

PHP Code:
#include <amxmodx>
#include <amxmisc>

new SoundsFile[64]
new 
SoundNumber

#define MAX_ALLOWED 64

new const Sound_Test[4][MAX_ALLOWED][64]

new 
Sound_One[MAX_ALLOWED][64]
new 
Sound_Two[MAX_ALLOWED][64]
new 
Sound_Three[MAX_ALLOWED][64]
new 
Sound_Four[MAX_ALLOWED][64]

public 
plugin_precache() {

    
register_plugin("","","")

    new 
cfgDir[32]
    
get_configsdir(cfgDir,31)
    
formatex(SoundsFile63"%s/SoundsFile.ini"cfgDir)

    if(
file_exists(SoundsFile)) {

        
SoundNumber 1

        
new sfLineData[1024]
        new 
file fopen(SoundsFile"rt")

        while(
file && !feof(file)) {
            
fgets(filesfLineData1023)

            
parse(sfLineDataSound_One[SoundNumber], 63Sound_Two[SoundNumber], 63Sound_Three[SoundNumber], 63Sound_Four[SoundNumber], 63)

            
Sound_Test[SoundNumber] = {Sound_One[SoundNumber], Sound_Two[SoundNumber], Sound_Three[SoundNumber], Sound_Four[SoundNumber]}

            
SoundNumber += 1
        
}

        if(
filefclose(file)
    }

    for (new 
1SoundNumber; ++i) {
            
precache_model(Sound_One[i])
            
precache_model(Sound_Two[i])
            
precache_model(Sound_Three[i])
            
precache_model(Sound_Four[i])
    }


l4ulwtlln 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 16:11.


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