AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Run time error 4: index out of bounds (https://forums.alliedmods.net/showthread.php?t=206733)

GhostMan 01-25-2013 14:55

Run time error 4: index out of bounds
 
Quote:

L 01/25/2013 - 17:04:52: Start of error session.
L 01/25/2013 - 17:04:52: Info (map "deathrun_blueoffice") (file "addons/amxmodx/logs/error_20130125.log")
L 01/25/2013 - 17:04:52: [AMXX] Displaying debug trace (plugin "dr_shop.amxx")
L 01/25/2013 - 17:04:52: [AMXX] Run time error 4: index out of bounds
L 01/25/2013 - 17:04:52: [AMXX] [0] dr_shop.sma::Hook_Deathmessage (line 1012)
PHP Code:

/* --| Event when player died */
public Hook_Deathmessage()
{
    
/* --| If plugin is on... */
    
if( get_pcvar_numgDrShopOn ) == )
    {
        
/* --| Get the killer and attacker */
        
new killer read_data);
        new 
victim read_data);

        
/* --| If player has died with world / trigger_hurt */
        
if( killer == victim )
        {
            return 
PLUGIN_HANDLED;
        }
        
        
/* --| Setting killer points when killed a enemy */
        
if(get_user_flags(killer) & ADMIN_LEVEL_H)
        {
            
gKillerPointskiller ] += get_pcvar_numgKillerPointsCvar ) * 2;
        }
        else
        {
            
gKillerPointskiller ] += get_pcvar_numgKillerPointsCvar );
        }
    
        
/* --| Reseting items */
        
if(!is_user_bot(victim))
        {
            
HasHevictim ] = false;
            
HasBothGrenvictim ] = false;
            
HasSilentvictim ] = false;
            
HasHealthvictim ] = false;
            
HasArmorvictim ] = false;
            
HasSpeedvictim ] = false;
            
HasGravityvictim ] = false;
            
HasInvisvictim ] = false;
            
HasNoclipvictim ] = false;
            
HasJetvictim ] = false;
            
HasDeaglevictim ] = false;
            
HasLongJumpvictim ] = false;
            
HasGlowvictim ] = false;
            
HasNVGvictim ] = false;
            
            
set_user_gravityvictim1.0 );    
            
set_user_maxspeedvictim0.0 );
            
set_user_footstepsvictim);
            
set_user_noclipvictim);
            
set_user_renderingvictim );
            
set_user_nvgvictim);
            
remove_user_nvgvictim );
            
remove_taskvictim );
        }
    }
    
    return 
PLUGIN_CONTINUE;


1012 line
PHP Code:

            HasHevictim ] = false

http://forums.alliedmods.net/showthread.php?t=87536

simanovich 01-25-2013 15:22

Re: Run time error 4: index out of bounds
 
Show us the register of varibles

fysiks 01-25-2013 16:05

Re: Run time error 4: index out of bounds
 
When posting error logs, you need to post the whole error (not all of the error lines have [AMXX]). Also, does this error occur when you run the original plugin? Your changes to this function should not have "created" this situation.

GhostMan 01-25-2013 16:44

Re: Run time error 4: index out of bounds
 
You can see all changes that i'v done in this funcion. I saw this error when i was using the original plugin, that's why i added "if(!is_user_bot)".

All rest of the code is the same, you can download SMA here http://forums.alliedmods.net/attachm...0&d=1253106683
I'm not posting this issue there becouse it's "unaproved/old plugin" so i think i wont get any help from the author.

fysiks 01-25-2013 16:58

Re: Run time error 4: index out of bounds
 
Anytime you have an index out of bounds, you need to know what the value of the index when the error occurs. Typically, I wouldn't check if a victim is a player but maybe you need to do that.

GhostMan 01-26-2013 09:09

Re: Run time error 4: index out of bounds
 
I see in that deathrun plugin values are reseted two times:
1. On player death
2. On new round

I have removed part where values are reset on player's death and did that not on new round, but on player's spawn.

I'v been getting this error when values were reset on player's death, now it's completely removed so i will see how it goes.

By the way. In this deathrun plugin i can see these parts
PHP Code:

public client_disconnectid )
{
    
HasHeid ] = false;
    
HasBothGrenid ] = false;
    
HasSilentid ] = false;
    
HasHealthid ] = false;
    
HasArmorid] = false;
    
HasSpeedid ] = false;
    
HasGravityid ] = false;
    
HasInvisid ] = false;
    
HasNoclipid ] = false;
    
HasJetid ] = false;
    
HasDeagleid ] = false;
    
HasLongJumpid ] = false;
    
HasGlowid ] = false;
    
HasNVGid ] = false;


PHP Code:

public client_connectid )
{
    
HasHeid ] = false;
    
HasBothGrenid ] = false;
    
HasSilentid ] = false;
    
HasHealthid ] = false;
    
HasArmorid] = false;
    
HasSpeedid ] = false;
    
HasGravityid ] = false;
    
HasInvisid ] = false;
    
HasNoclipid ] = false;
    
HasJetid ] = false;
    
HasDeagleid ] = false;
    
HasLongJumpid ] = false;
    
HasGlowid ] = false;
    
HasNVGid ] = false;


All variables are deleted when player disconnects, aren't they? So this part is completely useless and does no effect at all, isn't it?

fysiks 01-26-2013 22:11

Re: Run time error 4: index out of bounds
 
Quote:

Originally Posted by GhostMan (Post 1880997)
By the way. In this deathrun plugin i can see these parts
PHP Code:

public client_disconnectid )
{
    
HasHeid ] = false;
    
HasBothGrenid ] = false;
    
HasSilentid ] = false;
    
HasHealthid ] = false;
    
HasArmorid] = false;
    
HasSpeedid ] = false;
    
HasGravityid ] = false;
    
HasInvisid ] = false;
    
HasNoclipid ] = false;
    
HasJetid ] = false;
    
HasDeagleid ] = false;
    
HasLongJumpid ] = false;
    
HasGlowid ] = false;
    
HasNVGid ] = false;


PHP Code:

public client_connectid )
{
    
HasHeid ] = false;
    
HasBothGrenid ] = false;
    
HasSilentid ] = false;
    
HasHealthid ] = false;
    
HasArmorid] = false;
    
HasSpeedid ] = false;
    
HasGravityid ] = false;
    
HasInvisid ] = false;
    
HasNoclipid ] = false;
    
HasJetid ] = false;
    
HasDeagleid ] = false;
    
HasLongJumpid ] = false;
    
HasGlowid ] = false;
    
HasNVGid ] = false;


All variables are deleted when player disconnects, aren't they? So this part is completely useless and does no effect at all, isn't it?

Those two may or may not be redundant depending on how they are used in the code. It is most likely redundant but the performance difference will be negligible.


All times are GMT -4. The time now is 20:34.

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