SA-MP Forums Archive
Fremove/Frename - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Fremove/Frename (/showthread.php?tid=104753)



Fremove/Frename - bigcomfycouch - 26.10.2009

Hm. So, my /setname removes old player accounts and replaces them with the new name. It works perfectly on my home server, but when I upload it to the official server, it starts to clone accounts. Is this something with the host or is it just something wrong with the code?

Код:
zcmd(setname, playerid, params[])
{
	if(!IsPlayerConnected(playerid)) return 1;
	if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GRAD1, NO_AUTH_MSG);
	new giveplayerid, giveplayer[MAX_PLAYER_NAME], sendername[MAX_PLAYER_NAME], newname[MAX_PLAYER_NAME], string[128], string2[40];
	if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_GRAD1, BAD_ID_MSG);
	if(giveplayerid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GRAD1, BAD_ID_MSG);
	if(sscanf(params, "us", giveplayerid, newname)) return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /setname [playerid/PartOfName] [new nick]");
	GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
	GetPlayerName(playerid, sendername, sizeof(sendername));
	format(string2, sizeof(string2), "Players/%s.ini", newname);
	if(fexist(string2)) return SendClientMessage(playerid, COLOR_YELLOW, "That name is already registered, please try another.");
	format(string, sizeof(string), "Players/%s.ini", giveplayer);
	SetPlayerName(giveplayerid,newname);
	fremove(string);
	format(string, sizeof(string), "AdmCmd: %s has changed ID %s's name to %s",sendername, giveplayer, newname);
	ABroadCast(COLOR_YELLOW, string, 1);
	SaveAccount(giveplayerid);
	return 1;
}
Don't say anything about the efficiency of the code, I'll bother with that. I care if it works or not. I'm hosted on samp-servers.com by the way, if that matters. I'm just guessing it's the host because it works fine on my test server. Anybody know?