AlliedModders

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

Michell 10-24-2015 09:31

[HELP] Run time error 4: index out of bounds
 
Could anyone help me remove this error ?

L 10/24/2015 - 04:59:16: [AMXX] Displaying debug trace (plugin "pg.amxx", version "2015")
L 10/24/2015 - 04:59:16: [AMXX] Run time error 4: index out of bounds
L 10/24/2015 - 04:59:16: [AMXX] [0] 99a9e4b68481360b9fba15b8071f2334.sma:: PlayerDeath (line 662)


Quote:

public PlayerDeath(victim, attacker){

new vicname[32]
new killname[32]
new health

health = get_user_health(attacker);
gKillerID[victim] = attacker;

get_user_name(victim,vicname,31);
get_user_name(attacker,killname,31);

if(get_pcvar_num(VarShowHP) == 1){
if(iLive){
if(is_user_connected(victim) && victim != attacker){
client_print(victim,print_chat,"[ %s te matou, ficando com %i HP ]",killname,health);
gHPKiller[attacker] = health;
}

}
}
}
Quote:

line 662: gHPKiller[attacker] = health;

HamletEagle 10-24-2015 09:45

Re: [HELP] Run time error 4: index out of bounds
 
How is PlayerDeath registered ?

Michell 10-24-2015 09:47

Re: [HELP] Run time error 4: index out of bounds
 
Quote:

RegisterHam( Ham_Killed, "player", "PlayerDeath", 1)

Bugsy 10-24-2015 10:07

Re: [HELP] Run time error 4: index out of bounds
 
Show the definition for these 2 arrays:

gKillerID[]
gHPKiller[]

Try this
PHP Code:

#include <amxmodx>
#include <hamsandwich>

const MAXPLAYERS 32;

new 
gKillerIDMAXPLAYERS ];
new 
gHPKillerMAXPLAYERS ];

#define IsPlayer(%1)    (1<=%1<=MAXPLAYERS)

public plugin_init() 
{
    
RegisterHamHam_Killed "player" "PlayerDeath" 
}

public 
PlayerDeathvictim attacker )
{
    new 
vicname[32]
    new 
killname[32]
    new 
health

    
if( IsPlayerattacker ) && victim != attacker && is_user_connectedattacker ) )
    {
        
health get_user_health(attacker);
        
gKillerID[victim] = attacker;
        
        
get_user_name(victim,vicname,31);
        
get_user_name(attacker,killname,31);
        
client_print(victim,print_chat,"[ %s te matou, ficando com %i HP ]",killname,health);
        
        
gHPKiller[attacker] = health;
    }
    else
    {
        
client_printvictim print_chat "Attacker is self, not a player, or left the server" );
    }



Michell 10-24-2015 10:08

Re: [HELP] Run time error 4: index out of bounds
 
Quote:

new gKillerID[33]
new gHPKiller[33]

Michell 10-24-2015 10:19

Re: [HELP] Run time error 4: index out of bounds
 
OK

Michell 10-24-2015 10:33

Re: [HELP] Run time error 4: index out of bounds
 
when it happens the event just appears 2x .
EX :
Michell killed you , getting HP

RESOLVED DUPLICATION

Michell 10-25-2015 20:50

Re: [HELP] Run time error 4: index out of bounds
 
RESOLVED Run time error 4: index out of bounds


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

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