AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Damage stacking (https://forums.alliedmods.net/showthread.php?t=154625)

Wasc 04-11-2011 02:50

Damage stacking
 
I need help to write plugin, which shows damage done.
When player hits a target, in bottom of his screen appears HUD-message with (all damage)+(damage of this hit) in 1 constant.
I have constants:

damage = read_data(2)
dmdone = 0 (starting value)
new killer = get_user_attacker(id) - index, which uses in HUD-msg


I know that this is a cycle, but dont know how organizate it.
without cycle I tried to write:

dmdone = dmdone + damage

But no effect (HUD-message prints value 0 without changes)

P.S. Constant must changes with every hit
P.P.S For Zombie Server

!Morte 04-11-2011 10:40

Re: Damage stacking
 
PHP Code:

new g_totaldamage[33]

// Then in take damage

g_totaldamage[attacker] = g_totaldamage[attacker] + floatround(damage)

set_hudmessage(25500, -1.0, -1.006.012.0)
show_hudmessage(id"%d Damage"g_totaldamage[attacker]) 

something like this?

Wasc 04-11-2011 12:15

Re: Damage stacking
 
Constant doesn't change value with new hud.
Always displays 0.
I think that that's must be in a cycle. But dont know how organizate it. I think that if I'll use this actions in condition it always refreshes to 0.
Can you write cycle for me?

Wasc 04-12-2011 13:43

Re: Damage stacking
 
PHP Code:

#include <amxmodx>
#include <zombieplague>
#include <fakemeta>

new g_MsgSync
new g_MsgSync2
new g_MsgSync3
new g_totaldamage[33]

public 
plugin_init() {
    
register_plugin("Damage Dealt""1.0""Wasc")
    
register_event("Damage","event_damage","b","2!0","3=0","4!0")

    
g_MsgSync CreateHudSyncObj()
    
g_MsgSync2 CreateHudSyncObj()
    
g_MsgSync3 CreateHudSyncObj()
    }
    while(
zp_get_user_zombie(id))
    {
        
g_totaldamage[killer] = g_totaldamage[killer] + floatround(damage)
        
set_hudmessage(2005050, -1.00.8220.130.00.020.02, -1)
        
ShowSyncHudMsg(killer,g_MsgSync3"Damage Meter: %i",g_totaldamage[killer])
    }


Can someone help, please.

Why when someone starts to dealing damage server shutting down. It started when I added cycle "While"

fmcTheKing 04-13-2011 13:31

Re: Damage stacking
 
PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>

public plugin_init() 
{   
    
register_plugin("Damage","1.0","fmc")
    
    
RegisterHam(Ham_TakeDamage"player""Ham_TakeDamagePost"1)
}

public 
Ham_TakeDamagePost(victim idinflictoridattackerfloat:damagedamagebits
{    
    new 
damage pevvictim pev_dmg_take )
    
    
set_hudmessage(25500, -1.0, -1.006.02.0)
    
show_hudmessage(idattacker "%d"damage)
    
    return 
HAM_HANDLED


=)

#6 [PT-BR] Coloquei sem querer, obrigado por avisar.

Bugsy 04-13-2011 14:33

Re: Damage stacking
 
Use %d for integers, chief. %s is for strings.

Wasc 04-14-2011 10:38

Re: Damage stacking
 
fmcTheKing
Your plugin shows damage, which dealt by last bullet, but not calculating damage.

Bugsy 04-14-2011 20:20

Re: Damage stacking
 
Like this?
PHP Code:

#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>

new const Version[] = "0.1";

const 
MAX_PLAYERS 32;

enum KillData
{
    
CurrentDamage,
    
TotalDamage
}

new 
kdPlayerDataMAX_PLAYERS ][ KillData ];

public 
plugin_init() 
{   
    
register_plugin"Damage Tracker" Version "bugsy" );
    
    
RegisterHamHam_TakeDamage "player" "fw_HamTakeDamage_Post" );
}

public 
fw_HamTakeDamage_PostiVictim iInflictoriAttacker Float:fDamage DamageBits 
{    
    
kdPlayerDataiAttacker ][ TotalDamage ] += ( kdPlayerDataiAttacker ][ CurrentDamage ] = peviVictim pev_dmg_take ) );
    
    
set_hudmessage255 , -1.0 , -1.0 6.0 2.0 );
    
show_hudmessageiAttacker "Total Damage: %d | Attack Damage: %d" kdPlayerDataiAttacker ][ TotalDamage ] , kdPlayerDataiAttacker ][ CurrentDamage ] );
    
    return 
HAM_IGNORED;



fmcTheKing 04-14-2011 21:46

Re: Damage stacking
 
Wasc
Sorry, I do not speak English very well, not just reading the topics, I see the codes.

#palmface for me. =/

Wasc 04-15-2011 09:10

Re: Damage stacking
 
Bugsy
Ty, working. But last question: how can I refresh total damage when started new round.
I tried code in public_init:
PHP Code:

register_event("HLTV""event_round_start""a""1=0""2=0"

And code into body:
PHP Code:

public event_round_start(iAttacker)
{
    for (new 
idid <= 32id++) (kdPlayerDataiAttacker ][ TotalDamage ])[id] = false;


fmcTheKing
No problem. I am not english too


All times are GMT -4. The time now is 20:08.

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