Need help with rename CMD
#1

Hey, I have a little problem in Rename CMD , it changes name and all stats and everything but it create new account and move all stats to it like
OLDname: Test
NewName: Test123
Both of them are now on database, i want to rename Test to Test123 without creating New Account file

Код:
CMD:setname(playerid, params[])
{
        new string[128], tmp[256], tmp2[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
		if(isnull(tmp) || isnull(tmp2)) return SendClientMessage(playerid, red, "USAGE: /setname [playerid] [new name]");
		if (udb_Exists(tmp2)) return SendClientMessage(playerid,red,"This User Name Is Taken!");
		new player1 = strval(tmp);

		new OldName[24],str[128];
		GetPlayerName(player1,OldName,sizeof(OldName));
		format(str,sizeof(str),"admin/users/%s.sav",OldName);
		udb_RenameUser(OldName,tmp2);
		format(str,sizeof(str),"admin/users/%s.sav",params);
		SetPlayerName(player1,tmp2);
        format(string, sizeof(string),"Admin ''%s'' Has Changed Your Name To '%s'",PlayerName2(playerid), tmp2);
		return SendClientMessage(player1,yellow,string);
}
Reply
#2

Use sscanf, strtok is outdated.
Reply
#3

error 035: argument type mismatch (argument 2)
Reply
#4

Can you at least point out in which line you get that error ?

Код:
This forum requires that you wait 120 seconds between posts. Please try again in 12 seconds.
I don't want to come to this planet anymore.

EDIT : Btw, don't use strtok, and use
Код:
new OldName[MAX_PLAYER_NAME]
Reply
#5

Can anyone fix it for me ? +rep ofcourse
Reply
#6

pawn Код:
CMD:setname(playerid, params[])
{
        new string[128], tmp[256], tmp2[256], Index;
                if (sscanf(params,"s[256]",tmp2)) return SendClientMessage(playerid,red,"/setname [name]");
        if (udb_Exists(tmp2)) return SendClientMessage(playerid,red,"This User Name Is Taken!");
        new player1 = strval(tmp);

        new OldName[24],str[128];
        GetPlayerName(player1,OldName,sizeof(OldName));
        format(str,sizeof(str),"admin/users/%s.sav",OldName);
        udb_RenameUser(OldName,tmp2);
        format(str,sizeof(str),"admin/users/%s.sav",params);
        SetPlayerName(player1,tmp2);
        format(string, sizeof(string),"Admin ''%s'' Has Changed Your Name To '%s'",PlayerName2(playerid), NewName);
        return SendClientMessage(player1,yellow,string);
}
try this..
Reply
#7

Its now /setname [NEW NAME]

I Want it /setname [playername] [player-new-name] coz i use it for admins
Reply
#8

pawn Код:
CMD:setname(playerid, params[])
{
        new string[128], tmp[256], tmp2[256], Index;
                if (sscanf(params,"ss[256]",tmp,tmp2)) return SendClientMessage(playerid,red,"/setname [playername] [name]");
        if (udb_Exists(tmp2)) return SendClientMessage(playerid,red,"This User Name Is Taken!");
        new player1 = strval(tmp);

        new OldName[24],str[128];
        GetPlayerName(player1,OldName,sizeof(OldName));
        format(str,sizeof(str),"admin/users/%s.sav",OldName);
        udb_RenameUser(OldName,tmp2);
        format(str,sizeof(str),"admin/users/%s.sav",params);
        SetPlayerName(player1,tmp2);
        format(string, sizeof(string),"Admin ''%s'' Has Changed Your Name To '%s'",PlayerName2(playerid), NewName);
        return SendClientMessage(player1,yellow,string);
}
try this now
Reply
#9

That will work if player is already connected, what if not connected ? i want on both i be able to change his name
Reply
#10

anyone know what i mean ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)