11.06.2016, 15:38
How to detect a player nickname contains the symbol "[, ], ), ("? and automatically kicked
// Inside OnPlayerConnect callback or wherever you want to check
new
name[24];
GetPlayerName(playerid, name, sizeof(name));
for (new i, j = strlen(name); i != j; ++i)
{
switch (name[i])
{
case '[', ']', '(', ')':
{
// Symbols detected, kick the player.
}
}
}
stock isCharInString(const tmp[],const chars[])
{
for(new i,buffer[1],l=strlen(chars); i<l; i++)
{
buffer[0] = chars[i];
if(strfind(tmp,buffer,false) != -1) return true;
}
return false;
}
//You can use it like this:
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid,name,MAX_PLAYER_NAME);
if(isCharInString(tmp,"]<()[>"))
{
//Here some of the chars are in the name
}