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

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


Post New Thread Reply   
 
Thread Tools Display Modes
mentalproblems
Junior Member
Join Date: Mar 2019
Old 11-08-2019 , 13:25   Re: Best CT & T of the round. [BAD LOAD], help.
Reply With Quote #11

It's completely fine now.
Thanks again.

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

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""alKapone")
    
    
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")
    
register_clcmd("say /me""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
    
    
if (get_user_team(iAttacker) == 2)
    {
        
g_fDamagect[iAttacker] += fDamage
    
}
    else if (
get_user_team(iAttacker) == 1)
    {
        
g_fDamagete[iAttacker] += fDamage
    
}
    return 
HAM_HANDLED
}

public 
RoundEnd()
{
    
Get_Best_CT()
    
Get_Best_T()
    
    
get_user_name(g_iBestCtIndexszNameCtcharsmax(szNameCt)) // ct name
    
get_user_name(g_iBestTeIndexszNameTecharsmax(szNameTe)) // te name
    
    
if (g_iBestCtIndex == || g_fDamagect[g_iBestCtIndex] == 0.0)
        
colorchat(0"!y[!gRoyal Gaming!y] !tNo best Counter-Terrorist this round.")
    
    if (
g_iBestTeIndex == || g_fDamagete[g_iBestTeIndex] == 0.0)
        
colorchat(0"!y[!gRoyal Gaming!y] !tNo best Terrorist this round.")
    
    
colorchat(0"!y[!gRoyal Gaming!y] !tBest CT was !g%s !twith !g%i !tDamage."szNameCtfloatround(g_fDamagect[g_iBestCtIndex]))
    
colorchat(0"!y[!gRoyal Gaming!y] !tBest TE was !g%s !twith !g%i !tDamage."szNameTefloatround(g_fDamagete[g_iBestTeIndex]))
    
    
set_hudmessage(random(256), random(256), random(256), -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)) // ct name
    
get_user_name(g_iBestTeIndexszNameTecharsmax(szNameTe)) // te 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(1.0"ResetDmg")
}

public 
ResetDmg() // reset Damage and Infects at new round start
{
    for (new 
1<= get_maxplayers(); 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_maxplayers(); i++)
    {
        if (!
is_user_connected(i) || get_user_team(i) != 2)
            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_maxplayers(); i++)
    {
        if (!
is_user_connected(i) || get_user_team(i) != 1)
            continue
        
        if (
g_fDamagete[i] > fTempp)
        {
            
fTempp g_fDamagete[i]
            
g_iBestTeIndex i
        
}
    }
}

stock colorchat(const id, const input[], any:...)
{
    new 
count 1players[32], iplayer
    
static msg[191]

    if(
numargs() == 2)
        
copy(msg190input)
    else
        
vformat(msg190input3)

    
replace_all(msg190"!g""^4")
    
replace_all(msg190"!y""^1")
    
replace_all(msg190"!t""^3")
    
    if(
id) {
        if(!
is_user_connected(id)) return
        
players[0] = id
    
}
    else 
get_players(playerscount"ch")

    for(
0counti++)
    {
        
player players[i]
        
        
message_begin(MSG_ONE_UNRELIABLEget_user_msgid("SayText"), _player)
        
write_byte(player)
        
write_string(msg)
        
message_end()
    }


Last edited by mentalproblems; 11-08-2019 at 13:52.
mentalproblems is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 11-08-2019 , 13:32   Re: Best CT & T of the round. [BAD LOAD], help.
Reply With Quote #12

Not the best code, but it should work.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
mentalproblems
Junior Member
Join Date: Mar 2019
Old 11-09-2019 , 05:09   Re: Best CT & T of the round. [BAD LOAD], help.
Reply With Quote #13

It's working, but not smooth. The true damage is not shown actually...

What could I improve?
mentalproblems 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:31.


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