Raised This Month: $ Target: $400
 0% 

Initialization data exceeds declared value


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EpicKiller
Senior Member
Join Date: Jun 2014
Location: Constanta, Romania
Old 05-20-2016 , 10:16   Initialization data exceeds declared value
Reply With Quote #1

Code:
//// amx_who.sma
// E:\compiler 1.8.2\addons\amxmodx\scripting\amx_who.sma(19) : error 018: initialization data exceeds declared size
// E:\compiler 1.8.2\addons\amxmodx\scripting\amx_who.sma(28) : error 010: invalid function or declaration
// E:\compiler 1.8.2\addons\amxmodx\scripting\amx_who.sma(41) : error 018: initialization data exceeds declared size
// E:\compiler 1.8.2\addons\amxmodx\scripting\amx_who.sma(50) : error 010: invalid function or declaration
// E:\compiler 1.8.2\addons\amxmodx\scripting\amx_who.sma(90) : error 001: expected token: ";", but found "}"
// E:\compiler 1.8.2\addons\amxmodx\scripting\amx_who.sma(101) : warning 203: symbol is never used: "cmdSayWho"
//
// 5 Errors.
// Could not locate output file E:\compiler 1.8.2\addons\amxmodx\scripting\compiled\amx_who.amx (compile failed).
//
// Compilation Time: 0.06 sec
// ----------------------------------------
I spent quite some time tryin' to debug this. But it beats me. I can't figure out what's wrong. Give me a hand, please!

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

#pragma semicolon 1

#define MAX_GROUPS 18

new sNames[MAX_GROUPS][] = 
{
    
"Founder + |VIP|",
    
"Founder",
    
"Owner + |VIP|",
    
"Owner",
    
"Co-Owner + |VIP|",
    
"Co-Owner",
    
"God + |VIP|",
    
"God",
    
"Super-Moderator + |VIP|",
    
"Super-Moderator",
    
"Moderator + |VIP|",
    
"Moderator",
    
"Administrator + |VIP|",
    
"Administrator",
    
"Helper + |VIP|",
    
"Helper",
    
"|VIP|",
    
"Slot"
};

new 
sFlags[MAX_GROUPS][] = 
{
    
"abcdefghijklmnopqrstuv",    // Founder + VIP
    
"abcdefghijklmnopqrsuv",    // Founder
    
"abcdefghijkmnopqrstu",        // Owner + VIP
    
"abcdefghijkmnopqrsu",        // Owner
    
"abcdefijmnopqrstu",        // Co-Owner + VIP
    
"abcdefijmnopqrsu",            // Co-Owner
    
"abcdefijmnopqrst",            // God + VIP
    
"abcdefijmnopqrs",            // God
    
"abcdefijmnopqrt",            // Super-Moderator + VIP
    
"abcdefijmnopqr",            // Super-Moderator
    
"abcdefijmnopqt",            // Moderator + VIP
    
"abcdefijmnopq",            // Moderator
    
"abcdefijmnot",                // Administrator + VIP
    
"abcdefijmno",                // Administrator
    
"abceijmnot",                // Helper + VIP
    
"abceijmno",                // Helper
    
"abt",                        // VIP
    
"ab"                        // Slot
};

new 
sFlagsValue[MAX_GROUPS];

public 
plugin_init()
{
    
register_plugin("admin_who""1.0""rock!");
    
    
register_concmd("admin_who""cmdWho"0);
    
    
register_clcmd("say who""cmdSayWho"0);
    
register_clcmd("say admin""cmdSayWho"0);
    
register_clcmd("say /who""cmdSayWho"0);
    
register_clcmd("say /admin""cmdSayWho"0);
    
    for(new 
0MAX_GROUPSi++)
        
sFlagsValue[i] = read_flags(sFlags[i]);
}

public 
cmdWho(id)
{
    new 
iPlayers[32];
    new 
iNum;
    new 
iClient;
    new 
sName[32];
    
    
get_players(iPlayersiNum);
    
    
client_print(id"----- www..ro -----");
    
    for(new 
0MAX_GROUPSi++)
    {
        
console_print(id"~~~~[%d]%s~~~~", (1), sNames[i]);
        
        for(new 
0iNum; ++a)
        {
            
iClient iPlayers[a];
            
            
get_user_name(iClientsNamecharsmax(sName));
            
            if(
get_user_flags(iClient) == sFlagsValue[i])
                
console_print(id"%s"sName);
        }
    }
    
    
client_print(id"----- www..ro -----");
    
    return 
PLUGIN_HANDLED;
}

public 
cmdSayWho(id)
{
    
client_print(idprint_chat"* Verifica-ti consola!");
    
    
cmdWho(id);

__________________
~ Swiftly and with style ~
EpicKiller is offline
Send a message via Yahoo to EpicKiller Send a message via Skype™ to EpicKiller
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 05-20-2016 , 10:47   Re: Initialization data exceeds declared value
Reply With Quote #2

I don't get those errors. But they generally happen when doing this:
Code:
new var[4] = { 1, 2, 3, 4, 5 } // 5 entries trying to fit into 4 slots. It's like trying to fit 5 people in a Hyundai i10.

What you do is either increase MAX_GROUPS or make it more dynamic by replacing all of the MAX_GROUPS with "sizeof sNames" and "sizeof sFlags" in the code and removing the fixed number of indexes
Code:
new sFlags[][] =   {     "abcdefghijklmnopqrstuv",    // Founder + VIP     "abcdefghijklmnopqrsuv",    // Founder     "abcdefghijkmnopqrstu",        // Owner + VIP     // And so on ... }; // ...     for(new i = 0; i < sizeof sFlags ; i++)         sFlagsValue[i] = read_flags(sFlags[i]);

You do have these errors though.
Code:
// Line 78 & 95: client_print(id, "----- <a href="http://www..ro" target="_blank" rel="nofollow noopener">www..ro</a> -----"); // --> client_print(id, print_chat, "----- <a href="http://www..ro" target="_blank" rel="nofollow noopener">www..ro</a> -----"); // can also be print_center, print_notify, print_console
__________________

Last edited by Black Rose; 05-20-2016 at 10:52.
Black Rose is offline
EpicKiller
Senior Member
Join Date: Jun 2014
Location: Constanta, Romania
Old 05-20-2016 , 11:25   Re: Initialization data exceeds declared value
Reply With Quote #3

I tried increasing it before posting this thread and it didn't solve anything. I replaced the MAX_GROUPS with sizeofs, which resulted the same errors. As about those two lines, I was wondering what's wrong with them. I thought I used console_print.
Thank you, Black Rose! Maybe I messed it up, so here's the code:

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

#pragma semicolon 1

//#define MAX_GROUPS 18

new sNames[][] = 
{
    
"Founder + |VIP|",
    
"Founder",
    
"Owner + |VIP|",
    
"Owner",
    
"Co-Owner + |VIP|",
    
"Co-Owner",
    
"God + |VIP|",
    
"God",
    
"Super-Moderator + |VIP|",
    
"Super-Moderator",
    
"Moderator + |VIP|",
    
"Moderator",
    
"Administrator + |VIP|",
    
"Administrator",
    
"Helper + |VIP|",
    
"Helper",
    
"|VIP|",
    
"Slot"
};

new 
sFlags[][] = 
{
    
"abcdefghijklmnopqrstuv",    // Founder + VIP
    
"abcdefghijklmnopqrsuv",    // Founder
    
"abcdefghijkmnopqrstu",        // Owner + VIP
    
"abcdefghijkmnopqrsu",        // Owner
    
"abcdefijmnopqrstu",        // Co-Owner + VIP
    
"abcdefijmnopqrsu",            // Co-Owner
    
"abcdefijmnopqrst",            // God + VIP
    
"abcdefijmnopqrs",            // God
    
"abcdefijmnopqrt",            // Super-Moderator + VIP
    
"abcdefijmnopqr",            // Super-Moderator
    
"abcdefijmnopqt",            // Moderator + VIP
    
"abcdefijmnopq",            // Moderator
    
"abcdefijmnot",                // Administrator + VIP
    
"abcdefijmno",                // Administrator
    
"abceijmnot",                // Helper + VIP
    
"abceijmno",                // Helper
    
"abt",                        // VIP
    
"ab"                        // Slot
};

new 
sFlagsValue[sizeof(sNames)];

public 
plugin_init()
{
    
register_plugin("admin_who""1.0""rock!");
    
    
register_concmd("admin_who""cmdWho"0);
    
    
register_clcmd("say who""cmdSayWho"0);
    
register_clcmd("say admin""cmdSayWho"0);
    
register_clcmd("say /who""cmdSayWho"0);
    
register_clcmd("say /admin""cmdSayWho"0);
    
    for(new 
0sizeof(sNames); i++)
        
sFlagsValue[i] = read_flags(sFlags[i]);
}

public 
cmdWho(id)
{
    new 
iPlayers[32];
    new 
iNum;
    new 
iClient;
    new 
sName[32];
    
    
get_players(iPlayersiNum);
    
    
console_print(id"----- www..ro -----");
    
    for(new 
0sizeof(sNames); i++)
    {
        
console_print(id"~~~~[%d]%s~~~~", (1), sNames[i]);
        
        for(new 
0iNum; ++a)
        {
            
iClient iPlayers[a];
            
            
get_user_name(iClientsNamecharsmax(sName));
            
            if(
get_user_flags(iClient) == sFlagsValue[i])
                
console_print(id"%s"sName);
        }
    }
    
    
console_print(id"----- www..ro -----");
    
    return 
PLUGIN_HANDLED;
}

public 
cmdSayWho(id)
{
    
client_print(idprint_chat"* Verifica-ti consola!");
    
    
cmdWho(id);

__________________
~ Swiftly and with style ~

Last edited by EpicKiller; 05-20-2016 at 11:27.
EpicKiller is offline
Send a message via Yahoo to EpicKiller Send a message via Skype™ to EpicKiller
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 21:40.


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