[Cerere Plugin] Top15

Categoria cu cereri de pluginuri si nu numai.

Moderators: Moderatori ajutatori, Moderatori, Echipa eXtreamCS.com

Forum rules
Accesează link-ul pentru a putea vedea regulile forumului

Daca doriti sa vi se modifice un plugin, va rugam postati aici .
Post Reply
Retired
Membru, skill 0
Membru, skill 0
Posts: 60
Joined: 12 Apr 2019, 19:53
Detinator Steam: Nu
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
Has thanked: 8 times
Been thanked: 1 time

18 Jan 2022, 06:08

Plugin Cerut: Top15
Descriere (adica ce face el mai exact): Este un Top15 cu un Design diferit , pe langa citeste si Jucatori cu Steam si apare si Flag-ul tarii respective
Ai cautat pluginul?(daca da, precizeaza cum): Nu dau de el nici aici nici in alta parte
Serverul impune conditii strict HLDS/REHLDS?: -
Necesita mod special?: N-am idee
Versiune AMXX Server: -

respectiv : https://imgur.com/a/V71QJjN
RoyalServer
User avatar
levin
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 3844
Joined: 24 Aug 2011, 12:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Discord: devilclass
Has thanked: 36 times
Been thanked: 594 times
Contact:

18 Jan 2022, 12:04

du te pe sv unde ai vzt motd ăsta, apasă shift+tab cât timp ești pe cs și este motdu pe ecran
du te în folderu cstrike, caută motd_temp.html și deschide l cu notepad, copiează tot ce i acolo și pune aici
Pentru ajutor, faceți cerere bine detaliată, completând și respectând modelul corespunzător.
Nu-mi mai dați cereri doar pentru a mă avea în lista de prieteni.
Dacă te ajut, și mă ignori/etc > te adaug în „foe”.
Aveți grijă la cei ce încearcă să mă copieze sau să dea drept mine..Puteți lua legătura cu mine prin STEAM dacă aveți o problemă/nelămurire în acest caz! Cont de forum am doar aici.
În cazul în care utilizați ceva din ce am postat(ex: aici), e bine să fiți la curent cu modificările aduse și de aici, iar dacă sunt ceva probleme nu ezitați să luați legătura cu mine. Actualizarea unor coduri nu se vor afișa public, doar dacă se găsește ceva critic/urgent de remediat, unele fiind coduri vechi iar unele refăcute chiar recent dar private.
* Nume pe cs1.6: eVoLuTiOn \ Nume vechi: eVo
* Atelierul meu - post2819572.html#p2819572 (închis, click link ca să vedeți de ce)
Retired
Membru, skill 0
Membru, skill 0
Posts: 60
Joined: 12 Apr 2019, 19:53
Detinator Steam: Nu
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
Has thanked: 8 times
Been thanked: 1 time

19 Jan 2022, 00:06

LEVIN , am intrat , am incercat Shift + Tab , Dar nu imi salveaza nimic , din contra cand apas imi deschide Tab-ul de Scor normal .. ., si unicul fisier motd pe care-l am , e ala de text

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>Cstrike MOTD</title>
<style type="text/css">
pre 	{
		font-family:Verdana,Tahoma;
		color:#FFB000;
    	}
body	{
		background:#000000;
		margin-left:8px;
		margin-top:0px;
		}
a	{
    	text-decoration:    underline;
	}
a:link  {
    color:  #FFFFFF;
    }
a:visited   {
    color:  #FFFFFF;
    }
a:active    {
    color:  #FFFFFF;
    }
a:hover {
    color:  #FFFFFF;
    text-decoration:    underline;
    }
</style>
</head>
<body scroll="no">
<pre>
You are playing Counter-Strike v1.6
Visit the official CS web site @
www.counter-strike.net
<a href="http://www.counter-strike.net">Visit Counter-Strike.net</a>
</pre>
</body>
</html>
User avatar
levin
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 3844
Joined: 24 Aug 2011, 12:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Discord: devilclass
Has thanked: 36 times
Been thanked: 594 times
Contact:

19 Jan 2022, 13:25

men...ești pe sv și ai motdu de la top deschis
apeși SHIFT și nu i dai drumu, apoi apeși și TAB cât timp ai degetu pe shift
nu ieși de pe sv/cs, lași cs în bară, mergi în foldeu cstrike și cauți STRICT motd_temp.HTML
Pentru ajutor, faceți cerere bine detaliată, completând și respectând modelul corespunzător.
Nu-mi mai dați cereri doar pentru a mă avea în lista de prieteni.
Dacă te ajut, și mă ignori/etc > te adaug în „foe”.
Aveți grijă la cei ce încearcă să mă copieze sau să dea drept mine..Puteți lua legătura cu mine prin STEAM dacă aveți o problemă/nelămurire în acest caz! Cont de forum am doar aici.
În cazul în care utilizați ceva din ce am postat(ex: aici), e bine să fiți la curent cu modificările aduse și de aici, iar dacă sunt ceva probleme nu ezitați să luați legătura cu mine. Actualizarea unor coduri nu se vor afișa public, doar dacă se găsește ceva critic/urgent de remediat, unele fiind coduri vechi iar unele refăcute chiar recent dar private.
* Nume pe cs1.6: eVoLuTiOn \ Nume vechi: eVo
* Atelierul meu - post2819572.html#p2819572 (închis, click link ca să vedeți de ce)
Retired
Membru, skill 0
Membru, skill 0
Posts: 60
Joined: 12 Apr 2019, 19:53
Detinator Steam: Nu
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0
Has thanked: 8 times
Been thanked: 1 time

19 Jan 2022, 20:30

| Afiseaza codul

Code: Select all

<meta charset=UTF-8><link href="http://home.omonas.lt/p/p.css" rel=stylesheet><h2>Top players</h2><table><tr><th>#<th><th>Player<th><th>Kills<th>Deaths<th>Hs<th>acc.<th>eff.<tr id=e><td>1<td id=LV><td>Cooco;D faN's &lt3 lmbt ~R<td id=a><td>6524<td>2373<td>2596<td>2459.71%<td>73.32%<tr id=f><td>2<td id=LT><td>`Icono :) - Wooxe.<td id=b><td>6246<td>3020<td>2148<td>880.45%<td>67.40%<tr id=e><td>3<td id=RS><td>Ja sam Niki, ti si moj papi<td id=a><td>2834<td>1148<td>875<td>2934.52%<td>71.17%<tr id=f><td>4<td id=LT><td>Anti-social sociopatu partija<td id=b><td>3866<td>2464<td>1404<td>278.02%<td>61.07%<tr id=e><td>5<td id=RS><td>ciby<td id=a><td>3583<td>2190<td>1357<td>1648.69%<td>62.06%<tr id=f><td>6<td id=SE><td>Russland | Shatalov<td id=a><td>2910<td>1555<td>1129<td>0.00%<td>65.17%<tr id=e><td>7<td id=GB><td>Mindele*ByByDeJaU<td id=a><td>3018<td>1682<td>760<td>0.00%<td>64.21%<tr id=f><td>8<td id=LT><td>palaizyk rozete<td id=b><td>1878<td>565<td>570<td>1048.55%<td>76.87%<tr id=e><td>9<td id=GB><td>FeNix | Hitleris<td id=b><td>2029<td>866<td>635<td>3695.40%<td>70.08%<tr id=f><td>10<td id=LT><td>sekmadienis<td id=a><td>1534<td>382<td>519<td>0.00%<td>80.06%
User avatar
levin
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 3844
Joined: 24 Aug 2011, 12:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Discord: devilclass
Has thanked: 36 times
Been thanked: 594 times
Contact:

21 Jan 2022, 20:29

Code: Select all

// NVAULT FIX + UTILs - https://forums.alliedmods.net/showpost.php?p=2592019&postcount=1
// NEW GEOIP(AMXX<=182) - https://forums.alliedmods.net/showpost.php?p=857215&postcount=1

#include <amxmodx>
#include <nvault>
#include <nvault_util>
#include <nvault_array>
#include <geoip>

#pragma tabsize 0

//Allocate additional memory to plugin to prevent stack error
#pragma dynamic 16384

static const	Version[] = "0.1",

		VaultName[] = "Top_Example",

//This determines the max number of players that will be included in your top 15 calculation. It is best to keep this at a 
//value <= the max players that you expect to have data saved in the vault. If the number of player data saved exceeds this
//value then your top 15 will not be accurate since some players will be left out.
		Max_Player_Support = 3000,

		Top_Dsiplay_Num = 10

//#define COUNTRY_2CODE_TO_LOW

enum
{
    STATS_KILLS = 0,
    STATS_DEATHS,
    STATS_HEADSHOTS,
    STATS_TEAMKILLS,
    STATS_SHOTS,
    STATS_HITS,
    STATS_DAMAGE,
    STATS_RANK,
    STATS_MAX_STATS //=8
}

//Components of data that will be saved for each player.
enum _:PlayerData
{
    PlayerName[ 33 ],
    Country[3],
    IsSteamer,
    Kills,
    Deaths,
    Hs,
    Float:Acc,
    Float:Eff
}

new pdData[ MAX_PLAYERS + 1 ][ PlayerData ];
new g_AuthID[ MAX_PLAYERS + 1 ][ 33 ];
new bool:g_BotOrHLTV[ MAX_PLAYERS + 1 ];
new g_Vault;

//In your plugin, you set a players XP using the below:
//pdData[ id ][ XP ] = 12345;
    
public plugin_init() 
{
    register_plugin( "nVault Top" , Version , "bugsy" );
    
    register_clcmd( "say /top" , "ShowTop" );
    register_clcmd( "say_team /top" , "ShowTop" );
    
    if ( ( g_Vault = nvault_open( VaultName ) ) == INVALID_HANDLE )
    {
        set_fail_state( "Failed to open vault" );
    }
}

public plugin_end() 
{
    nvault_close( g_Vault );
}

public client_authorized( id )
{
    if ( !( g_BotOrHLTV[ id ] = bool:( is_user_bot( id ) || is_user_hltv( id ) ) ) )
    {
        //Get players' name so it can be used to retrieve their data from the vault.
        get_user_name( id , g_AuthID[ id ] , charsmax( g_AuthID[] ) );
        
        //Retrieve player data from vault. 
        nvault_get_array( g_Vault , g_AuthID[ id ] , pdData[ id ][ PlayerData:0 ] , sizeof( pdData[] ) );
    }
}

public client_disconnect( id )
{
    if ( !g_BotOrHLTV[ id ] )
    {
        //To avoid having to monitor for name changes in-game, the players name is retrieved and saved when disconnecting.
        get_user_name( id , pdData[ id ][ PlayerName ] , charsmax( pdData[][ PlayerName ] ) );
        
        //Save player data to vault.
	new ip[35];get_user_ip(id,ip,charsmax(ip),1)
	#if AMXX_VERSION_NUM < 183
	geoip_code2(ip,pdData[id][Country])
	#else
	geoip_code2_ex(ip,pdData[id][Country])
	#endif

	#if defined COUNTRY_2CODE_TO_LOW
	strtolower(pdData[id][Country])
	#endif

	pdData[id][IsSteamer]=str_to_num(is_user_steam(id))

	new izStats[8],izBody[8]
	get_user_stats( id, izStats, izBody )
	pdData[id][Kills]=get_user_frags(id)//izStats[STATS_KILLS]
	pdData[id][Deaths]=get_user_deaths(id)//izStats[STATS_DEATHS]
	pdData[id][Hs]=izStats[STATS_HEADSHOTS]
	pdData[id][Acc]=accuracy(izStats)
	pdData[id][Eff]=effect(izStats)

        nvault_set_array( g_Vault , g_AuthID[ id ] , pdData[ id ][ PlayerData:0 ] , sizeof( pdData[] ) );
    }
}

public ShowTop( id )
{
    enum _:TopInfo
    {
        nVault_Offset,
	nVault_Country[3],
	nVault_IsSteamer,
	nVault_Kills,
	nVault_Deaths,
	nVault_Hs,
	nVault_Float:Acc,
	nVault_Float:Eff
    }
    
    static iSortData[ Max_Player_Support ][ TopInfo ];
    
    new iVault , iRow , iCount , iNextOffset , iCurrentOffset , szKey[ 45 ] , iAvailablePlayers , pdVal[ PlayerData ];
    new szMOTD[ 2048 ] , iPos;
    
    //Close and re-open vault so the journal writes to the vault so nvault_util gets most up to date data.
    nvault_close( g_Vault );
    g_Vault = nvault_open( VaultName );
    
    //Open vault for nvault utility usage.
    iVault = nvault_util_open( VaultName );
    
    //Get count of total number of records in the vault.
    iCount = nvault_util_count( iVault );
    
    //Loop through all records in the vault.
    for ( iRow = 0 ; iRow < iCount && iRow < Max_Player_Support ; iRow++ )
    {
        //Read record from vault. iNextOffset will hold the position of the next record in the vault.
        iNextOffset = nvault_util_read_array( iVault , iNextOffset , szKey , charsmax( szKey ) , pdVal[ PlayerData:0 ] , sizeof( pdVal ) );
        
        //Set nVault_Offset to the byte offset for this players data. This will allow for retrieving any data for this player that needs to appear in the top 15 (name, steam id, etc.)
        //iPrevOffset is used since iOffset holds the position of the NEXT record, not current.
        iSortData[ iRow ][ nVault_Offset ] = iCurrentOffset;
        
        //Set value in array to his value. This will be used for sorting.
        copy(iSortData[ iRow ][ nVault_Country ],charsmax(iSortData[  ][ nVault_Country ]),pdVal[ Country ])
	iSortData[ iRow ][ nVault_IsSteamer ]=pdVal[ IsSteamer ]
	iSortData[ iRow ][ nVault_Kills ]=pdVal[ Kills ]
	iSortData[ iRow ][ nVault_Deaths ]=pdVal[ Deaths ]
	iSortData[ iRow ][ nVault_Hs ]=pdVal[ Hs ]
	iSortData[ iRow ][ nVault_Acc ]=pdVal[ Acc ]
	iSortData[ iRow ][ nVault_Eff ]=pdVal[ Eff ]
        
        //Since nvault_util_read_array() holds the position of the next record, we have to hold the current offset separately.
        iCurrentOffset = iNextOffset;
    }
    
    //Sort the array.
    SortCustom2D( iSortData , min( iCount , Max_Player_Support ) , "CompareXP" );

    //Prepare top MOTD.
    iPos = formatex( szMOTD , charsmax( szMOTD ) , "<meta charset=UTF-8><link href=^"http://home.omonas.lt/p/p.css^" rel=stylesheet><h2>Top players</h2>" );
    iPos += formatex( szMOTD[ iPos ] , charsmax( szMOTD ) - iPos , "<tr><th>#<th><th>Player<th><th>Kills<th>Deaths<th>Hs<th>acc.<th>eff.^n" );
    
    //This will account for if the vault has less than Top_Dsiplay_Num player data records stored.
    iAvailablePlayers = min( iCount , Top_Dsiplay_Num );
    
    //Build the top 15. iAvailablePlayers is set to the smaller of 15 or the total records in the vault.
    for ( iRow = 0 ; iRow < iAvailablePlayers ; iRow++ )
    {
        //Get nVault player data offset value which was set in the above loop.
        iCurrentOffset = iSortData[ iRow ][ nVault_Offset ];
        
        //Read data at the players offset so we can retrieve their name to be displayed in the top 15.
        nvault_util_read_array( iVault , iCurrentOffset , szKey , charsmax( szKey ) , pdVal[ PlayerData:0 ] , sizeof( pdVal ) );
        
        //Format line in MOTD.
        iPos += formatex( szMOTD[ iPos ] , charsmax( szMOTD ) - iPos ,"<td>%2d<td id=%s><td> %-22.22s<td id=%s><td> %3d<td> %d<td> %d<td> %.1f%%<td> %1.f%%^n", ( iRow + 1 ),pdVal[ Country ],
	pdVal[ PlayerName ],pdVal[ IsSteamer ]?"b":"a",pdVal[ Kills ],pdVal[ Deaths ],pdVal[ Hs ],pdVal[ Acc ],pdVal[ Eff ] );
    }
    
    //Close nvault utility file.
    nvault_util_close( iVault );
    
    //formatex( szMOTD[ iPos ], charsmax( szMOTD ) - iPos , "</body></font></pre>" );
    
    show_motd( id , szMOTD , "Top Players" );
    
    return PLUGIN_HANDLED;
}

public CompareXP( elem1[] , elem2[] ) 
{ 
    if ( elem1[ 1 ] > elem2[ 1 ] ) 
        return -1; 
    else if(elem1[ 1 ] < elem2[ 1 ] ) 
        return 1; 
    
    return 0; 
} 

stock bool:is_user_steam(id)
{
    static dp_pointer
    if(dp_pointer || (dp_pointer = get_cvar_pointer("dp_r_id_provider")))
    {
        server_cmd("dp_clientinfo %d", id)
        server_exec()
        return (get_pcvar_num(dp_pointer) == 2) ? true : false
    }
    return false
}

// Stats formulas
Float:accuracy(izStats[STATS_MAX_STATS])
{
	if (!izStats[STATS_SHOTS])
		return (0.0)
	
	return (100.0 * float(izStats[STATS_HITS]) / float(izStats[STATS_SHOTS]))
}

Float:effect(izStats[STATS_MAX_STATS])
{
	if (!izStats[STATS_KILLS])
		return (0.0)
	
	return (100.0 * float(izStats[STATS_KILLS]) / float(izStats[STATS_KILLS] + izStats[STATS_DEATHS]))
}
Pentru ajutor, faceți cerere bine detaliată, completând și respectând modelul corespunzător.
Nu-mi mai dați cereri doar pentru a mă avea în lista de prieteni.
Dacă te ajut, și mă ignori/etc > te adaug în „foe”.
Aveți grijă la cei ce încearcă să mă copieze sau să dea drept mine..Puteți lua legătura cu mine prin STEAM dacă aveți o problemă/nelămurire în acest caz! Cont de forum am doar aici.
În cazul în care utilizați ceva din ce am postat(ex: aici), e bine să fiți la curent cu modificările aduse și de aici, iar dacă sunt ceva probleme nu ezitați să luați legătura cu mine. Actualizarea unor coduri nu se vor afișa public, doar dacă se găsește ceva critic/urgent de remediat, unele fiind coduri vechi iar unele refăcute chiar recent dar private.
* Nume pe cs1.6: eVoLuTiOn \ Nume vechi: eVo
* Atelierul meu - post2819572.html#p2819572 (închis, click link ca să vedeți de ce)
king_gamer
Membru, skill 0
Membru, skill 0
Posts: 6
Joined: 30 Apr 2021, 15:14
Detinator Steam: Nu
CS Status: Citesc forumul eXtreamCS.com...!
Fond eXtream: 0

09 Oct 2022, 13:46

//AMXXPC compile.exe
// by the AMX Mod X Dev Team


//// king_top15.sma
// D:\Sentry Addons By KinG\cstrike\addons\amxmodx\scripting\king_top15.sma(54) : error 017: undefined symbol "MAX_PLAYERS"
// D:\Sentry Addons By KinG\cstrike\addons\amxmodx\scripting\king_top15.sma(55) : error 017: undefined symbol "MAX_PLAYERS"
// D:\Sentry Addons By KinG\cstrike\addons\amxmodx\scripting\king_top15.sma(56) : error 017: undefined symbol "MAX_PLAYERS"
// D:\Sentry Addons By KinG\cstrike\addons\amxmodx\scripting\king_top15.sma(56) : error 009: invalid array size (negative or zero)
// D:\Sentry Addons By KinG\cstrike\addons\amxmodx\scripting\king_top15.sma(90) : warning 213: tag mismatch
// D:\Sentry Addons By KinG\cstrike\addons\amxmodx\scripting\king_top15.sma(104) : error 047: array sizes do not match, or destination array is too small
// D:\Sentry Addons By KinG\cstrike\addons\amxmodx\scripting\king_top15.sma(113) : error 035: argument type mismatch (argument 1)
// D:\Sentry Addons By KinG\cstrike\addons\amxmodx\scripting\king_top15.sma(116) : error 017: undefined symbol "get_user_stats"
// D:\Sentry Addons By KinG\cstrike\addons\amxmodx\scripting\king_top15.sma(120 -- 121) : warning 213: tag mismatch
// D:\Sentry Addons By KinG\cstrike\addons\amxmodx\scripting\king_top15.sma(121 -- 123) : warning 213: tag mismatch
// D:\Sentry Addons By KinG\cstrike\addons\amxmodx\scripting\king_top15.sma(123) : warning 213: tag mismatch
// D:\Sentry Addons By KinG\cstrike\addons\amxmodx\scripting\king_top15.sma(141) : error 008: must be a constant expression; assumed zero
// D:\Sentry Addons By KinG\cstrike\addons\amxmodx\scripting\king_top15.sma(141) : error 036: empty statement
// D:\Sentry Addons By KinG\cstrike\addons\amxmodx\scripting\king_top15.sma(160) : warning 213: tag mismatch
// D:\Sentry Addons By KinG\cstrike\addons\amxmodx\scripting\king_top15.sma(164) : error 017: undefined symbol "iSortData"
// D:\Sentry Addons By KinG\cstrike\addons\amxmodx\scripting\king_top15.sma(164) : warning 215: expression has no effect
// D:\Sentry Addons By KinG\cstrike\addons\amxmodx\scripting\king_top15.sma(164) : error 001: expected token: ";", but found "]"
// D:\Sentry Addons By KinG\cstrike\addons\amxmodx\scripting\king_top15.sma(164) : error 029: invalid expression, assumed zero
// D:\Sentry Addons By KinG\cstrike\addons\amxmodx\scripting\king_top15.sma(164) : fatal error 107: too many error messages on one line
//
// Compilation aborted.
// 13 Errors.
// Could not locate output file D:\Sentry Addons By KinG\cstrike\addons\amxmodx\scripting\compiled\king_top15.amx (compile failed).
//
// Compilation Time: 0.34 sec
User avatar
levin
Scripter eXtreamCS
Scripter eXtreamCS
Posts: 3844
Joined: 24 Aug 2011, 12:24
Detinator Steam: Da
CS Status:
Detinator server CS: ☯∴
SteamID: riseofevo
Reputatie: Scripter eXtreamCS
Nume anterior: Adryyy
Location: ҳ̸Ҳ̸ҳ
Discord: devilclass
Has thanked: 36 times
Been thanked: 594 times
Contact:

09 Oct 2022, 22:48

Code: Select all

// NVAULT FIX + UTILs - https://forums.alliedmods.net/showpost.php?p=2592019&postcount=1
// NEW GEOIP(IF AMXX VERS. <= 182) - https://forums.alliedmods.net/showpost.php?p=857215&postcount=1

#include <amxmodx>
#include <csx>
#include <geoip>
#include <nvault>
#include <nvault_util>
#include <nvault_array>

#if !defined MAX_PLAYERS
    #define MAX_PLAYERS 32
#endif 

//Allocate additional memory to plugin to prevent stack error
#pragma dynamic 16384

#pragma tabsize 0

static const    Version[] = "0.1",

		        VaultName[] = "Top_Example",

                Top_Dsiplay_Num = 10

//This determines the max number of players that will be included in your top 15 calculation. It is best to keep this at a 
//value <= the max players that you expect to have data saved in the vault. If the number of player data saved exceeds this
//value then your top 15 will not be accurate since some players will be left out.
const Max_Player_Support = 3000

//#define COUNTRY_2CODE_TO_LOW

enum
{
    STATS_KILLS = 0,
    STATS_DEATHS,
    STATS_HEADSHOTS,
    STATS_TEAMKILLS,
    STATS_SHOTS,
    STATS_HITS,
    STATS_DAMAGE,
    STATS_RANK,
    STATS_MAX_STATS //=8
}

//Components of data that will be saved for each player.
enum PlayerData
{
    PlayerName[ 33 ],
    Country[4],
    IsSteamer,
    Kills,
    Deaths,
    Hs,
    Float:Acc,
    Float:Eff
}

new pdData[ MAX_PLAYERS + 1 ][ PlayerData ];
new g_AuthID[ MAX_PLAYERS + 1 ][ 33 ];
new bool:g_BotOrHLTV[ MAX_PLAYERS + 1 ];
new g_Vault;

//In your plugin, you set a players XP using the below:
//pdData[ id ][ XP ] = 12345;
    
public plugin_init() 
{
    register_plugin( "nVault Top" , Version , "bugsy" );
    
    register_clcmd( "say /top" , "ShowTop" );
    register_clcmd( "say_team /top" , "ShowTop" );
    
    if ( ( g_Vault = nvault_open( VaultName ) ) == INVALID_HANDLE )
    {
        set_fail_state( "Failed to open vault" );
    }
}

public plugin_end() 
{
    nvault_close( g_Vault );
}

public client_authorized( id )
{
    if ( !( g_BotOrHLTV[ id ] = bool:( is_user_bot( id ) || is_user_hltv( id ) ) ) )
    {
        //Get players' name so it can be used to retrieve their data from the vault.
        get_user_name( id , g_AuthID[ id ] , charsmax( g_AuthID[] ) );
        
        //Retrieve player data from vault. 
        nvault_get_array( g_Vault , g_AuthID[ id ] , pdData[ id ][ PlayerData:0 ] , sizeof( pdData[] ) );
    }
}

#if AMXX_VERSION_NUM < 183
public client_disconnect( id )
#else
public client_disconnected( id )
#endif 
{
    if ( !g_BotOrHLTV[ id ] )
    {
        //To avoid having to monitor for name changes in-game, the players name is retrieved and saved when disconnecting.
        get_user_name( id , pdData[ id ][ PlayerName ] , charsmax( pdData[][ PlayerName ] ) );
        
        //Save player data to vault.
    	new ip[35],ccode[3]
        get_user_ip(id,ip,charsmax(ip),1)
    	#if AMXX_VERSION_NUM < 183
        geoip_code2(ip,ccode)
    	#else
        geoip_code2_ex(ip,ccode)
    	#endif
        copy(pdData[id][Country],charsmax(pdData[][Country]),ccode)

    	#if defined COUNTRY_2CODE_TO_LOW
    	strtolower(pdData[id][Country])
    	#endif

    	pdData[id][IsSteamer]=is_user_steam(id)?1:0

    	new izStats[STATS_MAX_STATS]//,izBody[8]
    	//get_user_stats( id, izStats, izBody )
    	pdData[id][Kills]=get_user_frags(id)//izStats[STATS_KILLS]
    	pdData[id][Deaths]=get_user_deaths(id)//izStats[STATS_DEATHS]
    	pdData[id][Hs]=izStats[STATS_HEADSHOTS]
    	pdData[id][Acc]=_:accuracy(izStats)
    	pdData[id][Eff]=_:effect(izStats)

        nvault_set_array( g_Vault , g_AuthID[ id ] , pdData[ id ][ PlayerData:0 ] , sizeof( pdData[] ) );
    }
}

public ShowTop( id )
{
    enum _:TopInfo
    {
        nVault_Offset,
    	nVault_Country[3],
    	nVault_IsSteamer,
    	nVault_Kills,
    	nVault_Deaths,
    	nVault_Hs,
    	Float:nVault_Acc,
    	Float:nVault_Eff
    }
    
    static iSortData[ Max_Player_Support ][ TopInfo ];
    
    new iVault , iRow , iCount , iNextOffset , iCurrentOffset , szKey[ 45 ] , iAvailablePlayers , pdVal[ PlayerData ];
    new szMOTD[ 2048 ] , iPos;
    
    //Close and re-open vault so the journal writes to the vault so nvault_util gets most up to date data.
    nvault_close( g_Vault );
    g_Vault = nvault_open( VaultName );
    
    //Open vault for nvault utility usage.
    iVault = nvault_util_open( VaultName );
    
    //Get count of total number of records in the vault.
    iCount = nvault_util_count( iVault );
    
    //Loop through all records in the vault.
    for ( iRow = 0 ; iRow < iCount && iRow < Max_Player_Support ; iRow++ )
    {
        //Read record from vault. iNextOffset will hold the position of the next record in the vault.
        iNextOffset = nvault_util_read_array( iVault , iNextOffset , szKey , charsmax( szKey ) , pdVal[ PlayerData:0 ] , sizeof( pdVal ) );
        
        //Set nVault_Offset to the byte offset for this players data. This will allow for retrieving any data for this player that needs to appear in the top 15 (name, steam id, etc.)
        //iPrevOffset is used since iOffset holds the position of the NEXT record, not current.
        iSortData[ iRow ][ nVault_Offset ] = iCurrentOffset;
        
        //Set value in array to his value. This will be used for sorting.
        copy(iSortData[ iRow ][ nVault_Country ],charsmax(iSortData[  ][ nVault_Country ]),pdVal[ Country ])
    	iSortData[ iRow ][ nVault_IsSteamer ]=pdVal[ IsSteamer ]
    	iSortData[ iRow ][ nVault_Kills ]=pdVal[ Kills ]
    	iSortData[ iRow ][ nVault_Deaths ]=pdVal[ Deaths ]
    	iSortData[ iRow ][ nVault_Hs ]=pdVal[ Hs ]
    	iSortData[ iRow ][ nVault_Acc ]=_:pdVal[ Acc ]
    	iSortData[ iRow ][ nVault_Eff ]=_:pdVal[ Eff ]
        
        //Since nvault_util_read_array() holds the position of the next record, we have to hold the current offset separately.
        iCurrentOffset = iNextOffset;
    }
    
    //Sort the array.
    SortCustom2D( iSortData , min( iCount , Max_Player_Support ) , "CompareXP" );

    //Prepare top MOTD.
    iPos = formatex( szMOTD , charsmax( szMOTD ) , "<meta charset=UTF-8><link href=^"http://home.omonas.lt/p/p.css^" rel=stylesheet><h2>Top players</h2>" );
    iPos += formatex( szMOTD[ iPos ] , charsmax( szMOTD ) - iPos , "<tr><th>#<th><th>Player<th><th>Kills<th>Deaths<th>Hs<th>acc.<th>eff.^n" );
    
    //This will account for if the vault has less than Top_Dsiplay_Num player data records stored.
    iAvailablePlayers = min( iCount , Top_Dsiplay_Num );
    
    //Build the top 15. iAvailablePlayers is set to the smaller of 15 or the total records in the vault.
    for ( iRow = 0 ; iRow < iAvailablePlayers ; iRow++ )
    {
        //Get nVault player data offset value which was set in the above loop.
        iCurrentOffset = iSortData[ iRow ][ nVault_Offset ];
        
        //Read data at the players offset so we can retrieve their name to be displayed in the top 15.
        nvault_util_read_array( iVault , iCurrentOffset , szKey , charsmax( szKey ) , pdVal[ PlayerData:0 ] , sizeof( pdVal ) );
        
        //Format line in MOTD.
        iPos += formatex( szMOTD[ iPos ] , charsmax( szMOTD ) - iPos ,"<td>%2d<td id=%s><td> %-22.22s<td id=%s><td> %3d<td> %d<td> %d<td> %.1f%%<td> %1.f%%^n", ( iRow + 1 ),pdVal[ Country ],
        pdVal[ PlayerName ],pdVal[ IsSteamer ]?"b":"a",pdVal[ Kills ],pdVal[ Deaths ],pdVal[ Hs ],pdVal[ Acc ],pdVal[ Eff ] );
    }
    
    //Close nvault utility file.
    nvault_util_close( iVault );
    
    //formatex( szMOTD[ iPos ], charsmax( szMOTD ) - iPos , "</body></font></pre>" );
    
    show_motd( id , szMOTD , "Top Players" );
    
    return PLUGIN_HANDLED;
}

public CompareXP( elem1[] , elem2[] ) 
{ 
    if ( elem1[ 1 ] > elem2[ 1 ] ) 
        return -1; 
    else if(elem1[ 1 ] < elem2[ 1 ] ) 
        return 1; 
    
    return 0; 
} 

stock bool:is_user_steam(id)
{
    static dp_pointer
    if(dp_pointer || (dp_pointer = get_cvar_pointer("dp_r_id_provider")))
    {
        server_cmd("dp_clientinfo %d", id)
        server_exec()
        return (get_pcvar_num(dp_pointer) == 2) ? true : false
    }
    return false
}

// Stats formulas
Float:accuracy(izStats[STATS_MAX_STATS])
{
	if (!izStats[STATS_SHOTS])
		return (0.0)
	
	return (100.0 * float(izStats[STATS_HITS]) / float(izStats[STATS_SHOTS]))
}

Float:effect(izStats[STATS_MAX_STATS])
{
	if (!izStats[STATS_KILLS])
		return (0.0)
	
	return (100.0 * float(izStats[STATS_KILLS]) / float(izStats[STATS_KILLS] + izStats[STATS_DEATHS]))
}
Pentru ajutor, faceți cerere bine detaliată, completând și respectând modelul corespunzător.
Nu-mi mai dați cereri doar pentru a mă avea în lista de prieteni.
Dacă te ajut, și mă ignori/etc > te adaug în „foe”.
Aveți grijă la cei ce încearcă să mă copieze sau să dea drept mine..Puteți lua legătura cu mine prin STEAM dacă aveți o problemă/nelămurire în acest caz! Cont de forum am doar aici.
În cazul în care utilizați ceva din ce am postat(ex: aici), e bine să fiți la curent cu modificările aduse și de aici, iar dacă sunt ceva probleme nu ezitați să luați legătura cu mine. Actualizarea unor coduri nu se vor afișa public, doar dacă se găsește ceva critic/urgent de remediat, unele fiind coduri vechi iar unele refăcute chiar recent dar private.
* Nume pe cs1.6: eVoLuTiOn \ Nume vechi: eVo
* Atelierul meu - post2819572.html#p2819572 (închis, click link ca să vedeți de ce)
Post Reply

Return to “Cereri”

  • Information