Raised This Month: $ Target: $400
 0% 

Can anyone help me?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
zezokicker
Junior Member
Join Date: Sep 2008
Old 07-19-2010 , 12:17   Can anyone help me?
Reply With Quote #1

I want to create a plugin where it displays an end round result showing most destructive player in T or CT. Not overall like statsx has it, I am new at this whole amxx coding thing and I would love to learn how to do it since I always want my own custom things in addition to the plugins i already have.

EX.

HUD MSG

Counter-Terrorist MVP: <playername> killing <# of kills> Terrorists!
Terrorist MVP: <playername> killing <# of kills> Counter-Terrorists!
Most damage done by: <playername> Dealing <amount of dmg> damage overall.
zezokicker is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 07-19-2010 , 16:43   Re: Can anyone help me?
Reply With Quote #2

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

#define PLUGIN "Damage Dealt"
#define VERSION "1.0"
#define AUTHOR "RedRobster"

new g_PlayerDmg[33//Creates array to Store Dmg for all IDs
new g_Kills[33//Creates array to Store Kills for all IDs

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
RegisterHam(Ham_TakeDamage"player""Fwd_TakeDmg_Post"1//Will run whenever a person takes damage
    
    
register_event("DeathMsg""Fwd_Death""a""1!=2"//Will run whenever a person dies
    
    
register_logevent("RoundEnd"2"1=Round_End"//Will run on round end
}

public 
Fwd_TakeDmg_Post(victimwpnidattackerFloat:damagedamagebits)
    if(
is_user_alive(attacker) && is_user_connected(attacker) && victim != attacker//Checks to make sure attacker is connected and alive, and that the attacker is not the victim
        
g_PlayerDmg[attacker] += floatround(damagefloatround_floor//Adds the damage to the players array

public Fwd_Death()
{
    new 
attacker read_data(1//Gets the attacker's id
    
new victim read_data(2//Gets the victim's id
    
    
if(is_user_alive(attacker) && is_user_connected(attacker) && victim != attacker//Checks to make sure attacker is connected and alive, and that the attacker is not the victim
        
g_Kills[attacker]++ //Sets the kills of the attacker +1
}

public 
RoundEnd()
{
    new 
Msg[128], CTName[34], TName[34], DmgName[34//Creates the arrays for the names and the msg
    
    
new TLeaderKillsTLeaderID //Variables for the top T kills and ID
    
new CTLeaderKillsCTLeaderID //Variables for the top CT kills and ID
    
    
new iDmgDmgID // Variables for the most Dmg and ID
    
    
new iPlayers[32], iNum //Variables for the loop
    
get_players(iPlayersiNum)
    for(new 
iiNumi++) //Loops through the players
    
{
        new 
tempid iPlayers[i//This is more efficient than using iPlayers[i] everywhere
        
switch(cs_get_user_team(tempid))
        {
            case 
CS_TEAM_CT//If person's team is CT
            
{
                if(
g_Kills[tempid] > CTLeaderKills//If Kills of player > current top kills
                
{
                    
CTLeaderKills g_Kills[tempid//Ct top kills equals this players kills
                    
CTLeaderID tempid //CT top ID is this player's ID
                
}
                
                if(
g_PlayerDmg[tempid] > iDmg//If this player's dmg is higher than current top
                
{
                    
iDmg g_PlayerDmg[tempid//This player's dmg = the highest
                    
DmgID tempid //Top Dmg ID is this player's ID
                
}
            }
            
            case 
CS_TEAM_T//If person's team is T
            
{
                if(
g_Kills[tempid] > TLeaderKills)
                {
                    
TLeaderKills g_Kills[tempid]
                    
TLeaderID tempid
                
}
                
                if(
g_PlayerDmg[tempid] > iDmg)
                {
                    
iDmg g_PlayerDmg[tempid]
                    
DmgID tempid
                
}
            }
        }
    }
    
    
get_user_name(CTLeaderIDCTName33//Gets the name of the best CT
    
get_user_name(TLeaderIDTName33//Gets the name of the best T
    
get_user_name(DmgIDDmgName33//Gets the name of the highest Dmg Dealer
    
    //This formats the Msg array from above. %s indicates a string, %i means variable. ^n means new line
    
format(Msg127"CT MVP: %s killed %i Terrorists!^nT MVP: %s killed %i Counter-Terrorists!^nMost Damage: %s did %i damage!"CTNameCTLeaderKillsTNameTLeaderKillsDmgNameiDmg)
    
    
//This shows the Msg that we formatted above
    
set_hudmessage(02550, -1.0, -1.0)
    
show_hudmessage(0"%s"Msg)


Last edited by RedRobster; 07-19-2010 at 16:54.
RedRobster is offline
Kreation
Veteran Member
Join Date: Jan 2010
Location: Illinois
Old 07-19-2010 , 17:00   Re: Can anyone help me?
Reply With Quote #3

Also, this should've been in Suggestions/Request.
__________________
Hi.
Kreation is offline
zezokicker
Junior Member
Join Date: Sep 2008
Old 07-19-2010 , 17:55   Re: Can anyone help me?
Reply With Quote #4

Thank you so much. I've been studying it and now I understand the tracking of players/damage and to differentiate CT and Ts
There is one problem. The HUD doesn't show up after each round end. My guess is that it doesnt have a duration?

fixed.

Another problem.

The stats dont reset after every round. How do I make it reset?

Last edited by zezokicker; 07-19-2010 at 18:43.
zezokicker is offline
zezokicker
Junior Member
Join Date: Sep 2008
Old 07-19-2010 , 18:43   Re: Can anyone help me?
Reply With Quote #5

bump
zezokicker is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 07-19-2010 , 19:11   Re: Can anyone help me?
Reply With Quote #6

Add:
PHP Code:
register_logevent("RoundStart"2"1=Round_Start"
in plugin_init().

Then add
PHP Code:
public RoundStart()
{
      new 
iPlayers[32], iNum
      get_players
(iPlayersiNum)
      for(new 
iiNumi++)
      {
             
tempid iPlayers[i]
             
g_PlayerDmg[tempid] = 0
             g_PlayerKills
[tempid] = 0
      
}

somewhere in the plugin.
RedRobster is offline
zezokicker
Junior Member
Join Date: Sep 2008
Old 07-19-2010 , 19:43   Re: Can anyone help me?
Reply With Quote #7

Alright, thanks. I tested it and it works but now if the numbers remain 0 like either CT or T kills it will say the instead of playername it will be the servername. Is there a way to get around that so instead it just says something like,

No Ts have been killed this round
No CTs have been killed this round
No dmg has been done.
zezokicker is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 07-19-2010 , 21:22   Re: Can anyone help me?
Reply With Quote #8

Yes there is, haha.
I'm not exactly sure what is the best way to do this, but you can try this:

1. Remove the format() line. And the HUD message functions.
2. Add this:
PHP Code:
    if(CTLeaderKills)
        
formatex(CTInfo63"CT MVP: %s killed %i Terrorists!"CTNameCTLeaderKills)
    else
        
formatex(CTInfo63"No Terrorists were killed this round.")
    
    if(
TLeaderKills)
        
formatex(TInfo63"^nT MVP: %s killed %i Counter-Terrorists!"TNameTLeaderKills)
    else
        
formatex(TInfo63"^nNo Counter-Terrorists were killed this round.")
        
    if(
iDmg)
        
formatex(DmgInfo63"^nMost Damage: %s did %i damage!"DmgNameiDmg)
    else
        
formatex(DmgInfo63"^nNo damage was done this round.")
    
    
//This shows the Msg that we formatted above
    
set_hudmessage(02550, -1.0, -1.0)
    
show_hudmessage(0"%s%s%s"CTInfoTInfoDmgInfo
RedRobster is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-19-2010 , 21:40   Re: Can anyone help me?
Reply With Quote #9

This will do the same as Red Robsters code
PHP Code:
new HUDMsg193 ] , iPos;

iPos =  formatexHUDMsg charsmaxHUDMsg ) , CTLeaderKills "CT MVP: %s killed %i Terrorists!" "No Terrorists were killed this round." CTName CTLeaderKills );
iPos += formatexHUDMsgiPos ] , charsmaxHUDMsg ) , TLeaderKills "^nT MVP: %s killed %i Counter-Terrorists!""^nNo Counter-Terrorists were killed this round." TName TLeaderKills );
iPos += formatexHUDMsgiPos ] , charsmaxHUDMsg ) , iDmg "^nMost Damage: %s did %i damage!" "^nNo damage was done this round." DmgName iDmg );

set_hudmessage255 , -1.0 , -1.0 );
show_hudmessageHUDMsg ); 
__________________

Last edited by Bugsy; 07-19-2010 at 22:00.
Bugsy is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 07-19-2010 , 21:55   Re: Can anyone help me?
Reply With Quote #10

Bugsy, does formatex() return a value the size of string that you just formatted or I guess the size of the string that you just added?
RedRobster 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 07:08.


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