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

Help! Wrong stats in stats plugin


Post New Thread Reply   
 
Thread Tools Display Modes
cahervar
Member
Join Date: Mar 2021
Old 03-23-2021 , 20:56   Re: Help! Wrong stats in stats plugin
Reply With Quote #11

Quote:
Originally Posted by Bugsy View Post
Here's an initial copy. The below still needs to be completed. Players are ranked based on kills-deaths.

1. Player data only updates when they disconnect, so the topten is not real time
2. /rank

You will need:
nVault Utility
nVault Array

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <nvault_util>
#include <nvault_array>

#if AMXX_VERSION_NUM >= 190
#define client_disconnect client_disconnected
#endif

const MaxRanked 1000;

enum PlayerData
{
    
pd_Name33 ],
    
pd_AuthID34 ],
    
pd_Kills,
    
pd_Deaths,
    
pd_Headshots
}

new 
g_pdDataMAX_PLAYERS ][ PlayerData ];
new 
g_szTop101055 ];
new 
g_Vault;
new 
g_pEnabled;

public 
plugin_init() 
{
    
register_plugin"Knife Top" "0.1" "bugsy" );
    
    
register_event"DeathMsg" "DeathMsg" "a" "1>0" "4=knife" );
    
g_pEnabled register_cvar("kt_enabled" "1" );
    
    
register_clcmd"say reset" "ResetRanks" ADMIN_BAN );
    
register_clcmd"say rank" "ShowRank" );
    
register_clcmd"say topten" "TopTen" );
    
register_clcmd"say /info" "ShowInfo" );
    
    
g_Vault nvault_open"KnifeTop" );
}

public 
plugin_end()
{
    
nvault_closeg_Vault );
}

public 
client_authorizedid 
{
    if ( 
get_pcvar_numg_pEnabled ) && !is_user_botid ) ) 
    {    
        
get_user_authidid g_pdDataid ][ pd_AuthID ] , charsmaxg_pdData[][ pd_AuthID ] ) );
        
nvault_get_arrayg_Vault g_pdDataid ][ pd_AuthID ] , g_pdDataid ][ PlayerData:] , sizeofg_pdData[] ) );
        
get_user_nameid g_pdDataid ][ pd_Name ] , charsmaxg_pdData[][ pd_Name ] ) );
    }
}

public 
client_disconnectid )
{
    if ( 
get_pcvar_numg_pEnabled ) && !is_user_botid )  ) 
    {
        
nvault_set_arrayg_Vault g_pdDataid ][ pd_AuthID ] , g_pdDataid ][ PlayerData:] , sizeofg_pdData[] ) );
    }
}

public 
ShowRankid 
{
    if ( 
get_pcvar_numg_pEnabled ) ) 
    {
        
ColorChatid RED"[AMBA CS] Tu posicion es %s en el FakaTop, con %d cuchilladas" g_pdDataid ][ pd_Name ] , g_pdDataid ][ pd_Kills ] );
    }
}

public 
ShowInfoid 
{
    if ( 
get_pcvar_numg_pEnabled ) ) 
    {
        
ColorChatid RED "[AMBA CS] Escribe fakatop y ve el top10 de Fakas, o fakarank para ver tu estadistica" ); 
    }
}

public 
DeathMsg() 
{
    if ( 
get_pcvar_numg_pEnabled ) ) 
    {    
        new 
iKiller read_data); 
        
        
g_pdDataiKiller ][ pd_Kills ]++;
        
g_pdDataread_data) ][ pd_Deaths ]++;
        
g_pdDataiKiller ][ pd_Headshots ] += read_data);
    }
}

public 
TopTenid )
{
    if ( 
get_pcvar_numg_pEnabled ) ) 
    {
        
UpdateTop10();
        
show_motdid g_szTop10 );
    }
}

public 
UpdateTop10()
{
    
enum _:Top10Data
    
{
        
nVault_Offset,
        
Rank_Value
    
}
    
    static 
iRankDataMaxRanked ][ Top10Data ];
    new 
pdDataPlayerData ] , iCurrentOffset iNextOffset;
    new 
iVault iCount iPos iAvailablePlayers;
    
    
nvault_closeg_Vault );
    
g_Vault nvault_open"KnifeTop" );
    
    
iVault nvault_util_open"KnifeTop" );
    
iCount nvault_util_countiVault );
    
    if ( !
iCount )
    {
        
copyg_szTop10 charsmaxg_szTop10 ) , "<html>No players are ranked yet</html>" );
        return;
    }
    
    for ( new 
iRow iRow iCount && iRow MaxRanked iRow++ )
    {
        
iNextOffset nvault_util_read_arrayiVault iNextOffset "" pdDataPlayerData:] , sizeofpdData ) );
        
        
iRankDataiRow ][ nVault_Offset ] = iCurrentOffset;
        
iRankDataiRow ][ Rank_Value ] = ( pdDatapd_Kills ] - pdDatapd_Deaths ] );

        
iCurrentOffset iNextOffset;
    }
    
    
SortCustom2DiRankData miniCount MaxRanked ) , "SortCompare" );
    
    
iPos += copyg_szTop10iPos ] , charsmaxg_szTop10 ) - iPos "<html><style>body { background-color:#000000; }.tabel { color:#FFB000; }.header { background-color:#3d3c23; color:#FFB000;}</style><body>");
    
iPos += copyg_szTop10iPos ] , charsmaxg_szTop10 ) - iPos "<br><br><table align=center border=1 width=90% class=tabel>");
    
iPos += copyg_szTop10iPos ] , charsmaxg_szTop10 ) - iPos "<tr><td class=header width=5% align=center>#</td><td class=header width=24%>Nombre</td><td class=header width=24%>Fakas Dadas</td>" );
    
iPos += copyg_szTop10iPos ] , charsmaxg_szTop10 ) - iPos "<td class=header width=24%>Fakas Recibidas</td><td class=header width=24%>Fakas HeadShots</td></tr>");
    
    
iAvailablePlayers miniCount 10 );
    
    for ( new 
iAvailablePlayers i++ ) 
    {
        
nvault_util_read_arrayiVault iRankData][ nVault_Offset ] , "" pdDataPlayerData:] , sizeofpdData ) );
        
        
iPos += formatexg_szTop10iPos ] , charsmaxg_szTop10 ) - iPos "<tr><td>%d</td><td>%s</td><td>%d</td><td>%d</td><td>%d</td></tr>" i+pdDatapd_Name ] , pdDatapd_Kills ] , pdDatapd_Deaths ] , pdDatapd_Headshots ] );
    }
    
    
iPos += copyg_szTop10iPos ] , charsmaxg_szTop10 ) - iPos "</table></body></html>" );
    
    
nvault_util_closeiVault );
}

public 
SortCompareelem1[] , elem2[] ) 

    if ( 
elem1] > elem2] ) 
        return -
1
    else if(
elem1] < elem2] ) 
        return 
1
    else
        return 
0


public 
ResetRanksid level cid 
{
    if ( 
cmd_accessid  level cid ) ) 
    {
        
nvault_pruneg_Vault get_systime() );
        
ColorChatGREEN "[AMBA CS] EL ADMIN %s reseteo el Faka Top" g_pdDataid ][ pd_Name ] );
    }

Thanks, I'll try.
when changing the map is updated?
cahervar is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-23-2021 , 21:23   Re: Help! Wrong stats in stats plugin
Reply With Quote #12

Yes, since map change disconnects all players.
__________________
Bugsy is offline
cahervar
Member
Join Date: Mar 2021
Old 03-23-2021 , 21:33   Re: Help! Wrong stats in stats plugin
Reply With Quote #13

Quote:
Originally Posted by Bugsy View Post
Yes, since map change disconnects all players.
thanks!!!
I added the module that was missing
PHP Code:
#include <colorchat> 
cahervar is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-23-2021 , 21:59   Re: Help! Wrong stats in stats plugin
Reply With Quote #14

Oops, yeah I had that code commented out while I worked on this since I dont use color chat, forgot to re-add the include.
__________________
Bugsy is offline
cahervar
Member
Join Date: Mar 2021
Old 03-24-2021 , 14:14   Re: Help! Wrong stats in stats plugin
Reply With Quote #15

Quote:
Originally Posted by Bugsy View Post
Oops, yeah I had that code commented out while I worked on this since I dont use color chat, forgot to re-add the include.
How can I change the name of the motd? I don't want the server name to appear, I want "TOP FAKA" to appear
cahervar is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-24-2021 , 14:47   Re: Help! Wrong stats in stats plugin
Reply With Quote #16

Code:
show_motd( id , g_szTop10 );

=>

Code:
show_motd( id , g_szTop10, "motd name here" );
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
cahervar
Member
Join Date: Mar 2021
Old 03-24-2021 , 15:12   Re: Help! Wrong stats in stats plugin
Reply With Quote #17

Quote:
Originally Posted by OciXCrom View Post
Code:
show_motd( id , g_szTop10 );

=>

Code:
show_motd( id , g_szTop10, "motd name here" );
thaks!

now!
"reset" does not delete the data, it only deletes it but it returns when the map is changed
cahervar is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-24-2021 , 15:53   Re: Help! Wrong stats in stats plugin
Reply With Quote #18

Code:
public ResetRanks( id , level , cid ) {     if ( cmd_access( id  , level , cid , 0 ) )     {         nvault_prune( g_Vault , 0 , get_systime() );         ColorChat( 0 , GREEN , "[AMBA CS] EL ADMIN %s reseteo el Faka Top" , g_pdData[ id ][ pd_Name ] );     } }

=>

Code:
public ResetRanks( id , level , cid ) {     if ( cmd_access( id  , level , cid , 0 ) )     {         nvault_prune( g_Vault , 0 , get_systime() );         ColorChat( 0 , GREEN , "[AMBA CS] EL ADMIN %s reseteo el Faka Top" , g_pdData[ id ][ pd_Name ] );                 new iPlayers[ MAX_PLAYERS ], iPnum         get_players( iPlayers, iPnum )         for( new iPlayer, i; i < iPnum; i++ )         {             iPlayer = iPlayers[ i ]             g_pdData[ iPlayer ][ pd_Kills ] = 0             g_pdData[ iPlayer ][ pd_Deaths ] = 0             g_pdData[ iPlayer ][ pd_Headshots ] = 0         }     } }
__________________

Last edited by OciXCrom; 03-24-2021 at 15:54.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
cahervar
Member
Join Date: Mar 2021
Old 03-24-2021 , 16:22   Re: Help! Wrong stats in stats plugin
Reply With Quote #19

Quote:
Originally Posted by OciXCrom View Post
Code:
public ResetRanks( id , level , cid ) {     if ( cmd_access( id  , level , cid , 0 ) )     {         nvault_prune( g_Vault , 0 , get_systime() );         ColorChat( 0 , GREEN , "[AMBA CS] EL ADMIN %s reseteo el Faka Top" , g_pdData[ id ][ pd_Name ] );     } }

=>

Code:
public ResetRanks( id , level , cid ) {     if ( cmd_access( id  , level , cid , 0 ) )     {         nvault_prune( g_Vault , 0 , get_systime() );         ColorChat( 0 , GREEN , "[AMBA CS] EL ADMIN %s reseteo el Faka Top" , g_pdData[ id ][ pd_Name ] );                 new iPlayers[ MAX_PLAYERS ], iPnum         get_players( iPlayers, iPnum )         for( new iPlayer, i; i < iPnum; i++ )         {             iPlayer = iPlayers[ i ]             g_pdData[ iPlayer ][ pd_Kills ] = 0             g_pdData[ iPlayer ][ pd_Deaths ] = 0             g_pdData[ iPlayer ][ pd_Headshots ] = 0         }     } }
thanks!!
cahervar is offline
cahervar
Member
Join Date: Mar 2021
Old 03-24-2021 , 20:04   Re: Help! Wrong stats in stats plugin
Reply With Quote #20

the position nš10 is not seen. I attach a photo
Attached Images
File Type: jpg error.jpg (84.4 KB, 12 views)
cahervar 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 11:46.


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