Errors in crashdetect "Array index out of bounds"
#1

[16:33:21] [debug] Run time error 4: "Array index out of bounds"
[16:33:21] [debug] Attempted to read/write array element at index 65535 in array of size 90
[16:33:21] [debug] AMX backtrace:
[16:33:21] [debug] #0 0002c3b0 in ?? (27, 65535, 1079194420, 54) from Mundito.amx
[16:33:21] [debug] #1 0000ff18 in public OnPlayerTakeDamage (27, 65535, 1079194420, 54, 3) from Mundito.amx



PHP код:
public OnPlayerTakeDamage(playeridissueridFloatamountweaponid)
{
PlayerPlaySound(issuerid178020.00.00.0);
new 
Float:Vida;
GetPlayerHealth(playeridVida);
//==damage
#if defined SHOWN_ON_SCOREBOARD
        
totalDmg[issuerid] += amount;
        
SetPlayerScore(issueridfloatround(totalDmg[issuerid]));
        
#endif
        
currentHpLoss[0][issuerid][playerid] += amount;
        
currentHpLoss[1][playerid][issuerid] += amount;
        new
         
nick[MAX_PLAYER_NAME],
         
buffer[128];
        
GetPlayerName(playeridnickMAX_PLAYER_NAME);
        
format(buffer128"~g~~h~~h~%s~n~~g~~h~~h~%i (%s)"nickfloatround(currentHpLoss[0][issuerid][playerid]), weaponName[weaponid]);
        
TextDrawSetString(txd[0][issuerid], buffer);
        
GetPlayerName(issueridnickMAX_PLAYER_NAME);
        
format(buffer128"~r~~h~%s~n~~r~~h~-%i (%s)"nickfloatround(currentHpLoss[1][playerid][issuerid]), weaponName[weaponid]);
        
TextDrawSetString(txd[1][playerid], buffer);
        
txdAlpha[0][issuerid] = 0xFF;
        
txdAlpha[1][playerid] = 0xFF;
        return 
1;

help me D:
Reply
#2

You need check issuerid is not INVALID_PLAYER_ID ( 65535 )

if(issuerid != INVALID_PLAYER_ID)
{
// code here
}
Reply
#3

PHP код:
public OnPlayerTakeDamage(playeridissueridFloatamountweaponid)
{
PlayerPlaySound(issuerid178020.00.00.0);
new 
Float:Vida;
GetPlayerHealth(playeridVida);
//==damage
#if defined SHOWN_ON_SCOREBOARD
if(issuerid != INVALID_PLAYER_ID)
{
// code he
        
totalDmg[issuerid] += amount;
        
SetPlayerScore(issueridfloatround(totalDmg[issuerid]));
        
#endif
        
currentHpLoss[0][issuerid][playerid] += amount;
        
currentHpLoss[1][playerid][issuerid] += amount;
        new
         
nick[MAX_PLAYER_NAME],
         
buffer[128];
        
GetPlayerName(playeridnickMAX_PLAYER_NAME);
        
format(buffer128"~g~~h~~h~%s~n~~g~~h~~h~%i (%s)"nickfloatround(currentHpLoss[0][issuerid][playerid]), weaponName[weaponid]);
        
TextDrawSetString(txd[0][issuerid], buffer);
        
GetPlayerName(issueridnickMAX_PLAYER_NAME);
        
format(buffer128"~r~~h~%s~n~~r~~h~-%i (%s)"nickfloatround(currentHpLoss[1][playerid][issuerid]), weaponName[weaponid]);
        
TextDrawSetString(txd[1][playerid], buffer);
        
txdAlpha[0][issuerid] = 0xFF;
        
txdAlpha[1][playerid] = 0xFF;
        return 
1;

Reply
#4

yees, add closing bracket } before return but PlayerSound should be too inside that if
Reply
#5

PHP код:
public OnPlayerTakeDamage(playeridissueridFloatamountweaponid)
{
PlayerPlaySound(issuerid178020.00.00.0);
new 
Float:Vida;
GetPlayerHealth(playeridVida);
//==damage
#if defined SHOWN_ON_SCOREBOARD
if(issuerid != INVALID_PLAYER_ID)
{
}
// code he
        
totalDmg[issuerid] += amount;
        
SetPlayerScore(issueridfloatround(totalDmg[issuerid]));
        
#endif
        
currentHpLoss[0][issuerid][playerid] += amount;
        
currentHpLoss[1][playerid][issuerid] += amount;
        new
         
nick[MAX_PLAYER_NAME],
         
buffer[128];
        
GetPlayerName(playeridnickMAX_PLAYER_NAME);
        
format(buffer128"~g~~h~~h~%s~n~~g~~h~~h~%i (%s)"nickfloatround(currentHpLoss[0][issuerid][playerid]), weaponName[weaponid]);
        
TextDrawSetString(txd[0][issuerid], buffer);
        
GetPlayerName(issueridnickMAX_PLAYER_NAME);
        
format(buffer128"~r~~h~%s~n~~r~~h~-%i (%s)"nickfloatround(currentHpLoss[1][playerid][issuerid]), weaponName[weaponid]);
        
TextDrawSetString(txd[1][playerid], buffer);
        
txdAlpha[0][issuerid] = 0xFF;
        
txdAlpha[1][playerid] = 0xFF;
        return 
1;

It's okay like this?? :/
Reply
#6

pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
    if(issuerid != INVALID_PLAYER_ID)
    {
        PlayerPlaySound(issuerid, 17802, 0.0, 0.0, 0.0);
        new Float:Vida;
        GetPlayerHealth(playerid, Vida);
        //==damage
        #if defined SHOWN_ON_SCOREBOARD
        totalDmg[issuerid] += amount;
        SetPlayerScore(issuerid, floatround(totalDmg[issuerid]));
        #endif

        currentHpLoss[0][issuerid][playerid] += amount;
        currentHpLoss[1][playerid][issuerid] += amount;

        new
            nick[MAX_PLAYER_NAME],
            buffer[128]
        ;

        GetPlayerName(playerid, nick, MAX_PLAYER_NAME);

        format(buffer, 128, "~g~~h~~h~%s~n~~g~~h~~h~%i (%s)", nick, floatround(currentHpLoss[0][issuerid][playerid]), weaponName[weaponid]);
        TextDrawSetString(txd[0][issuerid], buffer);

        GetPlayerName(issuerid, nick, MAX_PLAYER_NAME);

        format(buffer, 128, "~r~~h~%s~n~~r~~h~-%i (%s)", nick, floatround(currentHpLoss[1][playerid][issuerid]), weaponName[weaponid]);
        TextDrawSetString(txd[1][playerid], buffer);
        txdAlpha[0][issuerid] = 0xFF;

        txdAlpha[1][playerid] = 0xFF;
    }
    return 1;
}
Reply
#7

tranks DDD !!!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)