Raised This Month: $32 Target: $400
 8% 

rank kills only


Post New Thread Reply   
 
Thread Tools Display Modes
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 01-21-2020 , 13:34   Re: rank kills only
Reply With Quote #11

everything, sometimes when i kill someone i dont get points or kills, nothing happens
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-21-2020 , 17:08   Re: rank kills only
Reply With Quote #12

Quote:
Originally Posted by Nutu_ View Post
everything, sometimes when i kill someone i dont get points or kills, nothing happens
If you kill someone, you mean you killed someone with a trap or using your knife or a gun?
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 01-22-2020 , 13:56   Re: rank kills only
Reply With Quote #13

both of them, even when im killing with a knife/gun or traps, sometimes i dont get anything!
__________________
a simple act of caring creates an endless ripple.
Nutu_ is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-22-2020 , 16:53   Re: rank kills only
Reply With Quote #14

Quote:
Originally Posted by Nutu_ View Post
both of them, even when im killing with a knife/gun or traps, sometimes i dont get anything!
That's not possible unless you kill someone in spectator. The traps makes sense to me, but if u make kills with a gun or your knife, it should always add, i've tested it many times.

also the rank system should be done by someone else since i have no idea on even starting it.
__________________

Last edited by Napoleon_be; 01-22-2020 at 16:54.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Nutu_
AlliedModders Donor
Join Date: Mar 2016
Location: Germany
Old 01-23-2020 , 12:47   Re: rank kills only
Reply With Quote #15

Quote:
Originally Posted by Napoleon_be View Post
That's not possible unless you kill someone in spectator. The traps makes sense to me, but if u make kills with a gun or your knife, it should always add, i've tested it many times.

also the rank system should be done by someone else since i have no idea on even starting it.
maybe this helps
Code:
#include < amxmodx >
#include < fvault >

enum _:RankData
{
	Rank_Kills,
	Rank_Name[ 32 ],
	Rank_SteamID[ 35 ]
};

new const g_szVaultName[ ] = "amxx_stats";

new pCvar_Top;

public plugin_init( )
{
	register_plugin( "AMXX Stats", "0.0.1", "Exolent" );
	
	register_srvcmd( "amxstats_reset", "CmdReset" );
	
	register_clcmd( "say /rank", "CmdRank" );
	register_clcmd( "say /top", "CmdTop" );
	register_clcmd( "say /top10", "CmdTop" );
	register_clcmd( "say /top15", "CmdTop" );
	
	register_event( "DeathMsg", "EventDeathMsg", "a" );
	
	pCvar_Top = register_cvar( "amxstats_top", "10" );
}

public CmdReset( )
{
	fvault_clear( g_szVaultName );
	
	server_print( "[AMXX] Stats have been reset." );
	
	log_amx( "[AMXX] Stats have been reset." );
	
	return PLUGIN_HANDLED;
}

public CmdRank( iPlayer )
{
	new Array:aRankData;
	new iTotal = GetPlayerRanks( aRankData );
	
	new iRank;
	new eRankData[ RankData ];
	
	if( iTotal )
	{
		new szPlayerSteamID[ 35 ];
		get_user_authid( iPlayer, szPlayerSteamID, charsmax( szPlayerSteamID ) );
		
		for( new i = 0; i < iTotal; i++ )
		{
			ArrayGetArray( aRankData, i, eRankData );
			
			if( equal( szPlayerSteamID, eRankData[ Rank_SteamID ] ) )
			{
				iRank = i + 1;
				break;
			}
		}
	}
	
	if( iRank )
	{
		client_print( iPlayer, print_chat, "* You are ranked %i of %i with %i kill%s!", iRank, iTotal, eRankData[ Rank_Kills ], ( eRankData[ Rank_Kills ] == 1 ) ? "" : "s" );
	}
	else
	{
		client_print( iPlayer, print_chat, "* You are not ranked because you have not killed anyone!" );
	}
	
	ArrayDestroy( aRankData );
}

public CmdTop( iPlayer )
{
	new Array:aRankData;
	new iTotal = max( 0, min( GetPlayerRanks( aRankData ), get_pcvar_num( pCvar_Top ) ) );
	
	if( iTotal )
	{
		static szMOTD[ 2500 ], iDefaultLen;
		if( !iDefaultLen )
		{
			iDefaultLen = copy( szMOTD, charsmax( szMOTD ), "<body><table align=center border=1><thead><tr><th>#.</th><th>Name</th><th>Kills</th></tr></thead><tbody>" );
		}
		
		new iLen = iDefaultLen;
		
		new eRankData[ RankData ];
		
		new szFixedName[ 128 ];
		
		for( new i = 0; i < iTotal; i++ )
		{
			ArrayGetArray( aRankData, i, eRankData );
			
			copy( szFixedName, charsmax( szFixedName ), eRankData[ Rank_Name ] );
			
			MakeNameMOTDSafe( szFixedName, 31 );
			
			iLen += formatex( szMOTD[ iLen ], charsmax( szMOTD ) - iLen, "<tr><td>%i</td><td>%s</td><td>%i</td></tr>", ( i + 1 ), szFixedName, eRankData[ Rank_Kills ] );
		}
		
		copy( szMOTD[ iLen ], charsmax( szMOTD ) - iLen, "</tbody></table></body>" );
		
		show_motd( iPlayer, szMOTD, "Top Players" );
	}
	else
	{
		client_print( iPlayer, print_chat, "* No players have been put on the top!" );
	}
	
	ArrayDestroy( aRankData );
}

public EventDeathMsg( )
{
	new iVictim = read_data( 2 );
	
	if( is_user_connected( iVictim ) )
	{
		new iKiller = read_data( 1 );
		
		if( iVictim != iKiller
		&&  is_user_connected( iKiller ) )
		{
			// killed by another player
			
			new szName[ 32 ], szSteamID[ 35 ];
			get_user_authid( iKiller, szSteamID, charsmax( szSteamID ) );
			
			new szKills[ 48 ], iKills;
			if( fvault_get_data( g_szVaultName, szSteamID, szKills, charsmax( szKills ) ) )
			{
				strbreak( szKills, szKills, charsmax( szKills ), szName, charsmax( szName ) );
				
				iKills = str_to_num( szKills );
			}
			
			if( get_user_team( iVictim ) == get_user_team( iKiller ) )
			{
				// killed by a teammate
				
				iKills--;
			}
			else
			{
				// killed by an enemy
				
				iKills++;
			}
			
			get_user_name( iKiller, szName ,charsmax( szName ) );
			
			formatex( szKills, charsmax( szKills ), "%i %s", iKills, szName );
			
			fvault_set_data( g_szVaultName, szSteamID, szKills );
		}
		else
		{
			// killed self somehow
		}
	}
}

GetPlayerRanks( &Array:aRankData )
{
	aRankData = ArrayCreate( RankData );
	new iTotal;
	
	new eRankData[ RankData ];
	
	new szFileName[ 128 ];
	_FormatVaultName( g_szVaultName, szFileName, charsmax( szFileName ) );
	
	new iFile = fopen( szFileName, "rt" );
	
	if( !iFile )
	{
		return iTotal;
	}
	
	new szFileData[ 128 ];
	new szKills[ 48 ];
	
	while( !feof( iFile ) )
	{
		fgets( iFile, szFileData, charsmax( szFileData ) );
		trim( szFileData );
		
		if( !szFileData[ 0 ] )
		{
			continue;
		}
		
		parse( szFileData, eRankData[ Rank_SteamID ], charsmax( eRankData[ Rank_SteamID ] ), szKills, charsmax( szKills ) );
		strbreak( szKills, szKills, charsmax( szKills ), eRankData[ Rank_Name ], charsmax( eRankData[ Rank_Name ] ) );
		eRankData[ Rank_Kills ] = str_to_num( szKills );
		
		ArrayPushArray( aRankData, eRankData );
		
		iTotal++;
	}
	
	fclose( iFile );
	
	ArraySort( aRankData, "SortData" );
	
	return iTotal;
}

public SortData( Array:aData, iIndex1, iIndex2, const iSortData[ ], iSortDataSize )
{
	new eData1[ RankData ], eData2[ RankData ];
	ArrayGetArray( aData, iIndex1, eData1 );
	ArrayGetArray( aData, iIndex2, eData2 );
	
	return clamp( ( eData2[ Rank_Kills ] - eData1[ Rank_Kills ] ), -1, 1 );
}

stock MakeNameMOTDSafe( szName[ 128 ], iMaxChars )
{
	szName[ 32 ] = 0;
	
	replace_all( szName, 127, "&", "&amp;" );
	replace_all( szName, 127, "<", "&lt;" );
	replace_all( szName, 127, ">", "&gt;" );
	replace_all( szName, 127, "^"", "&quot;" );
	
	if( iMaxChars > 128 ) return;
	
	new iLast;
	for( new i = 0; i < 128 && szName[ i ]; )
	{
		if( szName[ i ] == '&' )
		{
			if( equal( szName[ i ], "&amp;", 5 ) )
			{
				i += 4;
			}
			else if( equal( szName[ i ], "&quot;", 6 ) )
			{
				i += 5;
			}
			else if( equal( szName[ i ], "&lt;", 4 ) || equal( szName[ i ], "&gt;", 4 ) )
			{
				i += 3;
			}
		}
		
		if( ++i > iMaxChars )
		{
			break;
		}
		
		iLast = i;
	}
	
	szName[ iLast ] = 0;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/
i will try to put the plugin in the top of the plugins list, hopefully you can fix it!
__________________
a simple act of caring creates an endless ripple.
Nutu_ 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 19:27.


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