AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   award MVP Fragger based on: 1) frags, 2) HS's, 3) total dmg (https://forums.alliedmods.net/showthread.php?t=19344)

Riddick51 10-14-2005 18:24

award MVP Fragger based on: 1) frags, 2) HS's, 3) total dmg
 
ok, i collect the following data for each round of play:
1. total frags (each player)
2. total headshots (each player)
3. total damage (each player)

objective: assign the title "MVP Fragger: playername" based on:
1. Rank of total Frags comparing each of the 32 players against the others
2. Rank of total Headshots comparing each of the 32 players against the others
3. Rank of total Damage comparing each of the 32 players against the others

if You have the time, show me a structure i can use to evaluate the rank of each player in relation to all the others in each of the 3 categories. i'll probly figure out how to do this in time, but if You feel like offering suggestions on how to go about it, that'd be cool.

Code:
#define MAXPLAYERS 32 new g_MaxPlayers new gs_Name[MAXPLAYERS+1][32] // Arrays used for for public stats new g_KillStreak[MAXPLAYERS+1]      // How many kills a user has in a row. new g_DeathCount[MAXPLAYERS+1]      //Deaths per round (ea. player) new g_HeadShotK[MAXPLAYERS+1]       //Total Headshots (ea. killer) new g_HeadShotV[MAXPLAYERS+1]       //Headshots Taken (ea. victim) new g_KillCount[MAXPLAYERS+1]       //Total Killcount (ea. player) new g_DmgGiven[MAXPLAYERS+1]        //Total Dmg (ea. player) new g_DmgTaken[MAXPLAYERS+1]        //Dmg Taken (ea. player) // Used for personaly stats new g_PKillerStats[MAXPLAYERS+1][MAXPLAYERS+1]
Here are stats for 1 round of play:

Playername Frags HS's Damage
Player1: 3 2 320
Player2: 7 1 1200
Player3: 12 6 1200
Player4: 16 8 1900

Ok, the MVP Fragger for the round should be: Player4, because he ranked #1 in each of the 3 categories.

XxAvalanchexX 10-14-2005 18:56

Code:
stock highest_number(numbers[], size, index=0) {     new i, highest, indexNum;     for(i=0;i<size;i++) {         if(numbers[i] > highest) {             highest = numbers[i];             indexNum = i;         }     }     if(index)         return indexNum;     else         return highest; }

Example:

Code:
new players[32]; players[1] = 3; players[2] = 7; players[3] = 12; players[4] = 16; playerWithMostFrags = highest_number(players,32,1);

playerWithMostFrags in this case would be 4 (the index). If the last parameter was a 0 it would be 16 (the number).

Riddick51 10-15-2005 15:51

allright, forgive me, i didn't do a very good job of describing the scenario for end-of-round processing.

here is a table of data:
Code:
________________Frags   Rank            HS's    Rank            Damage  Rank Player[1]       14      4           8           3               1800        3 Player[2]       12      5           12          2               2100        2 Player[3]       8       6           3           6               766     9 Player[4]       7       7           6           5               1233        6 Player[5]       18      2           7           4               1337        5 Player[6]       22      1           2           7               1700        4 Player[7]       16      3           15          1               2251        1 Player[8]       3       9           1           8               333     10 Player[9]       6       8           3           6               921     8 Player[10]      7       7           1           8               1012        7


task: for each player, calculate rank against all players in each of the 3 categories. this is represented by the three Rank columns in the data table.

then, calculate each players overall score. here is how we arrive at Player[1]'s overall score:

Player[1] Overall Rank Calculation:
-----------------------------------
Rank in Frags: 4th
Rank in Headshots: 3rd
Rank in Damage: 3rd
===================================
Player[1] Overall Rank: 3.3333
===================================


Player Overall Rank Calculation:
--------------------------------
player[1]: (4+3+3)/3=3.3333
player[2]: (5+2+2)/3=3.0000
player[3]: (6+6+9)/3=7.0000
player[4]: (7+5+6)/3=6.0000
player[5]: (2+4+5)/3=3.6667
player[6]: (1+7+4)/3=4.0000
player[7]: (3+1+1)/3=1.6667
player[8]: (9+8+10)/3=9.0000
player[9]: (8+6+8.0)/3=7.3333
player[10]: (7+8+7)/3=7.3333
=================================
MVP Overall: Player[7] 1.6667
=================================

Riddick51 10-16-2005 02:28

ok, break it down to simplest terms.

let's look at only the frags for each player. need to sort them descending so that the most frags are in position 1, or at least, can be assigned rank=1. then spin thru the list, putting the rank value with the associated frags for a specific player.

reader: feel free to offer Your suggestion(s)


All times are GMT -4. The time now is 23:40.

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