Quote:
Originally Posted by Natsheh
That what equal function does?
I don't see the reason of you using this function since its totally useless.
|
You can't call something useless if you don't understand what it does.
If you're interested what it does, it compares each character of both strings to see if string1 contains all the characters from string2, normal contain/i compares strings as whole, so if we have abcd and adcb it's going to return false, even though they both are the same, except for the order.
Normal contain:
PHP Code:
#include < amxmodx >
new const g_szString1[ ] = "abcd";
new const g_szString2[ ] = "adcb";
public plugin_init( )
{
if( contain( g_szString1, g_szString2 ) != -1 )
{
log_to_file( "Contain.txt", "True" );
}
else
{
log_to_file( "Contain.txt", "False" );
}
}
Log:
Code:
L 07/17/2019 - 19:17:05: False
New contain:
PHP Code:
#include < amxmodx >
new g_szString1[ ] = "abcd";
new g_szString2[ ] = "adcb";
public plugin_init( )
{
if( contain_all( g_szString1, charsmax( g_szString1 ), g_szString2, charsmax( g_szString2 ) ) )
{
log_to_file( "Contain.txt", "True" );
}
else
{
log_to_file( "Contain.txt", "False" );
}
}
public contain_all( szStringSrc[ ], iSize1, szStringCompare[ ], iSize2 )
{
new bool:bEqual;
for( new i; i < iSize1; i++ )
{
for( new j; j < iSize2; j++ )
{
if( szStringSrc[ i ] == szStringCompare[ j ] )
{
bEqual = true;
break;
}
else
{
bEqual = false;
}
}
if( ! bEqual )
break;
}
return bEqual;
}
Log:
Code:
L 07/17/2019 - 19:20:00: True
__________________