AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need help on error fixing (https://forums.alliedmods.net/showthread.php?t=56699)

freamer 06-19-2007 06:29

Need help on error fixing
 
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
...


Arkshine 06-19-2007 06:37

Re: Need help on error fixing
 
Show the full code.

_Master_ 06-19-2007 09:32

Re: Need help on error fixing
 
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.

freamer 06-19-2007 09:58

Re: Need help on error fixing
 
1 Attachment(s)
Attached full source code

register_event("Damage", "doDamage", "b", "2!0")

freamer 06-20-2007 15:39

Re: Need help on error fixing
 
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

Deviance 06-20-2007 15:45

Re: Need help on error fixing
 
Quote:

Originally Posted by freamer (Post 492432)
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)


_Master_ 06-20-2007 20:08

Re: Need help on error fixing
 
I was unable to replicate the native error.


All times are GMT -4. The time now is 21:29.

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