AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Symbol is never used (https://forums.alliedmods.net/showthread.php?t=317508)

edon1337 07-17-2019 09:47

Symbol is never used
 
I get symbol is never used on iSize1 and iSize2, but the variables are already being used, is Pawn just, dumb?
Code:
public Function( ) {     if( containi_all( eRanks[ Rank_Flags ], charsmax( eRanks[ Rank_Flags ] ), szFlags, charsmax( szFlags ) ) )     {         j = i;     } } containi_all( szStringSrc[ ], iSize1, szStringCompare[ ], iSize2 ) {     new bool:bEqual;     for( new i; i < sizeof( iSize1 ); i++ )     {         for( new j; j < sizeof( iSize2 ); j++ )         {             if( szStringSrc[ i ] != szStringCompare[ j ] )             {                 bEqual = true;                 break;             }                         else             {                 bEqual = false;             }         }     }         return bEqual; }

AmXDusT 07-17-2019 10:08

Re: &quot;Symbol is never used&quot;
 
Afaik you shouldn't be able to use sizeof for iSize as they're not arrays

edon1337 07-17-2019 10:37

Re: &quot;Symbol is never used&quot;
 
Quote:

Originally Posted by AmXDusT (Post 2659457)
Afaik you shouldn't be able to use sizeof for iSize as they're not arrays

Yeah, I already saw the mistake, but the owner of the forum just restored my thread and warned me, oh well.

JusTGo 07-17-2019 11:02

Re: &quot;Symbol is never used&quot;
 
change :

containi_all( szStringSrc[ ], iSize1, szStringCompare[ ], iSize2 )

to :

stock containi_all( szStringSrc[ ], iSize1, szStringCompare[ ], iSize2 )

or :

public containi_all( szStringSrc[ ], iSize1, szStringCompare[ ], iSize2 )

edon1337 07-17-2019 11:03

Re: &quot;Symbol is never used&quot;
 
I already fixed everything, thanks anyways, here's the full solution:

Code:
public Function( ) {     if( containi_all( eRanks[ Rank_Flags ], charsmax( eRanks[ Rank_Flags ] ), szFlags, charsmax( szFlags ) ) )     {         j = i;     } } public containi_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; }

Natsheh 07-17-2019 12:42

Re: &quot;Symbol is never used&quot;
 
That what equal function does?

I don't see the reason of you using this function since its totally useless.

edon1337 07-17-2019 13:16

Re: &quot;Symbol is never used&quot;
 
Quote:

Originally Posted by Natsheh (Post 2659490)
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( 
containg_szString1g_szString2 ) != -)
    {
        
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_allg_szString1charsmaxg_szString1 ), g_szString2charsmaxg_szString2 ) ) )
    {
        
log_to_file"Contain.txt""True" );
    }

    else
    {
        
log_to_file"Contain.txt""False" );
    }
}

public 
contain_allszStringSrc[ ], iSize1szStringCompare[ ], iSize2 )
{
    new 
bool:bEqual;

    for( new 
iiSize1i++ )
    {
        for( new 
jiSize2j++ )
        {
            if( 
szStringSrc] == szStringCompare] )
            {
                
bEqual true;
                break;
            }
            
            else
            {
                
bEqual false;
            }
        }
        
        if( ! 
bEqual )
        break;
    }
    
    return 
bEqual;


Log:
Code:

L 07/17/2019 - 19:20:00: True

<VeCo> 07-17-2019 14:08

Re: &quot;Symbol is never used&quot;
 
If they are flags, you can just use read_flags with some bit operations.

edon1337 07-17-2019 14:09

Re: &quot;Symbol is never used&quot;
 
Quote:

Originally Posted by <VeCo> (Post 2659505)
If they are flags, you can just use read_flags with some bit operations.

My method is more efficient,

* Convert to bits (twice)
* Use read_flags (twice)
* Compare using equal

vs

* Use a single stock

Natsheh 07-17-2019 15:35

Re: &quot;Symbol is never used&quot;
 
Quote:

Originally Posted by edon1337 (Post 2659507)
My method is more efficient,

* Convert to bits (twice)
* Use read_flags (twice)
* Compare using equal

vs

* Use a single stock

You are wrong and this is the statistics


* Use read_flags (twice)
* Compare using == operator

Or you can just order them alphabetically and then use equal


All times are GMT -4. The time now is 20:32.

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