So, I've been working on this bug in the match plugin for the last week or so. I thought maybe a new pair of eyes would help me find it. Or fix it.
What happens is that when these two functions are call, they do not find the clan tags. So, I'm asking you guys, if you see anything in there that should be changed, fixed, whatever.
Also, it only finds tags at the front of the name, not the back. If anybody has suggestions feel free to comment...
Code:
public get_CTclantags(id)
{
CT_tags[0] = "Don't use Tags"
CT_tagspos = 1
new players[32], nbr
new player_name1[32], player_name2[32]
get_players(players,nbr,"e","CT")
for(new i=0;i<nbr;i++) {
get_user_name(players[i],player_name1,31)
for(new j=i+1;j<nbr;j++) {
if (CT_tagspos < MAX_TAGS) {
get_user_name(players[j],player_name2,31)
new k=MIN_TAG_LENGTH, l_max = min(strlen(player_name1),strlen(player_name2))
while(k < l_max) {
if (equal(player_name1,player_name2,k))
k++
else {
if (k > MIN_TAG_LENGTH) { // it's added to the Tags table after checking doubles
new l = 0
while(l < CT_tagspos) {
if (!equal(CT_tags[l],player_name1,max(strlen(CT_tags[l]),k-1)))
l++
else {
l = CT_tagspos+1
}
}
if (l == CT_tagspos) {
copy(CT_tags[CT_tagspos],k-1,player_name1)
CT_tagspos++
}
}
k = l_max
}
}
}
}
}
if (CT_tagspos == 1)
client_print(id,print_chat,"* [AMX MATCH] No CT clantag found :/")
return PLUGIN_CONTINUE
}
public get_Tclantags(id)
{
T_tagspos = 0
new players[32], nbr
new player_name1[32], player_name2[32]
get_players(players,nbr,"e","TERRORIST")
for(new i=0;i < nbr;i++) {
get_user_name(players[i],player_name1,31)
for(new j=i+1;j < nbr;j++) {
if (T_tagspos < MAX_TAGS) {
get_user_name(players[j],player_name2,31)
new k=MIN_TAG_LENGTH, l_max = min(strlen(player_name1),strlen(player_name2))
while(k < l_max) {
if (equal(player_name1,player_name2,k))
k++
else {
if (k > MIN_TAG_LENGTH) { // it's added to the Tags table after checking doubles
new l = 0
while(l < T_tagspos) {
if (!equal(T_tags[l],player_name1,max(strlen(T_tags[l]),k-1)))
l++
else {
l = T_tagspos+1
}
}
if (l == T_tagspos) {
copy(T_tags[T_tagspos],k-1,player_name1)
T_tagspos++
}
}
k = l_max
}
}
}
}
}
if (T_tagspos == 0)
client_print(id,print_chat,"* [AMX MATCH] No Terrorist clantag found :/")
return PLUGIN_CONTINUE
}