kicking player during...
#1

hello, how can i make a player join with a name of numeric get kicked from the server?
Reply
#2

pawn Code:
IsNumeric(const string[])
{
    for (new i = 0, j = strlen(string); i < j; i++)
    {
        if (string[i] > '9' || string[i] < '0') return 0;
    }
    return 1;
}
Reply
#3

So how the code will come ?
Reply
#4

Quote:
Originally Posted by P<3TS
View Post
So how the code will come ?
pawn Code:
public OnPlayerConnect(playerid)
{
    new name[MAX_PLAYERS+1];
    GetPlayerName(playerid, name, sizeof(name));
    if(IsNumeric(name))
    {
        Kick(playerid);
        return 1;
    }
    return 1;
}
Reply
#5

it is not working :SS
Reply
#6

pawn Code:
public OnPlayerConnect(playerid)
{
 new name[MAX_PLAYER_NAME];
 GetPlayerName(playerid,name,20);
 for(new i=0;name[i]!-'\0';++i) if(name[i] >= '0' && name[i] <='9') {SendClientMessage(playerid,-1,"Number's not allowed");
  Kick(playerid);
 }
}
Reply
#7

This error

pawn Code:
error 001: expected token: ";", but found "!"
 warning 215: expression has no effect
 error 001: expected token: ")", but found ";"
 error 036: empty statement
 fatal error 107: too many error messages on one line
line is
pawn Code:
for(new i=0;numname[i]!-'\0';++i)
Reply
#8

help.........
Reply
#9

pawn Code:
IsAValidNick(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    if(strfind(name, "0", true) != -1 || strfind(name, "1", true) != -1 || strfind(name, "2", true) != -1 || strfind(name, "3", true) != -1 || strfind(name, "4", true) != -1 || strfind(name, "5", true) != -1 || strfind(name, "6", true) != -1 || strfind(name, "7", true) != -1 || strfind(name, "8", true) != -1 || strfind(name, "9", true) != -1)
    {
        return 0;
    }
    return 1;
}

public OnPlayerConnect(playerid)
{
    if(IsAValidNick(playerid) == 0) {
        Kick(playerid);
    }
    return 1;
}
Reply
#10

Give a try.
pawn Code:
public OnPlayerConnect(playerid)
{
   static name[25];
   GetPlayerName(playerid,name,25);
   for(new i = 0; i != strlen(name); ++i)
   {
      if(name[i] >= '0' || name[i] < '9') return SendClientMessage(playerid,-1,"no numbers"),Kick(playerid);
   }
   return 1;
}
Reply
#11

If i add this then not a single number cannot be add along with their name? (i mean like this Crazyboobs123 )
Reply
#12

No, if a number is found, it will return the message and will kick the playerid. Simple as that.

to check if the player has a number in the end, just make a loop and get the size of the name of playerid, and check if the last char's are numbers.
Reply
#13

i need if a player join with the name only with number should get kick ( 2637345, 167.46.34.67, 56576, 000909 etc)
Is it possible?
Reply
#14

TESTED

pawn Код:
public OnPlayerConnect(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid,name,20);
    new bool:HasChar = false;
    for(new i=0; name[i]!='\0'; ++i)
        if((name[i] >= 'a' && name[i] <='z') || (name[i] >= 'A' && name[i] <='Z'))
        {
        HasChar = true;
        break;
        }

    if(HasChar == false)
    {
        SendClientMessage(playerid,-1,"Your name must have an alphabet");
        return Kick(playerid);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)