AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   error 009: Invalid array size. (https://forums.alliedmods.net/showthread.php?t=55982)

Humming Bird 06-03-2007 16:50

error 009: Invalid array size.
 
Hello, I'm getting a compiler error when I compile my code.

(note, i use "register_forward(FM_AlertMessage, "alertmessage", 1)")
(note2, i declare g_touchmap with "new g_touchmap[4][32]")

I also have bolded the line I get the error on - error 009: Invalid array size (negative or zero)

So anyone know what I'm doing wrong?

My code is as follows:
Code:

public alertmessage(atype, message[]) {
    if(containi(message,"force_map_") > -1) {
        new sstart = containi(message,"force_map_") + 10
        new empty[32]
        new forcemapstring[76]
        g_touchmap[0] = empty
        for(new i = sstart; i < (strlen(message) -2); i++) {
            g_touchmap[0][i - sstart] = message[i]
        }
        format(forcemapstring, 75, "Forcing map change to: %s", g_touchmap)
        msc_hudprint_all("Forcing Map", forcemapstring)
        client_print(0, print_console, "Forcing map change to: %s", g_touchmap)
        g_Answer = "dochangelevel %s"
        g_execLen = format(g_Execute,255,g_Answer,g_touchmap) + 1
        set_task(2.0, "delayedExec", 451986, g_Execute, g_execLen)
       
        return PLUGIN_HANDLED
    }
}


Sylwester 06-03-2007 17:33

Re: error 009: Invalid array size.
 
Check the declaration of g_touchmap.
Can you paste whole code?

Humming Bird 06-03-2007 17:37

Re: error 009: Invalid array size.
 
new g_touchmap[4][32]

I also have that added to my first post...

Sylwester 06-03-2007 18:58

Re: error 009: Invalid array size.
 
Code:
#include <amxmodx> #include <fakemeta> new g_touchmap[4][32] public plugin_init(){     register_plugin( "a", "a", "a" )     register_forward(FM_AlertMessage, "alertmessage", 1) } public alertmessage(atype, message[]) {     if(containi(message,"force_map_") > -1) {         new sstart = containi(message,"force_map_") + 10         new empty[32]         new forcemapstring[76]         g_touchmap[0] = empty         for(new i = sstart; i < (strlen(message) -2); i++) {             g_touchmap[0][i - sstart] = message[i]         }         format(forcemapstring, 75, "Forcing map change to: %s", g_touchmap) //        msc_hudprint_all("Forcing Map", forcemapstring) //        client_print(0, print_console, "Forcing map change to: %s", g_touchmap) //        g_Answer = "dochangelevel %s" //        g_execLen = format(g_Execute,255,g_Answer,g_touchmap) + 1 //        set_task(2.0, "delayedExec", 451986, g_Execute, g_execLen)                 return PLUGIN_HANDLED     } }
I tried this and it compiled without any errors. Paste whole plugin or find the error yourself.

regalis 06-03-2007 18:58

Re: error 009: Invalid array size.
 
This is a openSource community...why not posting your code!?
I don't think it is something too special that it should kept confidential...0o

greetz regalis


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

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