SA-MP Forums Archive
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: multi-dimensional arrays must be fully initialized (/showthread.php?tid=198234)



multi-dimensional arrays must be fully initialized - DVDK - 11.12.2010

What's wrong?

Quote:

new VehNames[211][] = {
"Landstalker","Bravura","Buffalo","Linerunner","Pe ren","Sentinel","Dumper","Firetruck","Truck","Stre tch",
"Manana","Infernus","Voodoo","Pony","Mule","Cheeta h","Ambulance","Leviathan","Moonbeam","Esperant"," Taxi",
"Washington","Bobcat","Mr. Whoopee","BF-Injection","Hunter","Premier","Enforcer","Securica ","Banshee",
"Predator","Bus","Rhino","Barracks","Hotknife","Ar tict-1","Previon","Coach","Cabbie","Stallion","Rumpo ",
"RC-Bandit","Romero","Packer","Monster","Admiral","Squ alo","Seasparrow","Pizzaboy","Tram","Artict-2","Turismo",
"Speeder","Reefer","Tropic","Flatbed","Yankee","Ca ddy","Solair","Topfun","Skimmer","PCJ600","Faggio" ,"Freeway",
"RC-Baron","RC-Raider","Glendale","Oceanic","Sanchez","Sparrow"," Patriot","Quad","Coastguard","Dinghy","Hermes",
"Sabre""Rustler","ZR350","Walton","Regina","Comet" ,"BMX","Buritto","Camper","Marquis","Baggage","Doz er","Maverick",
"VCN-Maverick","Rancher","FBI-Rancher","Virgo","Greenwood","Jetmax","Hotring","S andking","Blistac Compact",
"Police Maverick","Benson","Mesa","RC-Goblin","Hotring-A","Hotring-B","Bloodring Banger","Rancher Lure",
"SuperGT","Elegant","Journey","Bike","Mountain Bike","Beagle","Cropduster","Stunt","Petro","Nebul a",
"Majestic","Buccanee","Shamal","Hydra","FRC-900","NRG-500","Copbike","Cement","Towtruck","Fortune",
"Candrona","FBI-Truck","Willard","Forklift","Tractor","Combine","F eltzer","Remington","Slamvan",
"Blade","Freight","Streak","Vortex","Vincent","Bul let","Clover","Sadler","Firetruck","Hustler",
"Intruder","Primo","Cargobob","Tampa","Sunrise","M erit","Utility","Nevada","Yosemite","Windsor",
"Monster-A","Monster-B","Uranus","Jester","Sultan","Stratum","Elegy","R aindance","RC-Tiger",
"Flash","Tahoma","Savanna","Bandito","Freiflat","S treak-Car","Kart","Mower","Duneride","Sweeper",
"Broadway","Tornado","AT-400","DFT-30","Huntley","Stafford","BF-400","Newsvan","Tug","Petrot",
"Emperor","Wayfarer","Euros","Hotdog","Club","Frei box","Artict-3","Andromada","Dodo","RC-Cam",
"Launch","Copcar-LS","Copcar-SF","Copcar-LV","Copcar-Desert","Picador","Swatvan","Alpha","Phoenix",
"Glendale","Sadler","Bagbox-A","Bagbox-B","Tugstairs","Boxburg","Farm-Trailer","Utility-Trailer"
};

GetVehicleName(vehicleid)
{
return VehNames[GetVehicleModel(vehicleid)-400][0];
}

Quote:

(23) : error 052: multi-dimensional arrays must be fully initialized




Re: multi-dimensional arrays must be fully initialized - Mauzen - 11.12.2010

Try this:

new VehNames[][24] = {


Re: multi-dimensional arrays must be fully initialized - DVDK - 11.12.2010

Thanks it works, but why?


Re: multi-dimensional arrays must be fully initialized - smeti - 11.12.2010

Quote:
Originally Posted by DVDK
View Post
Thanks it works, but why?
The listed vehname 209 not 211!

Try:
pawn Code:
printf(" sizeof: %d", sizeof(VehNames));



Re: multi-dimensional arrays must be fully initialized - DVDK - 11.12.2010

Quote:
Originally Posted by smeti
View Post
The listed vehname 209 not 211!

Try:
pawn Code:
printf(" sizeof: %d", sizeof(VehNames));
Thanks, i already tried 210 211 and 212 but that also didn't worked, i was 1sec away from trying 209


Re: multi-dimensional arrays must be fully initialized - smeti - 11.12.2010

Nm.

Tips:

Correct:
pawn Code:
new VehNames[][] =
{
    ...,...,..
    //etc
};
#define GetVehicleName(%0) \
        VehNames[GetVehicleModel(%0)-400]
pawn Code:
new VehNames[][24] = // Set return string array  24
{
    ...,...,...
    //etc
};

stock
    GetVehicleName(vehicleid)
        return VehNames[GetVehicleModel(vehicleid)];
No correct:
pawn Code:
new VehNames[][] = // Not set return string array
{
    ...,...,...
    //etc
};

stock
    GetVehicleName(vehicleid)
        return VehNames[GetVehicleModel(vehicleid)];