Raised This Month: $ Target: $400
 0% 

The best player of round


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
^^KaMaZZ~.^
Junior Member
Join Date: Jan 2009
Old 01-03-2009 , 18:24   The best player of round
Reply With Quote #1

I made a plugin, but can you check correctly?
Srry, my english is ulow

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

#define PLUGIN "BestPlayer"
#define VERSION "1.0"
#define AUTHOR "KaMaZZ"

new kills[33]
new 
deaths[33]

new 
bestplayerid

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_logevent("clear"2"1=Round_Start")
    
register_logevent("endround",2,"1=Round_End")    
}

public 
client_connect(id
{
    
kills[id] = 0
    deaths
[id] = 0
}

public 
client_death(attacker)
{
    
id attacker    
    kills
[id] += 1;
    
deaths[id] += 1;        
}
        
public 
endround() 
{
    new 
players[32], pnumid;
    
get_players(playerspnum);
    
    if(
pnum 2)
        return

    
bestplayer players[0];
    
    for(new 
i=0pnumi++)
    {
        
id players[i]
        if(
kills[id] > kills[bestplayer] || kills[id] == kills[bestplayer] && deaths[id] < deaths[bestplayer])
        
bestplayer id
    
}
    
    new 
name[32];
    
get_user_name(bestplayername31);

    
client_print(0print_chat"Najlepszy gracz rundy: %s"name)
    
client_print(0print_chat"Zdobyl %d fragow"kills[bestplayer])
    
// client_print(0, print_chat, "Trafil %d razy w leb", hsfrag)
}

public 
clear()
{
    new 
players[32], pnum
    get_players
(playerspnum);
    
kills[players[pnum]] = 0
    deaths
[players[pnum]] = 0
    bestplayer 
players[0];

EDIT:
Newer version
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

#define PLUGIN "BestPlayer"
#define VERSION "1.0"
#define AUTHOR "KaMaZZ"

new kills[33]
new 
deaths[33]

new 
bestplayer

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("DeathMsg""death_event""a""1>0");
    
register_logevent("wyczysc"2"1=Round_Start")
    
register_logevent("wiadomosc",2,"1=Round_End")    
}

public 
client_connect(id
{
    
kills[id] = 0
    deaths
[id] = 0
}

public 
death_event(id)
{
    new 
killer read_data(1);
    new 
victim read_data(2);    
    
        
kills[killer] += 1;
        
kills[victim] = 0;
        
deaths[killer] = 0;
        
deaths[victim] += 1;        
}
        
public 
wiadomosc() 
{
    new 
players[32], pnumid;
    
get_players(playerspnum);
    
    if(
pnum 2)
        return

    
bestplayer players[0];
    
    for(new 
i=0pnumi++)
    {
        
id players[i]
        if(
kills[id] > kills[bestplayer] || kills[id] == kills[bestplayer] && deaths[id] < deaths[bestplayer])
        
bestplayer id
    
}
    
    new 
name[32];
    
get_user_name(bestplayername31);

    
client_print(0print_chat"Najlepszy gracz rundy: %s"name)
    
client_print(0print_chat"Zdobyl %d fragow"kills[bestplayer])
    
// client_print(0, print_chat, "Trafil %d razy w leb", hsfrag)
}

public 
wyczysc()
{
    new 
players[32], pnum
    get_players
(playerspnum);
    
kills[players[pnum]] = 0
    deaths
[players[pnum]] = 0
    bestplayer 
players[0];


Last edited by ^^KaMaZZ~.^; 01-03-2009 at 21:07.
^^KaMaZZ~.^ is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 01-03-2009 , 21:19   Re: The best player of round
Reply With Quote #2

Might be mistakes. Going to sleep now. -.-
Code:
#include <amxmodx>   #define PLUGIN "The Best Player of Round" #define VERSION "1.0" #define AUTHOR "hleV"   new g_iKills[33], g_iDeaths[33], g_iMaxPlayers;   public plugin_init() {         register_plugin(PLUGIN, VERSION, AUTHOR);           register_event("HLTV", "eHLTV", "a", "1=0", "2=0");         register_event("DeathMsg", "eDeathMsg", "a", "1>0");           register_logevent("eRoundEnd", 2, "1=Round_End");           g_iMaxPlayers = get_maxplayers(); }   public eHLTV()         for (new i = 1; i <= g_iMaxPlayers; i++)                 g_iKills[i] = 0;   public eDeathMsg() {         new iKiller = read_data(1), iVictim = read_data(2);           if (iKiller == iVictim)                 return;           g_iKills[iKiller]++;         g_iDeaths[iVictim]++; }   public eRoundEnd() {         new iKills, iDeaths, iBest, szName[32], iPlayers[32], iNum, id;         get_players(iPlayers, iNum);           if (iNum < 2)                 return;           for (new i = 0; i < iNum; i++)         {                 id = iPlayers[i];                   if (g_iKills[id] > iKills || g_iKills[id] == iKills && g_iDeaths[id] < iDeaths)                 {                         iBest = id;                         g_iKills[id] = iKills;                 }         }           get_user_name(iBest, szName, sizeof(szName) - 1);           client_print(0, print_chat, "Najlepszy gracz rundy: %s", szName);         client_print(0, print_chat, "Zdobyl %d fragow", iKills); }
__________________
hleV is offline
Dores
Veteran Member
Join Date: Jun 2008
Location: You really don't wanna k
Old 01-03-2009 , 21:35   Re: The best player of round
Reply With Quote #3

PHP Code:
#include <amxmodx>

#define PLUGIN "BestPlayer"
#define VERSION "1.0"
#define AUTHOR "KaMaZZ"

new kills[33]

new 
bestplayer 0g_iMaxPlayers;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("DeathMsg""death_event""a""1>0");
    
register_logevent("wyczysc"2"1=Round_Start")
    
register_logevent("wiadomosc",2,"1=Round_End")
    
g_iMaxPlayers get_maxplayers();
}

public 
client_connect(id
{
    
kills[id] = 0
}

public 
death_event()
{
    static 
killer;
    if( ( 
killer read_data) ) != read_data) )
    {
        
killsread_data) ]++;
    }
}
        
public 
wiadomosc() 
{    
    if(
get_playersnum() < 2)
        return
    
    new 
deaths;
    
    for(new 
i=1<= g_iMaxPlayersi++)
    {
        
deaths get_user_deaths);
        
kills[i] -= deaths// kills[i] = kills[i] - deaths.
        
if(kills[i] >= kills[bestplayer])
            
bestplayer i;
    }
    
    new 
name[32];
    
get_user_name(bestplayername31);
    
    
client_print(0print_chat"Najlepszy gracz rundy: %s"name)
    
client_print(0print_chat"Zdobyl %d fragow"kills[bestplayer] + deaths)
    
// client_print(0, print_chat, "Trafil %d razy w leb", hsfrag)
}

public 
wyczysc()
{
    for( new 
<= g_iMaxPlayers i++ )
    {
        
kills] = 0;
    }

Sorry, hleV was faster, but try whatever you like(I think there's a mistake or two in hleV's code, like he said himself).
__________________
O o
/¯________________________
| IMMA FIRIN' MAH LAZOR!!!
\_¯¯¯

Last edited by Dores; 01-03-2009 at 21:38.
Dores is offline
^^KaMaZZ~.^
Junior Member
Join Date: Jan 2009
Old 01-04-2009 , 06:56   Re: The best player of round
Reply With Quote #4

I remaked second plugin, because first don't work (show bad player and 0 frags), now I need to show number of headshot
ColorChat copied from WarmUPPro
PHP Code:
#include <amxmodx>

#define PLUGIN "BestPlayer"
#define VERSION "1.0"
#define AUTHOR "KaMaZZ"

new g_iKills[33]
new 
g_iDeaths[33]
new 
g_hs[33]

new 
bestplayer 0g_iMaxPlayers;

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_event("DeathMsg""death_event""a""1>0");
    
register_event("HLTV""eHLTV""a""1=0""2=0");
    
register_logevent("wiadomosc",2,"1=Round_End")
    
g_iMaxPlayers get_maxplayers();
}

/*================================================================================================*/
/*************************************** [Color Chat] *********************************************/
/*=============================================================================R=E=Y=M=O=N==A=R=G=*/


enum Color
{
    
NORMAL 1// clients scr_concolor cvar color
    
GREEN// Green Color
    
TEAM_COLOR// Red, grey, blue
    
GREY// grey
    
RED// Red
    
BLUE// Blue
}

new 
TeamName[][] = 
{
    
"",
    
"TERRORIST",
    
"CT",
    
"SPECTATOR"
}

ColorChat(idColor:type, const msg[], {Float,Sql,Result,_}:...)
{
    new 
message[256];

    switch(
type)
    {
        case 
NORMAL// clients scr_concolor cvar color
        
{
            
message[0] = 0x01;
        }
        case 
GREEN// Green
        
{
            
message[0] = 0x04;
        }
        default: 
// White, Red, Blue
        
{
            
message[0] = 0x03;
        }
    }

    
vformat(message[1], 251msg4);

    
// Make sure message is not longer than 192 character. Will crash the server.
    
message[192] = '^0';

    new 
teamColorChangeindexMSG_Type;
    
    if(
id)
    {
        
MSG_Type MSG_ONE;
        
index id;
    } else {
        
index FindPlayer();
        
MSG_Type MSG_ALL;
    }
    
    
team get_user_team(index);
    
ColorChange ColorSelection(indexMSG_Typetype);

    
ShowColorMessage(indexMSG_Typemessage);
        
    if(
ColorChange)
    {
        
Team_Info(indexMSG_TypeTeamName[team]);
    }
}

ShowColorMessage(idtypemessage[])
{
    static 
bool:saytext_used;
    static 
get_user_msgid_saytext;
    if(!
saytext_used)
    {
        
get_user_msgid_saytext get_user_msgid("SayText");
        
saytext_used true;
    }
    
message_begin(typeget_user_msgid_saytext_id);
    
write_byte(id)        
    
write_string(message);
    
message_end();    
}

Team_Info(idtypeteam[])
{
    static 
bool:teaminfo_used;
    static 
get_user_msgid_teaminfo;
    if(!
teaminfo_used)
    {
        
get_user_msgid_teaminfo get_user_msgid("TeamInfo");
        
teaminfo_used true;
    }
    
message_begin(typeget_user_msgid_teaminfo_id);
    
write_byte(id);
    
write_string(team);
    
message_end();

    return 
1;
}

ColorSelection(indextypeColor:Type)
{
    switch(
Type)
    {
        case 
RED:
        {
            return 
Team_Info(indextypeTeamName[1]);
        }
        case 
BLUE:
        {
            return 
Team_Info(indextypeTeamName[2]);
        }
        case 
GREY:
        {
            return 
Team_Info(indextypeTeamName[0]);
        }
    }

    return 
0;
}

FindPlayer()
{
    new 
= -1;

    while(
<= get_maxplayers())
    {
        if(
is_user_connected(++i))
            return 
i;
    }

    return -
1;
}

public 
client_connect(id
{
    
g_iKills[id] = 0
    g_iDeaths
[id] = 0
}

public 
death_event()
{
    new 
iKiller read_data(1), iVictim read_data(2), iHitplace read_data(4);
    
    if (
iKiller == iVictim)
    {
        
g_iDeaths[iKiller]++;
        return;
    }
    
    
g_iKills[iKiller]++;
    
g_iDeaths[iVictim]++;
    
    if(
iHitplace == HIT_HEAD)
    {
        
g_hs[iKiller]++;
    }
}
        
public 
wiadomosc() 
{    
    if(
get_playersnum() < 2)
        return
 
    for(new 
i=1<= g_iMaxPlayersi++)
    {
    if (
g_iKills[i] > g_iKills[bestplayer] || g_iKills[i] == g_iKills[bestplayer] && g_iDeaths[i] < g_iDeaths[bestplayer] || g_iKills[i] == g_iKills[bestplayer] && g_hs[i] > g_hs[bestplayer])
    {
        
bestplayer i;
    }
    }
    
    new 
name[32];
    
get_user_name(bestplayername31);
    
    new 
iKills g_iKills[bestplayer]
    new 
iHS g_hs[bestplayer]
    
    
ColorChat(0GREEN,"^x03 FragArena: Najlepszy gracz w tej rundzie: %s"name)
    if(
iKills >= || iKills == 0)
    {
         
ColorChat(0GREEN"^x03 FragArena: Zdobyl %d fragow"iKills)
    }
    else if(
iKills && iKills 5)
    {
    
ColorChat(0GREEN"^x03 FragArena: Zdobyl %d fragi"iKills)
    }
    else if(
iKills == 1)
    {
    
ColorChat(0GREEN"^x03 FragArena: Zdobyl 1 fraga")
    }
    
ColorChat(0GREEN"^x03 FragArena: Ustrzelil %d hsow"iHS)
}

public 
eHLTV()
{
    for( new 
<= g_iMaxPlayers i++ )
    {
        
g_iKills] = 0;
        
g_iDeaths] = 0;
        
g_hs] = 0;
    }

^^KaMaZZ~.^ is offline
zwfgdlc
Senior Member
Join Date: May 2006
Old 01-04-2009 , 08:01   Re: The best player of round
Reply With Quote #5

http://www.amxmodx.org/funcwiki.php?go=func&id=915
zwfgdlc is offline
^^KaMaZZ~.^
Junior Member
Join Date: Jan 2009
Old 01-04-2009 , 09:12   Re: The best player of round
Reply With Quote #6

How to use it?
^^KaMaZZ~.^ 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 09:06.


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