OnPlayerDeath - Array index out of bounds
#1

Код:
[21:06:46] [debug] Run time error 4: "Array index out of bounds"
[21:06:46] [debug]  Accessing element at index 65535 past array upper bound 499
[21:06:46] [debug] AMX backtrace:
[21:06:46] [debug] #0 0002482c in ?? () from jakadmin.amx
[21:06:46] [debug] #1 000121e0 in public OnPlayerDeath () from jakadmin.amx
Idk why. It happens all the time. When player died.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    new string[256];
    if(IsBeingSpeced[playerid] == 1)
    {
        foreach(new i : Player)
        {
            if(spectatorid[i] == playerid)
            {
                TogglePlayerSpectating(i, false);
            }
        }
    }
    if(InDuel[playerid] == 1)
    {
        if(invitation[playerid] != INVALID_PLAYER_ID)
        {
            if(InDuel[killerid] == 1)
            {
                format(string, sizeof(string), "** %s(ID:%d) won the Duel against %s(ID:%d) (Reason: %s disconnected)", GetName(killerid), killerid, GetName(playerid), playerid, GetName(playerid));
                SendClientMessageToAll(COLOR_GREEN, string);
                format(string, sizeof(string), "** You won a Bet from %s, $%i", GetName(playerid), bet);
                SendClientMessage(killerid, COLOR_YELLOW, string);
                ResetPlayerWeapons(killerid);
                SetPlayerPos(killerid, GetPVarFloat(killerid, "CurX"), GetPVarFloat(killerid, "CurY"), GetPVarFloat(killerid, "CurZ"));
                SetPlayerInterior(playerid, GetPVarInt(killerid, "CurInt"));
                format(weapons, 32, "None");
                GivePlayerMoney(killerid, bet);
                GivePlayerMoney(playerid, -bet);
            }
            GivePlayerMoney(playerid, -bet);
            InDuel[playerid] = 0;
            InDuel[killerid] = 0;
            invitation[playerid] = -1;
            invitation[killerid] = -1;
            dinuse = 0;
            bet = 0;
            wid = 0;
        }
    }
    if(sInfo[spawnkill] == 1)
    {
        new Float:pos[3];
        GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
        if(killerid != INVALID_PLAYER_ID)
        {
            if(IsPlayerInRangeOfPoint(killerid, Protection_Dist, Protection_X, Protection_Y, Protection_Z))
            {
                new Float:kpos[3];
                GetPlayerPos(killerid, kpos[0], kpos[1], kpos[2]);
                new Float:h;
                GetPlayerHealth(killerid, h);
                SetPlayerHealth(killerid, h - 95.0);
                CreateExplosion(kpos[0], kpos[1], kpos[2], 0, 10.0);
                SendClientMessage(killerid, COLOR_RED, "NOTICE: Spawn Killing isn't allowed! (brought you by JakAdmin's AntiSpawn Kill)");
                SendClientMessage(killerid, -1, "As result, You lose 1 score!");
                SetPlayerScore(killerid, GetPlayerScore(killerid) - 1);
            }
        }
    }
    if(sInfo[helikill] == 1)
    {
        if(reason == 50)
        {
            if(killerid != INVALID_PLAYER_ID)
            {
                SetPlayerHealth(killerid, 0.0);
                SendClientMessage(killerid, COLOR_RED, "NOTICE: Helicopter Killing isn't allowed! (brought you by JakAdmin's Anti Helicopter Kill)");
                SendClientMessage(killerid, -1, "As result, You lose 1 score!");
                SetPlayerScore(killerid, GetPlayerScore(killerid) - 1);
            }
        }
    }
    if(pInfo[playerid][cage] == 1)
    {
        Cage[playerid][0] = DestroyObject(Cage[playerid][0]);
        Cage[playerid][1] = DestroyObject(Cage[playerid][1]);
        Cage[playerid][2] = DestroyObject(Cage[playerid][2]);
        Cage[playerid][3] = DestroyObject(Cage[playerid][3]);
    }
    pInfo[playerid][Deaths]++;
    pInfo[killerid][Kills]++;
    Healed[playerid] = 0;
    Armoured[playerid] = 0;
    return 1;
}
Reply
#2

pInfo[killerid][Kills]++;

This line too but I think it would highly unlikely...

if(InDuel[killerid] == 1)

As a matter of fact I don't like how the duel looks at all what happens if the the player somehow dies another way? There is no reference to the other duelist besides checking the killerid is a poor assumption, duel info should be stored in a enum which references each other players id in the duel.
Reply
#3

So what should i do?
Reply
#4

if(killerid != INVALID_PLAYER_ID) if(InDuel[killerid] == 1);

Also read what I have to say about the duel script it is certainly flawed.
Reply
#5

fixed. Thank you.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)