Symbol nickname
#1

How to detect a player nickname contains the symbol "[, ], ), ("? and automatically kicked
Reply
#2

Loop the nickname and compare characters.
Reply
#3

PHP код:
// Inside OnPlayerConnect callback or wherever you want to check 
new
    
name[24];
GetPlayerName(playeridnamesizeof(name));
for (new 
istrlen(name); != j; ++i)
{
    switch (
name[i])
    {
        case 
'['']''('')':
        {
            
// Symbols detected, kick the player.
        
}
    }

Reply
#4

Here a function for you:

PHP код:
stock isCharInString(const tmp[],const chars[])
{
    for(new 
i,buffer[1],l=strlen(chars); i<li++)
    {
        
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

Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)