Raised This Month: $51 Target: $400
 12% 

Solved Error in Number Kill


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lantimilan
Senior Member
Join Date: May 2016
Old 03-21-2019 , 11:45   Error in Number Kill
Reply With Quote #1

I have one error in my server this :
PHP Code:
L 03/21/2019 15:08:49Start of error session.
L 03/21/2019 15:08:49Info (map "de_dust2") (file "addons/amxmodx/logs/error_20190321.log")
L 03/21/2019 15:08:49: [AMXXDisplaying debug trace (plugin "ls-numri-vrasjeve.amxx"version "0.0.2")
L 03/21/2019 15:08:49: [AMXXRun time error 4index out of bounds 
L 03
/21/2019 15:08:49: [AMXX]    [0ls-numri-vrasjeve.sma::CBasePlayer_Killed (line 56
Plugin :
PHP Code:
#include <amxmodx>
#include <fakemeta>     // for fake name change
#include <hamsandwich>  // for player hooks


/* Settings */
    // Minimum kills need to show counter in name.
const MIN_KILLS 2;
    
// Enable CSDM FFA kills support.
// #define FFA_MODE
/*          */

new g_iComboKills[MAX_PLAYERS 1] = { 0, ... };

public 
plugin_init()
{
    
register_plugin("Kill Number""0.0.2""mx0");

    
RegisterHam(Ham_Killed"player""CBasePlayer_Killed_Pre", .Post false, .specialbot true);
    
RegisterHam(Ham_Killed"player""CBasePlayer_Killed", .Post true, .specialbot true);

    
RegisterHam(Ham_Spawn"player""CBasePlayer_Spawn", .Post true, .specialbot true);
    
}

public 
CBasePlayer_Killed_Pre(pPlayerpKiller)
{
    if(!
IsValidKill(pPlayerpKiller))
        return;
    
    if(++
g_iComboKills[pKiller] < MIN_KILLS)
        return;
    
    static 
szKillerName[MAX_NAME_LENGTH];
    
get_user_name(pKillerszKillerNamecharsmax(szKillerName));

// ' [+100]' = 7 + 1(nullterm) = 8chars; MAX_NAME_LENGTH - 8 = 24
    
formatex(szKillerNamecharsmax(szKillerName), "%.24s [+%i]",szKillerNameg_iComboKills[pKiller]);
    
set_user_fake_name(pKillerszKillerName);
}

public 
CBasePlayer_Killed(pPlayerpKiller)
{
    if(
g_iComboKills[pKiller] < MIN_KILLS)
        return;

    
reset_user_info(pKiller);
}

public 
CBasePlayer_Spawn(pPlayer)
    
g_iComboKills[pPlayer] = 0;

// From: https://dev-cs.ru/resources/189/ (cuz i need fastest usage)
stock set_user_fake_name(const id, const name[])
{
    for(new 
1<= MaxClientsi++)
    {
        if(
is_user_connected(i) && !is_user_hltv(i))
        {
            
message_begin(MSG_ONESVC_UPDATEUSERINFO_i);
            
write_byte(id 1);
            
write_long(get_user_userid(id));
            
write_char('\');
            write_char('
n');
            write_char('
a');
            write_char('
m');
            write_char('
e');
            write_char('
\');
            write_string(name);
            for(new i; i < 4; i++) write_long(0);
            message_end();
        }
    }
}

stock reset_user_info(id)
{
    static szUserInfo[256];
    copy_infokey_buffer(engfunc(EngFunc_GetInfoKeyBuffer, id), szUserInfo, charsmax(szUserInfo));

    for(new i = 1; i <= MaxClients; i++)
    {
        if(is_user_connected(i) && !is_user_hltv(i))
        {
            message_begin(MSG_ONE, SVC_UPDATEUSERINFO, _, i);
            write_byte(id - 1);
            write_long(get_user_userid(id));
            write_string(szUserInfo);
            for(new i; i < 4; i++) write_long(0);
            message_end();
        }
    }
}

stock bool: IsValidKill(pPlayer, pKiller)
{    
    if(pPlayer == pKiller)
        return false;

    if(!is_user_alive(pKiller))
        return false;

#if !defined FFA_MODE
    if(get_user_team(pPlayer) == get_user_team(pKiller))
        return false;
#endif

    return true;
}



/* API?! */
public plugin_natives()
{
    enum { oldstyle };
    register_native("combo_GetKills", "native__combo_GetKills", .style = oldstyle);
}

stock CHECK_PLAYER(id)
{
    if(id < 1 || id > MaxClients)
    {
        log_error(AMX_ERR_NATIVE, "Player out of range (%i)", id);
        return 0;
    } else return 1;
}

/**
* Set count of combo kills to player.
*
* @note Usage examples:
*       combo_SetKills(id, .count = 5);
*
* @param index  Client index
* @param count  Count combo kills.   
*
* @noreturn
*/
    // native combo_SetKills(id, count)
public native__combo_SetKills(plugin_id, argc)
{
    enum { arg_index = 1, arg_count };

    new index = get_param(arg_index);
    if(!CHECK_PLAYER(index)) return 0;

    new count = get_param(arg_count);
    g_iComboKills[index] = count;

    return 1;
}

/**
* Retrieves count of combo kills from player.
*
* @note Usage examples:
*       combo_GetKills(id);
*
* @param index  Client index
*
* @return Combo kills count from player. 
*/
    // native combo_GetKills(id)
public native__combo_GetKills(plugin_id, argc)
{
    enum { arg_index = 1 };

    new index = get_param(arg_index);
    if(!CHECK_PLAYER(index)) return 0;

    return g_iComboKills[index];


Last edited by lantimilan; 03-23-2019 at 06:08.
lantimilan is offline
Send a message via MSN to lantimilan
<VeCo>
Veteran Member
Join Date: Jul 2009
Location: Bulgaria
Old 03-21-2019 , 11:51   Re: Error in Number Kill
Reply With Quote #2

this is fucking slowhack
__________________

Last edited by <VeCo>; 03-21-2019 at 11:51.
<VeCo> is offline
lantimilan
Senior Member
Join Date: May 2016
Old 03-21-2019 , 11:56   Re: Error in Number Kill
Reply With Quote #3

Quote:
Originally Posted by <VeCo> View Post
this is fucking slowhack
No i see effect show when kill 2 and more players in back name show plus 2 or 3 or 4
lantimilan is offline
Send a message via MSN to lantimilan
Moody92
Veteran Member
Join Date: May 2011
Location: Oman
Old 03-21-2019 , 12:17   Re: Error in Number Kill
Reply With Quote #4

The error is produced when there's a user that disconnects. His id becomes -1 and therefore becomes out of bounds. You have to check if player is connected in each function if it saves/applies data. And also check if he's alive if the function require the player being alive.

PHP Code:
is_user_connected(id)
is_user_alive(id
Moody92 is offline
thEsp
BANNED
Join Date: Aug 2017
Old 03-21-2019 , 15:02   Re: Error in Number Kill
Reply With Quote #5

"stock set_user_fake_name"
This gives me headache
use set_user_info
thEsp is offline
Moody92
Veteran Member
Join Date: May 2011
Location: Oman
Old 03-21-2019 , 20:14   Re: Error in Number Kill
Reply With Quote #6

PHP Code:
public CBasePlayer_Killed(pPlayerpKiller

    if(
g_iComboKills[pKiller] < MIN_KILLS
        return; 

    
reset_user_info(pKiller); 

----->
PHP Code:
public CBasePlayer_Killed(pPlayerpKiller

    if((!
is_user_connected(pKiller)) || is_user_bot(pKiller) || is_user_hltv(pKiller))
        return;
        

    if(
g_iComboKills[pKiller] < MIN_KILLS
        return; 

    
reset_user_info(pKiller); 


Last edited by Moody92; 03-21-2019 at 20:27.
Moody92 is offline
lantimilan
Senior Member
Join Date: May 2016
Old 03-22-2019 , 02:53   Re: Error in Number Kill
Reply With Quote #7

Quote:
Originally Posted by Moody92 View Post
PHP Code:
public CBasePlayer_Killed(pPlayerpKiller

    if(
g_iComboKills[pKiller] < MIN_KILLS
        return; 

    
reset_user_info(pKiller); 

----->
PHP Code:
public CBasePlayer_Killed(pPlayerpKiller

    if((!
is_user_connected(pKiller)) || is_user_bot(pKiller) || is_user_hltv(pKiller))
        return;
        

    if(
g_iComboKills[pKiller] < MIN_KILLS
        return; 

    
reset_user_info(pKiller); 

Thanks moody just i see now if make more error
lantimilan is offline
Send a message via MSN to lantimilan
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 22:05.


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