Thread: Top 5 values
View Single Post
WATCH_D0GS UNITED
Senior Member
Join Date: Jan 2023
Old 03-08-2024 , 18:36   Re: Top 5 values
Reply With Quote #2

(AI) We are a bit busy now.

Tested in game, it works well.

PHP Code:
new g_iKeys[33] = {105812315792611411413201819161725222123272426302931283233};

new 
g_iTopValues[5];
new 
g_iTopIndices[5]; 
PHP Code:
        for (new 0sizeof(g_iKeys); i++)
        {
                for (new 
0sizeof(g_iTopValues); j++)
                {
                        if (
g_iKeys[i] > g_iTopValues[j])
                        {
                                
// Shift the values and indices to make room for the new value
                                
for (new sizeof(g_iTopValues) - 1jk--)
                                {
                                        
g_iTopValues[k] = g_iTopValues[1];
                                        
g_iTopIndices[k] = g_iTopIndices[1];
                                }

                                
// Assign the new value and index to the correct position
                                
g_iTopValues[j] = g_iKeys[i];
                                
g_iTopIndices[j] = i;

                                break;
                        }
                }
        }

        for (new 
0sizeof(g_iTopValues); i++)
        {
                
client_print(id,print_chat,"Value: %d, Index: %d"g_iTopValues[i], g_iTopIndices[i])
        } 
__________________
💻Know Our New Blog👄
🔗tube2downs.blogspot.com
WATCH_D0GS UNITED is offline