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

Best CT & T of the round. [BAD LOAD], help.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mentalproblems
Junior Member
Join Date: Mar 2019
Old 11-06-2019 , 14:26   Best CT & T of the round. [BAD LOAD], help.
Reply With Quote #1

Can anyone tell me why is this not running. Appears "bad load" in amx_plugins.
Thanks.

Code:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <reapi>

new Float:g_fDamagect[33], g_iBestCtIndexFloat:g_fDamagete[33], g_iBestTeIndex

new szNameCt[32], szNameTe[32]

public 
plugin_init() {
    
register_plugin("Best CT & T""1.0""blabla")
    
    
RegisterHam(Ham_TakeDamage"player""Fw_TakeDamage_Post"1)
    
register_logevent("RoundEnd"2"1=Round_End")
    
register_logevent("RoundStart"2"1=Round_Start")
    
    
register_clcmd("say /best""ShowBest")
}

public 
Fw_TakeDamage_Post(iVictimiInflictoriAttackerFloat:fDamagebitsDamageType)
{
    if (!
is_user_alive(iVictim) || !is_user_alive(iAttacker) || get_user_team(iVictim) != get_user_team(iAttacker))
        return 
HAM_IGNORED
    
    g_fDamagect
[iAttacker] += fDamage
    g_fDamagete
[iAttacker] += fDamage
    
return HAM_HANDLED
}

public 
RoundEnd()
{
    
Get_Best_CT()
    
Get_Best_T()
    
    
get_user_name(g_iBestCtIndexszNameCtcharsmax(g_iBestCtIndex))
    
get_user_name(g_iBestTeIndexszNameTecharsmax(g_iBestTeIndex))
    
    if (
g_iBestCtIndex == || g_fDamagect[g_iBestCtIndex] == 0.0)
        
client_print(0print_chat"[Best Player] No best Counter-Terrorist this round.")
    
    if (
g_iBestTeIndex == || g_fDamagete[g_iBestTeIndex] == 0.0)
        
client_print(0print_chat"[Best Player] No best Terrorist this round.")
    
    
set_hudmessage(02550, -1.00.2306.05.0)
    
show_hudmessage(0"Best Counter Terrorist was [ %s ] with [ %i ] damage^n^nBest Terrorist was [ %s ] with [ %i ] damage"szNameCtfloatround(g_fDamagect[g_iBestCtIndex]), szNameTefloatround(g_fDamagete[g_iBestTeIndex]))
}

public 
ShowBest(id)
{
    
Get_Best_CT()
    
Get_Best_T()
    
    
get_user_name(g_iBestCtIndexszNameCtcharsmax(szNameCt)) // defender name
    
get_user_name(g_iBestTeIndexszNameTecharsmax(szNameTe)) // infector name
    
    
set_hudmessage(02550, -1.00.2306.05.0)
    
show_hudmessage(id"Best Counter Terrorist is [ %s ] with [ %i ] damage^n^nBest Terrorist is [ %s ] with [ %i ] damage"szNameCtfloatround(g_fDamagect[g_iBestCtIndex]), szNameTefloatround(g_fDamagete[g_iBestTeIndex]))
}

public 
RoundStart() // new round
{
    
set_task(3.0"ResetDmg")
}

public 
ResetDmg() // reset Damage and Infects at new round start
{
    for (new 
1<= get_member_game(m_nMaxPlayers); i++)
    {
        
g_fDamagect[i] = 0.0 // Reset Damage
        
g_fDamagete[i] = 0.0 // Reset Infects
    
}
}

public 
Get_Best_CT()
{
    new 
Float:fTemp 0.0
    
    
for (new 1<= get_member_game(m_nMaxPlayers); i++)
    {
        if (!
is_user_connected(i))
            continue
        
        if (
g_fDamagect[i] > fTemp)
        {
            
fTemp g_fDamagect[i]
            
g_iBestCtIndex i
        
}
    }
}

public 
Get_Best_T()
{
    new 
Float:fTempp 0.0
    
    
for (new 1<= get_member_game(m_nMaxPlayers); i++)
    {
        if (!
is_user_connected(i))
            continue
        
        if (
g_fDamagete[i] > fTempp)
        {
            
fTempp g_fDamagete[i]
            
g_iBestTeIndex i
        
}
    }


Last edited by mentalproblems; 11-06-2019 at 14:31.
mentalproblems is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 11-06-2019 , 15:56   Re: Best CT & T of the round. [BAD LOAD], help.
Reply With Quote #2

You can tell us, not we. Only "bad load" isn't enough information. A full error will show in the console when you start up the server - find it.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 11-07-2019 , 15:26   Re: Best CT & T of the round. [BAD LOAD], help.
Reply With Quote #3

Probably because it's using reapi and you're not using regamedll + reamxmodx
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
mentalproblems
Junior Member
Join Date: Mar 2019
Old 11-08-2019 , 08:59   Re: Best CT & T of the round. [BAD LOAD], help.
Reply With Quote #4

That's possible...


L 11/08/2019 - 14:56:54: [AMXX] Plugin file open error (plugin "best_players.amxx")
only this showing in console
mentalproblems is offline
mentalproblems
Junior Member
Join Date: Mar 2019
Old 11-08-2019 , 09:01   Re: Best CT & T of the round. [BAD LOAD], help.
Reply With Quote #5

By the way what do I add instead of "get_member_game". So I can remove reapi?
I mean this plugin is possible even without reapi. Can I replace "get_member_game" with another function similar to it?
mentalproblems is offline
georgik57
Veteran Member
Join Date: Oct 2008
Location: 🎧Music World
Old 11-08-2019 , 09:17   Re: Best CT & T of the round. [BAD LOAD], help.
Reply With Quote #6

Looks like get_maxplayers()
__________________
georgik57 is offline
Send a message via MSN to georgik57 Send a message via Yahoo to georgik57 Send a message via Skype™ to georgik57
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 11-08-2019 , 09:53   Re: Best CT & T of the round. [BAD LOAD], help.
Reply With Quote #7

The error definitely shows up when you start the server, you probably missed it. But yes, if you don't have ReAPI, of course you can't run plugins that use ReAPI functions.

And yes, replacing it with get_maxplayers() will work. Or better use get_players and eliminate the is_user_connected() check.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
mentalproblems
Junior Member
Join Date: Mar 2019
Old 11-08-2019 , 11:04   Re: Best CT & T of the round. [BAD LOAD], help.
Reply With Quote #8

Thank u both. Solved.

Last edited by mentalproblems; 11-08-2019 at 11:11.
mentalproblems is offline
mentalproblems
Junior Member
Join Date: Mar 2019
Old 11-08-2019 , 11:29   Re: Best CT & T of the round. [BAD LOAD], help.
Reply With Quote #9

But there comes another small problem.

Any player who made the most damage is shown as best in both CT and T same player (even if he is CT he is shown also in T as best player).
Look at the show_hudmessage line. What could I be mistaken on
mentalproblems is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 11-08-2019 , 13:17   Re: Best CT & T of the round. [BAD LOAD], help.
Reply With Quote #10

Well first of all there's this in the damage event:

Code:
if(get_user_team(iVictim) != get_user_team(iAttacker))     return HAM_IGNORED

So the plugin will only work if you damage your teammates.

Next, we have this genius thing that adds the damage to both teams without checking who is T and who CT:

Code:
g_fDamagect[iAttacker] += fDamage g_fDamagete[iAttacker] += fDamage

Then, we have the "Get_Best_CT" and "Get_Best_T" functions that both loop all players, again without checking their team.

Code:
for (new i = 1; i <= get_member_game(m_nMaxPlayers); i++)     {         if (!is_user_connected(i))             continue                 if (g_fDamagect[i] > fTemp)         {             fTemp = g_fDamagect[i]             g_iBestCtIndex = i         }     }

So, basically, the author of this plugin had no idea what he is doing and the entire code is garbage.
__________________

Last edited by OciXCrom; 11-08-2019 at 13:18.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
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 09:21.


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