Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
4.3 kB
1
Indexable
Never
CMD:faction(playerid, params[]) {
	if(PlayerInfo[playerid][pMember] != INVALID_GROUP_ID) 
	{
		new Cache:Result,pNameget[128],vzstr[50000];
		Result = mysql_query(MainPipeline, "SELECT `LastLogin`, `Username`, `Member`, `Leader`, `Rank`, `Level` FROM `accounts` WHERE `Member` >= 0");
		new count;
		new leader;
		new level;
		new rank;
		new LastLogin[255];
		if(cache_num_rows())
		{
			for(new i = 0; i < cache_num_rows(); i++)
			{
				cache_get_field_content(i, "LastLogin", LastLogin);
				cache_get_field_content(i, "Username", pNameget);
				count = cache_get_field_content_int(i, "Member");
				leader = cache_get_field_content_int(i, "Leader");
				rank = cache_get_field_content_int(i, "Rank");
				level = cache_get_field_content_int(i, "Level");
				if(count == PlayerInfo[playerid][pMember])
				{
					if(leader == INVALID_GROUP_ID)
						format(vzstr, sizeof(vzstr), "%s%s\t%d\t%d\t%s\n", vzstr, pNameget, level, rank, LastLogin);
					else
						format(vzstr, sizeof(vzstr), "%s%s (Leader)\t%d\t%d\t%s\n", vzstr, pNameget, level, rank, LastLogin);
				}
			}
		}
		else
		{
			return SendClientMessage(playerid, COLOR_WHITE, "Khong xu ly duoc du lieu");
		}
		cache_delete(Result);
		new danhsach[50000];
		format(danhsach, sizeof(danhsach), "Nguoi choi\tLevel\tRank\tLast Login\n%s", vzstr);
		ShowPlayerDialog(playerid, DIALOG_THANHVIEN_FACTION, DIALOG_STYLE_TABLIST_HEADERS, "List Faction Member", danhsach, "Dong y", "Huy bo");
	}
	return 1;
}

hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
	if(dialogid == DIALOG_THANHVIEN_FACTION && response == 1)  
	{
		if(PlayerInfo[playerid][pLeader] != INVALID_GROUP_ID) 
		{
			SetPVarString(playerid, "FactionKickName", inputtext);

			new string[1280];
			format(string, sizeof(string), "{FFFFFF}> Ban co dong y kick %s ra khoi %s khong?", inputtext,  arrGroupData[PlayerInfo[playerid][pMember]][g_szGroupName]);
		 	ShowPlayerDialog(playerid, DIALOG_FACTION_KICK, DIALOG_STYLE_MSGBOX, "Faction Kick", string, "Dong y", "{ff0000}Huy bo{FFFFFF}");
			return 1;
		}
	}

	if(dialogid == DIALOG_FACTION_KICK && response == 1) {
		new name[128];
		GetPVarString(playerid, "FactionKickName", name, sizeof(name));
		KickGuildOff(playerid, name);
		return 1;
	}
	return 1;
}

stock KickGuildOff(playerid, playername[]) {
	new giveplayerid = ReturnUser(playername);
	if(IsPlayerConnected(giveplayerid))
	{
	    if(PlayerInfo[giveplayerid][pLeader] == INVALID_GROUP_ID)
	    {
			new string[1280];
			format(string, sizeof(string), "[FACTION KICK]: %s da kick %s ra khoi guild %s.", GetPlayerNameEx(playerid), GetPlayerNameEx(giveplayerid), arrGroupData[PlayerInfo[playerid][pMember]][g_szGroupName]);
			Log("logs/factionkick.log", string);

			SendClientMessageEx(playerid, COLOR_LIGHTRED, string);
			SendClientMessageEx(giveplayerid, COLOR_LIGHTRED, string);

			PlayerInfo[giveplayerid][pDuty] = 0;
			PlayerInfo[giveplayerid][pMember] = INVALID_GROUP_ID;
			PlayerInfo[giveplayerid][pRank] = INVALID_RANK;
			PlayerInfo[giveplayerid][pLeader] = INVALID_GROUP_ID;
			PlayerInfo[giveplayerid][pDivision] = INVALID_DIVISION;
			if(!IsValidSkin(GetPlayerSkin(giveplayerid)))
			{
				new rand = random(sizeof(CIV));
				SetPlayerSkin(giveplayerid,CIV[rand]);
				PlayerInfo[giveplayerid][pModel] = CIV[rand];
			}
			player_remove_vip_toys(giveplayerid);
			pTazer{giveplayerid} = 0;
			SetPlayerToTeamColor(giveplayerid);
			return 1;
		}else SendClientMessageEx(playerid, COLOR_LIGHTRED, "> Ban khong duoc phep kick nhung thanh vien Leader.");
	}
	else
	{
		new query[128], tmpName[24];
		mysql_escape_string(playername, tmpName);
		format(query, sizeof(query), "UPDATE `accounts` SET `Member`=-1,`Leader`=-1 WHERE `Username`='%s'", tmpName);
		mysql_function_query(MainPipeline, query, false, "GuildTakeOffline", "i", playerid);

        new string[1280];
		format(string, sizeof(string), "[FACTION KICK OFFLINE]: %s da kick %s ra khoi %s.", GetPlayerNameEx(playerid), tmpName, arrGroupData[PlayerInfo[playerid][pMember]][g_szGroupName]);
		Log("logs/factionkick.log", string);
        SendClientMessageEx(playerid, COLOR_LIGHTRED, string);
        return 1;
	}
	return 1;
}
Leave a Comment