SA-MP Forums Archive
[Pedido] Novo nick - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: Non-English (https://sampforum.blast.hk/forumdisplay.php?fid=9)
+--- Forum: Languages (https://sampforum.blast.hk/forumdisplay.php?fid=33)
+---- Forum: Português/Portuguese (https://sampforum.blast.hk/forumdisplay.php?fid=34)
+---- Thread: [Pedido] Novo nick (/showthread.php?tid=615204)



Novo nick - Dishz - 18.08.2016

Bom, eu quero criar um comando para as pessoas mudarem o nick, meu sistema de salvamento й em dini, quem puder me ajudar eu agradeзo de coraзгo.


Re: Novo nick - Carlos001 - 19.08.2016

Aki: http://pastebin.com/TN6M0JTR
bom nгo й em DINI mas e so voce mudar de D0F2 para dini, nao conheзo as funзхes de Dini se nao eu mesmo passava
й so voce Adptar para seu Gm


Re: Novo nick - Dishz - 19.08.2016

Pode ser desse tipo, mas precisava em dini e dcmd.


Re: Novo nick - Whoo - 19.08.2016

http://pastebin.com/BWJyNjyV


Re: Novo nick - Dishz - 19.08.2016

Whoo, jб olhei esse link, mais na real que achei mt complicado, mas se nгo tiver nenhum outro, vou ter que vк o que faзo.


Re: Novo nick - F1N4L - 19.08.2016

Quote:
Originally Posted by Dishz
Посмотреть сообщение
Whoo, jб olhei esse link, mais na real que achei mt complicado, mas se nгo tiver nenhum outro, vou ter que vк o que faзo.
https://sampforum.blast.hk/showthread.php?tid=614793

A lуgica й exatamente a mesma, o que muda sгo as funзхes, pois estб estб em dof2.


Re: Novo nick - Dishz - 19.08.2016

Quote:
Originally Posted by F1N4L
Посмотреть сообщение
https://sampforum.blast.hk/showthread.php?tid=614793

A lуgica й exatamente a mesma, o que muda sгo as funзхes, pois estб estб em dof2.
Ok, mas onde encontro essa funзгo DOF2_RenameFile em dini?


Re: Novo nick - F1N4L - 19.08.2016

Lуgica bбsica de File Functions:

@edit
Код:
stock RenameFile(File_Name[], To_Name[])
{
	if(!fexist(File_Name)) return 0;
	if(fexist(To_Name)) return 0;
	
	new Buf[128], CopyLines[256], File:Rename, File:NewFile;
	
	Rename = fopen(File_Name, io_read);
	
	for(new i = 0; i < 50; ++ i)
	{
		fread(Rename, Buf);
		strcat(CopyLines, Buf);
	}
	
	NewFile = fopen(To_Name, io_write);
	
	fclose(Rename);
	fremove(File_Name);
	
	fwrite(NewFile, CopyLines);
	fclose(NewFile);
	
	return true;
}



Re: Novo nick - Dishz - 19.08.2016

Код:
dcmd_mudarnick(playerid,params[])
{
	new str[60], str2[60], name[32], logstring[60];

	if(isnull(params)) return SendClientMessage(playerid, ERRO, "[NOVONICK] /MudarNick [Nick novo]");
	if(!IsPlayerSpawned(playerid)) return SendClientMessage(playerid, ERRO, "[ERRO] Vocк nгo pode usar comandos antes de spawnar!");
	if(strlen(params) < 3) return SendClientMessage(playerid, ERRO,"[ERRO] Tamanho incorreto (Muito Pequeno)");
	if(strlen(params) > 20) return SendClientMessage(playerid, ERRO,"[ERRO] Tamanho incorreto (Muito Grande)");
	if(dini_Exists(str2)) return SendClientMessage(playerid, -1, "Esse nome jб estб registrado!!!!");

	GetPlayerName(playerid, name, sizeof(name));
	format(logstring, sizeof(logstring), "[NICK] %s mudou o nick para \"%s\"", name,params);
	SendClientMessageToAll(0xFFFF00FF,logstring);

	format(str, sizeof(str), "Admin/Contas/%s.ini", name);

	if(!dini_Exists(str)) return SendClientMessage(playerid, ERRO, "[ERRO] Seu nick atual nгo bate com o nick dos nossos arquivos, consulte um administrador!");

	format(str2, sizeof(str2), "Admin/Contas/%s.ini", params);

	RenameFile(str, str2);

	SetPlayerName(playerid, params);
	SendClientMessage(playerid, ERRO,"[NICK] Vocк trocou seu NickName com sucesso! Vocк deve relogar.");
	SetPlayerHealth(playerid,0.0);
	ForceClassSelection(playerid);

	return true;
}
Atualmente estб assim, mas quando o player coloca o nick igual ao atual, ele nгo estб chamando essa funзгo.
Код:
if(dini_Exists(str2)) return SendClientMessage(playerid, -1, "Esse nome jб estб registrado!");
E seta o novo nick, igual ao o antigo.


Re: Novo nick - F1N4L - 20.08.2016

Vocк nгo estб usando os parвmetros digitados, mas sim uma string nula!

Altere para params
Код:
if(dini_Exists(str2)) return SendClientMessage(playerid, -1, "Esse nome jб estб registrado!!!!");