Raised This Month: $ Target: $400
 0% 

Index out of bounds question


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EDUTz
Senior Member
Join Date: Jun 2010
Location: Dracula's Homeland
Old 01-10-2013 , 11:38   Index out of bounds question
Reply With Quote #1

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 )

Last edited by EDUTz; 01-10-2013 at 11:39.
EDUTz is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 01-10-2013 , 11:39   Re: Index out of bounds question
Reply With Quote #2

Depends on your usage of attacker, it might not be a player
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
EDUTz
Senior Member
Join Date: Jun 2010
Location: Dracula's Homeland
Old 01-10-2013 , 11:49   Re: Index out of bounds question
Reply With Quote #3

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 ......

Last edited by EDUTz; 01-10-2013 at 11:50.
EDUTz is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 01-10-2013 , 11:52   Re: Index out of bounds question
Reply With Quote #4

I said attacker, not victim
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
EDUTz
Senior Member
Join Date: Jun 2010
Location: Dracula's Homeland
Old 01-10-2013 , 18:13   Re: Index out of bounds question
Reply With Quote #5

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.
EDUTz is offline
AngeIII
Senior Member
Join Date: Sep 2007
Location: Latvia
Old 01-10-2013 , 18:22   Re: Index out of bounds question
Reply With Quote #6

post full code.
__________________
skype: pavle_ivanof
-=ThQ=-
PRIVATE SUPPORT = PAID SUPPORT
AngeIII is offline
Send a message via Skype™ to AngeIII
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 01-10-2013 , 18:22   Re: Index out of bounds question
Reply With Quote #7

The attacker is not a player. Check and make sure that it is a valid player.
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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