Run time error 4: "Array index out of bounds"
#1

[21:16:59] [debug] Run time error 4: "Array index out of bounds"
[21:16:59] [debug] Accessing element at index 50 past array upper bound 49
[21:16:59] [debug] AMX backtrace:
[21:16:59] [debug] #0 0016e09c in ?? () from gamemode.amx
[21:16:59] [debug] #1 00009d50 in public NewsFlash () from gamemode.amx

my public function :
Код:
public NewsFlash()
{
	for(new i = 0; i <= MAX_PLAYERS; i++)
	{
	new message1 = random(sizeof(NewsDE));
	new message2 = random(sizeof(NewsEN));
	if(GetPlayerLanguage(i)== LANG_DE)
	{
		SendClientMessage(i,NEWSFARBE,NewsDE[message1]);
		}
		else
		{
		SendClientMessage(i,NEWSFARBE,NewsEN[message2]);
		}
	}
	return true;
}
Help me please.it works fine untill the night comes in,the server gets empty, and in the morning,the server,crashed.and i have to restart it daily.
Reply
#2

Post the funcion "GetPlayerLinguage"

pawn Код:
public NewsFlash()
{
    static i;
    for(i = GetMaxPlayers(); i > -1; --i){
        if(GetPlayerLanguage(i)== LANG_DE)
        {
            SendClientMessage(i,NEWSFARBE,NewsDE[random(sizeof(NewsDE)]);
        }
        else
        {
            SendClientMessage(i,NEWSFARBE,NewsEN[random(sizeof(NewsEN))]);
        }
    }
    return true;
}
Reply
#3

i think arrays have something to do with the number of words i use per sentence in the NEWS lines, doesn't it?
for example i use this :
Код:
new NewsDE[1][128] = {
{"Ashley: {ffffff}Kauf dir Immobilien um Geld zu bekommen, sie sind auf der Map mit einem gelbem bzw rotem Icon eingezeichnet."}
};
Reply
#4

Don't need { and }.

pawn Код:
new NewsDE[2][128] =
{
    "Another string...",
    "Ashley: {ffffff}Kauf dir Immobilien um Geld zu bekommen, sie sind auf der Map mit einem gelbem bzw rotem Icon eingezeichnet."
};

Testing:
pawn Код:
new NewsDE[2][128] =
{
    "Another string...",
    "Ashley: {ffffff}Kauf dir Immobilien um Geld zu bekommen, sie sind auf der Map mit einem gelbem bzw rotem Icon eingezeichnet."
};


public OnFilterScriptInit(){


    printf(NewsDE[random(2)]);
    return true;
}
Reply
#5

aight testing it.i will post the result soon.
EDIT: Still the Same Error.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)