open.mp forum
[Pawn] Script: error 018: initialization data exceeds declared size - Printable Version

+ open.mp forum (https://forum.open.mp)
-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
--- Thread: [Pawn] Script: error 018: initialization data exceeds declared size (/showthread.php?tid=1757)



Script: error 018: initialization data exceeds declared size - RhaegarX - 2021-03-12

I am developing an event system that will have some customizations, and I started with the following data structure.

However, when the compiler is giving the following error:?(52) : error 018: initialization data exceeds declared size





Code Pawn - Pastebin.com





I am trying to find the solution, but I have no idea how to solve it.



RE: Script: error 018: initialization data exceeds declared size - Virsenas - 2021-03-12

enum eEvents

{

? ? eID,

? ? eName[20],

? ? eCapacity,

? ? bool:eSetHealth,

? ? bool:eSetArmour,

? ? bool:eResetWeapons,

? ? bool:eDeadOnExitVehicle,

? ? bool:eGivePistol

};



new EventConfig[MAX_EVENTS][eEvents] = {

? ? // Corridas

? ? { EVENTID_RUN1, "Rally", 10, true, false, true, true, false },

? ? { EVENTID_RUN2, "Bike Trilha", 10, true, false, true, true, false },

? ? { EVENTID_RUN3, "Barco", 10, true, false, true, true, false },

? ? { EVENTID_RUN4, "Kart", 10, true, false, true, true, false },

? ? { EVENTID_RUN5, "Corrida Maluca", 10, true, false, true, true, false },

? ? { EVENTID_RUN6, "Tratorrida", 10, true, false, true, true, false },

? ? { EVENTID_RUN7, "Moto Cross", 10, true, false, true, true, false },

? ? // ?ltimo Sobrevivente

? ? { EVENTID_SURVIVEL1, "?ltimo Sobrevivente", 10, true, true, true, false, true },

? ? // Funny Games

? ? { EVENTID_FUNNY1, "FallOut", MAX_PLAYERS, true, false, true, false, false },

? ? { EVENTID_FUNNY2, "Color Match", MAX_PLAYERS, true, false, true, false, false },

? ? { EVENTID_FUNNY3, "Hay", MAX_PLAYERS, true, false, true, false, false },

? ? { EVENTID_FUNNY4, "Tesouro", MAX_PLAYERS, false, false, false, false, false },

};





Last item in the list requires no comma, that is how you tell the compiler that that item is the last one in the list.


RE: Script: error 018: initialization data exceeds declared size - RhaegarX - 2021-03-12

I hadn't realized that. Thanks for the help!


RE: Script: error 018: initialization data exceeds declared size - Y_Less - 2021-03-13

That's only true on the old compiler. Trailing commas are very very common in programming and the updated compiler supports them. It's actually a good thing Virsenas noticed that because I wouldn't have - I'm too used to trailing commas being allowed that I wouldn't have seen that code as wrong in any way. Anyway, I suggest you update your compiler:



https://github.com/pawn-lang/compiler/



I also suggest you use an enum for the indexes as well:



https://pastebin.com/VeWhp8U0


RE: Script: error 018: initialization data exceeds declared size - RhaegarX - 2021-03-13

(2021-03-13, 02:18 PM)Y_Less Wrote: That's only true on the old compiler.? Trailing commas are very very common in programming and the updated compiler supports them.? It's actually a good thing Virsenas noticed that because I wouldn't have - I'm too used to trailing commas being allowed that I wouldn't have seen that code as wrong in any way.? Anyway, I suggest you update your compiler:

https://github.com/pawn-lang/compiler/

I also suggest you use an enum for the indexes as well:

https://pastebin.com/VeWhp8U0

Okay, I'll follow the advice.

I already use this version of the compiler :D