Array out of bound OnPlayerTakeDamage
#1

PHP код:
[21:36:30] [debugRun time error 4"Array index out of bounds"
[21:36:30] [debug]  Accessing element at index 65535 past array upper bound 999
[21:36:30] [debugAMX backtrace:
[
21:36:30] [debug#0 00003488 in ?? (0x0000ffff, 0x00000000) from WarRun.amx
[21:36:30] [debug#1 00002e20 in public OnPlayerTakeDamage (0x00000000, 0x0000ffff, 0x40533334, 0x00000036, 0x00000003) from WarRun.amx 
PHP код:
// --- other stuff ---
new Weapon[20] = {
    
422232426
};
// --- other stuff ---
public OnPlayerTakeDamage(playeridissueridFloat:amountweaponid)
{
    new 
Float:HP;
    new 
CharClass CharacterData[playerid][Class];    
    new 
AuthWeapon Weapon[CharClass]; // i can try only with the first that is 0 because after the kill "everything is bugged"
    
new string[128];
    
    if(
weaponid != AuthWeapon && weaponid != && weaponid != 0)
    {
        
GetPlayerHealth(playeridHP);
        
SetPlayerHealth(playeridHP+amount);
        
ClassDegrade(issueridfalse);
        if(
CharacterData[issuerid][Kill] != 0CharacterData[issuerid][Kill]--;
        
format(stringsizeof(string), "%s penalized for cheating!"PlayerName(issuerid));
        
SendClientMessageToAll(ORANGE,string);
    }
    return 
1;

Only when a player uses the melee doing "the execution" (stay behind the victim, aim and kill).

How can i know more about the cause of that?

Thanks
Reply
#2

ClassDegrade(issuerid, false);
Reply
#3

Check if issuerid is valid BEFORE using it as an array index. Players can also take damage from falling and other "natural" sources.
Reply
#4

Quote:
Originally Posted by Vince
Посмотреть сообщение
Check if issuerid is valid BEFORE using it as an array index. Players can also take damage from falling and other "natural" sources.
So i can simply add "&& issuerid != INVALID_PLAYER_ID" and should be ok..

I'll update you

p.s.
i sow that i made a big error.. i must check the issuer weapon not the player weapon <.<
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)