Raised This Month: $ Target: $400
 0% 

Need help on error fixing


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
freamer
Member
Join Date: Nov 2005
Old 06-19-2007 , 06:29   Need help on error fixing
Reply With Quote #1

I dont get it, why can this error occur? Seems like its crashing the server after some time.
Is there any way to fix it?
line 574: new plrHealth = get_user_health(id)

L 06/19/2007 - 13:14:48: [AMXX] Run time error 4: index out of bounds
L 06/19/2007 - 13:14:48: [AMXX] [0] phpy4ngxv.sma::doDamage (line 574)
L 06/19/2007 - 13:14:48: [AMXX] Displaying debug trace (plugin "weapons.amxx")
Code:
public doDamage(id){
    if (get_cvar_num("sv_xweapons")==0){
        return PLUGIN_CONTINUE
    }
    new plrDmg = read_data(2)
    new plrWeap
    new plrPartHit
    new plrAttacker = get_user_attacker(id, plrWeap, plrPartHit)
    if (!xmp5_carrier[plrAttacker] && !xm3_carrier[plrAttacker] && !xarmor_carrier[plrAttacker] && !xkevlar_carrier[plrAttacker] && !xknife_carrier[plrAttacker] && !xrevolver_carrier[plrAttacker]){
        return PLUGIN_CONTINUE
    }
    if (!is_user_alive(id)){
        return PLUGIN_CONTINUE
    }
    new plrHealth = get_user_health(id)
    new plrNewDmg
...
freamer is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-19-2007 , 06:37   Re: Need help on error fixing
Reply With Quote #2

Show the full code.
__________________
Arkshine is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 06-19-2007 , 09:32   Re: Need help on error fixing
Reply With Quote #3

I'm assuming that is the "Damage" event handler. If so then post the way you registered the event.
Also note that get_user_attacker() can return a non-player id.
_Master_ is offline
freamer
Member
Join Date: Nov 2005
Old 06-19-2007 , 09:58   Re: Need help on error fixing
Reply With Quote #4

Attached full source code

register_event("Damage", "doDamage", "b", "2!0")
Attached Files
File Type: sma Get Plugin or Get Source (weapon-x.sma - 674 views - 33.5 KB)

Last edited by freamer; 06-19-2007 at 10:26.
freamer is offline
freamer
Member
Join Date: Nov 2005
Old 06-20-2007 , 15:39   Re: Need help on error fixing
Reply With Quote #5

Changed event register to this:
register_event("Damage", "doDamage", "b", "2!0", "3=0", "4!0")
and modified function code to this:
Code:
public doDamage(id){
    if (get_cvar_num("sv_xweapons")==0){
        return PLUGIN_CONTINUE
    }
    switch ( id )
    {
	case 0:
	return PLUGIN_CONTINUE
    }

    new plrDmg = read_data(2)
    new plrWeap
    new plrPartHit
    new plrAttacker = get_user_attacker(id, plrWeap, plrPartHit)
    switch ( plrAttacker )
    {
        case 0:
	return PLUGIN_CONTINUE
    }
    if(!is_user_connected(id) || !is_user_connected(plrAttacker)) return PLUGIN_CONTINUE;
    if (!xmp5_carrier[plrAttacker] && !xm3_carrier[plrAttacker] && !xarmor_carrier[plrAttacker] && !xkevlar_carrier[plrAttacker] && !xknife_carrier[plrAttacker] && !xrevolver_carrier[plrAttacker]){
        return PLUGIN_CONTINUE
    }
    if (!is_user_alive(id)){
        return PLUGIN_CONTINUE
    }
    new plrHealth = get_user_health(id)
    new plrNewDmg
... but it is still writing the same error at the same line
however i noticed a compilation warning:
/home/groups/amxmodx/tmp3/phpI8CxOi.sma(414) : warning 217: loose indentation
what does it mean?
thank you for any help
freamer is offline
Deviance
Veteran Member
Join Date: Nov 2004
Location: Sweden
Old 06-20-2007 , 15:45   Re: Need help on error fixing
Reply With Quote #6

Quote:
Originally Posted by freamer View Post
Changed event register to this:
register_event("Damage", "doDamage", "b", "2!0", "3=0", "4!0")
and modified function code to this:
Code:
public doDamage(id){
    if (get_cvar_num("sv_xweapons")==0){
        return PLUGIN_CONTINUE
    }
    switch ( id )
    {
	case 0:
	return PLUGIN_CONTINUE
    }

    new plrDmg = read_data(2)
    new plrWeap
    new plrPartHit
    new plrAttacker = get_user_attacker(id, plrWeap, plrPartHit)
    switch ( plrAttacker )
    {
        case 0:
	return PLUGIN_CONTINUE
    }
    if(!is_user_connected(id) || !is_user_connected(plrAttacker)) return PLUGIN_CONTINUE;
    if (!xmp5_carrier[plrAttacker] && !xm3_carrier[plrAttacker] && !xarmor_carrier[plrAttacker] && !xkevlar_carrier[plrAttacker] && !xknife_carrier[plrAttacker] && !xrevolver_carrier[plrAttacker]){
        return PLUGIN_CONTINUE
    }
    if (!is_user_alive(id)){
        return PLUGIN_CONTINUE
    }
    new plrHealth = get_user_health(id)
    new plrNewDmg
... but it is still writing the same error at the same line
however i noticed a compilation warning:
/home/groups/amxmodx/tmp3/phpI8CxOi.sma(414) : warning 217: loose indentation
what does it mean?
thank you for any help
loose indentation means that the line is not in the same height as the others

An example on loose indentation:
Code:
public plugin_init()
{
	register_plugin(Plugin, Version, Author)
	register_concmd("amx_editor", "cmd_editor", ADMIN_CFG, "- Opens the editor")
	
    new Host[64], User[64], Pass[64], Db[64] // loose indentation

    	get_cvar_string("amx_sql_host", Host, 63)

Last edited by Deviance; 06-20-2007 at 15:48.
Deviance is offline
_Master_
Senior Member
Join Date: Dec 2006
Old 06-20-2007 , 20:08   Re: Need help on error fixing
Reply With Quote #7

I was unable to replicate the native error.
_Master_ 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 21:29.


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