AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED]catch top point (https://forums.alliedmods.net/showthread.php?t=153860)

One 03-30-2011 10:07

[SOLVED]catch top point
 
hi,

i have no idea how can i catch the best players points.

every user get every round X AGs ( set by speed )
example :
when user has 1000 units/s = 1 AG
when more than 1200 & less 1400 = 2 AGs

so i want to have a loop on round end and print which player got the most AGs in this/last round.
but i have no idea how to catch it.
i hope you know what i mean :(

xPaw 03-30-2011 11:20

Re: catch top point
 
Code:
new iBest, iPlayer; [ insert loop for players here ] {     if( g_iPoints[ id ] > iBest )     {         iBest = g_iPoints[ id ];         iPlayer = id;     } } if( iPlayer ) {     // iPlayer == best player     // iBest == his points }

One 03-30-2011 18:16

Re: catch top point
 
hmmm....
ty but how is it when 2 or more users are the top scorer?
and how to catch top 5?

gladius 03-30-2011 18:20

Re: catch top point
 
sort? :D

One 03-30-2011 18:50

Re: catch top point
 
hehe :D the question is how to sort?!

gladius 03-30-2011 18:58

Re: catch top point
 
you can see:

https://forums.alliedmods.net/showth...ight=arraysort
https://forums.alliedmods.net/showth...ht=sort&page=2
https://forums.alliedmods.net/showth...highlight=sort

One 04-01-2011 15:14

Re: catch top point
 
hmmm...
ok this works but what i want is complicated.

the rank must be sort by Received AGs and Maxspeed and lower fps.

For example :

there are 2 users which got 3 AGs.
both have 100 fps_max
but user 1 got 1250 units/s and user 2 got 1270 units/s.

so rank 1 willbe user 2 and rank 2 willbe user 1.

Example with names :

Xpaw got 4 AGs and his fps_max is on 100. his max speed 1420 units/s.
One got 4 AGs and his fps_max is on 100 too. his max speed 1534 units/s.

Rank :

1. One ( 4 AGs )
2. Xpaw ( 4 AGs )


what i have :

users_AG[id] = users AG
users_maxspeed_round[id] = maxspeed which user got in the round

i tried to sort it with AGs and maxspeed but like ever .... only errors.
so i didnt try to catch users fps_max.


i have realy no idea how to sort it.
i hope anyone has time and can give a start.for sure i give credit in release topic.

ty in advance

gladius 04-01-2011 15:56

Re: catch top point
 
I have a doubt.

What happens if Player 1 has 5 points, 90 fps and 1250 units / s and Player 2 has 10 points, 100 fps and 1150 units / s ??

Which is the order of priority?

One 04-01-2011 16:56

Re: catch top point
 
for sure player 2.
player 2 has more AGs.then you have to know you get more points/AGs when you are faster.
what i meant was if both/more users have the same points/AGs. then it willbe sorted by fps. if both have the same fps_max, it willbe sorted by speed.

maybe we can ignore the fps.
for first Points and after this speed.

Exolent[jNr] 04-01-2011 17:33

Re: catch top point
 
Code:
#include <amxmodx> #define MAX_PLAYERS 32 new g_points[MAX_PLAYERS + 1]; // your points variable for players new g_fps[MAX_PLAYERS + 1]; // your fps variable for players new g_speed[MAX_PLAYERS + 1]; // your speed variable for players GetTopPlayers(players[32], &pnum, const flags[]="", const team[]="") {     get_players(players, pnum, flags, team);         SortCustom1D(players, pnum, "SortPlayers"); } public SortPlayers(item1, item2) {     new diff = g_points[item2] - g_points[item1];         if( !diff )     {         diff = g_fps[item2] - g_fps[item1];                 if( !diff )         {             diff = g_speed[item2] - g_speed[item1];         }     }         return clamp(diff, -1, 1); }

Usage:
Code:
new players[32], pnum; GetTopPlayers(players, pnum, "ch"); // no bots or hltv new id; for( new i = 0; i < pnum; i++ ) {     id = players[i];         // player rank = i + 1     // player id = id } // #1 player = players[0] // #2 player = players[1] // ...


All times are GMT -4. The time now is 14:37.

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