AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get_clan_tag (https://forums.alliedmods.net/showthread.php?t=104853)

Empowers 09-28-2009 08:27

get_clan_tag
 
I need to get clan tag from names of 2 or more players.

For example I have 2 names:

<GooD TEam> ANdy
<GooD TeaM> cANdy
Clan Tag should be <GooD TeaM>

or

RON 'killers
Tonny 'killers
Clan Tag should be 'killers

it can be any other names with same clan tags..

so i need something like this:
PHP Code:

new clantag[32]
get_clan_tag(clantag,31,name1,name2,name3...) 

Any suggestions?

One 09-28-2009 08:30

Re: get_clan_tag
 
you must get the names of all players & then replace
PHP Code:

for(1<= g_MaxPlayersi++) 


Empowers 09-28-2009 08:43

Re: get_clan_tag
 
read my post fist =) and then answer ^^

Alka 09-28-2009 08:53

Re: get_clan_tag
 
You can't do that, because clan tag format can differ from one to other, like <WTF> |WTF| 'WTF' .:WTF:. and so...all you can do is to get the name and check for symbols like "<|'." then take the string between that symbols.

Empowers 09-28-2009 10:56

Re: get_clan_tag
 
man... but if there A two names like:
<GooD TEam> ANdy
<GooD TeaM> GGg

So we can find the same <GooD TeaM> ???

I talking about comparing 2 or more names and finding the same part that must be a clan tag

SnoW 09-28-2009 11:20

Re: get_clan_tag
 
You could start comparing each cell separately from the beginning of the names and check when they don't match anymore. Somehow for only two players and why not more, there's a chance for:
"[ Best Team > Manny"
"[ Best Team > Molly"
So whether you were going to remove the tag, the guys would get names of "anny" and "olly".

Empowers 09-28-2009 11:22

Re: get_clan_tag
 
i don't wanna to remove the rag =) just get to print it

Exolent[jNr] 09-28-2009 11:48

Re: get_clan_tag
 
Quote:

Originally Posted by Empowers (Post 945830)
i don't wanna to remove the rag =) just get to print it

Well like SnoW said:

Quote:

Originally Posted by SnoW (Post 945828)
You could start comparing each cell separately from the beginning of the names and check when they don't match anymore. Somehow for only two players and why not more, there's a chance for:
"[ Best Team > Manny"
"[ Best Team > Molly"
So whether you were going to remove the tag, the guys would get names of "anny" and "olly".

Even if you are just printing it, the tag would still be wrong:
"[ Best Team > M"

Empowers 09-28-2009 12:58

Re: get_clan_tag
 
Quote:

"[ Best Team > Manny"
"[ Best Team > Molly"
ok.. that is the bug.. It doesn't matter for me

Someone give me the code of this. I need this funtion even with that bug.

+karma

Exolent[jNr] 09-29-2009 13:05

Re: get_clan_tag
 
Code:
#include < amxmodx > #include < amxmisc > GetSimilarStringFromArray( const szStrings[ ][ ], const iTotalStrings, szOutput[ ], const iLen ) {     new szMatch[ 32 ], iMatchLength;     new iLongestMatchLength;         new i, j;     for( i = 0; i < iTotalStrings; i++ ) {         for( j = i + 1; j < iTotalStrings; j++ ) {             iMatchLength = GetSimilarStringFrom2( szStrings[ i ], szStrings[ j ], szMatch, charsmax( szMatch ) );             if( iMatchLength > iLongestMatchLength ) {                 iLongestMatchLength = iMatchLength;                 copy( szOutput, iMatchLength, szMatch );             }         }     }     return iLongestMatchLength; } GetSimilarStringFrom2( const szString1[ ], const szString2[ ], szOutput[ ], const iLen ) {     new iLen1 = strlen( szString1 );     if( !iLen1 ) {         return 0;     }         new iLen2 = strlen( szString2 );     if( !iLen2 ) {         return 0;     }         new iPos1, iPos2;     new bool:bMatched, iMatchLength;     new iLongestMatchLength;     for( iPos1 = 0; iPos1 < iLen1; iPos1++ ) {         bMatched = false;         for( iPos2 = 0; iPos2 < iLen2; iPos2++ ) {             if( szString1[ iPos1 ] == szString2[ iPos2 ] ) {                 bMatched = true;             }             else if( bMatched ) {                 iMatchLength = iPos2 - iPos1;                 if( iMatchLength > iLongestMatchLength ) {                     iLongestMatchLength = iMatchLength;                     copy( szOutput, iMatchLength, szString1[ iPos1 ] );                 }                 bMatched = false;             }         }     }     return iLongestMatchLength; } // Usage: public someFunction( ) {     new iPlayers[ 32 ], iNum;     get_players( iPlayers, iNum );         new szNames[ 32 ][ 32 ];     for( new i = 0; i < iNum; i++ ) {         get_user_name( iPlayers[ i ], szNames[ i ], charsmax( szNames[ ] ) );     }         new szClanTag[ 32 ];     GetSimilarStringFromArray( szNames, iNum, szClanTag, charsmax( szClanTag ) ); }


All times are GMT -4. The time now is 22:33.

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