Raised This Month: $32 Target: $400
 8% 

Run time error 4: index out of bounds


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JuanitoAlimana
Senior Member
Join Date: Aug 2021
Old 11-14-2022 , 19:49   Run time error 4: index out of bounds
Reply With Quote #1

I get the following error with this plugin that makes you invisible for 20 seconds:

[AMXX] [0] item_invisibilidad.sma::AddToFullPack (line 42)
[AMXX] Displaying debug trace (plugin "item_invisibilidad.amxx", version "1.0")
[AMXX] Run time error 4: index out of bounds

PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <fakemeta>
#include <jctf>
native Float:halflife_time()
new 
Float:fPtime[MAX_PLAYERS]
new 
bool:buyed[MAX_PLAYERS]
public 
plugin_init() 
{
    
register_plugin("Item Invisibilidad""1.0""Sugisaki")
    
register_forward(FM_AddToFullPack"AddToFullPack"1)
    
register_event_ex("DeathMsg""event_playerKilled"RegisterEvent_Global)
    
shop_add_item("MENU_SPITEMS_OP_1"90"buy_invisibility")
    
    
register_dictionary("jctf.txt")
}
public 
client_disconnected(id)
{
    
buyed[id] = false
}
public 
buy_invisibility(id)
{
    if(
buyed[id])
    {
        
client_print_color(idprint_team_default"^1[^4CTF^1] %L."id"PRINT_ITEM_USE")
        return 
PLUGIN_HANDLED
    
}
    
    
fPtime[id] = halflife_time() + 20.0
    buyed
[id] = true
    client_print_color
(idprint_team_default"^1[^4CTF^1] %L."id"PRINT_ITEM_INVISIBILITY_BUY")
    
    return 
PLUGIN_CONTINUE
}
public 
AddToFullPack(eseenthostflagsplayerset)
{
    if(!
player)
    {
        return
    }
    
    if(
buyed[ent])
    {
        
set_es(esES_EffectsEF_NODRAW)
        
client_print(entprint_center"%L"ent"PRINT_I_ITEM"fPtime[ent] - halflife_time(), (fPtime[ent] - halflife_time() > 1.9 "s" ""))
        if(
halflife_time() >= fPtime[ent] - 0.1)
        {
            
client_print_color(entprint_team_default"^1[^4CTF^1] %L."ent"PRINT_ITEM_INVISIBILITY_END")
            
buyed[ent] = false
        
}
    }
}
public 
event_playerKilled()
{
    new 
read_data(2)
    if(
buyed[v])
    {
        
buyed[v] = false
    
}

Any solutions?
JuanitoAlimana is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 11-16-2022 , 11:29   Re: Run time error 4: index out of bounds
Reply With Quote #2

try this one

PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <fakemeta>
#include <jctf>
native Float:halflife_time()
new 
Float:fPtime[MAX_PLAYERS]
new 
bool:buyed[MAX_PLAYERS]
public 
plugin_init() 
{
    
register_plugin("Item Invisibilidad""1.0""Sugisaki")
    
register_forward(FM_AddToFullPack"AddToFullPack"1)
    
register_event_ex("DeathMsg""event_playerKilled"RegisterEvent_Global)
    
shop_add_item("MENU_SPITEMS_OP_1"90"buy_invisibility")
    
    
register_dictionary("jctf.txt")
}
public 
client_disconnected(id)
{
    
buyed[id] = false
}
public 
buy_invisibility(id)
{
    if(
buyed[id])
    {
        
client_print_color(idprint_team_default"^1[^4CTF^1] %L."id"PRINT_ITEM_USE")
        return 
PLUGIN_HANDLED
    
}
    
    
fPtime[id] = halflife_time() + 20.0
    buyed
[id] = true
    client_print_color
(idprint_team_default"^1[^4CTF^1] %L."id"PRINT_ITEM_INVISIBILITY_BUY")
    
    return 
PLUGIN_CONTINUE
}
public 
AddToFullPack(eseenthostflagsplayerset)
{
    if(!
player)
    {
        return
    }

    new 
id pev(entpev_owner)
    
    if(
buyed[id])
    {
        
set_es(esES_EffectsEF_NODRAW)
        
client_print(idprint_center"%L"ent"PRINT_I_ITEM"fPtime[id] - halflife_time(), (fPtime[id] - halflife_time() > 1.9 "s" ""))
        if(
halflife_time() >= fPtime[id] - 0.1)
        {
            
client_print_color(idprint_team_default"^1[^4CTF^1] %l.""PRINT_ITEM_INVISIBILITY_END")
            
buyed[id] = false
        
}
    }
}
public 
event_playerKilled()
{
    new 
read_data(2)
    if(
buyed[v])
    {
        
buyed[v] = false
    
}

lexzor is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 11-16-2022 , 14:50   Re: Run time error 4: index out of bounds
Reply With Quote #3

PHP Code:
new Float:fPtime[MAX_PLAYERS]
new 
bool:buyed[MAX_PLAYERS


PHP Code:
new Float:fPtime[MAX_PLAYERS+1]
new 
bool:buyed[MAX_PLAYERS+1





@lexor
author already checking if the ent is a player

PHP Code:
public AddToFullPack(eseenthostflagsplayerset)
{
    if(!
player// Is it a non player entity ? return .... AKA IGNORE...
    
{
        return
    } 
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 11-16-2022 at 14:53.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
JuanitoAlimana
Senior Member
Join Date: Aug 2021
Old 11-16-2022 , 19:14   Re: Run time error 4: index out of bounds
Reply With Quote #4

Quote:
Originally Posted by Natsheh View Post
PHP Code:
new Float:fPtime[MAX_PLAYERS]
new 
bool:buyed[MAX_PLAYERS


PHP Code:
new Float:fPtime[MAX_PLAYERS+1]
new 
bool:buyed[MAX_PLAYERS+1



@lexor
author already checking if the ent is a player

PHP Code:
public AddToFullPack(eseenthostflagsplayerset)
{
    if(!
player// Is it a non player entity ? return .... AKA IGNORE...
    
{
        return
    } 
This worked perfectly. Thanks!

Last edited by JuanitoAlimana; 11-16-2022 at 19:14.
JuanitoAlimana 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 15:57.


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