Raised This Month: $ Target: $400
 0% 

Run time error 4 (Done)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 10-30-2013 , 17:10   Run time error 4 (Done)
Reply With Quote #1

I am using this:
PHP Code:
public plugin_init() {
    
RegisterHam(Ham_TakeDamage"player""ham_TakeDamage_Pre")
}

public 
ham_TakeDamage_Pre(victiminflictorattackerFloat:damagedamage_bits)
{
    if(!
is_user_connected(victim) || !is_user_connected(attacker))
        return 
HAM_IGNORED
        
    
if(g_Knife[attacker] && is_user_alive(attacker) && inflictor == attacker && get_user_weapon(attacker) == CSW_KNIFE)
    {        
        if(
damage >= && damage 30)
            
SetHamParamFloat(4250.0)
        
        else if(
damage >= 30)
            
SetHamParamFloat(4500.0)
    }
    
    return 
HAM_IGNORED


getting this error:
Code:
L 10/30/2013 - 21:40:38: [AMXX] Displaying debug trace (plugin "zbheroex_melee_combat.amxx")
L 10/30/2013 - 21:40:38: [AMXX] Run time error 4: index out of bounds 
L 10/30/2013 - 21:40:38: [AMXX]    [0] Untitled.sma::ham_TakeDamage_Pre (line 162) // In that code, line 7
__________________
Jhob94 is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 10-30-2013 , 17:20   Re: Run time error 4
Reply With Quote #2

In that code, line 7 is this
Code:
    if(!is_user_connected(victim) || !is_user_connected(attacker)
I see no error there.

But, given the error message, I'm going to assume that it is actually pointing to this line
Code:
if(g_Knife[attacker] && is_user_alive(attacker) && inflictor == attacker && get_user_weapon(attacker) == CSW_KNIFE)
The error is because attacker is out of range for the array g_Knife
__________________
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
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 10-30-2013 , 17:52   Re: Run time error 4
Reply With Quote #3

Quote:
Originally Posted by YamiKaitou View Post
In that code, line 7 is this
Code:
    if(!is_user_connected(victim) || !is_user_connected(attacker)
I see no error there.

But, given the error message, I'm going to assume that it is actually pointing to this line
Code:
if(g_Knife[attacker] && is_user_alive(attacker) && inflictor == attacker && get_user_weapon(attacker) == CSW_KNIFE)
The error is because attacker is out of range for the array g_Knife
So how to fix it?
__________________
Jhob94 is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 10-30-2013 , 17:56   Re: Run time error 4
Reply With Quote #4

Well, make g_Knife larger
__________________
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
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 10-30-2013 , 18:02   Re: Run time error 4
Reply With Quote #5

Quote:
Originally Posted by YamiKaitou View Post
Well, make g_Knife larger
new g_Knife[33]

What value should i put then?
__________________
Jhob94 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-30-2013 , 18:15   Re: Run time error 4
Reply With Quote #6

Quote:
Originally Posted by Jhob94 View Post
new g_Knife[33]

What value should i put then?
Increasing it is a solution but is likely not the right solution (for it to be "complete" this way you would need to make it the same size as the number of entities that the game can load). It usually happens when an entity is doing the damage where that entity has some entity number greater than 32. Most people that come across this problem just need to filter those entities out.
__________________
fysiks is online now
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 10-30-2013 , 18:36   Re: Run time error 4
Reply With Quote #7

Quote:
Originally Posted by fysiks View Post
Most people that come across this problem just need to filter those entities out.
How?
__________________
Jhob94 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 10-30-2013 , 19:50   Re: Run time error 4
Reply With Quote #8

Quote:
Originally Posted by Jhob94 View Post
How?
The same way you do it for anything else. Check if it's a value that you want, if not, don't run the code.

Also, this is an extremely common question here so you can find many threads that talk about it.
__________________

Last edited by fysiks; 10-30-2013 at 19:51.
fysiks is online now
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 10-30-2013 , 18:07   Re: Run time error 4
Reply With Quote #9

Depends on the value of attacker
__________________
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
Jhob94
AMX Mod X Donor
Join Date: Jul 2012
Old 10-31-2013 , 11:56   Re: Run time error 4
Reply With Quote #10

lol...
Sorry for this thread. I had 3 knifes that was basickly the same code but for diferent models/sounds/damage.
Both had that error, now it was only that one. When i got that errors, i hadnt checked if user was connected.
It seems it didnt copied one of the 3 plugins, btw thanks
__________________

Last edited by Jhob94; 10-31-2013 at 15:22.
Jhob94 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 23:19.


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