Hello (/setname) problem +REP
#7

i've tried this one, and still,
it doesn't change the account name, it does in game but in Accounts no it only deletes the old name, file,i wish i can fix it , please if you can help me tell me
i'm using Y_INI Save data..

Код:
CMD:setname(playerid, params[])
{
	new string[128], giveplayerid, name[MAX_PLAYER_NAME];
	new playername[MAX_PLAYER_NAME];
	if(sscanf(params, "us[24]", giveplayerid, name)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /setname [playerid/partofname] [newname]");

	if(IsPlayerConnected(giveplayerid))
	{
		if(PlayerInfo[playerid][pAdmin] >= 4)
		{

			if(!DoesAccountExist(name))
			{
				new
					newname[MAX_PLAYER_NAME + 10];

				GetPlayerName(giveplayerid, playername, sizeof(playername));
				format(newname, sizeof(newname), "Accounts/%s.ini", name);

				format(string, sizeof(string), " Your name has been changed from %s to %s.", GetPlayerNameEx(giveplayerid), name);
				SendClientMessage(giveplayerid,COLOR_YELLOW,string);
				format(string, sizeof(string), " You have changed %s's name to %s.", GetPlayerNameEx(giveplayerid), name);
				SendClientMessage(playerid,COLOR_YELLOW,string);

				SetPlayerName(giveplayerid, name);

				format(newname, sizeof(newname), "Accounts/%s.ini", playername);
				fremove(newname);

				if(DoesAccountExist(playername))  // If it doesn't get removed, blank the file with write io and check its length when a player attempts to authenticate (it'll be 0)
				{
					new File: BlankTheFile = fopen(newname, io_write);
					SendClientMessage(playerid, COLOR_GRAD2, "The old account couldn't be removed completely (it's been blanked for future use).");
					fclose(BlankTheFile);
				}
			}
			else
			{
				SendClientMessage(playerid, COLOR_WHITE, "This name is already registered.");
			}
		}
		else
		{
			SendClientMessage(playerid, COLOR_GRAD2, "You're not authorised to use this command.");
		}
	}
	else
	{
		SendClientMessage(playerid, COLOR_GRAD2, "No Such Player");
	}
	return 1;
}
And here the stock of "DoesAccountExist"

Код:
stock DoesAccountExist(account_name[])
{
	new sz_accStr[MAX_PLAYER_NAME + 12], File:f_Handle;

	format(sz_accStr, sizeof(sz_accStr), "Accounts/%s.ini", account_name);
	if(fexist(sz_accStr)) {

		if(!(f_Handle = fopen(sz_accStr, io_read))) {
			return 1;
		}

		if(flength(f_Handle) > 0) {
			fclose(f_Handle);
			return 1;
		}
		fclose(f_Handle);
	}
	return 0;
}
Reply


Messages In This Thread
Hello (/setname) problem +REP - by Antoniohl - 16.04.2015, 03:08
Re: Hello (/setname) problem +REP - by Antoniohl - 16.04.2015, 04:00
Respuesta: Hello (/setname) problem +REP - by JuanStone - 16.04.2015, 04:16
Re: Hello (/setname) problem +REP - by SickAttack - 16.04.2015, 06:32
Re: Hello (/setname) problem +REP - by iiNzTicTx - 16.04.2015, 09:03
Re: Hello (/setname) problem +REP - by Antoniohl - 16.04.2015, 16:57
Re: Hello (/setname) problem +REP - by Antoniohl - 16.04.2015, 21:55
Re: Hello (/setname) problem +REP - by Antoniohl - 17.04.2015, 03:22
Re: Hello (/setname) problem +REP - by Threshold - 17.04.2015, 09:03
Re: Hello (/setname) problem +REP - by Antoniohl - 17.04.2015, 16:50

Forum Jump:


Users browsing this thread: 1 Guest(s)