Raised This Month: $ Target: $400
 0% 

Solved Get max array of X flags in the loop


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 01-28-2022 , 04:55   Get max array of X flags in the loop
Reply With Quote #1

Hi all,
I have question i trying to make a code for check vip members in the chat but i had a small issue when compared vips number with max array number as example:

PHP Code:
@OnVipsOnlineid )
{
    new 
szBufferMAX_TEXT_LENGTH ], szPlayersMAX_PLAYERS ], iPlayeriNum;
    
formatexszBuffercharsmaxszBuffer ), "&x04Online:&x01 " );
    
    
get_playersszPlayersiNum "ch" ); // iNum = it is max player numbers in the server if i used it any where in the loop it also return all players in the server

    
for( new iIndexiiNumi++  )
    {
        if( 
g_iPlayer[ ( iIndex szPlayers] ) /* Check who has a vip flag */  ][ VIP ] & g_iSettingsAccess_OnlineList ] )
        { 
// i tried to compare iIndex with iNum and it work like adding symbol (,)  behinde all player names and another symbol (.) to the last player but work only when all players has that vip flag in the server so if anyone does not have that flag will add symbol (,) till if it was the last player
// I tried these ways but didn't work
            
formatszBuffercharsmaxszBuffer ), "%s%s%s"szBufferg_iPlayeriIndex ][ Name ], iNum < ( iPlayer iIndex /* return the vip numbers */ ) ? ", " "." );
            
formatszBuffercharsmaxszBuffer ), "%s%s%s"szBufferg_iPlayeriIndex ][ Name ], ( ( iPlayer iIndex ) < iNum ? ( iIndex <= iNum iIndex ) : ( iIndex <= iNum || iNum iIndex ) ) ? ", " "." );
            
formatszBuffercharsmaxszBuffer ), "%s%s%s"szBufferg_iPlayeriIndex ][ Name ], iNum == ( iPlayer iIndex ) ? "." ", " );
        }
    }
    
    if( !
iPlayer )
    {
        
addszBuffercharsmaxszBuffer ), "There are no vip's online." );
    }
    
    
CC_SendMessageidszBuffer );

I can do this with two loop but i think it's possible to do it with just one loop.
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 01-28-2022 at 07:24.
Supremache is offline
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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