Raised This Month: $51 Target: $400
 12% 

Solved Get max array of X flags in the loop


Post New Thread Reply   
 
Thread Tools Display Modes
Shadows Adi
AlliedModders Donor
Join Date: Aug 2019
Location: Romania
Old 01-28-2022 , 10:35   Re: Get max array of X flags in the loop
Reply With Quote #11

Quote:
Originally Posted by Natsheh View Post
This might not work because iNum might not be the last vip index.
Ok, you got a point.
__________________


Accepting Paid Requests, contact PM.

MVP Of The Round View project on GITHUB / AlliedModders
CSGO REMAKE ~ CSGO MOD [STABLE + SOURCE CODE]
Shadows Adi is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 01-28-2022 , 11:30   Re: Get max array of X flags in the loop
Reply With Quote #12

Quote:
Originally Posted by Natsheh View Post
This might not work because iNum might not be the last vip index.
You are right but your way it is not work too.

iPlayer = Check how much numbers are found in the loop
EOS or szBuffer[ 0 ] = Like i added break to the loop it show only the last player

Also i tried to make the code more optimization by doing this but got bug:

PHP Code:
@OnVipsOnlineid )
{
    new 
szBufferMAX_TEXT_LENGTH ], szPlayersMAX_PLAYERS ], iPlayeriNum;

    
get_playersszPlayersiNum "ch" );

    for( new 
iIndexiiNumi++ )
    {
        if( 
g_iPlayer[ ( iIndex szPlayers] ) ][ VIP ] & g_iSettingsAccess_OnlineList ] )
        {
            
formatexszBuffercharsmaxszBuffer ), "%s, "g_iPlayer[ ( iPlayer iIndex ) ][ Name ] )
        }
    }
    
    
szBufferstrlenszBuffer ) - ] = '.'
    
CC_SendMessageid"&x04Online:&x01 %s"iPlayer szBuffer "There are no vip's online." );

if there's not vips will not show this message "There are no vip's online." and send error log the reason is in szBuffer[ strlen( szBuffer ) - 2 ] = '.' but i dont have other way to do this so the final solution is:
PHP Code:
@OnVipsOnlineid )
{
    new 
szBufferMAX_TEXT_LENGTH ], szPlayersMAX_PLAYERS ], iPlayeriNum;

    
get_playersszPlayersiNum"ch" );

    for( new 
iIndexiiNumi++ )
    {
        if( 
g_iPlayer[ ( iIndex szPlayers] ) ][ VIP ] & g_iSettingsAccess_OnlineList ] )
        {
            
formatexszBuffercharsmaxszBuffer ), "%s, "g_iPlayer[ ( iPlayer iIndex ) ][ Name ] ) // More faster than format
        
}
    }
    
    if( 
iPlayer )
    {
        
szBufferstrlenszBuffer ) - ] = '.'
        
CC_SendMessageid"&x04Online:&x01 %s"szBuffer );
    }
    else
    {
        
CC_SendMessageid"&x04Online:&x01 There are no vip's online." );
    }

__________________
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 11:39.
Supremache is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-28-2022 , 11:44   Re: Get max array of X flags in the loop
Reply With Quote #13

Quote:
Originally Posted by Supremache View Post
You are right but your way it is not work too.

iPlayer = Check how much numbers are found in the loop
szBuffer = Show only the last player
Can you speak proper english, without making guessing the word game in each post, in the other hand you made iPlayer holds the last vip id and szBuffer is an array of charctures which holds the vips names. If the array is empty then there is no need to edit the buffer or print it.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 01-28-2022 , 11:53   Re: Get max array of X flags in the loop
Reply With Quote #14

Quote:
Originally Posted by Natsheh View Post
you made iPlayer holds the last vip id and szBuffer is an array of charctures which holds the vips names. If the array is empty then there is no need to edit the buffer or print it.
I had test it before answering you but it show only the last player id ْin contrast to what iPlayer does as example:

PHP Code:
get_vip_num( )
{
    new 
szBufferMAX_TEXT_LENGTH ], szPlayersMAX_PLAYERS ], iPlayeriNum;

    
get_playersszPlayersiNum )

    for( new 
iIndexiiNumi++ )
    {
        if( 
g_iPlayer[ ( iIndex szPlayers] ) ][ VIP ] & g_iSettingsAccess_OnlineList ] )
        {
            
iPlayer iIndex
        
}
    }
    
    return 
iPlayer

__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-28-2022 , 13:24   Re: Get max array of X flags in the loop
Reply With Quote #15

this will return an invalid counts of players whom are vips.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 01-28-2022 , 13:34   Re: Get max array of X flags in the loop
Reply With Quote #16

Quote:
Originally Posted by Natsheh View Post
this will return an invalid counts of players whom are vips.
anyways, i tested your provided code and only show the last player id
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-28-2022 , 13:38   Re: Get max array of X flags in the loop
Reply With Quote #17

Quote:
Originally Posted by Supremache View Post
anyways, i tested your provided code and only show the last player id
PHP Code:

@OnVipsOnlineid )
{
    new 
szBufferMAX_TEXT_LENGTH ], szPlayersMAX_PLAYERS ], iNum;

    
get_playersszPlayersiNum"ch" );
    new 
istrlen
    
for( new iIndexiiNumi++  )
    {
        if( 
g_iPlayer[ ( iIndex szPlayers] ) ][ VIP ] & g_iSettingsAccess_OnlineList ] )
        { 
            
istrlen += formatexszBuffer[istrlen], charsmax(szBuffer) - istrlen"%s, ",g_iPlayeriIndex ][ Name ]);
        }
    }

    if( 
szBuffer[0] != EOS )
    {
        
szBufferistrlen ] = EOS;
        
szBufferistrlen  ] = '.';
         
CC_SendMessage(idszBuffer);
    }
    else
    {
        
CC_SendMessageid"There are no vip's online." );
    } 

Test again, if you don't modify the code without understanding no problems will happen.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 01-28-2022 at 13:40.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 01-28-2022 , 13:45   Re: Get max array of X flags in the loop
Reply With Quote #18

Quote:
Originally Posted by Natsheh View Post
PHP Code:

@OnVipsOnlineid )
{
    new 
szBufferMAX_TEXT_LENGTH ], szPlayersMAX_PLAYERS ], iNum;

    
get_playersszPlayersiNum"ch" );
    new 
istrlen
    
for( new iIndexiiNumi++  )
    {
        if( 
g_iPlayer[ ( iIndex szPlayers] ) ][ VIP ] & g_iSettingsAccess_OnlineList ] )
        { 
            
istrlen += formatexszBuffer[istrlen], charsmax(szBuffer) - istrlen"%s, ",g_iPlayeriIndex ][ Name ]);
        }
    }

    if( 
szBuffer[0] != EOS )
    {
        
szBufferistrlen ] = EOS;
        
szBufferistrlen  ] = '.';
         
CC_SendMessage(idszBuffer);
    }
    else
    {
        
CC_SendMessageid"There are no vip's online." );
    } 

Test again, if you don't modify the code without understanding no problems will happen.
You have used this way " istrlen += formatex "
PHP Code:
  istrlen += formatexszBuffer[istrlen], charsmax(szBuffer) - istrlen"%s, ",g_iPlayeriIndex ][ Name ]); 
I was talking about native strlen
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 01-28-2022 , 14:06   Re: Get max array of X flags in the loop
Reply With Quote #19

What is the difference ?
You have used same way, custom variable for return a format which holds the vips names

Is it better than other one ? and why ?

PHP Code:
@OnVipsOnlineid )
{
    new 
szBufferMAX_TEXT_LENGTH ], szPlayersMAX_PLAYERS ], iNum;

    
get_playersszPlayersiNum"ch" );
    new 
istrlen
    
for( new iIndexiiNumi++  )
    {
        if( 
g_iPlayer[ ( iIndex szPlayers] ) ][ VIP ] & g_iSettingsAccess_OnlineList ] )
        { 
            
istrlen += formatexszBuffer[istrlen], charsmax(szBuffer) - istrlen"%s, ",g_iPlayeriIndex ][ Name ]);
        }
    }

    if( 
szBuffer[0] != EOS )
    {
        
szBufferistrlen ] = EOS;
        
szBufferistrlen  ] = '.';
         
CC_SendMessage(idszBuffer);
    }
    else
    {
        
CC_SendMessageid"There are no vip's online." );
    } 

I mean this one:
PHP Code:
@OnVipsOnlineid )
{
    new 
szBufferMAX_TEXT_LENGTH ], szPlayersMAX_PLAYERS ], iPlayeriNum;

    
get_playersszPlayersiNum"ch" );

    for( new 
iIndexiiNumi++ )
    {
        if( 
g_iPlayer[ ( iIndex szPlayers] ) ][ VIP ] & g_iSettingsAccess_OnlineList ] )
        {
            
formatexszBuffercharsmaxszBuffer ), "%s, "g_iPlayer[ ( iPlayer iIndex ) ][ Name ] ) // More faster than format
        
}
    }
    
    if( 
iPlayer )
    {
        
szBufferstrlenszBuffer ) - ] = '.'
        
CC_SendMessageid"&x04Online:&x01 %s"szBuffer );
    }
    else
    {
        
CC_SendMessageid"&x04Online:&x01 There are no vip's online." );
    }

__________________
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 14:17.
Supremache is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-29-2022 , 07:49   Re: Get max array of X flags in the loop
Reply With Quote #20

The 2nd code in your post will output the last vip in the players array, test it with two vips and you will see what is happening.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Reply



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 06:45.


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