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:
@OnVipsOnline( id )
{
new szBuffer[ MAX_TEXT_LENGTH ], szPlayers[ MAX_PLAYERS ], iPlayer, iNum;
formatex( szBuffer, charsmax( szBuffer ), "&x04Online:&x01 " );
get_players( szPlayers, iNum , "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 iIndex, i; i < iNum; i++ )
{
if( g_iPlayer[ ( iIndex = szPlayers[ i ] ) /* Check who has a vip flag */ ][ VIP ] & g_iSettings[ Access_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
format( szBuffer, charsmax( szBuffer ), "%s%s%s", szBuffer, g_iPlayer[ iIndex ][ Name ], iNum < ( iPlayer = iIndex /* return the vip numbers */ ) ? ", " : "." );
format( szBuffer, charsmax( szBuffer ), "%s%s%s", szBuffer, g_iPlayer[ iIndex ][ Name ], ( ( iPlayer = iIndex ) < iNum ? ( iIndex <= iNum < iIndex ) : ( iIndex <= iNum || iNum < iIndex ) ) ? ", " : "." );
format( szBuffer, charsmax( szBuffer ), "%s%s%s", szBuffer, g_iPlayer[ iIndex ][ Name ], iNum == ( iPlayer = iIndex ) ? "." : ", " );
}
}
if( !iPlayer )
{
add( szBuffer, charsmax( szBuffer ), "There are no vip's online." );
}
CC_SendMessage( id, szBuffer );
}
I can do this with two loop but i think it's possible to do it with just one loop.
__________________