AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   find player with most kills of a team (https://forums.alliedmods.net/showthread.php?t=28155)

nightscreem 05-08-2006 16:30

find player with most kills of a team
 
eumh i need to know how you can find the player with the most kills of a team

thx in advance

o0panda 05-08-2006 16:59

Tab button :lol:

nightscreem 05-08-2006 17:01

omg pls post something usefull

v3x 05-08-2006 17:10

Something like this. Correct me if I'm wrong.
Code:
public most_kills_by_team(CsTeams:team) {   new last_frags , last_id , frags;   new CsTeams:p_team;   new const max_players = get_maxplayers();   for(new id = 1; id <= max_players; id++)   {     if(!is_user_connected(id)) continue;     p_team = cs_get_user_team(id);     if(p_team == team)     {       frags = get_user_frags(id);       if(frags > last_frags)       {         last_frags = frags;         last_id = id;       }     }   }   return last_id; }

Greenberet 05-08-2006 17:12

i think you want it for cs:
Code:
getMostKills( CsTeams:team ) {         new maxPlayers = get_maxplayers();         new mostkills[2] = { 0, 0 }; // 0 = id, 1 = frags         for( new i = 1; i <= maxPlayers; i++ )         {                 if( !is_user_connected( i ) || cs_get_user_team( i ) != team )                         continue;                 new frags = get_user_frags( i );                 if( frags > mostkills[1] )                 {                         mostkills[1] = frags;                         mostkills[0] = i;                 }                         }         return mostkills[0];       }
I didn't tried it, so use it at you own risk

edit:
v3x why are you always so fast?

v3x 05-08-2006 17:13

Pretty much what I did.

Greenberet 05-08-2006 17:15

Quote:

Originally Posted by v3x
Pretty much what I did.

i wrote this b4 i saw your post...

nightscreem 05-08-2006 17:23

thx for the posts but i need the player with the most frags from the T & the one from the CT

v3x 05-08-2006 17:39

You can do that. Just use it twice like so:
Code:
new top_terror = most_kills_by_team(CS_TEAM_T); new top_ct = most_kills_by_team(CS_TEAM_CT);

Xanimos 05-08-2006 17:51

My way of doing it. I don't like get_maxplayers() and is_user_connected()
Code:
stock most_kills_by_team(CsTeams:Team) {     new Players[32] , pnum , Winner[2], temp[2];     get_players(Players , pnum , "ce" , (Team == CS_TEAM_CT) ? "CT" : "TERRORIST");     for( new i = 0 ; i < pnum ; i++)     {         temp[0] = Players[i];         temp[1] = get_user_frags(temp[0]);         if(temp[1] > Winner[1])         {             Winner[0] = temp[0];             Winner[1] = temp[1];         }     }     return Winner[0]; }


All times are GMT -4. The time now is 04:59.

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