AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get 3 names (https://forums.alliedmods.net/showthread.php?t=82051)

Starsailor 12-16-2008 10:21

Get 3 names
 
hello ..

I would like to know how to get the names of the 3 who finish first in each team .. or

1st, 2nd and 3rd Team CT
1st, 2nd and 3rd of the team TERR

thanks!

SnoW 12-16-2008 11:08

Re: Get 3 names
 
"Finish first", maybe you should explain little better what they "finish"?

Spunky 12-17-2008 03:30

Re: Get 3 names
 
He's asking how to get the names belonging to the top three scores for each team at the end of the round, I think.

MPNumB 12-17-2008 06:03

Re: Get 3 names
 
Stupid idea, cuz if frags are the same they are puted by player id (not by playing time).

Ontopic: just loop players and get best 3 with highest frags.

hleV 12-17-2008 07:59

Re: Get 3 names
 
I thought about something like this.
Code:
new i1st, i2nd, i3rd;   for (new i = 1; i <= get_maxplayers(); i++) {         if (get_user_frags(i) > i1st)         {                 i2nd = i1st;                 i1st = i;         }         else if (i1st >= get_user_frags(i) > i2nd)         {                 i3rd = i2nd;                 i2nd = i;         }         else if (i2nd >= get_user_frags(i) > i3rd)                 i3rd = i; }   new sz1st[32], sz2nd[32], sz3rd[32]; get_user_name(i1st, sz1st, 31); // Name of the 1st get_user_name(i2nd, sz2nd, 31); // Name of the 2nd get_user_name(i3rd, sz3rd, 31); // Name of the 3rd

But IMO players' deaths also should play a role here.

Exolent[jNr] 12-17-2008 11:05

Re: Get 3 names
 
Why are you comparing the player indexes with the frags?

EDIT:

Code:
new bestClient[3], bestFrags[3], frags; for( new client = 1; client <= g_max_clients; client++ ) {     if( !is_user_connected(client) ) continue;         frags = get_user_frags(client);         for( new i = 0; i < 3; i++ )     {         if( frags > bestFrags[i] )         {             for( new j = i + 1; j < 3; j++ )             {                 bestFrags[j] = bestFrags[j - 1];                 bestClient[j] = bestClient[j - 1];             }                         bestFrags[i] = frags;             bestClient[i] = client;                         break;         }     } } new name[3][32], client; for( new i = 0; i < 3; i++ ) {     if( (client = bestClient[i]) )     {         get_user_name(client, name[i], sizeof(name[]) - 1);     } }


All times are GMT -4. The time now is 09:17.

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