Array index out of bounds
#1

Код:
[debug] Run time error 4: "Array index out of bounds"
[debug]  Accessing element at index 65535 past array upper bound 999
[debug] AMX backtrace:
[debug] #0 0003b8f4 in public OnPlayerDeath (2, 65535, 255) from gm.amx
Код:
new Streaks[MAX_PLAYERS];
Код:
Streaks[playerid] = 0;
Код:
if(IsPlayerConnected(killerid) &&  killerid != INVALID_PLAYER_ID ) { //check if the player is connected and it's a VALID KILL
        if(GetPlayerWantedLevel(killerid) < 6) //if the player's wantedlevel is under 6
		  {
		    SetPlayerWantedLevel(killerid, GetPlayerWantedLevel(killerid) + 1); //increase it by 1
	      }
       	Streaks[killerid] ++; //the sign '++' means, increase the variable for the killerid by 1
        GivePlayerMoney(killerid, 500); //if you like, give the killer some money, else comment this line out
        }
	SetPlayerWantedLevel(playerid, 0); //the player who died will get his wanted level reset to 0
	Streaks[playerid] = 0; //and his streak will end, while giving the value '0' to this variable
	// Check that the killerid is valid before doing anything with it
	new str[ 256 ], KillerName[MAX_PLAYER_NAME]; //here, you're defining a string and the killername
	GetPlayerName(killerid, KillerName, sizeof(KillerName)); //receive the information of the killer's name
	switch(Streaks[killerid]) //IMPORTANT: with the function "switch", you're switching / toggling through the killstreaks of a player (Streals). you need the killerid here, because the playerid is the one which is GETTING killed
        	{
            	case 2: // we won't start with the first kill (case 1), because it wouldn't be countable as streak
			{
			    format(str, sizeof(str), "[KILLINGSPREE] %s je ucinio double kill!", KillerName); //here, you're formatting the defined string and add the content (text)
			    SendClientMessageToAll(COLOR_GREEN, str); //this is a function, which will show a short, colored big text for all the players (str, 4000ms, stylenumber 4)
			}
				case 3:
			{
			    format(str, sizeof(str), "[KILLINGSPREE] Triple Kill za %s!", KillerName);
			    SendClientMessageToAll(COLOR_GREEN, str);
			}
				case 4:
			{
			    format(str, sizeof(str), "[KILLINGSPREE] Quadro Kill za %s!", KillerName);
			    SendClientMessageToAll(COLOR_GREEN, str);
			}
				case 5:
			{
			    format(str, sizeof(str), "[KILLINGSPREE] %s dominira sa 5 ubistava!", KillerName);
       			SendClientMessageToAll(COLOR_GREEN, str);
			}
				case 6:
			{
			    format(str, sizeof(str), "[KILLINGSPREE] %s nezaustavljiv sa 6 ubistava!", KillerName);
			    SendClientMessageToAll(COLOR_GREEN, str);
			}
				case 7:
			{
			    format(str, sizeof(str), "[KILLINGSPREE] RAMPAGE za %s.  7 ubistava!", KillerName);
				SendClientMessageToAll(COLOR_GREEN, str);
			}
				case 8:
			{
			    format(str, sizeof(str), "[KILLINGSPREE] %s je neverovatan, 8 ubistava!", KillerName);
				SendClientMessageToAll(COLOR_GREEN, str);
			}
				case 9:
			{
			    format(str, sizeof(str), "[KILLINGSPREE] %s GODLIKE, deveta smrt!", KillerName);
			    SendClientMessageToAll(COLOR_GREEN, str);
			}
				case 10:
			{
			    format(str, sizeof(str), "[KILLINGSPREE] %s resava sa desetom smrcu!", KillerName);
			    SendClientMessageToAll(COLOR_GREEN, str);
			}
		}
	return 1;
}
What is wrong with it?
Reply
#2

Can you post all onplayerdeath callback?
Reply
#3

Sure
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
	SendDeathMessage(killerid,playerid,reason);
	if(IsPlayerConnected(killerid) &&  killerid != INVALID_PLAYER_ID ) { //check if the player is connected and it's a VALID KILL
        if(GetPlayerWantedLevel(killerid) < 6) //if the player's wantedlevel is under 6
		  {
		    SetPlayerWantedLevel(killerid, GetPlayerWantedLevel(killerid) + 1); //increase it by 1
	      }
       	Streaks[killerid] ++; //the sign '++' means, increase the variable for the killerid by 1
        GivePlayerMoney(killerid, 500); //if you like, give the killer some money, else comment this line out
        }
	SetPlayerWantedLevel(playerid, 0); //the player who died will get his wanted level reset to 0
	Streaks[playerid] = 0; //and his streak will end, while giving the value '0' to this variable
	// Check that the killerid is valid before doing anything with it
	new str[ 256 ], KillerName[MAX_PLAYER_NAME]; //here, you're defining a string and the killername
	GetPlayerName(killerid, KillerName, sizeof(KillerName)); //receive the information of the killer's name
	switch(Streaks[killerid]) //IMPORTANT: with the function "switch", you're switching / toggling through the killstreaks of a player (Streals). you need the killerid here, because the playerid is the one which is GETTING killed
        	{
            	case 2: // we won't start with the first kill (case 1), because it wouldn't be countable as streak
			{
			    format(str, sizeof(str), "[KILLINGSPREE] %s je ucinio double kill!", KillerName); //here, you're formatting the defined string and add the content (text)
			    SendClientMessageToAll(COLOR_GREEN, str); //this is a function, which will show a short, colored big text for all the players (str, 4000ms, stylenumber 4)
			}
				case 3:
			{
			    format(str, sizeof(str), "[KILLINGSPREE] Triple Kill za %s!", KillerName);
			    SendClientMessageToAll(COLOR_GREEN, str);
			}
				case 4:
			{
			    format(str, sizeof(str), "[KILLINGSPREE] Quadro Kill za %s!", KillerName);
			    SendClientMessageToAll(COLOR_GREEN, str);
			}
				case 5:
			{
			    format(str, sizeof(str), "[KILLINGSPREE] %s dominira sa 5 ubistava!", KillerName);
       			SendClientMessageToAll(COLOR_GREEN, str);
			}
				case 6:
			{
			    format(str, sizeof(str), "[KILLINGSPREE] %s nezaustavljiv sa 6 ubistava!", KillerName);
			    SendClientMessageToAll(COLOR_GREEN, str);
			}
				case 7:
			{
			    format(str, sizeof(str), "[KILLINGSPREE] RAMPAGE za %s.  7 ubistava!", KillerName);
				SendClientMessageToAll(COLOR_GREEN, str);
			}
				case 8:
			{
			    format(str, sizeof(str), "[KILLINGSPREE] %s je neverovatan, 8 ubistava!", KillerName);
				SendClientMessageToAll(COLOR_GREEN, str);
			}
				case 9:
			{
			    format(str, sizeof(str), "[KILLINGSPREE] %s GODLIKE, deveta smrt!", KillerName);
			    SendClientMessageToAll(COLOR_GREEN, str);
			}
				case 10:
			{
			    format(str, sizeof(str), "[KILLINGSPREE] %s resava sa desetom smrcu!", KillerName);
			    SendClientMessageToAll(COLOR_GREEN, str);
			}
		}
	return 1;
}
Reply
#4

Try this
Код:
SendDeathMessage(killerid,playerid,reason);
    if(IsPlayerConnected(killerid) &&  killerid != INVALID_PLAYER_ID )
    { 
        if(GetPlayerWantedLevel(killerid) < 6) //if the player's wantedlevel is under 6
        {
            SetPlayerWantedLevel(killerid, GetPlayerWantedLevel(killerid) + 1); //increase it by 1
        }
        Streaks[killerid] ++; //the sign '++' means, increase the variable for the killerid by 1
        GivePlayerMoney(killerid, 500); //if you like, give the killer some money, else comment this line out
    }
    SetPlayerWantedLevel(playerid, 0); //the player who died will get his wanted level reset to 0
    Streaks[playerid] = 0; //and his streak will end, while giving the value '0' to this variable
    // Check that the killerid is valid before doing anything with it
    if(IsPlayerConnected(killerid) &&  killerid != INVALID_PLAYER_ID )
    { 
        new str[ 256 ], KillerName[MAX_PLAYER_NAME]; //here, you're defining a string and the killername
        GetPlayerName(killerid, KillerName, sizeof(KillerName)); //receive the information of the killer's name
        switch(Streaks[killerid]) //IMPORTANT: with the function "switch", you're switching / toggling through the killstreaks of a player (Streals). you need the killerid here, because the playerid is the one which is GETTING killed
        {
            case 2: // we won't start with the first kill (case 1), because it wouldn't be countable as streak
            {
                format(str, sizeof(str), "[KILLINGSPREE] %s je ucinio double kill!", KillerName); //here, you're formatting the defined string and add the content (text)
                SendClientMessageToAll(COLOR_GREEN, str); //this is a function, which will show a short, colored big text for all the players (str, 4000ms, stylenumber 4)
            }
                case 3:
            {
                format(str, sizeof(str), "[KILLINGSPREE] Triple Kill za %s!", KillerName);
                SendClientMessageToAll(COLOR_GREEN, str);
            }
                case 4:
            {
                format(str, sizeof(str), "[KILLINGSPREE] Quadro Kill za %s!", KillerName);
                SendClientMessageToAll(COLOR_GREEN, str);
            }
                case 5:
            {
                format(str, sizeof(str), "[KILLINGSPREE] %s dominira sa 5 ubistava!", KillerName);
                SendClientMessageToAll(COLOR_GREEN, str);
            }
                case 6:
            {
                format(str, sizeof(str), "[KILLINGSPREE] %s nezaustavljiv sa 6 ubistava!", KillerName);
                SendClientMessageToAll(COLOR_GREEN, str);
            }
                case 7:
            {
                format(str, sizeof(str), "[KILLINGSPREE] RAMPAGE za %s.  7 ubistava!", KillerName);
                SendClientMessageToAll(COLOR_GREEN, str);
            }
                case 8:
            {
                format(str, sizeof(str), "[KILLINGSPREE] %s je neverovatan, 8 ubistava!", KillerName);
                SendClientMessageToAll(COLOR_GREEN, str);
            }
                case 9:
            {
                format(str, sizeof(str), "[KILLINGSPREE] %s GODLIKE, deveta smrt!", KillerName);
                SendClientMessageToAll(COLOR_GREEN, str);
            }
                case 10:
            {
                format(str, sizeof(str), "[KILLINGSPREE] %s resava sa desetom smrcu!", KillerName);
                SendClientMessageToAll(COLOR_GREEN, str);
            }
        }
    }
Reply
#5

C:\Users\Aleksa\Desktop\SAMP server\gamemodes\gm.pwn(2302) : error 010: invalid function or declaration
C:\Users\Aleksa\Desktop\SAMP server\gamemodes\gm.pwn(2304) : error 010: invalid function or declaration
C:\Users\Aleksa\Desktop\SAMP server\gamemodes\gm.pwn(2314) : error 010: invalid function or declaration
C:\Users\Aleksa\Desktop\SAMP server\gamemodes\gm.pwn(2317) : error 021: symbol already defined: "GetPlayerName"
C:\Users\Aleksa\Desktop\SAMP server\gamemodes\gm.pwn(231 : error 010: invalid function or declaration
C:\Users\Aleksa\Desktop\SAMP server\gamemodes\gm.pwn(2320) : error 010: invalid function or declaration
C:\Users\Aleksa\Desktop\SAMP server\gamemodes\gm.pwn(2325) : error 010: invalid function or declaration
C:\Users\Aleksa\Desktop\SAMP server\gamemodes\gm.pwn(2330) : error 010: invalid function or declaration
C:\Users\Aleksa\Desktop\SAMP server\gamemodes\gm.pwn(2335) : error 010: invalid function or declaration
C:\Users\Aleksa\Desktop\SAMP server\gamemodes\gm.pwn(2340) : error 010: invalid function or declaration
C:\Users\Aleksa\Desktop\SAMP server\gamemodes\gm.pwn(2345) : error 010: invalid function or declaration
C:\Users\Aleksa\Desktop\SAMP server\gamemodes\gm.pwn(2350) : error 010: invalid function or declaration
C:\Users\Aleksa\Desktop\SAMP server\gamemodes\gm.pwn(2355) : error 010: invalid function or declaration
C:\Users\Aleksa\Desktop\SAMP server\gamemodes\gm.pwn(2360) : error 010: invalid function or declaration
C:\Users\Aleksa\Desktop\SAMP server\gamemodes\gm.pwn(2367) : error 010: invalid function or declaration
C:\Users\Aleksa\Desktop\SAMP server\gamemodes\gm.pwn(3243) : warning 203: symbol is never used: "KillerName"
Reply
#6

Where....did....you placed....it?And......how?
Reply
#7

I copy pasted it to onplayerdeath
Reply
#8

Seems like a bracket "{}" is missing
somewhere
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)