Raised This Month: $ Target: $400
 0% 

[AMXX] Run time error 4 (index out of bounds)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Shinzon
Senior Member
Join Date: Feb 2005
Location: Hellfire
Old 02-01-2005 , 11:05   [AMXX] Run time error 4 (index out of bounds)
Reply With Quote #1

Hi,

need a bit help, error occurs imho here:
Code:
public death_event(id) {     new streak = get_streak()     if ((streak&1) || (streak&2)){     new killer = read_data(1);     new victim = read_data(2);     kills[killer] += 1;     kills[victim] = 0;     deaths[killer] = 0;     deaths[victim] += 1;     for (new i = 0; i < LEVELS; i++) {         if (kills[killer] == levels[i]) {            <------- suspected error here             announce(killer, i);             return PLUGIN_CONTINUE;         }         }     }     return PLUGIN_CONTINUE; }

I don't have any clue, new in scripting, sorry.
Any hints ?
__________________
Shinzon

CS:1.6 [max-torgau.de] Fun Server 83.142.83.26:27016
CS:1.6 [max-torgau.de] DeathMatch 83.142.83.26:27017
CS:1.6 [max-torgau.de] .::N!CkYs fUn sErVeR wC3::. XP-SAVE 83.142.83.26:27035
nihil aliud est ebrietas quam voluntaria insania
Shinzon is offline
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 02-01-2005 , 11:22  
Reply With Quote #2

How did you define the variables killer and levels?
__________________
hello, i am pm
PM is offline
Shinzon
Senior Member
Join Date: Feb 2005
Location: Hellfire
Old 02-01-2005 , 11:38  
Reply With Quote #3

Omg, seen this:

Code:
#define LEVELS 15 new levels[10] = {3, 5, 7, 9, 11, 12, 13, 14, 15, 16};

Maybe this is the error, testing this now.
Thanks.
__________________
Shinzon

CS:1.6 [max-torgau.de] Fun Server 83.142.83.26:27016
CS:1.6 [max-torgau.de] DeathMatch 83.142.83.26:27017
CS:1.6 [max-torgau.de] .::N!CkYs fUn sErVeR wC3::. XP-SAVE 83.142.83.26:27035
nihil aliud est ebrietas quam voluntaria insania
Shinzon is offline
BAILOPAN
Join Date: Jan 2004
Old 02-01-2005 , 11:45  
Reply With Quote #4

Code:
#define LEVELS 15 new levels[10] = {3, 5, 7, 9, 11, 12, 13, 14, 15, 16}; .. for (new i = 0; i < LEVELS; i++) {

You're declaring an array of size 10 and then trying to access 15 slots.
__________________
egg
BAILOPAN is offline
Knare
Member
Join Date: Oct 2004
Location: New York, USA
Old 02-01-2005 , 12:07  
Reply With Quote #5

if you are not using a MAC computer then the compiler tells the line with the error by a number before the error/warning
__________________
0110101100111011100110000101110010011001
Knare is offline
Send a message via AIM to Knare Send a message via MSN to Knare
Shinzon
Senior Member
Join Date: Feb 2005
Location: Hellfire
Old 02-01-2005 , 12:09  
Reply With Quote #6

comes from:

Code:
#define LEVELS 25 new levels[19] = {3, 5, 7, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25}; new stksounds[19][] = {             "misc/tripplekill",                         "misc/multikill",             "misc/monsterkill",             "misc/megakill",                         "misc/ultrakill",             "misc/ludicrouskill",                         "misc/unstoppable",             "misc/whickedsick",             "misc/godlike",                         "misc/holyshit_en",             "misc/holyshit_en",             "misc/holyshit_en",             "misc/holyshit_en",                         "misc/holyshit_en",             "misc/holyshit_en",                         "misc/holyshit_en",             "misc/holyshit_en",             "misc/holyshit_en",             "misc/holyshit_en"}; new stkmessages[19][] = {                      "%s: Triple-KILL!! (3 in row)",                      "%s Multi-KILL!! (5 in row)",                      "%s Monster-KILL!! (7 in row)",                      "%s Mega-KILL!! (9 in row)",                      "%s Ultra-KILL!! (11 in row)",                      "%s Ludicrous-KILL!! (12 in row)",                      "%s UNSTOPPABLE!! (13 in row)",                      "%s WICKED SICK!! (14 in row)",                      "%s GODLIKE!! (15 in row)",                      "%s HOLY SHIT!!! (16 in row)",                      "%s HOLY SHIT!!! (17 in row)",                      "%s HOLY SHIT!!! (18 in row)",                      "%s HOLY SHIT!!! (19 in row)",                      "%s HOLY SHIT!!! (20 in row)",                      "%s HOLY SHIT!!! (21 in row)",                      "%s HOLY SHIT!!! (22 in row)",                      "%s HOLY SHIT!!! (23 in row)",                      "%s HOLY SHIT!!! (24 in row)",                      "%s HOLY SHIT!!! (25 in row)"};

If i set
Code:
new levels[25] = {3, 5, 7, 9, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25};
get an internal error on compiling, with 19 it compiled without errors.
__________________
Shinzon

CS:1.6 [max-torgau.de] Fun Server 83.142.83.26:27016
CS:1.6 [max-torgau.de] DeathMatch 83.142.83.26:27017
CS:1.6 [max-torgau.de] .::N!CkYs fUn sErVeR wC3::. XP-SAVE 83.142.83.26:27035
nihil aliud est ebrietas quam voluntaria insania
Shinzon is offline
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 02-01-2005 , 13:00  
Reply With Quote #7

thats b/c u only have 19 values in that array, not 25, add 6 more values and you won't get a compiler error
__________________
Need war3ft help? DO NOT PM ME... Check the forums
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu
Shinzon
Senior Member
Join Date: Feb 2005
Location: Hellfire
Old 02-01-2005 , 13:15  
Reply With Quote #8

Then i get:

Code:
c:\amxx windows\scripting\sounds.sma(71) : error 018: initialization data exceeds declared size
hmmmm.....weird....

havn't written this plugin by myself, comes from amx, only changes i have made are different sounds...
__________________
Shinzon

CS:1.6 [max-torgau.de] Fun Server 83.142.83.26:27016
CS:1.6 [max-torgau.de] DeathMatch 83.142.83.26:27017
CS:1.6 [max-torgau.de] .::N!CkYs fUn sErVeR wC3::. XP-SAVE 83.142.83.26:27035
nihil aliud est ebrietas quam voluntaria insania
Shinzon is offline
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 02-01-2005 , 13:19  
Reply With Quote #9

then add 5 values, not 6
__________________
Need war3ft help? DO NOT PM ME... Check the forums
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu
Shinzon
Senior Member
Join Date: Feb 2005
Location: Hellfire
Old 02-01-2005 , 13:23  
Reply With Quote #10

Sorry, same result.

Have attached the sma, maybe you can have a look at....
Attached Files
File Type: sma Get Plugin or Get Source (sounds.sma - 827 views - 17.9 KB)
__________________
Shinzon

CS:1.6 [max-torgau.de] Fun Server 83.142.83.26:27016
CS:1.6 [max-torgau.de] DeathMatch 83.142.83.26:27017
CS:1.6 [max-torgau.de] .::N!CkYs fUn sErVeR wC3::. XP-SAVE 83.142.83.26:27035
nihil aliud est ebrietas quam voluntaria insania
Shinzon is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 19:17.


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