Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <amxmisc>
- #define PLUGIN "[DD2] (MVP) Najlepszy gracz"
- #define VERSION "0.07"
- #define AUTHOR "Leqally"
- #define MAX_PLAYERS 32
- //rozrabiaka
- #define PREPARE_HUD() set_dhudmessage(0, 255, 0, -1.0, 0.13, 0, 6.0, 6.0,_,_,2)
- //koniec szalenstwa
- #define PREPARE_HUD2() set_hudmessage(42, 42, 255, 0.62, -1.0, 0, 6.0, 6.0,_,_,1)
- //#define DEBUG
- new g_points[MAX_PLAYERS+1][2];
- new g_pointsThisRound[MAX_PLAYERS+1][2];
- new g_cvarLimit,g_cvarEndShow;
- public plugin_init(){
- register_plugin(PLUGIN, VERSION, AUTHOR);
- register_event("DeathMsg","onDeath","a");
- register_event("TextMsg", "resetAll", "a", "2&#Game_will_restart_in" );
- register_event("TextMsg", "resetAll", "a", "2&#Game_C");
- register_logevent("onEndRound", 2, "1=Round_End")
- register_logevent("resetAllThisRound", 2, "1=Round_Start")
- g_cvarLimit=register_cvar("amx_spree_limit","5");
- g_cvarEndShow=register_cvar("amx_endshow","1");
- #if defined DEBUG
- register_concmd("show_points","cmd_show_points",ADMIN_KICK);
- #endif
- }
- reset(id){
- g_points[id][0]=0;
- g_points[id][1]=0;
- }
- resetRound(id){
- g_pointsThisRound[id][0]=0;
- g_pointsThisRound[id][1]=0;
- }
- public resetAllThisRound(){
- for(new i=0;i<=MAX_PLAYERS;i++)
- resetRound(i);
- }
- public resetAll(){
- for(new i=0;i<=MAX_PLAYERS;i++)
- reset(i);
- }
- public onEndRound(){
- if(get_pcvar_num(g_cvarEndShow))
- set_task(0.3,"podsumowanie");
- }
- public podsumowanie(){
- new bool:double=false;
- new id=0;
- for(new i=1;i<=MAX_PLAYERS;i++){
- if(g_pointsThisRound[id][0]==g_pointsThisRound[i][0]){
- if(g_pointsThisRound[id][1] == g_pointsThisRound[i][1]){
- double=true;
- }
- else if(g_pointsThisRound[id][1] < g_pointsThisRound[i][1]){
- id=i;
- double=false;
- }
- }
- else if(g_pointsThisRound[id][0] < g_pointsThisRound[i][0]){
- id=i;
- double=false;
- }
- }
- if(!double && id){
- PREPARE_HUD();
- new szNick[33];
- get_user_name(id,szNick,32);
- show_dhudmessage(0, "[DD2] %s %d zabojstwa oraz %d headshot",szNick,g_pointsThisRound[id][0],g_pointsThisRound[id][1]);
- }
- }
- public client_putinserver(id){
- reset(id);
- resetRound(id);
- }
- public client_disconnect(id){
- reset(id);
- resetRound(id);
- }
- public onDeath(){
- new kid=read_data(1);
- new vid=read_data(2);
- log_amx("%d->%d",kid,vid);
- if(!is_user_connected(kid)){
- reset(vid);
- return PLUGIN_CONTINUE;
- }
- log_amx("(2)%d->%d",kid,vid);
- g_points[kid][0]++;
- g_pointsThisRound[kid][0]++;
- if(read_data(3)){
- g_points[kid][1]++;
- g_pointsThisRound[kid][1]++;
- }
- if(get_pcvar_num(g_cvarLimit)<=0)
- return PLUGIN_CONTINUE;
- if(g_points[vid][0]>=get_pcvar_num(g_cvarLimit)){
- new szVicNick[33],szKilNick[33];
- get_user_name(vid,szVicNick,32);
- get_user_name(kid,szKilNick,32);
- PREPARE_HUD2();
- show_hudmessage(0, "Szalenstwo zabijania^n%s^n [%d w tym %d w glowe]^n^nzatrzymane przez:^n%s",szVicNick,g_points[vid][0],g_points[vid][1],szKilNick);
- }
- reset(vid);
- return PLUGIN_CONTINUE;
- }
- #if defined DEBUG
- public cmd_show_points(id,level,cid){
- if( !cmd_access(id, level, cid, 1))
- return PLUGIN_HANDLED;
- client_print(id,print_console,"----------Points------------");
- new Players[32];
- new playerCount, id2;
- get_players(Players, playerCount);
- for ( new i=0; i<playerCount; i++){
- id2 = Players[i];
- client_print(id,print_console,"[%d] P=%d(%dhs), PTR=%d(%dhs)",id2,g_points[id2][0],g_points[id2][1],g_pointsThisRound[id2][0],g_pointsThisRound[id2][1])
- }
- client_print(id,print_console,"--------------------------");
- return PLUGIN_HANDLED;
- }
- #endif
- stock __dhud_color;
- stock __dhud_x;
- stock __dhud_y;
- stock __dhud_effect;
- stock __dhud_fxtime;
- stock __dhud_holdtime;
- stock __dhud_fadeintime;
- stock __dhud_fadeouttime;
- stock __dhud_reliable;
- stock set_dhudmessage( red = 0, green = 160, blue = 0, Float:x = -1.0, Float:y = 0.65, effects = 2, Float:fxtime = 6.0, Float:holdtime = 3.0, Float:fadeintime = 0.1, Float:fadeouttime = 1.5, bool:reliable = false )
- {
- #define clamp_byte(%1) ( clamp( %1, 0, 255 ) )
- #define pack_color(%1,%2,%3) ( %3 + ( %2 << 8 ) + ( %1 << 16 ) )
- __dhud_color = pack_color( clamp_byte( red ), clamp_byte( green ), clamp_byte( blue ) );
- __dhud_x = _:x;
- __dhud_y = _:y;
- __dhud_effect = effects;
- __dhud_fxtime = _:fxtime;
- __dhud_holdtime = _:holdtime;
- __dhud_fadeintime = _:fadeintime;
- __dhud_fadeouttime = _:fadeouttime;
- __dhud_reliable = _:reliable;
- return 1;
- }
- stock show_dhudmessage( index, const message[], any:... )
- {
- new buffer[ 128 ];
- new numArguments = numargs();
- if( numArguments == 2 )
- {
- send_dhudMessage( index, message );
- }
- else if( index || numArguments == 3 )
- {
- vformat( buffer, charsmax( buffer ), message, 3 );
- send_dhudMessage( index, buffer );
- }
- else
- {
- new playersList[ 32 ], numPlayers;
- get_players( playersList, numPlayers, "ch" );
- if( !numPlayers )
- {
- return 0;
- }
- new Array:handleArrayML = ArrayCreate();
- for( new i = 2, j; i < numArguments; i++ )
- {
- if( getarg( i ) == LANG_PLAYER )
- {
- while( ( buffer[ j ] = getarg( i + 1, j++ ) ) ) {}
- j = 0;
- if( GetLangTransKey( buffer ) != TransKey_Bad )
- {
- ArrayPushCell( handleArrayML, i++ );
- }
- }
- }
- new size = ArraySize( handleArrayML );
- if( !size )
- {
- vformat( buffer, charsmax( buffer ), message, 3 );
- send_dhudMessage( index, buffer );
- }
- else
- {
- for( new i = 0, j; i < numPlayers; i++ )
- {
- index = playersList[ i ];
- for( j = 0; j < size; j++ )
- {
- setarg( ArrayGetCell( handleArrayML, j ), 0, index );
- }
- vformat( buffer, charsmax( buffer ), message, 3 );
- send_dhudMessage( index, buffer );
- }
- }
- ArrayDestroy( handleArrayML );
- }
- return 1;
- }
- stock send_dhudMessage( const index, const message[] )
- {
- message_begin( __dhud_reliable ? ( index ? MSG_ONE : MSG_ALL ) : ( index ? MSG_ONE_UNRELIABLE : MSG_BROADCAST ), SVC_DIRECTOR, _, index );
- {
- write_byte( strlen( message ) + 31 );
- write_byte( DRC_CMD_MESSAGE );
- write_byte( __dhud_effect );
- write_long( __dhud_color );
- write_long( __dhud_x );
- write_long( __dhud_y );
- write_long( __dhud_fadeintime );
- write_long( __dhud_fadeouttime );
- write_long( __dhud_holdtime );
- write_long( __dhud_fxtime );
- write_string( message );
- }
- message_end();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement