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

[TUT] Recording Damage/Hits Per-Round and Displaying It


Post New Thread Reply   
 
Thread Tools Display Modes
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 03-17-2010 , 21:28   Re: [TUT] Recording Damage/Hits Per-Round and Displaying It
Reply With Quote #41

So you want damage taken and damage inflicted?
Will post in a sec.

EDIT: Here ya go:
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

#define PLUGIN    "Show Damage"
#define AUTHOR    "Seta00"
#define VERSION    "1.0"

new hits[33][33],
    
dmgs[33][33],
    
lives[33];
    
new 
cv_roundstart_delay;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
register_clcmd("say .dmg""showLastRoundDamage");
    
    
RegisterHam(Ham_TakeDamage"player""Ham_TakeDamagePost"1);
    
    
register_logevent("logevent_RoundStart"2"1=Round_Start");
    
register_logevent("logevent_RoundEnd"2"1=Round_End")  
    
    
cv_roundstart_delay register_cvar("dmg_roundstartdelay""5.0");
}

public 
client_connect(id) {
    
arrayset(hits[id], 0charsmax(hits[]));
    
dmgs[id] = hits[id];
}

public 
Ham_TakeDamagePost(thisidinflictoridattackerFloat:damagedamagebits) {
    
hits[this][idattacker]++;
    
dmgs[this][idattacker] += floatround(damage);
    return 
HAM_HANDLED;
}

public 
logevent_RoundStart() {
    
set_task(get_pcvar_float(cv_roundstart_delay), "resetScores");
}

public 
logevent_RoundEnd() {
    for (new 
033; ++i) {
        
lives[i] = get_user_health(i);
    }
}

public 
resetScores() {
    for (new 
0charsmax(hits); ++i) {
        
arrayset(hits[i], 0charsmax(hits[]));
        
dmgs[i] = hits[i];
    }
    
lives hits[0];
}

public 
showLastRoundDamage(id) {
    new 
message[255], username[32];
    new 
bool:tookHit false;
    
    
copy(messagecharsmax(message), "Given: ( %d Damage / %d Hits ) Taken: ( %d Damage / %d Hits) to/from ^"%s^" (%d HP)");
    
    for (new 
0charsmax(hits[]); ++i) {
        if (
hits[id][i] != || hits[i][id] != 0) {
            if (
i) {
                if (
== id)
                    
copy(usernamecharsmax(username), "self");
                else
                    
get_user_name(iusernamecharsmax(username));
            } else {
                
copy(usernamecharsmax(username), "Worldspawn");
            }
            
client_print(idprint_chatmessagemin(dmgs[i][id],100), hits[i][id], min(dmgs[id][i],100), hits[id][i], usernamelives[i]);
            
tookHit true;
        }
    }
    
    if (!
tookHit)
        
client_print(idprint_chat"You didn't take any hit in the last round.");
    
    return 
PLUGIN_HANDLED_MAIN;


Last edited by Seta00; 03-17-2010 at 21:35.
Seta00 is offline
flamin
BANNED
Join Date: Jul 2009
Location: Los Teques
Old 03-17-2010 , 21:33   Re: [TUT] Recording Damage/Hits Per-Round and Displaying It
Reply With Quote #42

Setta00 my code already shows that way the problem is that only shows me to the players that i did damage and that i harm but not shows me all the players on the team if you realize in the image emerging players to which no i harm or made me harm, i want to run the command .dmg i am all players i understand? Wrecked did so with cs_get_user_team but i want to implement my code...
flamin is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 03-17-2010 , 21:39   Re: [TUT] Recording Damage/Hits Per-Round and Displaying It
Reply With Quote #43

What?! My code doesn't show people you didn't hurt/who didn't hurt you, and it doesn't show team attacks.
Seta00 is offline
flamin
BANNED
Join Date: Jul 2009
Location: Los Teques
Old 03-17-2010 , 21:45   Re: [TUT] Recording Damage/Hits Per-Round and Displaying It
Reply With Quote #44

Seta00 excuse me for not speak well ok you explain my code already shows me the dmg and hits like the image but i achieve what he did wrecked that is show all players to run the command .dmg because my code only shows me that i did harm, i repeat to you want is that i am all players in carrying out the command checks my code and the code of wrecked and really that what achievement with cs_get_user_team which i have not been able implement correctly in my code
flamin is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 03-17-2010 , 22:08   Re: [TUT] Recording Damage/Hits Per-Round and Displaying It
Reply With Quote #45

Sorry, I can't understand anything you said.

EDIT: Or maybe I can: You want to show to all users in the server who damaged who?

EDIT: By reading many times your posts I realize you want the plugin to display the damage all the users in the enemy team did to you, and vice-versa.
The funny thing is: my code does exactly what you want, except it doesn't show 0 damages.

Last edited by Seta00; 03-17-2010 at 22:16.
Seta00 is offline
flamin
BANNED
Join Date: Jul 2009
Location: Los Teques
Old 03-17-2010 , 22:19   Re: [TUT] Recording Damage/Hits Per-Round and Displaying It
Reply With Quote #46

Ok you explain a little better my code is this:

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

#include <yap_modspecific>
#include <yap_forwards>
#include <yap_stocks>
#include <yap_const>

new const plugin_author[] = "PsychO"
new const plugin_name[] = "YAP-AUX"
new const plugin_version[] = "0.0.1"

#define RESET_DELAY    15.0
new bool:allowdmg

public plugin_init()
{
    
register_plugin(plugin_name,plugin_version,plugin_author);

    
register_dictionary("yap.txt")
    
register_dictionary("yap_aux.txt")

    
register_pug_admincmd("help","cmd_cmdlist",_,"Lista de todos los comandos PUG")

    
register_pug_clcmd("hp","cmd_rdmg",_,"Muestra el hp de los oponentes")

    
register_pug_clcmd("dmg","cmd_dmg",_,"Muestra el daño que causastes y el que te causo el oponente")
    
register_pug_clcmd("rdmg","cmd_dmg",_,"Muestra el daño que causastes y el que te causo el oponente")

    
register_pug_admincmd("svrestart","cmd_restart",PUG_CMD_LVL,"Solo para ADMIN")

    
//parse_header("BOE-E",pug_header,5)
}

// Rukia: We need to reset the dmg and hits when a client connects, disconnects, and rounds start
new pug_dmg[33][33]
new 
pug_hits[33][33]
new 
pug_lastroundhp[33]

public 
client_connect(id
{
    
arrayset(pug_dmg[id], 033); 
    
arrayset(pug_hits[id], 033);
    
pug_lastroundhp[id] = floatround(entity_get_float(idEV_FL_max_health));
}

public 
client_disconnect(id)
{
    for (new 
033i++)
    {
        
pug_dmg[i][id] = 0;
        
pug_hits[i][id] = 0;
    }
}

public 
pug_round_start()
{
    
#if defined RESET_DELAY
        
set_taskRESET_DELAY"allowdmgreset" )
    
#else
        
allowdmgreset()
    
#endif
    
    
allowdmg true
}

public 
pug_round_start_failed()
{
    
#if defined RESET_DELAY
        
set_taskRESET_DELAY"allowdmgreset" )
    
#else
        
allowdmgreset()
    
#endif
    
    
allowdmg true
}

// Rukia: Assume that the mod specific plugin has loaded the correct module, or provided this for us
public  client_damage attackervictimamountwpnindexhitplaceTA )
{
    
//if (attacker == victim) return;

    
pug_dmg[attacker][victim] += amount
    pug_hits
[attacker][victim] += 1
    pug_lastroundhp
[victim] -= amount
}

#include <yap_aux>


public cmd_hpall(id)
{
    if(
is_user_alive(id) && id != 0) { pug_msg_tmp_empty(id,"PUG_CMD_NOTALLOWED"); }
    else
    {
        static 
Players[32], name[32]
        new 
playerCountiplayer
        get_players
(PlayersplayerCount"ah")

        for (
i=0i<playerCounti++)
        {
            
player Players[i]
            
get_user_name(player,name,31)

            
client_print(id,print_chat,"%s %L",pug_header2,id,"PUG_AUX_HP",name,get_user_health(player),get_user_armor(player))
        }
    }
    return 
PLUGIN_HANDLED
}

public 
cmd_hpteam(id)
{
    if( 
is_user_alive(id) && id != && !allowdmg ) { pug_msg_tmp_empty(id,"PUG_CMD_NOTALLOWED"); }
    else
    {
        static 
Players[32], name[32]
        new 
playerCountiplayer
        get_players
(PlayersplayerCount"ah")

        new 
teamid pug_get_client_team(id)
        for (
i=0i<playerCounti++)
        {
            
player Players[i]
            if(
teamid == pug_get_client_team(player) ) continue;
            
get_user_name(player,name,31)

            
client_print(id,print_chat,"%s %L",pug_header2,id,"PUG_AUX_HP",is_user_aliveplayer ) ? pug_lastroundhp[player] : 0get_user_armor(player), name)
        }
    }
    return 
PLUGIN_HANDLED
}

public 
allowdmgreset()
{
    for (new 
033; ++i)
    {
        
arrayset(pug_dmg[i], 033)    
        
arrayset(pug_hits[i], 033)
    
pug_lastroundhp[i] = 100 
    
}
    
allowdmg false
}

public 
cmd_dmg(id)
{
    if( 
is_user_alive(id) && id != && !allowdmg pug_msg_tmp_empty(id,"PUG_CMD_NOTALLOWED");
    else
    {
        static 
Players[32], name[32]
        new 
playerCountiplayer
        get_players
(PlayersplayerCount"ch")

        new 
tmp_hitstmp_dmgtmp_rhitstmp_rdmgcheck
        
for (i=0i<playerCounti++)
        {
            
player Players[i]
            
tmp_hits pug_hits[id][player]
            
tmp_rhits pug_hits[player][id]

            if( 
tmp_hits || tmp_rhits )
            {
                
check 1
                tmp_dmg 
pug_dmg[id][player]
                
tmp_rdmg pug_dmg[player][id]

                if(
player == idclient_print(id,print_chat,"%s %L",pug_header2,id,"PUG_AUX_DMG_SELF",tmp_dmg,tmp_hitsis_user_aliveplayer ) ? get_user_health(player) : 0)
                else
                {
                    
get_user_name(player,name31)
                    
client_print(id,print_chat,"%s %L",pug_header2,id,"PUG_AUX_DMG",tmp_dmg,tmp_hits,tmp_rdmg,tmp_rhitsnameis_user_aliveplayer ) ? get_user_health(player) : 0)
                }
            }
          }

        
tmp_hits pug_hits[id][0]
        
tmp_rhits pug_hits[0][id]
        if( 
tmp_hits || tmp_rhits )
        {
            
tmp_dmg pug_dmg[id][0]
            
tmp_rdmg pug_dmg[0][id]
            
client_print(id,print_chat,"%s %L",pug_header2,id,"PUG_AUX_DMG","WorldSpawn",tmp_hits,tmp_dmgis_user_aliveplayer ) ? get_user_health(player) : 0)
        }
        else if(!
checkclient_print(id,print_chat,"%s %L",pug_header2,id,"PUG_AUX_NODMG")
    }
    return 
PLUGIN_HANDLED

It works to the perfection but i just lack add something to the code cmd_dmg(id) what i want is what achievement wrecked in this code:

PHP Code:
public CMD_ShowDamageid )
{
    if( 
is_user_aliveid ) && !b_CanTypeWhileAlive )
    {
        
client_printidprint_chat"Hey! You can't do that right now!" )
        
        return 
PLUGIN_CONTINUE;
    }
    
    new 
iPlayers[32]
    new 
iNum
    
new plrid
    
    get_players
iPlayersiNum )
    
    static 
name[32]
    static 
message[108]
    
    new 
CsTeams:idteam cs_get_user_teamid )
    
    for( new 
0iNumi++ )
    {
        
plrid iPlayers[i]
        
        if( 
id == plrid || cs_get_user_teamplrid ) == idteam )
        {
            continue;
        }
        
        
get_user_nameplridname31 )
        
        
formatex(
        
message107"Given: ( %i Damage / %i Hits ) Taken: ( %i Damage / %i Hits )",
        
iDamageGiven[id][plrid],
        
iHitsGiven[id][plrid],
        
iDamageTaken[id][plrid],
        
iHitsTaken[id][plrid]
        )
        
        
client_printidprint_chat"[%s] %s"namemessage )
    }
    
    return 
PLUGIN_CONTINUE;

He has worked with cs_get_user_team which makes the following:

*
Shows all the team to run the command! So does not have inflicted damage or you have inflicted damage, meaning that it does not have done damage to nadien you show all players to execute the command if i do not understand warn! Back to view the image and really that shows all the players that are in the other team so it is not beeches inflicted damage to nobody

I have tried to implement the code asi but does not work

PHP Code:
public cmd_dmg(id)
{
    if( 
is_user_alive(id) && id != && !allowdmg pug_msg_tmp_empty(id,"PUG_CMD_NOTALLOWED");
    else
    {
        static 
Players[32], name[32]
        new 
playerCountiplayer
        get_players
(PlayersplayerCount"ch")

        new 
tmp_hitstmp_dmgtmp_rhitstmp_rdmgcheck
        
new CsTeams:teamid cs_get_user_teamid )
        for (
i=0i<playerCounti++)
        {
            
player Players[i]
            
tmp_hits pug_hits[id][player]
            
tmp_rhits pug_hits[player][id]

            if( 
tmp_hits || tmp_rhits )
            {
                
check 1
                tmp_dmg 
pug_dmg[id][player]
                
tmp_rdmg pug_dmg[player][id]

                if( 
id == player || cs_get_user_teamplayer ) == teamid )
                {
                    continue;
                }

                
get_user_name(player,name31)
                
client_print(id,print_chat,"%s %L",pug_header2,id,"PUG_AUX_DMG",tmp_dmg,tmp_hits,tmp_rdmg,tmp_rhitsnameis_user_aliveplayer ) ? get_user_health(player) : 0)
            }
          }

        
tmp_hits pug_hits[id][0]
        
tmp_rhits pug_hits[0][id]
        if( 
tmp_hits || tmp_rhits )
        {
            
tmp_dmg pug_dmg[id][0]
            
tmp_rdmg pug_dmg[0][id]
            
client_print(id,print_chat,"%s %L",pug_header2,id,"PUG_AUX_DMG","WorldSpawn",tmp_hits,tmp_dmgis_user_aliveplayer ) ? get_user_health(player) : 0)
        }
        else if(!
checkclient_print(id,print_chat,"",pug_header2,id,"PUG_AUX_NODMG")
    }
    return 
PLUGIN_HANDLED

Attached Thumbnails
Click image for larger version

Name:	Image.jpg
Views:	146
Size:	93.4 KB
ID:	61669  

Last edited by flamin; 03-17-2010 at 22:22.
flamin is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 03-17-2010 , 22:33   Re: [TUT] Recording Damage/Hits Per-Round and Displaying It
Reply With Quote #47

Quote:
Originally Posted by flamin View Post
He has worked with cs_get_user_team which makes the following:

*
Shows all the team to run the command! So does not have inflicted damage or you have inflicted damage, meaning that it does not have done damage to nadien you show all players to execute the command if i do not understand warn! Back to view the image and really that shows all the players that are in the other team so it is not beeches inflicted damage to nobody
cs_get_user_team doesn't make anything more than returning the user's team.

My code works like your picture shows, only difference is that it doesn't show 0 damages, did you even test it?
Seta00 is offline
flamin
BANNED
Join Date: Jul 2009
Location: Los Teques
Old 03-17-2010 , 22:53   Re: [TUT] Recording Damage/Hits Per-Round and Displaying It
Reply With Quote #48

wrecked the code does the same as yours!

and you are right cs_get_user_team does is returning the user's team, that's what we need to implement in my code but I have failed you help me implement it in my code?

wrecked what he did was call cs_get_user_team with the entire team to run the command. dmg and that is what we need to implement in my code can help?
flamin is offline
Seta00
The Seta00 user has crashed.
Join Date: Jan 2010
Location: Berlin
Old 03-17-2010 , 23:00   Re: [TUT] Recording Damage/Hits Per-Round and Displaying It
Reply With Quote #49

So what exactly your code does now?
Seta00 is offline
flamin
BANNED
Join Date: Jul 2009
Location: Los Teques
Old 03-17-2010 , 23:36   Re: [TUT] Recording Damage/Hits Per-Round and Displaying It
Reply With Quote #50

My code is the same as the yours, look the first image and now look the second image Where is the code of wrecked and look wrecked the code shows the whole team well not have caused damage anyone, however our code only shows the player that cause damage

He has managed to show all the team with the function cs_get_user_team

That is what i want to implement in my code, Watches the images.

How could then implement it in my code?
Attached Thumbnails
Click image for larger version

Name:	seta00.jpg
Views:	212
Size:	92.9 KB
ID:	61695   Click image for larger version

Name:	wrecked.jpg
Views:	209
Size:	99.8 KB
ID:	61696  

Last edited by flamin; 03-18-2010 at 15:11.
flamin 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 18:36.


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