Raised This Month: $ Target: $400
 0% 

Top damagers sorting


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Wasc
Junior Member
Join Date: Apr 2011
Old 11-09-2011 , 04:12   Top damagers sorting
Reply With Quote #1

Hello!
I already have plugin, which calculates damage of player.
But I want to make HUD-message to show top 3 players by damage.
I use sort by descending and retrieves from new sorted massive [0],[1] and [2] players.
Code:
const MAX_PLAYERS = 32;

enum KillData
{
    CurrentDamage,
    TotalDamage
}

new kdPlayerData[ MAX_PLAYERS + 1 ][ KillData ];

public plugin_init() 
{   
    register_plugin( "" , "" , "" );
    RegisterHam( Ham_TakeDamage , "player" , "fw_HamTakeDamage_Post" , 1 );
    register_logevent("fw_RoundStart" , 2 , "1=Round_Start" );
}

public fw_HamTakeDamage_Post(TopDamagers[32],iVictim , iInflictor, iAttacker , Float:fDamage , DamageBits){
        
    kdPlayerData[ iAttacker ][ TotalDamage ] += ( kdPlayerData[ iAttacker ][ CurrentDamage ] = pev( iVictim , pev_dmg_take ) );
    
    set_hudmessage( 0, 51, 102 , -1.0 , 0.75 , 0 , 15.0 , 2.0 );
    show_hudmessage( iAttacker , "TOTAL DAMAGE: %d" , kdPlayerData[ iAttacker ][ TotalDamage ]);
    
    for (new i=1;i<sizeof(kdPlayerData);i++){
        TopDamagers[i] = kdPlayerData[i]
    }
    
    new Top1[18],Top2[18],Top3[18]
    
    get_user_name(TopDamagers[0],Top1,17)
    get_user_name(TopDamagers[1],Top2,17)
    get_user_name(TopDamagers[2],Top3,17)
    
    SortIntegers(TopDamagers,sizeof(TopDamagers),Sort_Descending)
    
    set_hudmessage( 0, 51, 102 , -0.5 , 0.25 , 0 , 15.0 , 2.0 );
    show_hudmessage(0,"TOP DAMAGERS: 1.%s: %d\n2.%s: %d\n3.%s: %d",Top1,TopDamagers[0],Top2,TopDamagers[1],Top3,TopDamagers[2]);

     return HAM_IGNORED;
}

public fw_RoundStart(){
    for ( new i = 1 ; i < sizeof( kdPlayerData ) ; i++ ){
        arrayset( kdPlayerData[ i ] , 0 , sizeof( kdPlayerData[] ) );
    }
}
but in string where
Code:
  
for (new i=1;i<sizeof(kdPlayerData);i++){
        TopDamagers[i] = kdPlayerData[i]
}
must be assigned to an array

Last edited by Wasc; 11-09-2011 at 08:20.
Wasc is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-09-2011 , 04:19   Re: Top damagers sorting
Reply With Quote #2

TopDamagers[i] = kdPlayerData[i][CurrentDamage]

or

TopDamagers[i] = kdPlayerData[i][TotalDamage]

depending on your needs.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Wasc
Junior Member
Join Date: Apr 2011
Old 11-09-2011 , 08:29   Re: Top damagers sorting
Reply With Quote #3

ye I tried this before.
It is compiling without problems but plugin don't work.
This is console:
Code:
L 11/09/2011 - 17:22:43: [AMXX] Displaying debug trace (plugin "crazzard_TotalDamage.amxx")
L 11/09/2011 - 17:22:43: [AMXX] Run time error 4: index out of bounds 
L 11/09/2011 - 17:22:43: [AMXX]    [0] TotalDamage.sma::fw_HamTakeDamage_Post (line 42)
Line 42 is calculator of damage:
Code:
kdPlayerData[ iAttacker ][ TotalDamage ] += ( kdPlayerData[ iAttacker ][ CurrentDamage ] = pev( iVictim , pev_dmg_take ) );
Calculator works perfectly without new scriptes for top players

Last edited by Wasc; 11-09-2011 at 08:29.
Wasc is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-09-2011 , 08:38   Re: Top damagers sorting
Reply With Quote #4

Do you know that csx module stores the same datas as your plugin is trying to do ?
Use get_user_*stats native and retrieve damage done or damage taken.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Wasc
Junior Member
Join Date: Apr 2011
Old 11-09-2011 , 09:02   Re: Top damagers sorting
Reply With Quote #5

I understood your recommendation, but if I want to set to zero if round ended, and next round this value will begin from 0. stats.dat keeps damage of all gametime which player played. I think this method doesn't suit me

Last edited by Wasc; 11-09-2011 at 09:03.
Wasc is offline
Wasc
Junior Member
Join Date: Apr 2011
Old 11-09-2011 , 16:18   Re: Top damagers sorting
Reply With Quote #6

I tried this:
Code:
    for (new i=1;i<sizeof(kdPlayerData);i++){
        arrayset(TopDamagers[i],kdPlayerData[i],sizeof(kdPlayerData[]))
    }
But compilator says:argument type mismatch
If I try to modify it to arrayset(TopDamagers[i],kdPlayerData[i][TotalDamage],sizeof(kdPlayerData[])) - it's error which I described in my second message

Last edited by Wasc; 11-09-2011 at 16:28.
Wasc 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 14:21.


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