Raised This Month: $ Target: $400
 0% 

[REQ] Need someone to create this small easy plugin regarding knife


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xxxperts
Senior Member
Join Date: Oct 2013
Location: India
Old 05-29-2015 , 04:47   Re: [REQ] Need someone to create this small easy plugin regarding knife
Reply With Quote #1

Quote:
Originally Posted by Klatypaus View Post
thank you for the effort , but could you make it that it updates every round like in csstats... thanks alot though but I will need the top knife killers to be updated every round
i think that can't be done with nvault.
__________________
All my work is here
xxxperts is offline
Klatypaus
Member
Join Date: Jan 2015
Old 05-31-2015 , 06:02   Re: [REQ] Need someone to create this small easy plugin regarding knife
Reply With Quote #2

Quote:
Originally Posted by xxxperts View Post
i think that can't be done with nvault.
ok but any other way? Because we rarely change the map on my server and also live updates of the top knifers will be better
Klatypaus is offline
xxxperts
Senior Member
Join Date: Oct 2013
Location: India
Old 05-31-2015 , 11:53   Re: [REQ] Need someone to create this small easy plugin regarding knife
Reply With Quote #3

Knife Kills Plugin v0.1 [ UNTESTED ] - ( 31/05/2015 )


PHP Code:
/*
 * Declaration :
 *     ZOF 'X Plugins Comply With GNU General Public License.
 *  Knife Kills is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation, either version 3 of the License, or
 *     (at your option) any later version.
 * 
 *     Under no circumstances are you allowed to redistribute and/or modify
 *     it claming that you are the original author of such plugin/modification.
 * 
 *     Knife Kills is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 * 
 *     You should have received a copy of the GNU General Public License
 *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
 * 
 *     =========================================================================
 *     Contact : '[email protected]' | 'facebook.com/RP.ROHIT07'
 *     =========================================================================
 * 
 * Description :
 *     AMXX Knife Kills Plugin v0.1 By ZOF 'X ( Rohit Panchal ).
 * 
 * 
 * Change Log :
 *     v0.1 ( 31/05/2015 ) - Initial Release ( UNTESTED ).
 *
 */

#include < amxmodx >
#include < amxmisc >

#pragma semicolon         1
#define MAX_PLAYERS     32
#define MAX_BUFFER        2047
#define IsPlayer(%1)    ( 1 <= %1 <= iMaxPlayers )

new const PLUGIN[ ] = "Knife Kills";
new const 
VERSION[ ]= "0.1";
new const 
AUTHOR[ ] = "ZOF 'X";
new const 
PREFIX[ ] = "[AMXX]";

enum _:_mPlayerData {
    
    
szAuth35 ],
    
szName32 ],
    
szKills,
    
szDeaths
};

new Array:
pAuth;
new 
gSaveFile128 ], iMaxPlayers;
new 
szBufferMAX_BUFFER ] = 0;
new 
Trie:pNameTrie:pKillsTrie:pDeaths;
new 
gPlayerInfoMAX_PLAYERS ][ _mPlayerData ];

public 
plugin_init( ) {
    
    
register_pluginPLUGINVERSIONAUTHOR );
    
register_cvar"amxx_knife_kills_version"VERSIONFCVAR_SERVER );
    
    
get_datadirgSaveFilesizeofgSaveFile ) - );
    
addgSaveFilesizeofgSaveFile ) - 1"/knife_kills.ini" );
    
    
pAuth ArrayCreateMAX_PLAYERS);
    
pName TrieCreate( );
    
pKills TrieCreate( );
    
pDeaths TrieCreate( );
    
    
LoadDataFile( );
    
ArraySortpAuth"SortArray" );
    
MakeTOP15( );
    
    
register_clcmd"say /kniferank""cmdShowRank" );
    
register_clcmd"say /knifetop""cmdShowTop" );
    
    
register_event"DeathMsg""EventDead""a""1>0""4&knife" );
    
register_logevent"EventRoundStart"2"1=Round_Start" );
    
}

public 
plugin_end( ) {
    
    
ArraySortpAuth"SortArray" );
    
SaveDataFile( );
    
    
ArrayDestroypAuth );
}

public 
client_putinserverindex ) {
    
    
get_user_nameindexgPlayerInfoindex ][ szName ], sizeofgPlayerInfo[ ][ szName ] ) - );
    
get_user_authidindexgPlayerInfoindex ][ szAuth ], sizeofgPlayerInfo[ ][ szAuth ] ) - );
    
    if( 
TrieKeyExistspNamegPlayerInfoindex ][ szAuth ] ) ) {
        
        
LoadDataindex );
    } else {
        
        
CreateDataindex );
    }
    
    
UpdateDataindextrue );
}

public 
client_infochangedindex ) {
    
    if( 
is_user_connectedindex ) ) {
        
        static 
tNewNameMAX_PLAYERS ];
        
get_user_infoindex"name"tNewNamesizeoftNewName ) - );
        
        if( 
equaltNewNamegPlayerInfoindex ][ szName ] ) ) {
            
            return 
PLUGIN_HANDLED;
        } else {
            
            
copygPlayerInfoindex ][ szName ], sizeofgPlayerInfo[ ][ szName ] ) - 1tNewName );
            
UpdateDataindextrue );
        }
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
cmdShowRankindex ) {
    
    static 
iRankiSize;
    
    
iRank GetRankindex );
    
iSize ArraySizepAuth );
    
    if( !
iRank ) {
        
        
client_printindexprint_chat"%s You are not ranked"PREFIX );
    } else {
        
        
client_printindexprint_chat"%s You're rank is %d of %d with %d kills and %d deaths"PREFIXiRankiSizegPlayerInfoindex ][ szKills ], gPlayerInfoindex ][ szDeaths ] );
    }
    
    return 
PLUGIN_CONTINUE;
}

public 
cmdShowTopindex ) {
    
    
show_motdindexszBuffer"TOP 15" );
    
    return 
PLUGIN_CONTINUE;
}

public 
EventDead( ) {
    
    static 
iKilleriVictim;
    
    
iKiller read_data);
    
iVictim read_data);
    
    if( 
iKiller && IsPlayeriKiller ) && iKiller != iVictim ) {
        
        
gPlayerInfoiKiller ][ szKills ]++;
        
UpdateDataiKillerfalse );
    }
    
    if( 
iVictim && IsPlayeriVictim ) ) {
        
        
gPlayerInfoiVictim ][ szDeaths ]++;
        
UpdateDataiVictimfalse );
    }
}

public 
EventRoundStart( ) {
    
    static 
PlayersMAX_PLAYERS ], iNumid;
    
    
get_playersPlayersiNum );
    
    while( --
iNum >= ) {
        
        
id PlayersiNum ];
        
        
UpdateDataidfalse );
    }
    
    
ArraySortpAuth"SortArray" );
    
SaveDataFile( );
    
MakeTOP15( );
}

public 
SortArray( Array:aArrayiPos1iPos2iData[ ], iDataSize ) {
    
    static 
tData1MAX_PLAYERS ], tData2MAX_PLAYERS ];
    
    
ArrayGetStringaArrayiPos1tData1sizeoftData1 ) - );
    
ArrayGetStringaArrayiPos2tData2sizeoftData2 ) - );
    
    static 
tKills1tKills2;
    
    
TrieGetCellpKillstData1tKills1 );
    
TrieGetCellpKillstData2tKills2 );
    
    static 
tDeaths1tDeaths2;
    
    
TrieGetCellpDeathstData1tDeaths1 );
    
TrieGetCellpDeathstData2tDeaths2 );
    
    return( 
tKills1 tDeaths1 tKills2 tDeaths2 ) ? -: ( ( tKills1 tDeaths1 tKills2 tDeaths2 ) ? );
}

LoadDataFile( ) {
    
    static 
WriteFile;
    
WriteFile fopengSaveFile"r" );
    
    if( !
WriteFile ) return PLUGIN_HANDLED;    
    static 
tData128 ], tAuthMAX_PLAYERS ], tNameMAX_PLAYERS ], tKills], tDeaths];
    
    while( !
feofWriteFile ) ) {
        
        
fgetsWriteFiletDatasizeoftData ) - );
        
        if( !
strlentData ) ) {
            
            continue;
        } else {
            
            
parsetDatatAuthsizeoftAuth ) - 1tNamesizeoftName ) - 1tKillssizeoftKills ) - 1tDeathssizeoftDeaths ) - );
            
            
ArrayPushStringpAuthtAuth );
            
TrieSetStringpNametAuthtName );
            
TrieSetCellpKillstAuthstr_to_numtKills ) );
            
TrieSetCellpDeathstAuthstr_to_numtDeaths ) );
        }
    }
    
    
fcloseWriteFile );
    
    return 
PLUGIN_CONTINUE;
}

SaveDataFile( ) {
    
    static 
WriteFile;
    
WriteFile fopengSaveFile"w+" );
    
    if( !
WriteFile ) return PLUGIN_HANDLED;
    
    static 
iPositioniSizetAuthMAX_PLAYERS ], tNameMAX_PLAYERS ], tKillstDeaths;
    
iSize ArraySizepAuth );
    
    for( 
iPosition 0iPosition iSizeiPosition++ ) {
        
        
ArrayGetStringpAuthiPositiontAuthsizeoftAuth ) - );
        
TrieGetStringpNametAuthtNamesizeoftName ) - );
        
TrieGetCellpKillstAuthtKills );
        
TrieGetCellpDeathstAuthtDeaths );
        
        
fprintfWriteFile"%s ^"%s^" %d %d^n"tAuthtNametKillstDeaths );
    }
    
    
fcloseWriteFile );
    
    return 
PLUGIN_CONTINUE;
    
}

CreateDataindex ) {
    
    
gPlayerInfoindex ][ szKills ] = 0;
    
gPlayerInfoindex ][ szDeaths ] = 0;
    
    
ArrayPushStringpAuthgPlayerInfoindex ][ szAuth ] );
    
TrieSetStringpNamegPlayerInfoindex ][ szAuth ], gPlayerInfoindex ][ szName ] );
    
}

LoadDataindex ) {
    
    
TrieGetCellpKillsgPlayerInfoindex ][ szAuth ], gPlayerInfoindex ][ szKills ] );
    
TrieGetCellpDeathsgPlayerInfoindex ][ szAuth ], gPlayerInfoindex ][ szDeaths ] );
    
}

UpdateDataindexbool:tName ) {
    
    if( 
tName ) {
        
        
TrieSetStringpNamegPlayerInfoindex ][ szAuth ], gPlayerInfoindex ][ szName ] );
    } else {
        
        
TrieSetCellpKillsgPlayerInfoindex ][ szAuth ], gPlayerInfoindex ][ szKills ] );
        
TrieSetCellpDeathsgPlayerInfoindex ][ szAuth ], gPlayerInfoindex ][ szDeaths ] );
    }
    
}

GetRankindex ) {
    
    static 
iPositioniSizetAuthMAX_PLAYERS ];
    
iSize ArraySizepAuth );
    
    for( 
iPosition 0iPosition iSizeiPosition++ ) {
        
        
ArrayGetStringpAuthiPositiontAuthsizeoftAuth ) );
        
        if( 
equaltAuthgPlayerInfoindex ][ szAuth ] ) ) {
            
            return 
iPosition 1;
        }
    }
    
    return 
0;
    
}

MakeTOP15( ) {
    
    static 
iLen;
    
    
iLen formatexszBuffersizeofszBuffer ) - 1,
    
"<STYLE>\
    body{background:#FFFFFF;color:#4f6b72;font-family:sans-serif;font: normal 11px auto;}\
    table{border-style:solid;border-width:1px;border-color:#FFFFFF;font-size:11px;font-family:sans-serif}\
    th{border-right:1px solid #C1DAD7;border-bottom: 1px solid #C1DAD7;border-top:1px solid #C1DAD7;padding:8px 8px 8px;}\
    td{border-right:1px solid #C1DAD7;border-bottom:1px solid #C1DAD7;padding:6px 8px 6px;}\
    </STYLE>\
    <table align=center width=100%% cellpadding=2 cellspacing=0 border=0>" 
);
    
    
iLen += formatexszBufferiLen ], sizeofszBuffer ) - iLen,
    
"<tr align=left bgcolor=#CAE8EA>\
    <th width=5%% align=left> # \
    <th width=65%% align=left> Nick \
    <th width=15%%> Kills \
    <th width=15%%> Deaths" 
);
    
    static 
iPositioniArraySizeiSizetAuthMAX_PLAYERS ], tNameMAX_PLAYERS ], tKillstDeaths;
    
    
iArraySize ArraySizepAuth );
    
iSize clampiArraySize015 );
    
    for( 
iPosition 0iPosition iSizeiPosition++ ) {
        
        
ArrayGetStringpAuthiPositiontAuthsizeoftAuth ) - );
        
TrieGetStringpNametAuthtNamesizeoftName ) - );
        
TrieGetCellpKillstAuthtKills );
        
TrieGetCellpDeathstAuthtDeaths );
        
        
iLen += formatexszBufferiLen ], sizeofszBuffer ) - iLen"<tr align=left bgcolor=#FFFFFF>" );
        
iLen += formatexszBufferiLen ], sizeofszBuffer ) - iLen"<td>%d"iPosition );
        
iLen += formatexszBufferiLen ], sizeofszBuffer ) - iLen"<td align=left>%s"tName );
        
iLen += formatexszBufferiLen ], sizeofszBuffer ) - iLen"<td>%d"tKills );
        
iLen += formatexszBufferiLen ], sizeofszBuffer ) - iLen"<td>%d"tDeaths );
        
    }
    
    
iLen += formatexszBufferiLen ], sizeofszBuffer ) - iLen"</table></body>" );
    

Attached Files
File Type: sma Get Plugin or Get Source (knife_kills.sma - 281 views - 9.8 KB)
__________________
All my work is here
xxxperts 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 20:21.


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