Setname question
#1

i want to set my name like /changename NewName not /setname Name NewName how i cand do it?
I have /setname:
Код:
if(!strcmp("/setname", cmd, true))
	{
	if (PlayerInfo[playerid][pAdmin] < 1338) return SendClientMessage(playerid, COLOR_GRAD2, "   you are not authorized to use that command!");
	tmp = strtok(cmdtext,idx);
	if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_GRAD2, "UTILIZARE: /setname [id] [newname]");
	giveplayerid = ReturnUser(tmp);
	if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_GRAD2, "Invalid Playerid!");
	new str[128],gpname[MAX_PLAYER_NAME];
	GetPlayerName(giveplayerid, gpname, MAX_PLAYER_NAME);
	format(str, 128, "users/%s.ini", gpname);
	if(!fexist(str)) return SendClientMessage(playerid, COLOR_YELLOW, "The person havent an account on this server");
	tmp = strtok(cmdtext,idx);
	if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_GRAD2, "UTILIZARE: /setname [id] [newname]");
	new str2[128];
	format(str2,128,"users/%s.ini",tmp);
	frename(str,str2);
	new pname[MAX_PLAYER_NAME];
	GetPlayerName(playerid, pname, MAX_PLAYER_NAME);
	SetPlayerName(giveplayerid,tmp);
	format(string, sizeof(string), "AdmCmd: %s changed name of \"%s\" to \"%s\"",pname,gpname,tmp);
	SendClientMessageToAll(COLOR_LIGHTRED,string);
	new year, month,day;
	getdate(year, month, day);
	format(string, sizeof(string), "(%d-%d-%d) Admin: %s was changed name of %s to %s", day,month,year, pname,gpname,tmp);
    NameChangeLog(string);
	return 1;
	}
Reply
#2

You can't even speak english correctly. So.. let me get what are you trying to say. You want your command(/setname ID newname) to work like /setname NewName ? And then to change the name to the player that uses it ?
Reply
#3

You can't do that, you need "old name" in your command parameters to check if nickname is valid.
Reply
#4

His english it's like hell , but i think he want that command to be changed in /changename and to be used by all players (i don't know sure ... but that it's what i understand) .
Reply
#5

i want to set my name no other player name... exemple: Current name: Hazliu. if i try command "/changename Justin" my name changed in Justin
And i want to change, that command "/setname" in "/changename", somebody?
Reply
#6

pawn Код:
if(!strcmp(cmd, "/changename", true))
{
    if(PlayerInfo[playerid][pAdmin] < 1338) SendClientMessage(playerid, COLOR_GRAD2, "   you are not authorized to use that command!");
    else
    {
        tmp = strtok(cmdtext,idx);
        if(!(3 <= strlen(tmp) < MAX_PLAYER_NAME)) SendClientMessage(playerid, COLOR_GRAD2, "UTILIZARE: /changename [newname]");
        else
        {
            new str[128];
            format(str, sizeof(str), "users/%s.ini", tmp);
            if(fexist(str)) SendClientMessage(playerid, COLOR_YELLOW, "This account already exists");
            else
            {
                new old_name_str[35], gpname[MAX_PLAYER_NAME];
                GetPlayerName(playerid, gpname, MAX_PLAYER_NAME);
                format(old_name_str, sizeof(old_name_str), "users/%s.ini", gpname);

                new idx = SetPlayerName(playerid, tmp);
                if(idx == -1) SendClientMessage(playerid, COLOR_GRAD2, "Unable to change your name.");
                else
                {
                    frename(old_name_str, str);
                    format(string, sizeof(string), "SERVER: %s changed name to \"%s\"",gpname,tmp);
                    SendClientMessageToAll(COLOR_LIGHTRED,string);
                    new year, month,day;
                    getdate(year, month, day);
                    format(string, sizeof(string), "(%d-%d-%d) Player: %s was changed name to %s", day,month,year,gpname,tmp);
                    NameChangeLog(string);
                }
            }
        }
    }
    return 1;
}
You need replace PlayerInfo[playerid][pAdmin] < 1338 to IsPlayerLogged or something
Reply
#7

Thanks man!! +1
Edit, how i can make that command in Dialog_style_input??
Reply
#8

PHP код:
if(!strcmp(cmd,"/changename",true))
{
    if(
PlayerInfo[playerid][pAdmin] < 1338)return SendClientMessage(playeridCOLOR_GRAD2"   you are not authorized to use that command!");
    
ShowPlayerDialog(playerid,DIALOG_CHANGENAME,DIALOG_STYLE_INPUT,"Namechange","Please put you new name in this dialog:","Go on","Back");
    return 
1;
}
if(
dialogid == DIALOG_CHANGENAME)
{
    if(!(
<= strlen(inputtext) < MAX_PLAYER_NAME))return SendClientMessage(playeridCOLOR_GRAD2"UTILIZARE: /changename [newname]");
    new 
str[MAX_PLAYER_NAME 11];
    
format(str,sizeof str,"users/%s.ini",inputtext);
    if(
fexist(str))return SendClientMessage(playeridCOLOR_YELLOW"This account already exists");
    new 
old_name_str[MAX_PLAYER_NAME],gpname[MAX_PLAYER_NAME];
    
GetPlayerName(playerid,gpname,sizeof gpname);
    
format(old_name_str,sizeof old_name_str,"users/%s.ini",gpname);
    
SetPlayerName(playerid,inputtext);
    
frename(old_name_str,str);
    
format(string,sizeof string,"SERVER: %s changed name to \"%s\"",gpname,inputtext);
    
SendClientMessageToAll(COLOR_LIGHTRED,string);
    new 
year,month,day;
    
getdate(year,month,day);
    
format(stringsizeof(string), "(%d-%d-%d) Player: %s was changed name to %s"day,month,year,gpname,inputtext);
    
NameChangeLog(string);
    return 
1;

Reply
#9

+rep, Thanks :d
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)