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

Run time error on client_death


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MASKED
Junior Member
Join Date: Jan 2016
Old 07-02-2017 , 13:55   Run time error on client_death
Reply With Quote #1

Hello
my server drop this msg sometimes on client death and i been tryning to fix a while, but i have run out of ideas.
Code:
L 07/02/2017 - 19:42:20: [AMXX] Displaying debug trace (plugin "system.amxx")
L 07/02/2017 - 19:42:20: [AMXX] Run time error 4: index out of bounds 
L 07/02/2017 - 19:42:20: [AMXX]    [0] eq5240s5.sma.p::Halottt (line 2695)
L 07/02/2017 - 19:42:20: [AMXX]    [1] eq5240s5.sma.p::client_death (line 2545)
PHP Code:
public client_death()
{
    new 
Killer read_data(1);
    new 
Victim read_data(2);
    
    if( 
Killer get_maxplayers() || Victim get_maxplayers() )
    {
        return 
PLUGIN_CONTINUE;
    }
    if(
Killer == Victim)
    {
        return 
PLUGIN_HANDLED;
    }
    
Gyilkos(Killer);
    
Halottt(Victim);
    return 
PLUGIN_HANDLED;
}

public 
Gyilkos(id)
{
if(
User[id] == logged_in)
{
    new 
Namee[32];
    
get_user_name(idNamee31);
    new 
pPont;
    
    
    if(
VIP[id] >= 1)
    {
        
pPont += random_num(515);
        
Nicepont[id] += pPont;
        
        
set_dhudmessage(random(256), random(256), random(256), -1.00.2006.03.0);
        
show_dhudmessage(id"+%d NP"pPont);
    }
    else
    {
        
pPont += random_num(25);
        
Nicepont[id] += pPont;
        
        
set_dhudmessage(random(256), random(256), random(256), -1.00.2006.03.0);
        
show_dhudmessage(id"+%d NP"pPont);
    }
    
    
    
DropKill[id]++;
    if(
SwitchFrag)
    {
        
kill[id]++;
    }
    
    if(
get_user_weapon(id) == CSW_AWP)
    {
        
awp_oles[id]++;
    }
    
    if(
get_user_weapon(id) == CSW_AK47)
    {
        
ak47_oles[id]++;
    }
    
    if(
get_user_weapon(id) == CSW_M4A1)
    {
        
m4a1_oles[id]++;
    }
    
    if(
get_user_weapon(id) == CSW_KNIFE)
    {
        
kes_oles[id]++;
        new 
szMapname[32];
        
get_mapname(szMapnamecharsmax(szMapname));
        if(
equali(szMapname"35hp_2")) 
        {
            
set_user_health(idget_user_health(id)+5);
            new 
random_num(11000);
            if(
== 1)
            {
                
Kredit[id] += 508;
                
print_color(0"!g%s!t %s!y szerzett!g 508!y Kreditet!"PrefixNamee);
            }
            else if( 
>= && 101)
            {
                
Kredit[id] += 10;
                
print_color(0"!g%s!t %s!y szerzett!g 10!y Kreditet!"PrefixNamee);
            }
        }
        else
        {
            new 
random_num(12000);
            if(
== 1)
            {
                
Kredit[id] += 508;
                
print_color(0"!g%s!t %s!y szerzett!g 508!y Kreditet!"PrefixNamee);
            }
            else if( 
>= && 101)
            {
                
Kredit[id] += 10;
                
print_color(0"!g%s!t %s!y szerzett!g 10!y Kreditet!"PrefixNamee);
            }
        }
    }    
    
    if(
Rang[id] <= 3)
    {
        
Kills[id]+=4;
    }
    else if(
Rang[id] > && Rang[id] <= 6)
    {
        
Kills[id]+=3;
    }
    else if(
Rang[id]==7)
    {
        
Kills[id]+=2;
    }
    else if(
Rang[id]==8)
    {
        
Kills[id]++;
    }
    else if(
Rang[id]>=9)
    {
        
Kills[id]++;
    }
     
        if(
Rang[id] < sizeof(Rangs) && Rang[id] < file_size(RangFile1)-1)
        {
            if(
Kills[id] >= NeedKills[Rang[id]])
            {
                
Rang[id]++;
                
Kills[id]+=15;
                
print_color(0"!g%s!t %s!y szintet lĂ©pett, Ăşj rangja:!g%s"PrefixNameeRangs[Rang[id]]);
                
client_cmd(id"spk %s"levelup);
            }
        }
    
Dropellenor(id);
}
}

public 
Halottt(id)
{
    if(
User[id] == logged_in)
    {
        new 
Namee[32];
        
get_user_name(idNamee31);
        if(
Rang[id] <= 7)
        {
            if(
Kills[id] > 30)
            {
                
Kills[id]-=2;
            }
        }
        else if(
Rang[id]==8)
        {
            
Kills[id]--;
        }
        else if(
Rang[id]>=9)
        {
            
Kills[id]-=2;
        }
     
        if(
Rang[id] < sizeof(Rangs) && Rang[id] < file_size(RangFile1)-1)
        {
            new 
Rangminusz[33];
            
Rangminusz[id] = Rang[id]-1;
            if(
Kills[id] < NeedKills[Rangminusz[id]])
            {
                
Rang[id]--;
                
Kills[id]-=15;
                
print_color(0"!g%s!t %s!y leesett egy szintet, Ăşj rangja:!g%s"PrefixNameeRangs[Rang[id]]);
                
client_cmd(id"spk %s"leveldown);
            }
        }
    }


Last edited by MASKED; 07-02-2017 at 14:05.
MASKED is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-02-2017 , 16:21   Re: Run time error on client_death
Reply With Quote #2

What is the value of "Victim" when the error happens?

Also, make sure that all your global arrays are declared with a large enough size (any array created to hold player-specific data should have its first dimension set to 33).
__________________

Last edited by fysiks; 07-02-2017 at 16:22.
fysiks is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 07-02-2017 , 16:36   Re: Run time error on client_death
Reply With Quote #3

read_data in client_death?
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 07-02-2017 , 17:08   Re: Run time error on client_death
Reply With Quote #4

In theory if tfcx, csx, tsx, or dodx is not included then it could be a registered message (i.e. DeathMsg) and not the forward from those includes. I guess that's what I assumed. Without the rest of the plugin we can't tell.

So, we can't really help all that much until you attach your full .sma file.
__________________
fysiks is offline
MASKED
Junior Member
Join Date: Jan 2016
Old 07-03-2017 , 05:03   Re: Run time error on client_death
Reply With Quote #5

Here it is how i defined the variables:
PHP Code:
new Rang[33], Kills[33], Prefix[32], NeedKills[33], Rangs[33][32];
new 
Nicepont[33];
public 
plugin_precache() 
{
     new 
Line[128], Data[4][48], Len;
        
get_configsdir(Folder47);
        
format(Folder47"%s/ncrang"Folder);
     
        
format(RangFile47"%s/rangs.cfg"Folder);
        
format(Prefix31"[ NiCE ]");
     
        if(
file_exists(RangFile))
        {
            for(new 
ifile_size(RangFile1); i++)
            {
                
read_file(RangFileiLine127Len);
                
parse(LineData[0], 31Data[1], 31);
     
                
copy(Rangs[i], 31Data[0]);
                
NeedKills[i] = str_to_num(Data[1]);
            }
        }
}
public 
plugin_init() {
      
register_event("DeathMsg""client_death""a");

__________________

Last edited by MASKED; 07-03-2017 at 05:05.
MASKED is offline
PRoSToTeM@
Veteran Member
Join Date: Jan 2010
Location: Russia, Ivanovo
Old 07-03-2017 , 09:43   Re: Run time error on client_death
Reply With Quote #6

Victim in DeathMsg must always be valid, but attacker can be valid or 0.
As I can see from log you have an error here:
Code:
            Rangminusz[id] = Rang[id]-1;             if(Kills[id] < NeedKills[Rangminusz[id]]) // <--- here
Rand[id] can be zero, so Rangminusz[id] can be -1 and it is invalid index for NeedKills (index can't be negative).
__________________
PRoSToTeM@ is offline
Send a message via ICQ to PRoSToTeM@ Send a message via Skype™ to PRoSToTeM@
MASKED
Junior Member
Join Date: Jan 2016
Old 07-11-2017 , 15:18   Re: Run time error on client_death
Reply With Quote #7

Ok i will check it out. Thanks body!
__________________
MASKED is offline
Reply


Thread Tools
Display Modes

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 03:50.


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