SA-MP Forums Archive
IsVaildNick (details inside) - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: IsVaildNick (details inside) (/showthread.php?tid=250214)



IsVaildNick (details inside) - nuriel8833 - 22.04.2011

Hello
I have a mode that I improve (download it somewhere in an Israeli forum).The mode uses the function IsVaildNick several times (you probably know what that does - checks if the player's nick is vaild).
Unfortunatly I lost the include that has this stock,and I always get errors for that.
I also tried searching for this function in many diffrent names but I just can't find it.
So does anyone has this stock and he can give it to me? (it doesn't have to be in the exact name,as long as it does the same action)
Thank you very much for your help.


Re: IsVaildNick (details inside) - Alby Fire - 22.04.2011

Quote:
Originally Posted by Montserrat
Посмотреть сообщение
Hello
(you probably know what that does - checks if the player's nick is vaild).
I don't get what do you mean for "valid", an RP name? Or an online player's name?


Re: IsVaildNick (details inside) - nuriel8833 - 22.04.2011

Quote:
Originally Posted by Alby Fire
Посмотреть сообщение
I don't get what do you mean for "valid", an RP name? Or an online player's name?
Umm you know - nick that includes only the characters 0-9 A-Z a-z [ ] ( ) and all those stuff


Re: IsVaildNick (details inside) - Calgon - 22.04.2011

SA-MP performs an integrity check on all names before a player can connect to a server.

You're probably refering to whether a nickname contains a '_' (underscore) which is practically a standard for all RP servers.

Use strfind.


Re: IsVaildNick (details inside) - nuriel8833 - 22.04.2011

Quote:
Originally Posted by Calg00ne
Посмотреть сообщение
SA-MP performs an integrity check on all names before a player can connect to a server.

You're probably refering to whether a nickname contains a '_' (underscore) which is practically a standard for all RP servers.

Use strfind.
This stock is for the /changenick command
And no I mean that when a player changes him name using /changenick,if he changes his name to a name that has illegal characters (like & % # @ etc...) He won't be able to change the name


Re: IsVaildNick (details inside) - miokie - 22.04.2011

Like this?
pawn Код:
public NameValidator(playerid)
{
    if(IsPlayerConnected(playerid))
    {
        new pname[MAX_PLAYER_NAME],underline=0;
        GetPlayerName(playerid, pname, sizeof(pname));
        if(strfind(pname,"[",true) != (-1)) return 0;
        else if(strfind(pname,"]",true) != (-1)) return 0;
        else if(strfind(pname,"$",true) != (-1)) return 0;
        else if(strfind(pname,"(",true) != (-1)) return 0;
        else if(strfind(pname,")",true) != (-1)) return 0;
        else if(strfind(pname,"=",true) != (-1)) return 0;
        else if(strfind(pname,"@",true) != (-1)) return 0;
        else if(strfind(pname,"1",true) != (-1)) return 0;
        else if(strfind(pname,"2",true) != (-1)) return 0;
        else if(strfind(pname,"3",true) != (-1)) return 0;
        else if(strfind(pname,"4",true) != (-1)) return 0;
        else if(strfind(pname,"5",true) != (-1)) return 0;
        else if(strfind(pname,"6",true) != (-1)) return 0;
        else if(strfind(pname,"7",true) != (-1)) return 0;
        else if(strfind(pname,"8",true) != (-1)) return 0;
        else if(strfind(pname,"9",true) != (-1)) return 0;
        else if(strfind(pname,"0",true) != (-1)) return 0;
        new maxname = strlen(pname);
        for(new i=0; i<maxname; i++)
        {
            if(pname[i] == '_') underline ++;
        }
        if(underline != 1) return 0;
        pname[0] = toupper(pname[0]);
        for(new x=1; x<maxname; x++)
        {
            if(pname[x] == '_') pname[x+1] = toupper(pname[x+1]);
            else if(pname[x] != '_' && pname[x-1] != '_') pname[x] = tolower(pname[x]);
        }
        SetPlayerName(playerid, "New_Name");
        SetPlayerName(playerid, pname);
        return 1;
    }
    return 0;
}
I'm can't remember coding this, So credits go to the original coder, whoever that may be.