Raised This Month: $32 Target: $400
 8% 

[TF2] Melee for One team only?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DeathGod
Junior Member
Join Date: Jan 2016
Old 11-23-2017 , 23:43   [TF2] Melee for One team only?
Reply With Quote #1

Is there a way of setting one team to only melee? I've searched for melee plugins but I can't find any that can set only one team to melee.

Any help?
__________________
DeathGod is offline
Drixevel
AlliedModders Donor
Join Date: Sep 2009
Location: Somewhere headbangin'
Old 11-24-2017 , 09:56   Re: [TF2] Melee for One team only?
Reply With Quote #2

Code:
//Pragma
#pragma semicolon 1
#pragma newdecls required

//Sourcemod Includes
#include <sourcemod>
#include <tf2_stocks>

public Plugin myinfo =
{
	name = "Melee Only For Team",
	author = "Keith Warren (Drixevel)",
	description = "Melee only for one team.",
	version = "1.0.0",
	url = "http://www.drixevel.com/"
};

public void OnPluginStart()
{
	HookEvent("player_spawn", Event_OnPlayerSpawn);
}

public void Event_OnPlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
	int client = GetClientOfUserId(GetEventInt(event, "userid"));
	
	if (client > 0 && IsClientInGame(client) && IsPlayerAlive(client) && TF2_GetClientTeam(client) == TFTeam_Red)
	{
		TF2_AddCondition(client, TFCond_RestrictToMelee, TFCondDuration_Infinite);
	}
}

public void TF2_OnConditionAdded(int client, TFCond condition)
{
	if (condition == TFCond_RestrictToMelee && TF2_GetClientTeam(client) == TFTeam_Red)
	{
		int melee = GetPlayerWeaponSlot(client, TFWeaponSlot_Melee);
		
		if (IsValidEntity(melee))
		{
			SetEntPropEnt(client, Prop_Send, "m_hActiveWeapon", melee);
		}
	}
}

public void TF2_OnConditionRemoved(int client, TFCond condition)
{
	if (condition == TFCond_RestrictToMelee && TF2_GetClientTeam(client) == TFTeam_Red)
	{
		TF2_AddCondition(client, TFCond_RestrictToMelee, TFCondDuration_Infinite);
	}
}
Change all signs of 'TFTeam_Red' to 'TFTeam_Blue' if you want it to be the blue team.
Attached Files
File Type: sp Get Plugin or Get Source (meleeonly.sp - 359 views - 1.3 KB)

Last edited by Drixevel; 11-25-2017 at 09:12.
Drixevel is offline
DeathGod
Junior Member
Join Date: Jan 2016
Old 11-24-2017 , 23:34   Re: [TF2] Melee for One team only?
Reply With Quote #3

I'm pretty new to this, where would I add this code to?
__________________
DeathGod is offline
RumbleFrog
Great Tester of Whatever
Join Date: Dec 2016
Location: Fish Tank
Old 11-25-2017 , 11:26   Re: [TF2] Melee for One team only?
Reply With Quote #4

Quote:
Originally Posted by DeathGod View Post
I'm pretty new to this, where would I add this code to?
Hit "Get Plugin" and drag it to your Sourcemod plugins folder.
__________________
RumbleFrog 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 02:16.


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