Help [CRASH ERROR]
#1

Код:
[17:06:05] [debug] Run time error 4: "Array index out of bounds"
[17:06:06] [debug]  Accessing element at index 65535 past array upper bound 499
[17:06:06] [debug] AMX backtrace:
[17:06:06] [debug] #0 000207e0 in public cmd_spec (playerid=26, params[]=@0x0012d08c "8") at C:\Users\MaHdy\Desktop\DAdmin6.pwn:1934
[17:06:06] [debug] #1 native CallLocalFunction () [080dcc00] from samp03svr
[17:06:06] [debug] #2 00000800 in public OnPlayerCommandText (playerid=26, cmdtext[]=@0x0012d06c "/spec 8") at C:\Users\MaHdy\Desktop\SPA Orginal Build 2\pawno\include\ZCMD.inc:111
Caused a crash in server :/ what is the problem

here is the cmd spec:
Код:
CMD:spec(playerid,params[])
{
	if(pInfo[playerid][Admin] >= 2 || IsPlayerAdmin(playerid))
	{
	    new player1 = strval(params);
		if(sscanf(params,"u",player1))return SendClientMessage(playerid,Red,"[Useage]:- {FFFFFF}/spec [playerid]");
		if(pInfo[player1][Admin] == 6 && pInfo[playerid][Admin] != 6) return SendClientMessage(playerid,Red,"ERROR: You cannot use this command on this admin");
        if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID)
		{
			if(player1 == playerid)return SendClientMessage(playerid,Red, "ERROR: You cannot spectate Yourself");
			if(GetPlayerState(player1) == PLAYER_STATE_SPECTATING && pInfo[player1][Spectating] != INVALID_PLAYER_ID)return SendClientMessage(playerid, Red, "ERROR: Player spectating someone else");
			if(GetPlayerState(player1) != 1 && GetPlayerState(player1) != 2 && GetPlayerState(player1) != 3)return SendClientMessage(playerid, Red, "ERROR: Player not Spawned");
			if((pInfo[player1][Admin] != 6) || (pInfo[player1][Admin] == 6 && pInfo[playerid][Admin] == 6))
			{
				SendCommandToAdmins(playerid,"SPEC");
				SendClientMessage(playerid,blue,"Spectating On");
				TextDrawShowForPlayer(playerid,LspecText[playerid]);
				pInfo[playerid][SpecUpdateTimer] = SetTimerEx("UpdateSpecText",1000,1,"d",playerid);

			 	return StartSpectate(playerid, player1);
			}
			else return SendClientMessage(playerid,Red,"ERROR: You cannot spectate the highest level admin");
		}
		else return SendClientMessage(playerid,Red,"[ERROR]:- Player Not Connected!");
	}
	else return LevelMSG(playerid,2);
}
Here is the errors:
Код:
[16:32:23] [debug] AMX backtrace:
[16:32:23] [debug] #0 00020898 in public cmd_spec (playerid=2, params[]=@0x0019d574 "ggs") at C:\Users\MaHdy\Desktop\SPA Orginal Build 2\filterscripts\DAdmin6.pwn:1935
[16:32:23] [debug] #1 native CallLocalFunction () [080dcc00] from samp03svr
[16:32:23] [debug] #2 00000800 in public OnPlayerCommandText (playerid=2, cmdtext[]=@0x0019d54c "/spec ggs") at C:\Users\MaHdy\Desktop\SPA Orginal Build 2\pawno\include\ZCMD.inc:111
Reply
#2

Код:
[17:06:05] [debug] Run time error 4: "Array index out of bounds"
[17:06:06] [debug]  Accessing element at index 65535 past array upper bound 499
What this says is that the server is trying to access an element of '65535' where the maximum is only 499.

In this instance, 65535 = INVALID_PLAYER_ID, and 499 = MAX_PLAYERS - 1.
Which means you are trying to access an array of MAX_PLAYERS with an invalid player id.
(Eg. pInfo[player1][Admin] where 'player1' is INVALID_PLAYER_ID)

pawn Код:
CMD:spec(playerid, params[])
{
    if(pInfo[playerid][Admin] < 2 && !IsPlayerAdmin(playerid)) return LevelMSG(playerid, 2);
    new player1;
    if(sscanf(params, "u", player1)) return SendClientMessage(playerid, Red, "[Usage]:- {FFFFFF}/spec [playerid]");
    if(IsPlayerConnected(player1) || player1 == INVALID_PLAYER_ID) return SendClientMessage(playerid, Red, "[ERROR]:- Player Not Connected!");
    if(player1 == playerid) return SendClientMessage(playerid, Red, "ERROR: You cannot spectate Yourself");
    if(pInfo[player1][Admin] == 6 && pInfo[playerid][Admin] != 6) return SendClientMessage(playerid, Red, "ERROR: You cannot spectate the highest level admin");
    if(GetPlayerState(player1) == PLAYER_STATE_SPECTATING && pInfo[player1][Spectating] != INVALID_PLAYER_ID) return SendClientMessage(playerid, Red, "ERROR: Player spectating someone else");
    if(!(0 < GetPlayerState(player1) < 4)) return SendClientMessage(playerid, Red, "ERROR: Player not Spawned");
    SendCommandToAdmins(playerid, "SPEC");
    SendClientMessage(playerid, blue, "Spectating On");
    TextDrawShowForPlayer(playerid, LspecText[playerid]);
    pInfo[playerid][SpecUpdateTimer] = SetTimerEx("UpdateSpecText", 1000, 1, "d", playerid);
    StartSpectate(playerid, player1);
    return 1;
}
Reply
#3

Thanks are you sure this will work ?
+rep !
Reply
#4

Well bump not working
Reply
#5

pawn Код:
CMD:spec(playerid, params[])
{
    if(pInfo[playerid][Admin] < 2 && !IsPlayerAdmin(playerid)) return LevelMSG(playerid, 2);
    new player1;
    if(sscanf(params, "u", player1)) return SendClientMessage(playerid, Red, "[Usage]:- {FFFFFF}/spec [playerid]");
    if(!IsPlayerConnected(player1) || player1 == INVALID_PLAYER_ID) return SendClientMessage(playerid, Red, "[ERROR]:- Player Not Connected!");
    if(player1 == playerid) return SendClientMessage(playerid, Red, "ERROR: You cannot spectate Yourself");
    if(pInfo[player1][Admin] == 6 && pInfo[playerid][Admin] != 6) return SendClientMessage(playerid, Red, "ERROR: You cannot spectate the highest level admin");
    if(GetPlayerState(player1) == PLAYER_STATE_SPECTATING && pInfo[player1][Spectating] != INVALID_PLAYER_ID) return SendClientMessage(playerid, Red, "ERROR: Player spectating someone else");
    if(!(0 < GetPlayerState(player1) < 4)) return SendClientMessage(playerid, Red, "ERROR: Player not Spawned");
    SendCommandToAdmins(playerid, "SPEC");
    SendClientMessage(playerid, blue, "Spectating On");
    TextDrawShowForPlayer(playerid, LspecText[playerid]);
    pInfo[playerid][SpecUpdateTimer] = SetTimerEx("UpdateSpecText", 1000, 1, "d", playerid);
    StartSpectate(playerid, player1);
    return 1;
}
I forgot a '!' in one of the if statements. Other than that, this should work...
Reply
#6

Thanks worked, i'v added it .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)