Your code formatting is very bad. This is how it should look:
Код:
public check_name(id,username[])
{
get_user_ip(id, playerip, 16, 1)
if (geoip_code3(playerip, country))
{
format(stra,4,"[%s]", country)
if (contain(username, stra) == -1)
{
geoip_code3(playerip, country)
format(strb,32,"%s[%s]", username, country)
if (equali(country, "DZA"))
{
format(strb,32,"%s[%s]", username, "USB")
}
set_user_info(id,"name", strb)
}
}
return PLUGIN_CONTINUE
}
In future posts try to follow good formatting or your examples are too hard to understand.
Код:
format(stra,4,"[%s]", country)
if (contain(username, stra) == -1)
You think you bail out if country code contained in the user name, but you forgot that you change country code later to "USB", so user with name "Player [USB]" will never match here, so country code will be added again. Could be so:
Код:
format(stra,4,"[%s]", country)
if (contain(username, stra) == -1 && contain(username, "[USB]") == -1)
Also your code has some redundancy and errors. Here how it should be:
Код:
public check_name(id,username[])
{
new stra[32], strb[32];
get_user_ip(id, playerip, 16, 1)
if (geoip_code3(playerip, country))
{
if (equali(country, "DZA"))
copy(stra, charsmax(stra), "[USB]");
else
format(stra, 5, "[%s]", country); // formatted length limited to 5
if (contain(username, stra) == -1)
{
// You should limit username first, because you add country code to the end. Cut 5 letters
username[27] = 0;
format(strb, charsmax(strb), "%s%s", username, stra);
set_user_info(id, "name", strb);
}
}
return PLUGIN_CONTINUE;
}