AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   need help with level determine (https://forums.alliedmods.net/showthread.php?t=185334)

K.K.Lv 05-15-2012 21:48

need help with level determine
 
Hi all, I'm confused how to determine there were the same level in the server.
e.g:

in the server, there were 32 players, and the level like
PHP Code:

level[32] = {1,1,1,2,2,3,3,3,3,12,12,9,8,5,5,14,14,15,15,13,13,20,25,25,42,42,32,32,20,20,20,21}; 

and I want to get the same level count and player index

Liverwiz 05-15-2012 22:45

Re: need help with level determine
 
Code:

new count[100]
for(new i=0; i<32; i++)
{
new k = level[i]
count[k]++
}

like that? Counting how many people have each level.

K.K.Lv 05-16-2012 00:31

Re: need help with level determine
 
you don't know what I mean,
I want to show a message like:

Level A: name1,name2
Level B: name3,name4
...

Bilal Pro 05-16-2012 07:45

Re: need help with level determine
 
Can you explain it better?

Exolent[jNr] 05-16-2012 09:44

Re: need help with level determine
 
Something like this:
Code:
#include <amxmodx> #define MAX_PLAYERS 32 // Global array holding each player's level new gLevel[MAX_PLAYERS + 1]; SomeFunction() {     // Get all players     new players[32], pnum;     get_players(players, pnum, "h");         // Sort all players with custom callback     SortCustom1D(players, pnum, "ComparePlayerLevels");         // Keep track of last level, default as no level found yet     new lastLevel = -1;         // Prepare level, name, and message variables for loop     new id, level, name[32], message[192], len;         // Loop through all players     for(new i = 0; i < pnum; i++) {         // Grab the player index         id = players[i];                 // Grab this player's level         level = gLevel[id];                 // Grab this player's name         get_user_name(id, name, charsmax(name));                 // Check if this level is different from last         if(level > lastLevel) {             // Check if there was a level already put in the message             if(len) {                 // Print the message                 client_print(0, print_chat, "%s", message);             }                         // Add the level name and first player to message             len = formatex(message, charsmax(message), "Level %d: %s", level, name);         } else {             // Add the player's name to the end of this level's message             len += formatex(message[len], charsmax(message) - len, ", %s", name);         }     }         // Check if there was message text left over     if(len) {         // Print the message         client_print(0, print_chat, "%s", message);     } } public ComparePlayerLevels(index1, index2, players[], data[], dataSize) {     // Grab levels for both players     new level1 = level[players[index1]];     new level2 = level[players[index2]];         // Give back proper return value from level comparisons     if(level1 < level2) return -1;     if(level1 > level2) return  1;         // Levels are the same     return 0; }

K.K.Lv 05-17-2012 21:53

Re: need help with level determine
 
thx man(maybe I'm right), I have got you thinking !

Exolent[jNr] 05-18-2012 00:13

Re: need help with level determine
 
Quote:

Originally Posted by K.K.Lv (Post 1711040)
thx man(maybe I'm right), I have got you thinking !

Yes, you're right. This didn't take much thinking :P


All times are GMT -4. The time now is 00:25.

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