AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Get player with most kills] (https://forums.alliedmods.net/showthread.php?t=135835)

Dranix 08-20-2010 06:35

[Get player with most kills]
 
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!

lucas_7_94 08-20-2010 08:02

Re: [Get player with most kills]
 
you can look any part from my plugin.

lazarev 08-20-2010 08:40

Re: [Get player with most kills]
 
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.

GXLZPGX 08-20-2010 11:32

Re: [Get player with most kills]
 
Quote:

Originally Posted by lazarev (Post 1276680)
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.

Dranix 08-20-2010 12:09

Re: [Get player with most kills]
 
What about RequiredKills ?

Kreation 08-20-2010 12:26

Re: [Get player with most kills]
 
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.

lazarev 08-20-2010 15:04

Re: [Get player with most kills]
 
Quote:

Originally Posted by GXLZPGX (Post 1276843)
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.

GXLZPGX 08-20-2010 15:59

Re: [Get player with most kills]
 
Quote:

Originally Posted by lazarev (Post 1277022)
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.

Bugsy 08-20-2010 17:13

Re: [Get player with most kills]
 
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 );
    }    



platzpatrone 08-28-2010 23:12

Re: [Get player with most kills]
 
or this may help u too:

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

post #4:

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

:wink:


All times are GMT -4. The time now is 21:58.

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