SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 01/08/2016, 01:14 PM   #1
Shady
Huge Clucker
 
Shady's Avatar
 
Join Date: Aug 2014
Location: Egypt
Posts: 203
Reputation: 30
Default SOLVED!

Hello,

I was working on my server, but I had some issues while complying/complie the script. Actually, the issue came from my rank system which I do not know what's wrong with it. I have never faced any of these errors before, so It'd be appreciated if you helped me to fix the problem/issue. I'll be writing the details below, so you can help me. Marked with Red is the line which I do receive the errors from.

Error:
pawn Code:
E:\Programming\gamemodes\csmp.pwn(3062) : error 052: multi-dimensional arrays must be fully initialized

Codes:
pawn Code:
removed
__________________
Management & Developer @ Golden Gate Bay Roleplay.

Former developer @ IV.Digital, Prospect:RP, Core:RP, SARP, OS:RP, SC:RP, NG:RP, OG:RP, CNRSF, and SWF.

Last edited by Shady; 01/08/2016 at 11:53 PM.
Shady is offline   Reply With Quote
Old 01/08/2016, 01:19 PM   #2
FuNkYTheGreat
Huge Clucker
 
FuNkYTheGreat's Avatar
 
Join Date: Jun 2016
Location: Pakistan.
Posts: 270
Reputation: 124
Default Re: error 052: multi-dimensional arrays must be fully initialized

Removed On Request ( Because OF Copy Cats )

Last edited by FuNkYTheGreat; 02/08/2016 at 09:03 AM.
FuNkYTheGreat is offline   Reply With Quote
Old 01/08/2016, 01:21 PM   #3
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,079
Reputation: 2655
Default Re: error 052: multi-dimensional arrays must be fully initialized

If you declare it with 500 ranks then you also have to initialize it with 500 ranks. I recommend you let the compiler calculate the amount; keep the brackets empty (i.e. new RankInfo[][rInfo]) and use sizeof if you need to know its size.
__________________
Vince is offline   Reply With Quote
Old 01/08/2016, 01:24 PM   #4
Shady
Huge Clucker
 
Shady's Avatar
 
Join Date: Aug 2014
Location: Egypt
Posts: 203
Reputation: 30
Default Re: error 052: multi-dimensional arrays must be fully initialized

Quote:
Originally Posted by Vince View Post
If you declare it with 500 ranks then you also have to initialize it with 500 ranks. I recommend you let the compiler calculate the amount; keep the brackets empty (i.e. new RankInfo[][rInfo]) and use sizeof if you need to know its size.
Thanks man, it is okay now.

Quote:
Originally Posted by FuNkYTheGreat View Post
Try this
Code:
removed
You too, thanks.
__________________
Management & Developer @ Golden Gate Bay Roleplay.

Former developer @ IV.Digital, Prospect:RP, Core:RP, SARP, OS:RP, SC:RP, NG:RP, OG:RP, CNRSF, and SWF.

Last edited by Shady; 01/08/2016 at 11:53 PM.
Shady is offline   Reply With Quote
Old 01/08/2016, 02:03 PM   #5
Shady
Huge Clucker
 
Shady's Avatar
 
Join Date: Aug 2014
Location: Egypt
Posts: 203
Reputation: 30
Default Re: error 052: multi-dimensional arrays must be fully initialized

Well, I am getting AMX Backtrace errors after I updated my codes to Funky's.

Errors from server logs:
pawn Code:
[15:55:43] [debug] AMX backtrace:
[15:55:43] [debug] #0 0002bd94 in ?? (0) from csmp.amx
[15:55:43] [debug] #1 00011c78 in public OnPlayerUpdate (0) from csmp.amx
[15:55:43] [debug] Run time error 4: "Array index out of bounds"
[15:55:43] [debug]  Accessing element at index 18 past array upper bound 17
[15:55:43] [debug] AMX backtrace:
[15:55:43] [debug] #0 0002bd94 in ?? (0) from csmp.amx
[15:55:43] [debug] #1 00011c78 in public OnPlayerUpdate (0) from csmp.amx

pawn Code:
deleted
__________________
Management & Developer @ Golden Gate Bay Roleplay.

Former developer @ IV.Digital, Prospect:RP, Core:RP, SARP, OS:RP, SC:RP, NG:RP, OG:RP, CNRSF, and SWF.

Last edited by Shady; 01/08/2016 at 11:54 PM.
Shady is offline   Reply With Quote
Old 01/08/2016, 02:06 PM   #6
[XST]O_x
High-roller
 
[XST]O_x's Avatar
 
Join Date: Aug 2009
Posts: 1,962
Reputation: 94
Default Re: error 052: multi-dimensional arrays must be fully initialized

Change the loop to this:
pawn Code:
for(new x = sizeof(RankInfo)-1; x >= 0; x--)

The error is caused because you have 18 elements, indexed at 0 to 17, and you're accessing index 18 which is the 19th element which doesn't exist yet.
[XST]O_x is offline   Reply With Quote
Old 01/08/2016, 02:07 PM   #7
Konstantinos
Spam Machine
 
Konstantinos's Avatar
 
Join Date: Dec 2011
Posts: 11,841
Reputation: 1399
Default Re: error 052: multi-dimensional arrays must be fully initialized

This is incorrect:
pawn Code:
for(new x = 18; x != 0; x--)
The size of the array is 18 and that makes 0-17 as valid indexes. Your loops goes (backwards) from 18-1. Change to:
pawn Code:
for(new x = sizeof RankInfo - 1; x != -1; x--)

@[XST]O_x: "x" still starts at 18 and the first index will never be accessed.
__________________
Life is like riding a bicycle. To keep your balance, you must keep moving.

[Tutorial] How to use SQLite
[FilterScript] Tune System
Konstantinos is offline   Reply With Quote
Old 01/08/2016, 02:09 PM   #8
[XST]O_x
High-roller
 
[XST]O_x's Avatar
 
Join Date: Aug 2009
Posts: 1,962
Reputation: 94
Default Re: error 052: multi-dimensional arrays must be fully initialized

Quote:
Originally Posted by Konstantinos View Post
This is incorrect:
pawn Code:
for(new x = 18; x != 0; x--)
The size of the array is 18 and that makes 0-17 as valid indexes. Your loops goes (backwards) from 18-1. Change to:
pawn Code:
for(new x = sizeof RankInfo - 1; x != -1; x--)

@[XST]O_x: "x" still starts at 18 and the first index will never be accessed.
Yes. I forgot to decrease 1
[XST]O_x is offline   Reply With Quote
Old 01/08/2016, 03:34 PM   #9
Shady
Huge Clucker
 
Shady's Avatar
 
Join Date: Aug 2014
Location: Egypt
Posts: 203
Reputation: 30
Default Re: error 052: multi-dimensional arrays must be fully initialized

Quote:
Originally Posted by Konstantinos View Post
This is incorrect:
pawn Code:
for(new x = 18; x != 0; x--)
The size of the array is 18 and that makes 0-17 as valid indexes. Your loops goes (backwards) from 18-1. Change to:
pawn Code:
for(new x = sizeof RankInfo - 1; x != -1; x--)

@[XST]O_x: "x" still starts at 18 and the first index will never be accessed.
Thank you, Konstantinos.

This problem has been solved.
__________________
Management & Developer @ Golden Gate Bay Roleplay.

Former developer @ IV.Digital, Prospect:RP, Core:RP, SARP, OS:RP, SC:RP, NG:RP, OG:RP, CNRSF, and SWF.
Shady is offline   Reply With Quote
Reply

Thread Tools
Display Modes

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
/set script issue nmader Scripting Help 7 03/05/2012 02:01 AM
Script Issue Nuk3d1nk Help Archive 6 11/04/2011 07:53 PM
0.3b script issue. BP13 Help Archive 0 28/08/2010 04:13 PM
I need A COMPLIER who can complie my script Roleplaya Help Archive 2 28/12/2009 01:13 PM


All times are GMT. The time now is 12:47 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.