SA-MP Forums Archive
kicking player during... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: kicking player during... (/showthread.php?tid=364962)



kicking player during... - P<3TS - 01.08.2012

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


Re: kicking player during... - Disturn - 01.08.2012

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;
}



Re: kicking player during... - P<3TS - 01.08.2012

So how the code will come ?


Re: kicking player during... - Disturn - 01.08.2012

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;
}



Re: kicking player during... - P<3TS - 02.08.2012

it is not working :SS


Re: kicking player during... - [MM]RoXoR[FS] - 02.08.2012

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);
 }
}



Re: kicking player during... - P<3TS - 02.08.2012

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)



Re: kicking player during... - P<3TS - 03.08.2012

help.........


Re: kicking player during... - Larceny - 03.08.2012

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;
}



Re: kicking player during... - leonardo1434 - 03.08.2012

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;
}



Re: kicking player during... - P<3TS - 03.08.2012

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


Re: kicking player during... - leonardo1434 - 03.08.2012

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.


Re: kicking player during... - P<3TS - 03.08.2012

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?


Re: kicking player during... - [MM]RoXoR[FS] - 03.08.2012

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;
}