Raised This Month: $32 Target: $400
 8% 

Solved Get max array of X flags in the loop


Post New Thread Reply   
 
Thread Tools Display Modes
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 01-29-2022 , 09:30   Re: Get max array of X flags in the loop
Reply With Quote #21

Quote:
Originally Posted by Natsheh View Post
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.
Sorry, after testing it i found i was wrong but i tried to optimize for the code by using strlen native
Is there any problem with this ? or another way is faster than this ?
PHP Code:
@OnVipsOnlineid )
{
    new 
szBufferMAX_TEXT_LENGTH ], szPlayersMAX_PLAYERS ], iNum;

    
get_playersszPlayersiNum)//, "ch" );

    
for( new iIndexiiNumi++ )
    {
        if( 
g_iPlayer[ ( iIndex szPlayers] ) ][ VIP ] & g_iSettingsAccess_OnlineList ] )
        {
            
formatexszBufferstrlenszBuffer ) ], charsmaxszBuffer ), "%s, "g_iPlayeriIndex ][ Name ] )
        }
    }
    
    if( 
szBuffer] != EOS )
    {
        
szBufferstrlenszBuffer ) - ] = '.'
        
CC_SendMessageidszBuffer );
    }
    else
    {
        
CC_SendMessageid"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-29-2022 at 10:15.
Supremache is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 01-29-2022 , 10:13   Re: Get max array of X flags in the loop
Reply With Quote #22

Yes this will mostly like cause an index out of bounds error, because you're submitting a size which is bigger than the array size.

PHP Code:
formatexszBufferstrlenszBuffer ) ], charsmaxszBuffer 
you don't need to call strlen !!!!
formatex will return the length of the buffer

PHP Code:
    new iLen;
    for( new 
iIndexiiNumi++ )
    {
        if( 
g_iPlayer[ ( iIndex szPlayers] ) ][ VIP ] & g_iSettingsAccess_OnlineList ] )
        {
            
iLen  += formatexszBufferiLen ], charsmaxszBuffer ) - iLen "%s, "g_iPlayeriIndex ][ Name ] )
        }
    } 
You keep making the same mistakes over and over without trying to understand what is happening
__________________
@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-29-2022 at 10:14.
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-29-2022 , 11:35   Re: Get max array of X flags in the loop
Reply With Quote #23

Quote:
Originally Posted by Natsheh View Post
Yes this will mostly like cause an index out of bounds error, because you're submitting a size which is bigger than the array size.

PHP Code:
formatexszBufferstrlenszBuffer ) ], charsmaxszBuffer 
you don't need to call strlen !!!!
formatex will return the length of the buffer

PHP Code:
    new iLen;
    for( new 
iIndexiiNumi++ )
    {
        if( 
g_iPlayer[ ( iIndex szPlayers] ) ][ VIP ] & g_iSettingsAccess_OnlineList ] )
        {
            
iLen  += formatexszBufferiLen ], charsmaxszBuffer ) - iLen "%s, "g_iPlayeriIndex ][ Name ] )
        }
    } 
You keep making the same mistakes over and over without trying to understand what is happening
Well, i got it
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.
Supremache is offline
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 22:30.


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