AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Best CT & T of the round. [BAD LOAD], help. (https://forums.alliedmods.net/showthread.php?t=319539)

mentalproblems 11-06-2019 14:26

Best CT & T of the round. [BAD LOAD], help.
 
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
        
}
    }



OciXCrom 11-06-2019 15:56

Re: Best CT & T of the round. [BAD LOAD], help.
 
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.

georgik57 11-07-2019 15:26

Re: Best CT & T of the round. [BAD LOAD], help.
 
Probably because it's using reapi and you're not using regamedll + reamxmodx

mentalproblems 11-08-2019 08:59

Re: Best CT & T of the round. [BAD LOAD], help.
 
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 11-08-2019 09:01

Re: Best CT & T of the round. [BAD LOAD], help.
 
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?

georgik57 11-08-2019 09:17

Re: Best CT & T of the round. [BAD LOAD], help.
 
Looks like get_maxplayers()

OciXCrom 11-08-2019 09:53

Re: Best CT & T of the round. [BAD LOAD], help.
 
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.

mentalproblems 11-08-2019 11:04

Re: Best CT & T of the round. [BAD LOAD], help.
 
Thank u both. Solved.

mentalproblems 11-08-2019 11:29

Re: Best CT & T of the round. [BAD LOAD], help.
 
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

OciXCrom 11-08-2019 13:17

Re: Best CT & T of the round. [BAD LOAD], help.
 
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.


All times are GMT -4. The time now is 02:55.

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