Setname Problem!
#1

I using zcmd vа mysql. but command setname does not work
(Sorry, i bad English)
Код:
CMD:setname(playerid, params[])
{
	new giveplayerid, name[MAX_PLAYER_NAME];
	if(sscanf(params, "us[24]", giveplayerid, name)) return SendClientMessageEx(playerid, COLOR_WHITE, "SUDUNG: /setname [playerid] [newname]");

	if(IsPlayerConnected(giveplayerid))
	{
		if (PlayerInfo[playerid][pAdmin] >= 4)
		{
		    if(strlen(name) > 20) return SendClientMessageEx( playerid, COLOR_WHITE, "You can't select a name that's above 20 characters." );
			new query[128], tmpName[MAX_PLAYER_NAME];
			if(strcmp(name, tmpName, false) == 0)
			{
	   			SetPVarString(playerid, "OnSetName", tmpName);

				format(query, sizeof(query), "SELECT `Username` FROM `accounts` WHERE `Username`='%s'", tmpName);
				mysql_function_query(MainPipeline, query, true, "OnSetName", "ii", playerid, giveplayerid);
			}
			else return SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid characters!");
		}
		else
		{
			SendClientMessageEx(playerid, COLOR_GRAD2, "You aren't authorised to use this command.");
		}
	}
	else
	{
		SendClientMessageEx(playerid, COLOR_GRAD2, "No Such Player");
	}
	return 1;
}

forward OnSetName(index, extraid);
public OnSetName(index, extraid)
{
	if(IsPlayerConnected(index))
	{
		if(IsPlayerConnected(extraid))
		{
		    new rows, fields;
			cache_get_data(rows, fields, MainPipeline);
			if(rows < 1)
			{
				new string[128], tmpName[24], playername[24];
				GetPVarString(index, "OnSetName", tmpName, 24);

				GetPlayerName(extraid, playername, sizeof(playername));

				if(PlayerInfo[extraid][pPhousekey] != INVALID_HOUSE_ID && strcmp(playername, HouseInfo[PlayerInfo[extraid][pPhousekey]][hOwner], true) == 0)
				{
					strmid(HouseInfo[PlayerInfo[extraid][pPhousekey]][hOwner], tmpName, 0, strlen(tmpName), 255);
					format(string, sizeof(string), "Nha so huu boi\n %s\nLevel: %d\nID: %d",HouseInfo[PlayerInfo[extraid][pPhousekey]][hOwner],HouseInfo[PlayerInfo[extraid][pPhousekey]][hLevel],PlayerInfo[extraid][pPhousekey]);
					UpdateDynamic3DTextLabelText(HouseInfo[PlayerInfo[extraid][pPhousekey]][hTextID], COLOR_GREEN, string);
				}

				if(PlayerInfo[extraid][pPhousekey2] != INVALID_HOUSE_ID && strcmp(playername, HouseInfo[PlayerInfo[extraid][pPhousekey2]][hOwner], true) == 0)
				{
					strmid(HouseInfo[PlayerInfo[extraid][pPhousekey2]][hOwner], tmpName, 0, strlen(tmpName), 255);
					format(string, sizeof(string), "Nha so huu boi\n %s\nLevel: %d\nID: %d",HouseInfo[PlayerInfo[extraid][pPhousekey2]][hOwner],HouseInfo[PlayerInfo[extraid][pPhousekey2]][hLevel],PlayerInfo[extraid][pPhousekey2]);
					UpdateDynamic3DTextLabelText(HouseInfo[PlayerInfo[extraid][pPhousekey2]][hTextID], COLOR_GREEN, string);
				}

				if(PlayerInfo[extraid][pDonateRank] >= 1)
				{
					new string2[128];
					format(string2, sizeof(string2), "[VIP NAMECHANGES] %s has changed their name to %s.", GetPlayerNameEx(extraid), tmpName);
					Log("logs/vipnamechanges.log", string2);
				}

				if(strlen(tmpName) > 0)
				{
					format(string, sizeof(string), " Ban da duoc doi ten %s la %s.", GetPlayerNameEx(extraid), tmpName);
					SendClientMessageEx(extraid,COLOR_YELLOW,string);
					format(string, sizeof(string), " You have changed %s's name to %s.", GetPlayerNameEx(extraid), tmpName);
					SendClientMessageEx(index,COLOR_YELLOW,string);
					format(string, sizeof(string), "%s changed %s's name to %s",GetPlayerNameEx(index),GetPlayerNameEx(extraid),tmpName);
					Log("logs/stats.log", string);
					format(string, sizeof(string), "UPDATE `accounts` SET `Username`='%s' WHERE `Username`='%s'", tmpName, playername);
					mysql_function_query(MainPipeline, string, true, "OnSetNameTwo", "ii", index, extraid);
					SetPlayerName(extraid, tmpName);
					OnPlayerStatsUpdate(extraid);
				}
			}
		}
	}
	DeletePVar(index, "OnSetName");
	return 1;
}
Reply
#2

mind showing us the error's if you have any?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)