Help With Changename +rep
#1

How To Prevent Players From Using Symbols?
Ex Name: ™Canga™ or {INA}Canga
This Is My Changename Script
PHP код:
    if(dialogid == DIALOG_CHANGENAME)
    {
        if(!
response)
        {
            
SendClientMessage(playerid,-1,"You have to cancel to change nickname");
        }
        else
        {
            if(
PlayerInfo[playerid][LoggedIn] == 1)
            {
                if(
udb_Exists(inputtext)) return ShowPlayerDialog(playerid,DIALOG_CHANGENAMEDIALOG_STYLE_INPUT"Changename""{FFFFFF}This {FF0000}Name {FFFFFF}is Taken..!""Change""Cancel");
                if(
strlen(inputtext) > 12) return ShowPlayerDialog(playerid,DIALOG_CHANGENAMEDIALOG_STYLE_INPUT"Changename""{FF0000}Incorrect New Name Lenght..!\n{FFFFFF}Max Lenght is {00FF00}12 Characters""Change""Cancel");
                if(
GetPlayerMoney(playerid) < 10000000) return ShowDescriptionTextError(playerid"~r~ERROR: ~w~Kamu Tidak Punya Cukup ~r~Uang Untuk ~y~Mengganti Nama");
                
GivePlayerMoney(playerid, -10000000);
                new 
nameee[24];  GetPlayerName(playeridnameee16);
                new 
OldName[24],str[128],strings[512];
                
GetPlayerName(playerid,OldName,sizeof(OldName));
                
format(str,sizeof(str),"ladmin/users/%s.sav",udb_encode(OldName));
                
udb_RenameUser(OldName,inputtext);
                
format(str,sizeof(str),"ladmin/users/%s.sav",udb_decode(params));
                
SetPlayerName(playerid,inputtext);
                  
format(stringssizeof(strings),"{4CC417}  .'XSG:FR'.  {FFFF00}\"%s\" {FFFFFF}successfully change to {FF0000}\"%s\".",OldName,inputtext);
                  
SendClientMessageToAll(-1,strings);
                
afixcars(playerid);
                
afixhs(playerid);
                
afixbizs(playerid);
                
format(stringssizeof(strings),"{FFFFFF}[CHANGENAME] {FFFF00}you have successfully change to \"%s\"",inputtext);
                  
SendClientMessage(playerid,-1,strings);
                
SetTimerEx("AntiSA"2000false"i"playerid);
                return 
1;
            }
            else return 
SendClientMessage(playerid,-1,"Error : You Must Login.");
        }
        return 
1;
    } 
Reply
#2

umm in not exactly sure, but use this to find certain things in a string:

Код:
if(strfind(playername, "_", true) == -1)
{
       Kick(playerid);
}
Reply
#3

You can try using this.

Код:
else if( dialogid == DIALOG_NAMECHANGE )
	{
	    if(!response || strlen(inputtext) == 0) return SendClientMessageEx(playerid, COLOR_WHITE, "You have prevented yourself from changing your name." );
	    if(strlen(inputtext) > 20)
	    {
	        SendClientMessageEx( playerid, COLOR_WHITE, "You can't select a name that's above 20 characters." );
	    }
	    else
	    {
	        if( strlen(inputtext) >= 1 )
	        {
	            if(!response)
	            {
	                SendClientMessageEx(playerid, COLOR_WHITE, "You have prevented yourself from changing your name." );
	            }
	            else
	            {
		            for(new i = 0; i < strlen( inputtext ); i++)
					{
					    if (inputtext[i] == ' ') return SendClientMessageEx(playerid, COLOR_GRAD2, "Please use the '_'(underscore) instead of the ' '(space)");
					}
					if( strfind( inputtext, "_", true) == -1 )
					{
						SendClientMessageEx( playerid, COLOR_WHITE, "Name change rejected. Please choose a name in the correct format: Firstname_Lastname." );
						return 1;
					}
					new namechangecost;
					namechangecost = (PlayerInfo[playerid][pLevel]) * 15000;

                    new tmpName[MAX_PLAYER_NAME];
					mysql_escape_string(inputtext, tmpName);
					if(strcmp(inputtext, tmpName, false) != 0) return SendClientMessageEx(playerid, COLOR_GRAD2, "Unacceptable characters used in namechange, try again");
					if((0 <= PlayerInfo[playerid][pMember] < MAX_GROUPS) && PlayerInfo[playerid][pRank] >= arrGroupData[PlayerInfo[playerid][pMember]][g_iFreeNameChange])
					{
					    if(GetPVarType(playerid, "HasReport")) {
							SendClientMessageEx(playerid, COLOR_GREY, "You can only have 1 active report at a time. (/cancelreport)");
							return 1;
						}
	    				new String[128];
						SetPVarInt(playerid, "RequestingNameChange", 1);
						SetPVarString(playerid, "NewNameRequest", inputtext);
						SetPVarInt(playerid, "NameChangeCost", 0);
						new playername[MAX_PLAYER_NAME];
						GetPlayerName(playerid, playername, sizeof(playername));
		            	format( String, sizeof( String ), "You have requested a namechange from %s to %s at no cost, please wait until a General Admin approves it.", playername, inputtext);
		            	SendClientMessageEx( playerid, COLOR_YELLOW, String );
	           	 		SendReportToQue(playerid, "Name Change Request", 2, 4);
		            	return 1;
					}
					if(PlayerInfo[playerid][pAdmin] == 1 && PlayerInfo[playerid][pSMod] > 0)
					{
					    if(GetPVarType(playerid, "HasReport")) {
							SendClientMessageEx(playerid, COLOR_GREY, "You can only have 1 active report at a time. (/cancelreport)");
							return 1;
						}
	    				new String[128];
						SetPVarInt(playerid, "RequestingNameChange", 1);
						SetPVarString(playerid, "NewNameRequest", inputtext);
						new playername[MAX_PLAYER_NAME];
						GetPlayerName(playerid, playername, sizeof(playername));
		            	format( String, sizeof( String ), "You have requested a namechange from %s to %s at no cost (Senior Mod), please wait until a General Admin approves it.", playername, inputtext, namechangecost);
		            	SendClientMessageEx( playerid, COLOR_YELLOW, String );
		                SendReportToQue(playerid, "Name Change Request", 2, 4);
		            	return 1;
					}

					if(GetPlayerCash(playerid) >= namechangecost)
					{
					    if(GetPVarType(playerid, "HasReport")) {
							SendClientMessageEx(playerid, COLOR_GREY, "You can only have 1 active report at a time. (/cancelreport)");
							return 1;
						}
					    new String[128];
						SetPVarInt(playerid, "RequestingNameChange", 1);
						SetPVarString(playerid, "NewNameRequest", inputtext);
						SetPVarInt(playerid, "NameChangeCost", namechangecost);
						new playername[MAX_PLAYER_NAME];
						GetPlayerName(playerid, playername, sizeof(playername));
		            	format( String, sizeof( String ), "You have requested a namechange from %s to %s for $%d, please wait until a General Admin approves it.", playername, inputtext, namechangecost);
		            	SendClientMessageEx( playerid, COLOR_YELLOW, String );
		            	SendReportToQue(playerid, "Name Change Request", 2, 4);
					}
					else
					{
					    SendClientMessageEx(playerid, COLOR_GRAD2, "You don't have enough money for the name change.");
					}
	            }
	        }
	        else
	        {
	            SendClientMessageEx( playerid, COLOR_WHITE, "Your name must be longer than 1 character." );
	        }
	    }
	}
	else if( dialogid == DIALOG_NAMECHANGE2 )
	{
	    if(!response || strlen(inputtext) == 0) return Kick(playerid);
	    if(strlen(inputtext) >= 20)
	    {
	        SendClientMessageEx( playerid, COLOR_WHITE, "You can't select a name that's above 20 characters." );
	        ShowPlayerDialog( playerid, DIALOG_NAMECHANGE2, DIALOG_STYLE_INPUT, "Free name change","This is a roleplay server where you must have a name in this format: Firstname_Lastname.\nFor example: John_Smith or Jimmy_Johnson\n\nAn admin has offered you to change your name to the correct format for free. Please enter your desired name below.\n\nNote: If you press cancel you will be kicked from the server.", "Change", "Cancel" );
	    }
	    else
	    {
	        if( strlen(inputtext) >= 1 )
	        {
	            if(!response)
	            {
				    ShowPlayerDialog( playerid, DIALOG_NAMECHANGE2, DIALOG_STYLE_INPUT, "Free name change","This is a roleplay server where you must have a name in this format: Firstname_Lastname.\nFor example: John_Smith or Jimmy_Johnson\n\nAn admin has offered you to change your name to the correct format for free. Please enter your desired name below.\n\nNote: If you press cancel you will be kicked from the server.", "Change", "Cancel" );
				}
	            else
	            {
           			for(new i = 0; i < strlen( inputtext ); i++)
					{
    					if (inputtext[i] == ' ')
    					{
							SendClientMessageEx(playerid, COLOR_WHITE, "Please use the '_'(underscore) instead of the ' '(space)");
							ShowPlayerDialog( playerid, DIALOG_NAMECHANGE2, DIALOG_STYLE_INPUT, "Free name change","This is a roleplay server where you must have a name in this format: Firstname_Lastname.\nFor example: John_Smith or Jimmy_Johnson\n\nAn admin has offered you to change your name to the correct format for free. Please enter your desired name below.\n\nNote: If you press cancel you will be kicked from the server.", "Change", "Cancel" );
							return 1;
						}
					}
					if( strfind( inputtext, "_", true) == -1 )
					{
						SendClientMessageEx( playerid, COLOR_WHITE, "Name change rejected. Please choose a name in the correct format: Firstname_Lastname." );
						ShowPlayerDialog( playerid, DIALOG_NAMECHANGE2, DIALOG_STYLE_INPUT, "Free name change","This is a roleplay server where you must have a name in this format: Firstname_Lastname.\nFor example: John_Smith or Jimmy_Johnson\n\nAn admin has offered you to change your name to the correct format for free. Please enter your desired name below.\n\nNote: If you press cancel you will be kicked from the server.", "Change", "Cancel" );
						return 1;
					}
     				else
					{
					    if(GetPVarType(playerid, "HasReport")) {
							SendClientMessageEx(playerid, COLOR_GREY, "You can only have 1 active report at a time. (/cancelreport)");
							return 1;
						}
						new String[128];
						SetPVarInt(playerid, "RequestingNameChange", 1);
						SetPVarString(playerid, "NewNameRequest", inputtext);
						SetPVarInt(playerid, "NameChangeCost", 0);
						new playername[MAX_PLAYER_NAME];
						GetPlayerName(playerid, playername, sizeof(playername));
    					format( String, sizeof( String ), "You have requested a namechange from %s to %s please wait until a General Admin approves it.", playername, inputtext);
       					SendClientMessageEx( playerid, COLOR_YELLOW, String );
          //			format( String, sizeof( String ), "{AA3333}AdmWarning{FFFF00}: %s (ID %d) requested a name change to %s for free (non-RP name) - /approvename %d (accept), or /denyname %d (deny).", playername, playerid, inputtext, playerid, playerid);
            //			ABroadCast( COLOR_YELLOW, String, 3 );
						SendReportToQue(playerid, "Name Change Request", 2, 4);
            			return 1;
            		}
				}
	        }
	        else
	        {
	            SendClientMessageEx( playerid, COLOR_WHITE, "Your name must be longer than 1 character." );
	            ShowPlayerDialog( playerid, DIALOG_NAMECHANGE2, DIALOG_STYLE_INPUT, "Free name change","This is a roleplay server where you must have a name in this format: Firstname_Lastname.\nFor example: John_Smith or Jimmy_Johnson\n\nAn admin has offered you to change your name to the correct format for free. Please enter your desired name below.\n\nNote: If you press cancel you will be kicked from the server.", "Change", "Cancel" );
	        }
	    }
	}
Reply
#4

try this
PHP код:
if(dialogid == DIALOG_CHANGENAME)
{
        if(!
response)
        {
            
SendClientMessage(playerid,-1,"You have to cancel to change nickname");
        }
        else
        {
            if(
PlayerInfo[playerid][LoggedIn] == 1)
            {
                new 
tmp[256], string[30];
                
tmp strlen(inputtext);
                if(
udb_Exists(tmp)) return ShowPlayerDialog(playerid,DIALOG_CHANGENAMEDIALOG_STYLE_INPUT"Changename""{FFFFFF}This {FF0000}Name {FFFFFF}is Taken..!""Change""Cancel");
                if(
strlen(tmp) > 12) return ShowPlayerDialog(playerid,DIALOG_CHANGENAMEDIALOG_STYLE_INPUT"Changename""{FF0000}Incorrect New Name Lenght..!\n{FFFFFF}Max Lenght is {00FF00}12 Characters""Change""Cancel");
                if(
GetPlayerMoney(playerid) < 10000000) return ShowDescriptionTextError(playerid"~r~ERROR: ~w~Kamu Tidak Punya Cukup ~r~Uang Untuk ~y~Mengganti Nama");
                for (new 
0strlen(tmp); i++)
                {
                    if ((
tmp[i] < '$') || (tmp[i] > '$' && tmp[i] < '.') || (tmp[i] == '/') || (tmp[i] > '9' && tmp[i] < '=') || (tmp[i] > '=' && tmp[i] < '@') || (tmp[i] == '\\' || tmp[i] == '^' || tmp[i] == '`') || (tmp[i] > 'z'))
                    {
                        
format(string24"Invalid symbol %c"tmp[i]);
                        
SendClientMessage2(playeridCOLOR_REDstring);
                        return 
1;
                    }
                }
                
GivePlayerMoney(playerid, -10000000);
                new 
nameee[24];  GetPlayerName(playeridnameee16);
                new 
OldName[24],str[128],strings[512];
                
GetPlayerName(playerid,OldName,sizeof(OldName));
                
format(str,sizeof(str),"ladmin/users/%s.sav",udb_encode(OldName));
                
udb_RenameUser(OldName,inputtext);
                
format(str,sizeof(str),"ladmin/users/%s.sav",udb_decode(params));
                
SetPlayerName(playeridtmp);
                
format(stringssizeof(strings),"{4CC417}  .'XSG:FR'.  {FFFF00}\"%s\" {FFFFFF}successfully change to {FF0000}\"%s\".",OldName,tmp);
                
SendClientMessageToAll(-1,strings);
                
afixcars(playerid);
                
afixhs(playerid);
                
afixbizs(playerid);
                
format(stringssizeof(strings),"{FFFFFF}[CHANGENAME] {FFFF00}you have successfully change to \"%s\"",tmp);
                
SendClientMessage(playerid,-1,strings);
                
SetTimerEx("AntiSA"2000false"i"playerid);
                return 
1;
            }
            else return 
SendClientMessage(playerid,-1,"Error : You Must Login.");
        }
        return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)