AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   052 - multi-dimensional arrays must be fully initialized (https://forums.alliedmods.net/showthread.php?t=232728)

jay7981 01-04-2014 02:24

052 - multi-dimensional arrays must be fully initialized
 
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



Arkshine 01-04-2014 03:37

Re: 052 - multi-dimensional arrays must be fully initialized
 
You declare an array of 8 items, while you have only 7.

BlueGaming 01-04-2014 03:59

Re: 052 - multi-dimensional arrays must be fully initialized
 
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



jay7981 01-04-2014 11:02

Re: 052 - multi-dimensional arrays must be fully initialized
 
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?

Black Rose 01-05-2014 04:22

Re: 052 - multi-dimensional arrays must be fully initialized
 
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.


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

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