/changename
#1

My problem is I can change name even the name is already taken So I can get his stats and messed everything.

Anyone know how to fix this? if Player is already registered with the same name im going to change name, and I do "/changename Samplename"

SendClientMessage "The name is already taken"

pawn Код:
dcmd_changename(playerid,params[])
{
    if(AccInfo[playerid][Level] >= 3 || IsPlayerAdmin(playerid))
    {
        new Index;
        new tmp[256];  tmp  = strtok(params, Index);
        if(!strlen(tmp)) return
        SendClientMessage(playerid, 0xFFFFFFFF, "{FFFF00}Usage: /changename [NewName]") &&
        SendClientMessage(playerid, 0xFFFFFFFF, "{FF9900}Function: Will change your name to new name");
        new length = strlen(tmp);
        if(length < 3 || length > MAX_PLAYER_NAME) return SendClientMessage(playerid, 0xFFFFFFFF,"{FF0000}ERROR: Incorrect Name Length");
        new string[64];
        SendCommandToAdmins(playerid,"ChangeName");
        format(string,sizeof(string),"You have set your Name to %s", tmp);
        SendClientMessage(playerid, LIGHTGREEN, string);
        OnPlayerDisconnect(playerid, -1);
        udb_RenameUser(pName(playerid),tmp);
        SetPlayerName(playerid, tmp);
        return OnPlayerConnect(playerid);
    }
    else return ErrorMessages(playerid, 1);
}
Reply
#2

Heres something you could add to it aswell;
Код:
if(playerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "*** Player not connected ***");
Reply
#3

Quote:
Originally Posted by kickerbat
Посмотреть сообщение
Heres something you could add to it aswell;
Код:
if(playerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "*** Player not connected ***");
What is this thing do?? and what for?
Reply
#4

im giving you a little exemple for dini

Код:
                   if(dini_Exists(string))
		            {
		            	SendClientMessage(playerid, COLOR_WHITE, "User Already Exist.");
			            return 1;
		            }
PS : rep if i helps you
Reply
#5

Quote:
Originally Posted by BigBaws
Посмотреть сообщение
im giving you a little exemple for dini

Код:
                   if(dini_Exists(string))
		            {
		            	SendClientMessage(playerid, COLOR_WHITE, "User Already Exist.");
			            return 1;
		            }
PS : rep if i helps you
Can you do this with the code I have given?
Reply
#6

pawn Код:
new path[128];
format(path,sizeof(path),"Your directory/%s.ini",tmp);
if(fexists(path)) return SendClientMessage(playerid,-1,"This name is taken.. try again!");
Change Your Directory to where you are storing their files and change .ini to the extention required.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)