AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Index out of bounds question (https://forums.alliedmods.net/showthread.php?t=205412)

EDUTz 01-10-2013 11:38

Index out of bounds question
 
So i have this issue, maybe someone can help me.

Run time error 4: index out of bounds
Line: UserDamage[attacker] += damage;

The stragest thing i've seen is that userdamage is properly defined:
new Float:UserDamage[33]

SO WTF ? What can it be ? I don't have more that 32 players on the server :))

YamiKaitou 01-10-2013 11:39

Re: Index out of bounds question
 
Depends on your usage of attacker, it might not be a player

EDUTz 01-10-2013 11:49

Re: Index out of bounds question
 
yes, indeed. It's used in a npc plugin, but the awkward thing is that the npc shouldn't take damage to himself.

Code:

public TakeDamage(victim, weapon, attacker, Float:damage, damagetype) {
        static ClassName[32]
        pev(victim, pev_classname, ClassName, charsmax(ClassName))
        if (equal(ClassName, "NPC")) {
                pev(victim, pev_health, g_Health)
                UserDamage[attacker] += damage;
                blablabla ......


YamiKaitou 01-10-2013 11:52

Re: Index out of bounds question
 
I said attacker, not victim

EDUTz 01-10-2013 18:13

Re: Index out of bounds question
 
well, that's the bizzare question.
That's the actual code line, no tricks, not so ever. I hardly know if it's attacker or victim, that's why i asked for you help.

AngeIII 01-10-2013 18:22

Re: Index out of bounds question
 
post full code.

YamiKaitou 01-10-2013 18:22

Re: Index out of bounds question
 
The attacker is not a player. Check and make sure that it is a valid player.


All times are GMT -4. The time now is 13:22.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.