Raised This Month: $209 Target: $400
 52% 

only teamates show in menu


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mrmiki
Junior Member
Join Date: Mar 2021
Old 05-30-2021 , 09:48   only teamates show in menu
Reply With Quote #1

hello
how can i make this plugin to show only temates in menu not all players?

HTML Code:
#include <sourcemod>
#pragma semicolon 1

public void OnPluginStart()
{
	RegConsoleCmd("sm_mute1", Command_Mute);
}

public Action:Command_Mute(id, args)
{	
	new client = id;
	if(client == -1)
	{
		return Plugin_Handled;
	}
	DisplayTargetsMenu(client);
	
	return Plugin_Handled;
}

void CheckAndPerformBan(int client, char[] sName, int minutes, char[] reason)
{
		ServerCommand("sm_mute \"%s\" %d %s", sName, minutes, reason);

}

public void DisplayTargetsMenu(int client)
{
	Menu MainMenu = new Menu(TargetsMenu_CallBack, MenuAction_Select | MenuAction_End);
	MainMenu.SetTitle("Select a target!");
	char sDisplayBuffer[128], sInfo2[32], sName[MAX_NAME_LENGTH];
	//char sName[MAX_NAME_LENGTH], sInfo2[8];
	for(int target = 1; target <= MaxClients; target++)
	{
		if(IsClientInGame(target) && !IsFakeClient(target) && CanUserTarget(client, target))
		{
			GetClientName(target, sName, sizeof(sName));
			IntToString(GetClientUserId(target), sInfo2, sizeof(sInfo2));
			Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%s (%s)", sName, sInfo2);
			MainMenu.AddItem(sName, sDisplayBuffer);
		}
	}
	
	SetMenuExitBackButton(MainMenu, true);
	DisplayMenu(MainMenu, client, MENU_TIME_FOREVER);
}
public int TargetsMenu_CallBack(Menu MainMenu, MenuAction action, int param1, int param2)
{
	switch (action)
	{
		case MenuAction_Select:
		{
			char sInfo[128];
			GetMenuItem(MainMenu, param2, sInfo, sizeof(sInfo));
			DisplayBanTimeMenu(param1, sInfo);
		}
		case MenuAction_Cancel:
		{

			
		}
		case MenuAction_End:
		{
			CloseHandle(MainMenu);
		}
	}
}
public void DisplayBanTimeMenu(int client, char[] sInfo)
{
	Menu BanTimeMenu = new Menu(BanTime_CallBack, MenuAction_Select | MenuAction_End);
	BanTimeMenu.SetTitle("Select A Time:");
	char sInfoBuffer[128];
	Format(sInfoBuffer, sizeof(sInfoBuffer), "%s,30240", sInfo);
	BanTimeMenu.AddItem(sInfoBuffer, "1 Week");
	Format(sInfoBuffer, sizeof(sInfoBuffer), "%s,0", sInfo);
	BanTimeMenu.AddItem(sInfoBuffer, "Permanent");
	Format(sInfoBuffer, sizeof(sInfoBuffer), "%s,5", sInfo);
	BanTimeMenu.AddItem(sInfoBuffer, "5 Min");
	Format(sInfoBuffer, sizeof(sInfoBuffer), "%s,30", sInfo);
	BanTimeMenu.AddItem(sInfoBuffer, "30 Min");
	Format(sInfoBuffer, sizeof(sInfoBuffer), "%s,360", sInfo);
	BanTimeMenu.AddItem(sInfoBuffer, "1 Hour");
	Format(sInfoBuffer, sizeof(sInfoBuffer), "%s,1440", sInfo);
	BanTimeMenu.AddItem(sInfoBuffer, "1 Day");
	Format(sInfoBuffer, sizeof(sInfoBuffer), "%s,30240", sInfo);
	BanTimeMenu.AddItem(sInfoBuffer, "3 Weeks");
	Format(sInfoBuffer, sizeof(sInfoBuffer), "%s,43830", sInfo);
	BanTimeMenu.AddItem(sInfoBuffer, "1 Month");
	Format(sInfoBuffer, sizeof(sInfoBuffer), "%s,131490", sInfo);
	BanTimeMenu.AddItem(sInfoBuffer, "3 Months");
	Format(sInfoBuffer, sizeof(sInfoBuffer), "%s,262980", sInfo);
	BanTimeMenu.AddItem(sInfoBuffer, "6 Months");
	SetMenuExitBackButton(BanTimeMenu, true);
	DisplayMenu(BanTimeMenu, client, MENU_TIME_FOREVER);
}
public int BanTime_CallBack(Handle BanTimeMenu, MenuAction action, int param1, int param2)
{
	switch (action)
	{
		case MenuAction_Select:
		{
			char sInfo[128];
			GetMenuItem(BanTimeMenu, param2, sInfo, sizeof(sInfo));
			DisplayBanReasonMenu(param1, sInfo);
		}
		case MenuAction_Cancel:
		{

		}
		case MenuAction_End:
		{
			CloseHandle(BanTimeMenu);
		}
	}
}
void DisplayBanReasonMenu(int client, char[] sInfo)
{
	Menu BanReasonMenu = new Menu(BanReason_CallBack, MenuAction_Select | MenuAction_End);
	BanReasonMenu.SetTitle("Select A Reason:");
	char sInfoBuffer[128];
	Format(sInfoBuffer, sizeof(sInfoBuffer), "%s,DJ", sInfo);
	BanReasonMenu.AddItem(sInfoBuffer, "DJ");
	Format(sInfoBuffer, sizeof(sInfoBuffer), "%s,Mic spamming", sInfo);
	BanReasonMenu.AddItem(sInfoBuffer, "Mic spamming");
	Format(sInfoBuffer, sizeof(sInfoBuffer), "%s,Foreign Lanquage", sInfo);
	BanReasonMenu.AddItem(sInfoBuffer, "Foreign Lanquage");
	Format(sInfoBuffer, sizeof(sInfoBuffer), "%s,Ignoring Admin", sInfo);
	BanReasonMenu.AddItem(sInfoBuffer, "Ignoring Admin");
	Format(sInfoBuffer, sizeof(sInfoBuffer), "%s,Broken Mic", sInfo);
	BanReasonMenu.AddItem(sInfoBuffer, "Broken Mic");
	SetMenuExitBackButton(BanReasonMenu, true);
	DisplayMenu(BanReasonMenu, client, MENU_TIME_FOREVER);
}
public int BanReason_CallBack(Handle BanReasonMenu, MenuAction action, int param1, int param2)
{
	switch (action)
	{
		case MenuAction_Select:
		{
			char sInfo[128], sTempArray[3][64];
			GetMenuItem(BanReasonMenu, param2, sInfo, sizeof(sInfo));
			ExplodeString(sInfo, ",", sTempArray, 3, 64);
			CheckAndPerformBan(param1, sTempArray[0], StringToInt(sTempArray[1]), sTempArray[2]);
		}
		case MenuAction_Cancel:
		{

		}
		case MenuAction_End:
		{
			CloseHandle(BanReasonMenu);
		}
	}
}

Last edited by mrmiki; 05-30-2021 at 09:49.
mrmiki is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 05-30-2021 , 19:01   Re: only teamates show in menu
Reply With Quote #2

Code:
if(IsClientInGame(target) && !IsFakeClient(target) && CanUserTarget(client, target) && GetClientTeam(client) == GetClientTeam(target))
__________________
Discord: Drixevel#9016 - Steam Profile - Github (Always taking paid work, add me.)

Last edited by Drixevel; 05-31-2021 at 04:30.
Drixevel is offline
mrmiki
Junior Member
Join Date: Mar 2021
Old 05-31-2021 , 22:45   Re: only teamates show in menu
Reply With Quote #3

tnq its solved <3

also i need another help
i want to save teams scores to a txt file at the end of the match
like ct score :16 | t score : 14
also if it could save players kills and deaths and mvp and headshots

i know it is very big request but i couldnt find or create any



HTML Code:
#pragma semicolon 1
#include <sourcemod>
#include <cstrike>
#include <sdktools>
static String:chatFile[128];
new Handle:fileHandle       = INVALID_HANDLE;


public void OnPluginStart() {
    HookEvent("cs_intermission", Event_MapEnd);
    
    
    new String:date[21];
    new String:logFile[100];
    FormatTime(date, sizeof(date), "%d%m%y", -1);
    Format(logFile, sizeof(logFile), "/data/scores%s.txt", date);
    BuildPath(Path_SM, chatFile, PLATFORM_MAX_PATH, logFile);
}

public OnMapStart(){
	new String:map[128];
	new String:msg[1024];
	new String:date[21];
	new String:time[21];
	new String:logFile[100];

	GetCurrentMap(map, sizeof(map));

	/* The date may have rolled over, so update the logfile name here */
	FormatTime(date, sizeof(date), "%d%m%y", -1);
	Format(logFile, sizeof(logFile), "/logs/chat%s.log", date);
	BuildPath(Path_SM, chatFile, PLATFORM_MAX_PATH, logFile);

	FormatTime(time, sizeof(time), "%d/%m/%Y %H:%M:%S", -1);
	Format(msg, sizeof(msg), "[%s] --- NEW MAP STARTED: %s ---", time, map);

	SaveMessage("--=================================================================--");
	SaveMessage(msg);
	SaveMessage("--=================================================================--");
}

public Action Event_MapEnd(Event event, const char[] name, bool dontBroadcast) 
{
	new String:msg[1024];
	int scorect = CS_GetTeamScore(CS_TEAM_CT);
	int scoret = CS_GetTeamScore(CS_TEAM_T);
	
	
	Format(msg, sizeof(msg), "Team CT: score %s | Team T: score %s", scorect, scoret);
	
	SaveMessage(msg);

}

public SaveMessage(const String:message[])
{
	fileHandle = OpenFile(chatFile, "a");  /* Append */
	WriteFileLine(fileHandle, message);
	CloseHandle(fileHandle);
}
mrmiki is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:02.


Powered by vBulletin®
Copyright ©2000 - 2021, vBulletin Solutions, Inc.
Theme made by Freecode