Raised This Month: $ Target: $400
 0% 

052 - multi-dimensional arrays must be fully initialized


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
jay7981
Junior Member
Join Date: Jan 2014
Old 01-04-2014 , 02:24   052 - multi-dimensional arrays must be fully initialized
Reply With Quote #1

Hey all,
i have tried to compile this on and offline and keep getting this error ...
Quote:
Welcome to the AMX Mod X 1.8.1-300 Compiler.
Copyright (c) 1997-2013 ITB CompuPhase, AMX Mod X Team

Error: Multi-dimensional arrays must be fully initialized on line 18

1 Error.
Could not locate output file C:\Users\Joe\Documents\Jay\AMX Stuff\namechanger.amx (compile failed).
I cannot find the error in this code for the life of me.. any help would be appreciated.

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

#define PLUGIN "No Player"
#define VERSION "1.0"
#define AUTHOR "Uncle Bob"
#define MAXNAMES 7

new nameList[MAXNAMES+1][] = 
{
"Noobalator",
"Sir Killalot",
"Sneaking Tiger",
"Speedy Gonzales",
"Crash Test Dummy",
"Lameguy",
"Super Trooper"
}

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
}
public 
client_putinserver(id)
{
    new 
name[32]
    
get_user_info(id"name"name31)
    if(
containi(name,"Player")!=-1)
    {
        
set_user_info(id"name"nameList[random_num(0,MAXNAMES)])
    }
    return 
PLUGIN_HANDLED

jay7981 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-04-2014 , 03:37   Re: 052 - multi-dimensional arrays must be fully initialized
Reply With Quote #2

You declare an array of 8 items, while you have only 7.
__________________
Arkshine is offline
BlueGaming
BANNED
Join Date: Nov 2013
Old 01-04-2014 , 03:59   Re: 052 - multi-dimensional arrays must be fully initialized
Reply With Quote #3

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

#define PLUGIN "No Player"
#define VERSION "1.0"
#define AUTHOR "Uncle Bob"
#define MAXNAMES 7

new nameList[MAXNAMES][] = 
{
"Noobalator",
"Sir Killalot",
"Sneaking Tiger",
"Speedy Gonzales",
"Crash Test Dummy",
"Lameguy",
"Super Trooper"
}

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
}
public 
client_putinserver(id)
{
    new 
name[32]
    
get_user_info(id"name"name31)
    if(
containi(name,"Player")!=-1)
    {
        
set_user_info(id"name"nameList[random_num(0,MAXNAMES)])
    }
    return 
PLUGIN_HANDLED

BlueGaming is offline
jay7981
Junior Member
Join Date: Jan 2014
Old 01-04-2014 , 11:02   Re: 052 - multi-dimensional arrays must be fully initialized
Reply With Quote #4

i feel like such a noob thanks guys .. i know better than to enumerate my values like that.

Now what would the most efficient way be to house nameList in an .ini file and use that instead of hard coding the list in the plugin, i was trying to keep the plugin as simple as possible but it seems that if i ever wanted to change the names or add more i would have to recompile the plugin each time ... so in trying to make things easier for me and keeping the plugin small what would you suggest?

Last edited by jay7981; 01-04-2014 at 11:13.
jay7981 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 01-05-2014 , 04:22   Re: 052 - multi-dimensional arrays must be fully initialized
Reply With Quote #5

nameList[random_num(0,MAXNAMES)]
->
nameList[random(sizeof nameList)]
By making that change you don't need MAXNAMES at all. Which would make it a lot easier to edit.

Make a dynamic array. (Look in cellarray.inc)
Load the names into it from the ini.
Done.
__________________
Black Rose 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 10:12.


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