SA-MP Forums Archive
error 052: multi-dimensional arrays must be fully initialized - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: error 052: multi-dimensional arrays must be fully initialized (/showthread.php?tid=270210)



error 052: multi-dimensional arrays must be fully initialized - dowster - 19.07.2011

so for the past 10 minutes ive been searching the forums and the wiki trying to fix this error, it is dealing with this array:
Code:
new DeathReason[54][31] = 
{	
{"Fists"},
{"Brass Knuckles"},
{"Golf Club"},
{"Nite Stick"},
{"Knife"},
{"Baseball Bat"},
{"Shovel"},
{"Pool Cue"},
{"Katana"},
{"Chainsaw"},
{"Purple Dildo"},
{"Small Whit Vibrator"},
{"Large White Vibrator"},
{"Silver Vibrator"},
{"Flowers"},
{"Cane"},
{"Grenade"},
{"Tear Gas"},
{"Molotov Cocktail"},
{"9mm"},
{"Silenced 9mm"},
{"Desert Eagle"}, 
{"Shotgun"},
{"Sawn-off Shotgun"},
{"Combat Shotgun"},
{"Micro SMG"},
{"MP5"},
{"AK-47"},
{"M4"},
{"Tec9"},
{"Country Rifle"},
{"Sniper Rifle"},
{"Rocket Launcher"},
{"Heat Seeking Rocket Launcher"},
{"Flamethrower"},
{"Minigun"},
{"Satchel Charge"},
{"Detonator"},
{"Spraycan"},
{"Fire Extinguisher"},
{"Camera"},
{"Nightvision Goggles"},
{"Thermal Goggles"},
{"Parachute"},
{"Fake Pistol"},
{"Vehicle"},
{"Helicopter Blades"},
{"Explosion"},
{"Invalid"},
{"Drowned"},
{"Fall"}
}; //<<-- compiler prints error on this line
is there something i'm doing wrong? do i need 32 characters in each string, like filling it in with spaces?


Re: error 052: multi-dimensional arrays must be fully initialized - Skaizo - 19.07.2011

try this:
Code:
new DeathReason[51] = 
{	
{"Fists"},
{"Brass Knuckles"},
{"Golf Club"},
{"Nite Stick"},
{"Knife"},
{"Baseball Bat"},
{"Shovel"},
{"Pool Cue"},
{"Katana"},
{"Chainsaw"},
{"Purple Dildo"},
{"Small Whit Vibrator"},
{"Large White Vibrator"},
{"Silver Vibrator"},
{"Flowers"},
{"Cane"},
{"Grenade"},
{"Tear Gas"},
{"Molotov Cocktail"},
{"9mm"},
{"Silenced 9mm"},
{"Desert Eagle"}, 
{"Shotgun"},
{"Sawn-off Shotgun"},
{"Combat Shotgun"},
{"Micro SMG"},
{"MP5"},
{"AK-47"},
{"M4"},
{"Tec9"},
{"Country Rifle"},
{"Sniper Rifle"},
{"Rocket Launcher"},
{"Heat Seeking Rocket Launcher"},
{"Flamethrower"},
{"Minigun"},
{"Satchel Charge"},
{"Detonator"},
{"Spraycan"},
{"Fire Extinguisher"},
{"Camera"},
{"Nightvision Goggles"},
{"Thermal Goggles"},
{"Parachute"},
{"Fake Pistol"},
{"Vehicle"},
{"Helicopter Blades"},
{"Explosion"},
{"Invalid"},
{"Drowned"},
{"Fall"}
};
or
Code:
new DeathReason[] = 
{	
{"Fists"},
{"Brass Knuckles"},
{"Golf Club"},
{"Nite Stick"},
{"Knife"},
{"Baseball Bat"},
{"Shovel"},
{"Pool Cue"},
{"Katana"},
{"Chainsaw"},
{"Purple Dildo"},
{"Small Whit Vibrator"},
{"Large White Vibrator"},
{"Silver Vibrator"},
{"Flowers"},
{"Cane"},
{"Grenade"},
{"Tear Gas"},
{"Molotov Cocktail"},
{"9mm"},
{"Silenced 9mm"},
{"Desert Eagle"}, 
{"Shotgun"},
{"Sawn-off Shotgun"},
{"Combat Shotgun"},
{"Micro SMG"},
{"MP5"},
{"AK-47"},
{"M4"},
{"Tec9"},
{"Country Rifle"},
{"Sniper Rifle"},
{"Rocket Launcher"},
{"Heat Seeking Rocket Launcher"},
{"Flamethrower"},
{"Minigun"},
{"Satchel Charge"},
{"Detonator"},
{"Spraycan"},
{"Fire Extinguisher"},
{"Camera"},
{"Nightvision Goggles"},
{"Thermal Goggles"},
{"Parachute"},
{"Fake Pistol"},
{"Vehicle"},
{"Helicopter Blades"},
{"Explosion"},
{"Invalid"},
{"Drowned"},
{"Fall"}
};
or
Code:
new DeathReason[1][51] = 
{	
{"Fists"},
{"Brass Knuckles"},
{"Golf Club"},
{"Nite Stick"},
{"Knife"},
{"Baseball Bat"},
{"Shovel"},
{"Pool Cue"},
{"Katana"},
{"Chainsaw"},
{"Purple Dildo"},
{"Small Whit Vibrator"},
{"Large White Vibrator"},
{"Silver Vibrator"},
{"Flowers"},
{"Cane"},
{"Grenade"},
{"Tear Gas"},
{"Molotov Cocktail"},
{"9mm"},
{"Silenced 9mm"},
{"Desert Eagle"}, 
{"Shotgun"},
{"Sawn-off Shotgun"},
{"Combat Shotgun"},
{"Micro SMG"},
{"MP5"},
{"AK-47"},
{"M4"},
{"Tec9"},
{"Country Rifle"},
{"Sniper Rifle"},
{"Rocket Launcher"},
{"Heat Seeking Rocket Launcher"},
{"Flamethrower"},
{"Minigun"},
{"Satchel Charge"},
{"Detonator"},
{"Spraycan"},
{"Fire Extinguisher"},
{"Camera"},
{"Nightvision Goggles"},
{"Thermal Goggles"},
{"Parachute"},
{"Fake Pistol"},
{"Vehicle"},
{"Helicopter Blades"},
{"Explosion"},
{"Invalid"},
{"Drowned"},
{"Fall"}
};



Re: error 052: multi-dimensional arrays must be fully initialized - JaTochNietDan - 19.07.2011

Quote:
Originally Posted by Skaizo
View Post
try this:
You're forgetting about the cell for the string characters to be stored in!

pawn Code:
new DeathReason[51][] =
{
    {"Fists"},
    {"Brass Knuckles"},
    {"Golf Club"},
    {"Nite Stick"},
    {"Knife"},
    {"Baseball Bat"},
    {"Shovel"},
    {"Pool Cue"},
    {"Katana"},
    {"Chainsaw"},
    {"Purple Dildo"},
    {"Small Whit Vibrator"},
    {"Large White Vibrator"},
    {"Silver Vibrator"},
    {"Flowers"},
    {"Cane"},
    {"Grenade"},
    {"Tear Gas"},
    {"Molotov Cocktail"},
    {"9mm"},
    {"Silenced 9mm"},
    {"Desert Eagle"},
    {"Shotgun"},
    {"Sawn-off Shotgun"},
    {"Combat Shotgun"},
    {"Micro SMG"},
    {"MP5"},
    {"AK-47"},
    {"M4"},
    {"Tec9"},
    {"Country Rifle"},
    {"Sniper Rifle"},
    {"Rocket Launcher"},
    {"Heat Seeking Rocket Launcher"},
    {"Flamethrower"},
    {"Minigun"},
    {"Satchel Charge"},
    {"Detonator"},
    {"Spraycan"},
    {"Fire Extinguisher"},
    {"Camera"},
    {"Nightvision Goggles"},
    {"Thermal Goggles"},
    {"Parachute"},
    {"Fake Pistol"},
    {"Vehicle"},
    {"Helicopter Blades"},
    {"Explosion"},
    {"Invalid"},
    {"Drowned"},
    {"Fall"}
};
You can just leave the cell sizes blank and the compiler will do the work for you.


JaTochNietDan - dowster - 19.07.2011

now i get
Code:
error 008: must be a constant expression; assumed zero
and if i remove all the curly brackets i get
Code:
error 018: initialization data exceeds declared size
Quote:
Originally Posted by JaTochNietDan
View Post
You're forgetting about the cell for the string characters to be stored in!

pawn Code:
new DeathReason[51][] =
{
    {"Fists"},
    {"Brass Knuckles"},
    {"Golf Club"},
    {"Nite Stick"},
    {"Knife"},
    {"Baseball Bat"},
    {"Shovel"},
    {"Pool Cue"},
    {"Katana"},
    {"Chainsaw"},
    {"Purple Dildo"},
    {"Small Whit Vibrator"},
    {"Large White Vibrator"},
    {"Silver Vibrator"},
    {"Flowers"},
    {"Cane"},
    {"Grenade"},
    {"Tear Gas"},
    {"Molotov Cocktail"},
    {"9mm"},
    {"Silenced 9mm"},
    {"Desert Eagle"},
    {"Shotgun"},
    {"Sawn-off Shotgun"},
    {"Combat Shotgun"},
    {"Micro SMG"},
    {"MP5"},
    {"AK-47"},
    {"M4"},
    {"Tec9"},
    {"Country Rifle"},
    {"Sniper Rifle"},
    {"Rocket Launcher"},
    {"Heat Seeking Rocket Launcher"},
    {"Flamethrower"},
    {"Minigun"},
    {"Satchel Charge"},
    {"Detonator"},
    {"Spraycan"},
    {"Fire Extinguisher"},
    {"Camera"},
    {"Nightvision Goggles"},
    {"Thermal Goggles"},
    {"Parachute"},
    {"Fake Pistol"},
    {"Vehicle"},
    {"Helicopter Blades"},
    {"Explosion"},
    {"Invalid"},
    {"Drowned"},
    {"Fall"}
};
You can just leave the cell sizes blank and the compiler will do the work for you.
Thanks, i also removed all the curly brackets from that, is that against programming conventions? but it worked so im going to leave it.
however now it isn't running the code in on player death, it is supposed to insert the string from the array into the message.
Code:
public OnPlayerDeath(playerid, killerid, reason)
{
	new string[96], deadplayer[MAX_PLAYER_NAME], killer[MAX_PLAYER_NAME];
	GetPlayerName( playerid, deadplayer, sizeof(deadplayer));
	GetPlayerName( killerid, killer, sizeof(killer));
	if (IsPlayerConnected(killerid))
	{	
		format(string, sizeof(string), "%s killed %s, with a %s\r\n", killer, deadplayer, DeathReason[reason]);
	}
	else
	{
		format(string, sizeof(string), "%s had died from %s\r\n", deadplayer, DeathReason[reason]);
	}
	SendClientMessageToAll( COLOR_RED, string);
	new File:deathlog = fopen("Logs/Death Log.txt", io_append);
	fwrite(deathlog, string);
	fclose(deathlog);
	return 1;
}
nevermind i fixed it, reason 19-21 are invalid as they don't mean anything