Crashdetect error
#1

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    if(LumberJob[issuerid] == 1 && issuerid != INVALID_PLAYER_ID && playerid != INVALID_PLAYER_ID)
    {
        if(weaponid == 9)
        {
            GivePlayerHealth(playerid, amount);
            return 1;
        }
    }
        return 1;
}
Error:
Код:
[13:00:14] [debug]  Accessing element at index 65535 past array upper bound 499
[13:00:14] [debug] AMX backtrace:
[13:00:14] [debug] #0 00141608 in public OnPlayerTakeDamage () from mygm.amx
I know this comes when something is assigned to array slot greater than 500.I just want to avoid the situation when player is in lumberjack job and use the weapon to kill players.

Help will be appreciated!
Reply
#2

You should've checked if they're not invalid IDs first before using it at LumberJob.

Change to:
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID && playerid != INVALID_PLAYER_ID)
    {
        if(LumberJob[issuerid] == 1 && weaponid == 9) GivePlayerHealth(playerid, amount);
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
You should've checked if they're not invalid IDs first before using it at LumberJob.

Change to:
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID && playerid != INVALID_PLAYER_ID)
    {
        if(LumberJob[issuerid] == 1 && weaponid == 9) GivePlayerHealth(playerid, amount);
    }
    return 1;
}
OH Fuck thanks alot mate.I m so dumb.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)