Y_INI Changenick problem
#1

Hello everyone, i'm having a problem with my Changenick command

Код:
CMD:cambianick(playerid, params[])
{
	new name[25];
	new string[256];
	if(sscanf(params, "s", name))return SendClientMessage(playerid, COLOR_RED, "Usa: /cambianick [nome]");

	if(strlen(name) < 3)return SendClientMessage(playerid, COLOR_RED, "Errore: La lunghezza del nome non puo' essere minore di 3!");
	if(strlen(name) > MAX_PLAYER_NAME)return SendClientMessage(playerid, COLOR_RED, "Errore: La lunghezza del nome non puo' superare il limite!");
	new file[64];
	format(file, sizeof(file), "/Users/%s.ini", name);// change it to your User Path
	if (fexist(file)) return SendClientMessage(playerid, COLOR_RED, "Errore: Quel nome e' gia in uso!");
	fremove(UserPath(playerid));
	SetPlayerName(playerid,name);
	format(string,sizeof(string),"%s ha effettuato un cambio nome! E' stato kickato per poter salvare i suoi dati");
	SendClientMessageToAll(Lightblue,string);
        Kick(playerid);
	return 1;
}
Here's the OnPlayerDisconnect stuff
Код:
new INI:File = INI_Open(UserPath(playerid));
	INI_SetTag(File,"data");
	INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
	INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
	INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]);
	INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]);
	INI_WriteInt(File,"Exp",PlayerInfo[playerid][pExp]);
	INI_WriteInt(File,"Level",PlayerInfo[playerid][pLevel]);
	INI_WriteInt(File,"Clan",PlayerInfo[playerid][pClan]);
	INI_WriteInt(File,"ClanKills",PlayerInfo[playerid][pCKills]);
	INI_WriteInt(File,"Skin",PlayerInfo[playerid][pSkin]);
	INI_WriteInt(File,"Bank",PlayerInfo[playerid][pBank]);
	INI_WriteInt(File,"VIP",PlayerInfo[playerid][pVIP]);
	INI_WriteInt(File,"Eventi",PlayerInfo[playerid][pGare]);

	INI_Close(File);
For some reason everytime i use this command the .ini files changes its name but the Password gets deleted like this:

Before doing the command:
Код:
[data]
ClanKills = 0
Level = 2
Exp = 2
Deaths = 0
Kills = 0
Admin = 10
Cash = 150000
Password = *** Hidden for obvious reasons
Eventi = 0
VIP = 0
Bank = 36000
Skin = 129
Clan = 1
After the command:

Код:
[data]
ClanKills = 0
Level = 2
Exp = 2
Deaths = 0
Kills = 0
Admin = 10
Cash = 150000
Eventi = 0
VIP = 0
Bank = 36000
Skin = 129
Clan = 1
I tried everything but the bug it's still around, it fixes only if i don't use the command and i only save stats when a player disconnects
Reply
#2

You're creating a new file with that player's name but you're not saving the player's password.

You can either or save the password under OnPlayerDisconnect, or write it in the file when the player type the command, up to you.
Reply
#3

Quote:
Originally Posted by Troydere
Посмотреть сообщение
You're creating a new file with that player's name but you're not saving the player's password.
Mhmm, i followed this tutorial:https://sampforum.blast.hk/showthread.php?tid=273088

In his "OnPlayerDisconnect" there's no password saved, my system works but when i add something external (Like an autosave function) the password doesn't get saved.
Reply
#4

Try adding this under OnPlayerDisconnect:

Код:
INI_WriteInt(File,"Password",PlayerInfo[playerid][pPass]);
Reply
#5

Quote:
Originally Posted by Troydere
Посмотреть сообщение
Try adding this under OnPlayerDisconnect:

Код:
INI_WriteInt(File,"Password",PlayerInfo[playerid][pPass]);
It seems to work now, thank you for the help!
I have another question: i'm using an external House System (This one:https://sampforum.blast.hk/showthread.php?tid=283501)
I'd like to change the name even in the "house's .ini" and update it in real time.

How can i do this? I simply have no idea :/
Reply
#6

I wouldn't do it if I were you, that is a well-made complex house system. It'd be better to not touch any of it.

However, as you learn quickly, you can look for guides to make your own. That'd be way better than changing values of other's system.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)