Raised This Month: $ Target: $400
 0% 

[Get player with most kills]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dranix
Junior Member
Join Date: Aug 2010
Old 08-20-2010 , 06:35   [Get player with most kills]
Reply With Quote #1

Hello everyone,

I got question..

If a player kills someone it do: Kills[iAttacker]++;

Then on round end, I need to know who got most kill of each team.


How I can get that?

Thank you!
__________________
[Learning Pawn-Scripting]
Dranix is offline
lucas_7_94
Leche Loco
Join Date: Mar 2009
Location: Argentina
Old 08-20-2010 , 08:02   Re: [Get player with most kills]
Reply With Quote #2

you can look any part from my plugin.
__________________
ATWWMH - MiniDuels
Madness is like gravity, just need a little push.
lucas_7_94 is offline
Send a message via Skype™ to lucas_7_94
lazarev
Veteran Member
Join Date: Sep 2008
Old 08-20-2010 , 08:40   Re: [Get player with most kills]
Reply With Quote #3

PHP Code:
WinnerCheck()
{
    new 
players[32], numid;
    
get_playersplayersnum );
    for( new 
0numi++ )
    {
        
id players];
        if(
Kills[id] >= RequiredKills)
        {
            new 
szName33 ];
            
get_user_nameidszName32 );
            
client_print(0,print_chat "%s have won this event!"szName );
            return 
PLUGIN_CONTINUE;
        }
    }
    return 
PLUGIN_CONTINUE;

call WinnerCheck() at round end or at deathmsg.
lazarev is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 08-20-2010 , 11:32   Re: [Get player with most kills]
Reply With Quote #4

Quote:
Originally Posted by lazarev View Post
PHP Code:
WinnerCheck()
{
    new 
players[32], numid;
    
get_playersplayersnum );
    for( new 
0numi++ )
    {
        
id players];
        if(
Kills[id] >= RequiredKills)
        {
            new 
szName33 ];
            
get_user_nameidszName32 );
            
client_print(0,print_chat "%s have won this event!"szName );
            return 
PLUGIN_CONTINUE;
        }
    }
    return 
PLUGIN_CONTINUE;

call WinnerCheck() at round end or at deathmsg.
It's stupid, but you're missing a comma after print_chat. Also, he wants it for both teams so..

PHP Code:
WinnerCheck()
{
    new 
players[32], numid;
    
get_playersplayersnum );
    for( new 
0numi++ )
    {
        
id players];
        
        if( (
cs_get_user_team(id) == CS_TEAM_T) && (Kills[id] >= RequiredKills) )
        {
            new 
szName33 ];
            
get_user_nameidszName32 );
            
client_print(0print_chat"%s has the most kills on the terrorist team!"szName );
            
            return 
PLUGIN_CONTINUE;
        }
        
        if( (
cs_get_user_team(id) == CS_TEAM_CT) && (Kills[id] >= RequiredKills) )
        {
            new 
szName33 ];
            
get_user_nameidszName32 );
            
client_print(0print_chat"%s has the most kills on the counter-terrorist team!"szName );
            
            return 
PLUGIN_CONTINUE;
        }
    }
    
    return 
PLUGIN_CONTINUE;

Of course with the cs_get_user_team he'll have to use #include <cstrike> but it couldn't hurt anyone.
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
Dranix
Junior Member
Join Date: Aug 2010
Old 08-20-2010 , 12:09   Re: [Get player with most kills]
Reply With Quote #5

What about RequiredKills ?
__________________
[Learning Pawn-Scripting]
Dranix is offline
Kreation
Veteran Member
Join Date: Jan 2010
Location: Illinois
Old 08-20-2010 , 12:26   Re: [Get player with most kills]
Reply With Quote #6

With both of those versions he'd have to hardcode a max kill count or something, if he makes it like 20-30 and someone gets over that, then there will be two that are >= that number and there will be problems.

EDIT: Look at BF2 Mod, it has a map change type of winner thing you could use, but just use it on roundend and not map change.
__________________
Hi.
Kreation is offline
lazarev
Veteran Member
Join Date: Sep 2008
Old 08-20-2010 , 15:04   Re: [Get player with most kills]
Reply With Quote #7

Quote:
Originally Posted by GXLZPGX View Post
It's stupid, but you're missing a comma after print_chat. Also, he wants it for both teams so..
Of course with the cs_get_user_team he'll have to use #include <cstrike> but it couldn't hurt anyone.
I just took the code from mine.. and you r so pro.
lazarev is offline
GXLZPGX
Veteran Member
Join Date: Sep 2009
Old 08-20-2010 , 15:59   Re: [Get player with most kills]
Reply With Quote #8

Quote:
Originally Posted by lazarev View Post
I just took the code from mine.. and you r so pro.
If you're saying that I took your code, the way I think of it, why would I make a whole new code when you have already placed one in your post that I can revise.
__________________
Currently accepting payment US DOLLARS ONLY for custom plugins, contact me through PM.
GXLZPGX is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 08-20-2010 , 17:13   Re: [Get player with most kills]
Reply With Quote #9

Use a variable to store the current highest kill number and current highest player id. Check each players kills against it and if that player had a higher kill number update that variable with his kill# and id. After the loop you will be left with highest kill number and the players id.

Something like this, with the addition of team checks, should work for you. untested.
PHP Code:
MostKills()
{
    new 
iMostKills_id iMostKills_Num iMaxPlayers get_maxplayers();
    
    for ( new 
<= iMaxPlayers i++ )
    {
        if ( 
Kills] > iMostKills_Num )
        {
            
iMostKills_Num Kills];
            
iMostKills_id i;
        }
    }
    
    if ( 
iMostKills_id )
    {
        new 
szName33 ];
        
get_user_nameiMostKills_id szName charsmaxszName ) );
        
client_printprint_chat "* %s has most kills @ %d!" szName iMostKills_Num );
    }    

__________________

Last edited by Bugsy; 08-20-2010 at 23:59.
Bugsy is offline
platzpatrone
Veteran Member
Join Date: Apr 2007
Location: Germany
Old 08-28-2010 , 23:12   Re: [Get player with most kills]
Reply With Quote #10

or this may help u too:

http://forums.alliedmods.net/showthread.php?t=109842

post #4:

http://forums.alliedmods.net/showpos...94&postcount=4

platzpatrone 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 21:58.


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