Raised This Month: $12 Target: $400
 3% 

Solved [REQ/IDEA][TF2]Plugin requests (ideas?)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xjonx
Member
Join Date: Nov 2016
Location: Builders League UnitedHQ
Old 11-12-2016 , 16:28   [REQ/IDEA][TF2]Plugin requests (ideas?)
Reply With Quote #1

I am trying to replicate Muselk's zombie mode on my server. I've got everything down besides last man standing crits and blue team based medic double jumping. This leads to the requests/ideas.

1.) A plugin that detects if there is one man standing in red team, then executes a command (ie. I have two plugins: one which gives crits to a selected player and one that has double jump for everyone)

2.) A plugin that can toggle the enabling of double jumping for the blue team only. Not like super jumping from Saxton hale, but like this (however, it isn't team based.) (which could probably make this easier, as the double jump code is already in that plugin)

I don't expect you to make these. I don't "need" these plugins as I could go without crits and have double jump for everyone, but having these plugins will make it more authentic.

Thanks for reading
__________________
I'm sometimes slow at responding... just be patient.
My favorite quote: "...for I believe in an eye for an eye."
My Website: http://jon-xjonx-nat.jimdo.com/

Last edited by xjonx; 11-26-2016 at 19:14. Reason: Requests Fullfilled
xjonx is offline
Send a message via Skype™ to xjonx
Jillchang
Senior Member
Join Date: Mar 2014
Old 11-13-2016 , 01:13   Re: [REQ/IDEA][TF2]Plugin requests (ideas?)
Reply With Quote #2

can you share the zombie mod plugin? Maybe that will help others pitch in.
Jillchang is offline
xjonx
Member
Join Date: Nov 2016
Location: Builders League UnitedHQ
Old 11-14-2016 , 21:07   Re: [REQ/IDEA][TF2]Plugin requests (ideas?)
Reply With Quote #3

Quote:
Originally Posted by Jillchang View Post
can you share the zombie mod plugin? Maybe that will help others pitch in.
The zombie plugin was made privately for Muselk and isn't released.I'm just using a bunch of plugins to replicate it.
__________________
I'm sometimes slow at responding... just be patient.
My favorite quote: "...for I believe in an eye for an eye."
My Website: http://jon-xjonx-nat.jimdo.com/
xjonx is offline
Send a message via Skype™ to xjonx
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 11-14-2016 , 23:13   Re: [REQ/IDEA][TF2]Plugin requests (ideas?)
Reply With Quote #4

For 1, i wrote the plugin to give crits to the last man standing on red team as it is more efficient than executing another plugin to give crits.

Code:
#pragma semicolon 1

#define PLUGIN_AUTHOR "Tak (Chaosxk)"
#define PLUGIN_VERSION "1.0"

#include <sourcemod>
#include <tf2_stocks>

#pragma newdecls required

int g_iRedCounter;

public Plugin myinfo = 
{
	name = "[TF2] One man standing ~ Crits",
	author = PLUGIN_AUTHOR,
	description = "1 man on red = Crits",
	version = PLUGIN_VERSION,
	url = "https://forums.alliedmods.net/showthread.php?t=290409"
};

public void OnPluginStart()
{
	HookEvent("teamplay_round_start", Event_RoundStart);
	HookEvent("player_spawn", Event_PlayerSpawn);
	HookEvent("player_death", Event_PlayerDeath);
	
	//late-load execute
	g_iRedCounter = GetRedCount();
}

public Action Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
{
	//Resets the counter when new round starts
	g_iRedCounter = GetRedCount();
}

//Don't think this event is necessary unless map or admin respawns players
//Just a precaution i guess, so it doesn't bug out if you do respawn
public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
	int client = GetClientOfUserId(event.GetInt("userid"));
	
	if (TF2_GetClientTeam(client) != TFTeam_Red)
		return Plugin_Continue;
	
	g_iRedCounter++;
	return Plugin_Continue;
}

public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
{
	int client = GetClientOfUserId(event.GetInt("userid"));
	
	if (TF2_GetClientTeam(client) != TFTeam_Red)
		return Plugin_Continue;
	
	if (--g_iRedCounter == 1)
	{
		for (int i = 1; i <= MaxClients; i++)
		{
			if (!IsClientInGame(i) || !IsPlayerAlive(i) || TF2_GetClientTeam(i) != TFTeam_Red)
				continue;
			TF2_AddCondition(i, TFCond_Kritzkrieged, TFCondDuration_Infinite);
			//Break as we should only be getting 1 player alive on red
			break;
		}
	}
	return Plugin_Continue;
}

//GetClientCount of red team INCLUDING bots
int GetRedCount()
{
	int r;
	for (int i = 1; i <= MaxClients; i++)
	{
		if (!IsClientInGame(i) || TF2_GetClientTeam(i) != TFTeam_Red)
			continue;
		r++;
	}
	return r;
}
For 2, i edited the plugin you linked to only work for blue team.

Code:
/*
 * Double Jump
 *
 * Description:
 *  Allows players to double-jump
 *  Original idea: NcB_Sav
 *
 * Convars:
 *  sm_doublejump_enabled [bool] : Enables or disable double-jumping. Default: 1
 *  sm_doublejump_boost [amount] : Amount to boost the player. Default: 250
 *  sm_doublejump_max [jumps]    : Maximum number of re-jumps while airborne. Default: 1
 *
 * Changelog:
 *  v1.0.1
 *   Minor code optimization.
 *  v1.0.0
 *   Initial release.
 *
 * Known issues:
 *  Doesn't register all mouse-wheel triggered +jumps
 *
 * Todo:
 *  Employ upcoming OnClientCommand function to remove excess OnGameFrame-age.
 *
 * Contact:
 *  Paegus: [email protected]
 *  SourceMod: http://www.sourcemod.net
 *  Hidden:Source: http://www.hidden-source.com
 *  NcB_Sav: http://forums.alliedmods.net/showthread.php?t=99228
 */
#define PLUGIN_VERSION		"1.0.1"

#include <sdktools>


public Plugin:myinfo = {
	name		= "Double Jump",
	author		= "Paegus",
	description	= "Allows double-jumping.",
	version		= PLUGIN_VERSION,
	url			= ""
}

new
	Handle:g_cvJumpBoost	= INVALID_HANDLE,
	Handle:g_cvJumpEnable	= INVALID_HANDLE,
	Handle:g_cvJumpMax		= INVALID_HANDLE,
	Float:g_flBoost			= 250.0,
	bool:g_bDoubleJump		= true,
	g_fLastButtons[MAXPLAYERS+1],
	g_fLastFlags[MAXPLAYERS+1],
	g_iJumps[MAXPLAYERS+1],
	g_iJumpMax
	
public OnPluginStart() {
	CreateConVar(
		"sm_doublejump_version", PLUGIN_VERSION,
		"Double Jump Version",
		FCVAR_PLUGIN|FCVAR_NOTIFY
	)
	
	g_cvJumpEnable = CreateConVar(
		"sm_doublejump_enabled", "1",
		"Enables double-jumping.",
		FCVAR_PLUGIN|FCVAR_NOTIFY
	)
	
	g_cvJumpBoost = CreateConVar(
		"sm_doublejump_boost", "250.0",
		"The amount of vertical boost to apply to double jumps.",
		FCVAR_PLUGIN|FCVAR_NOTIFY
	)
	
	g_cvJumpMax = CreateConVar(
		"sm_doublejump_max", "1",
		"The maximum number of re-jumps allowed while already jumping.",
		FCVAR_PLUGIN|FCVAR_NOTIFY
	)
	
	HookConVarChange(g_cvJumpBoost,		convar_ChangeBoost)
	HookConVarChange(g_cvJumpEnable,	convar_ChangeEnable)
	HookConVarChange(g_cvJumpMax,		convar_ChangeMax)
	
	g_bDoubleJump	= GetConVarBool(g_cvJumpEnable)
	g_flBoost		= GetConVarFloat(g_cvJumpBoost)
	g_iJumpMax		= GetConVarInt(g_cvJumpMax)
}

public convar_ChangeBoost(Handle:convar, const String:oldVal[], const String:newVal[]) {
	g_flBoost = StringToFloat(newVal)
}

public convar_ChangeEnable(Handle:convar, const String:oldVal[], const String:newVal[]) {
	if (StringToInt(newVal) >= 1) {
		g_bDoubleJump = true
	} else {
		g_bDoubleJump = false
	}
}

public convar_ChangeMax(Handle:convar, const String:oldVal[], const String:newVal[]) {
	g_iJumpMax = StringToInt(newVal)
}

public OnGameFrame() {
	if (g_bDoubleJump) {							// double jump active
		for (new i = 1; i <= MaxClients; i++) {		// cycle through players
			if (
				IsClientInGame(i) &&				// is in the game
				IsPlayerAlive(i) &&					// is alive
				GetClientTeam(i) == 3				// is player on blue
			) {
				DoubleJump(i)						// Check for double jumping
			}
		}
	}
}

stock DoubleJump(const any:client) {
	new
		fCurFlags	= GetEntityFlags(client),		// current flags
		fCurButtons	= GetClientButtons(client)		// current buttons
	
	if (g_fLastFlags[client] & FL_ONGROUND) {		// was grounded last frame
		if (
			!(fCurFlags & FL_ONGROUND) &&			// becomes airbirne this frame
			!(g_fLastButtons[client] & IN_JUMP) &&	// was not jumping last frame
			fCurButtons & IN_JUMP					// started jumping this frame
		) {
			OriginalJump(client)					// process jump from the ground
		}
	} else if (										// was airborne last frame
		fCurFlags & FL_ONGROUND						// becomes grounded this frame
	) {
		Landed(client)								// process landing on the ground
	} else if (										// remains airborne this frame
		!(g_fLastButtons[client] & IN_JUMP) &&		// was not jumping last frame
		fCurButtons & IN_JUMP						// started jumping this frame
	) {
		ReJump(client)								// process attempt to double-jump
	}
	
	g_fLastFlags[client]	= fCurFlags				// update flag state for next frame
	g_fLastButtons[client]	= fCurButtons			// update button state for next frame
}

stock OriginalJump(const any:client) {
	g_iJumps[client]++	// increment jump count
}

stock Landed(const any:client) {
	g_iJumps[client] = 0	// reset jumps count
}

stock ReJump(const any:client) {
	if ( 1 <= g_iJumps[client] <= g_iJumpMax) {						// has jumped at least once but hasn't exceeded max re-jumps
		g_iJumps[client]++											// increment jump count
		decl Float:vVel[3]
		GetEntPropVector(client, Prop_Data, "m_vecVelocity", vVel)	// get current speeds
		
		vVel[2] = g_flBoost
		TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vVel)		// boost player
	}
}
Both untested! So if any issues just reply back.
__________________
Chaosxk is offline
xjonx
Member
Join Date: Nov 2016
Location: Builders League UnitedHQ
Old 11-16-2016 , 21:15   Re: [REQ/IDEA][TF2]Plugin requests (ideas?)
Reply With Quote #5

Quote:
Originally Posted by Chaosxk View Post
For 1, i wrote the plugin to give crits to the last man standing on red team as it is more efficient than executing another plugin to give crits.

Code:
#pragma semicolon 1

#define PLUGIN_AUTHOR "Tak (Chaosxk)"
#define PLUGIN_VERSION "1.0"

#include <sourcemod>
#include <tf2_stocks>

#pragma newdecls required

int g_iRedCounter;

public Plugin myinfo = 
{
	name = "[TF2] One man standing ~ Crits",
	author = PLUGIN_AUTHOR,
	description = "1 man on red = Crits",
	version = PLUGIN_VERSION,
	url = "https://forums.alliedmods.net/showthread.php?t=290409"
};

public void OnPluginStart()
{
	HookEvent("teamplay_round_start", Event_RoundStart);
	HookEvent("player_spawn", Event_PlayerSpawn);
	HookEvent("player_death", Event_PlayerDeath);
	
	//late-load execute
	g_iRedCounter = GetRedCount();
}

public Action Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
{
	//Resets the counter when new round starts
	g_iRedCounter = GetRedCount();
}

//Don't think this event is necessary unless map or admin respawns players
//Just a precaution i guess, so it doesn't bug out if you do respawn
public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
	int client = GetClientOfUserId(event.GetInt("userid"));
	
	if (TF2_GetClientTeam(client) != TFTeam_Red)
		return Plugin_Continue;
	
	g_iRedCounter++;
	return Plugin_Continue;
}

public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
{
	int client = GetClientOfUserId(event.GetInt("userid"));
	
	if (TF2_GetClientTeam(client) != TFTeam_Red)
		return Plugin_Continue;
	
	if (--g_iRedCounter == 1)
	{
		for (int i = 1; i <= MaxClients; i++)
		{
			if (!IsClientInGame(i) || !IsPlayerAlive(i) || TF2_GetClientTeam(i) != TFTeam_Red)
				continue;
			TF2_AddCondition(i, TFCond_Kritzkrieged, TFCondDuration_Infinite);
			//Break as we should only be getting 1 player alive on red
			break;
		}
	}
	return Plugin_Continue;
}

//GetClientCount of red team INCLUDING bots
int GetRedCount()
{
	int r;
	for (int i = 1; i <= MaxClients; i++)
	{
		if (!IsClientInGame(i) || TF2_GetClientTeam(i) != TFTeam_Red)
			continue;
		r++;
	}
	return r;
}
For 2, i edited the plugin you linked to only work for blue team.

Code:
/*
 * Double Jump
 *
 * Description:
 *  Allows players to double-jump
 *  Original idea: NcB_Sav
 *
 * Convars:
 *  sm_doublejump_enabled [bool] : Enables or disable double-jumping. Default: 1
 *  sm_doublejump_boost [amount] : Amount to boost the player. Default: 250
 *  sm_doublejump_max [jumps]    : Maximum number of re-jumps while airborne. Default: 1
 *
 * Changelog:
 *  v1.0.1
 *   Minor code optimization.
 *  v1.0.0
 *   Initial release.
 *
 * Known issues:
 *  Doesn't register all mouse-wheel triggered +jumps
 *
 * Todo:
 *  Employ upcoming OnClientCommand function to remove excess OnGameFrame-age.
 *
 * Contact:
 *  Paegus: [email protected]
 *  SourceMod: http://www.sourcemod.net
 *  Hidden:Source: http://www.hidden-source.com
 *  NcB_Sav: http://forums.alliedmods.net/showthread.php?t=99228
 */
#define PLUGIN_VERSION		"1.0.1"

#include <sdktools>


public Plugin:myinfo = {
	name		= "Double Jump",
	author		= "Paegus",
	description	= "Allows double-jumping.",
	version		= PLUGIN_VERSION,
	url			= ""
}

new
	Handle:g_cvJumpBoost	= INVALID_HANDLE,
	Handle:g_cvJumpEnable	= INVALID_HANDLE,
	Handle:g_cvJumpMax		= INVALID_HANDLE,
	Float:g_flBoost			= 250.0,
	bool:g_bDoubleJump		= true,
	g_fLastButtons[MAXPLAYERS+1],
	g_fLastFlags[MAXPLAYERS+1],
	g_iJumps[MAXPLAYERS+1],
	g_iJumpMax
	
public OnPluginStart() {
	CreateConVar(
		"sm_doublejump_version", PLUGIN_VERSION,
		"Double Jump Version",
		FCVAR_PLUGIN|FCVAR_NOTIFY
	)
	
	g_cvJumpEnable = CreateConVar(
		"sm_doublejump_enabled", "1",
		"Enables double-jumping.",
		FCVAR_PLUGIN|FCVAR_NOTIFY
	)
	
	g_cvJumpBoost = CreateConVar(
		"sm_doublejump_boost", "250.0",
		"The amount of vertical boost to apply to double jumps.",
		FCVAR_PLUGIN|FCVAR_NOTIFY
	)
	
	g_cvJumpMax = CreateConVar(
		"sm_doublejump_max", "1",
		"The maximum number of re-jumps allowed while already jumping.",
		FCVAR_PLUGIN|FCVAR_NOTIFY
	)
	
	HookConVarChange(g_cvJumpBoost,		convar_ChangeBoost)
	HookConVarChange(g_cvJumpEnable,	convar_ChangeEnable)
	HookConVarChange(g_cvJumpMax,		convar_ChangeMax)
	
	g_bDoubleJump	= GetConVarBool(g_cvJumpEnable)
	g_flBoost		= GetConVarFloat(g_cvJumpBoost)
	g_iJumpMax		= GetConVarInt(g_cvJumpMax)
}

public convar_ChangeBoost(Handle:convar, const String:oldVal[], const String:newVal[]) {
	g_flBoost = StringToFloat(newVal)
}

public convar_ChangeEnable(Handle:convar, const String:oldVal[], const String:newVal[]) {
	if (StringToInt(newVal) >= 1) {
		g_bDoubleJump = true
	} else {
		g_bDoubleJump = false
	}
}

public convar_ChangeMax(Handle:convar, const String:oldVal[], const String:newVal[]) {
	g_iJumpMax = StringToInt(newVal)
}

public OnGameFrame() {
	if (g_bDoubleJump) {							// double jump active
		for (new i = 1; i <= MaxClients; i++) {		// cycle through players
			if (
				IsClientInGame(i) &&				// is in the game
				IsPlayerAlive(i) &&					// is alive
				GetClientTeam(i) == 3				// is player on blue
			) {
				DoubleJump(i)						// Check for double jumping
			}
		}
	}
}

stock DoubleJump(const any:client) {
	new
		fCurFlags	= GetEntityFlags(client),		// current flags
		fCurButtons	= GetClientButtons(client)		// current buttons
	
	if (g_fLastFlags[client] & FL_ONGROUND) {		// was grounded last frame
		if (
			!(fCurFlags & FL_ONGROUND) &&			// becomes airbirne this frame
			!(g_fLastButtons[client] & IN_JUMP) &&	// was not jumping last frame
			fCurButtons & IN_JUMP					// started jumping this frame
		) {
			OriginalJump(client)					// process jump from the ground
		}
	} else if (										// was airborne last frame
		fCurFlags & FL_ONGROUND						// becomes grounded this frame
	) {
		Landed(client)								// process landing on the ground
	} else if (										// remains airborne this frame
		!(g_fLastButtons[client] & IN_JUMP) &&		// was not jumping last frame
		fCurButtons & IN_JUMP						// started jumping this frame
	) {
		ReJump(client)								// process attempt to double-jump
	}
	
	g_fLastFlags[client]	= fCurFlags				// update flag state for next frame
	g_fLastButtons[client]	= fCurButtons			// update button state for next frame
}

stock OriginalJump(const any:client) {
	g_iJumps[client]++	// increment jump count
}

stock Landed(const any:client) {
	g_iJumps[client] = 0	// reset jumps count
}

stock ReJump(const any:client) {
	if ( 1 <= g_iJumps[client] <= g_iJumpMax) {						// has jumped at least once but hasn't exceeded max re-jumps
		g_iJumps[client]++											// increment jump count
		decl Float:vVel[3]
		GetEntPropVector(client, Prop_Data, "m_vecVelocity", vVel)	// get current speeds
		
		vVel[2] = g_flBoost
		TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vVel)		// boost player
	}
}
Both untested! So if any issues just reply back.
Sorry for the late reply, been busy lately.
Double jump works and only on blue team, which is good. I also get 4 warnings when compiling the plugin.
Compile Warnings


However, last red man standing crits does not work.
I think it has to do with one of my plugins that switches a random player to blue team there fore bypassing the red death counter in the script.
__________________
I'm sometimes slow at responding... just be patient.
My favorite quote: "...for I believe in an eye for an eye."
My Website: http://jon-xjonx-nat.jimdo.com/

Last edited by xjonx; 11-16-2016 at 21:19. Reason: Woops, less detailed. Added more detail :P
xjonx is offline
Send a message via Skype™ to xjonx
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 11-17-2016 , 15:19   Re: [REQ/IDEA][TF2]Plugin requests (ideas?)
Reply With Quote #6

You can ignore safety ignore those warnings, but if you want you can just delete "FCVAR_PLUGIN|" 4 times from code and recompile.

Try this code for the red man standing:
Code:
#pragma semicolon 1

#define PLUGIN_AUTHOR "Tak (Chaosxk)"
#define PLUGIN_VERSION "1.0"

#include <sourcemod>
#include <tf2_stocks>

#pragma newdecls required

int g_iRedCounter;

public Plugin myinfo = 
{
	name = "[TF2] One man standing ~ Crits",
	author = PLUGIN_AUTHOR,
	description = "1 man on red = Crits",
	version = PLUGIN_VERSION,
	url = "https://forums.alliedmods.net/showthread.php?t=290409"
};

public void OnPluginStart()
{
	HookEvent("teamplay_round_start", Event_RoundStart);
	HookEvent("player_spawn", Event_PlayerSpawn);
	HookEvent("player_death", Event_PlayerDeath);
	HookEvent("player_team", Event_PlayerTeam);
	
	//late-load execute
	g_iRedCounter = GetRedCount();
}

public Action Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
{
	//Resets the counter when new round starts
	g_iRedCounter = GetRedCount();
}

//Don't think this event is necessary unless map or admin respawns players
//Just a precaution i guess, so it doesn't bug out if you do respawn
public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
	int client = GetClientOfUserId(event.GetInt("userid"));
	
	if (TF2_GetClientTeam(client) != TFTeam_Red)
		return Plugin_Continue;
	
	g_iRedCounter++;
	return Plugin_Continue;
}

public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
{
	int client = GetClientOfUserId(event.GetInt("userid"));
	
	if (TF2_GetClientTeam(client) != TFTeam_Red)
		return Plugin_Continue;
		
	FindLastPlayer();
	
	return Plugin_Continue;
}

public Action Event_PlayerTeam(Event event, const char[] name, bool dontBroadcast)
{
	int client = GetClientOfUserId(event.GetInt("userid"));
	
	if (TF2_GetClientTeam(client) != TFTeam_Red)
	{
		g_iRedCounter++;
		return Plugin_Continue;
	}
	
	if (!IsPlayerAlive(client))
		return Plugin_Continue;
	
	FindLastPlayer();
	
	return Plugin_Continue;
}

void FindLastPlayer()
{
	if (--g_iRedCounter == 1)
	{
		for (int i = 1; i <= MaxClients; i++)
		{
			if (!IsClientInGame(i) || !IsPlayerAlive(i) || TF2_GetClientTeam(i) != TFTeam_Red)
				continue;
			TF2_AddCondition(i, TFCond_Kritzkrieged, TFCondDuration_Infinite);
			//Break as we should only be getting 1 player alive on red
			break;
		}
	}
}

//GetClientCount of red team INCLUDING bots
int GetRedCount()
{
	int r;
	for (int i = 1; i <= MaxClients; i++)
	{
		if (!IsClientInGame(i) || TF2_GetClientTeam(i) != TFTeam_Red)
			continue;
		r++;
	}
	return r;
}
__________________
Chaosxk is offline
xjonx
Member
Join Date: Nov 2016
Location: Builders League UnitedHQ
Old 11-20-2016 , 17:52   Re: [REQ/IDEA][TF2]Plugin requests (ideas?)
Reply With Quote #7

Quote:
Originally Posted by Chaosxk View Post
You can ignore safety ignore those warnings, but if you want you can just delete "FCVAR_PLUGIN|" 4 times from code and recompile.

Try this code for the red man standing:
Code:
#pragma semicolon 1

#define PLUGIN_AUTHOR "Tak (Chaosxk)"
#define PLUGIN_VERSION "1.0"

#include <sourcemod>
#include <tf2_stocks>

#pragma newdecls required

int g_iRedCounter;

public Plugin myinfo = 
{
	name = "[TF2] One man standing ~ Crits",
	author = PLUGIN_AUTHOR,
	description = "1 man on red = Crits",
	version = PLUGIN_VERSION,
	url = "https://forums.alliedmods.net/showthread.php?t=290409"
};

public void OnPluginStart()
{
	HookEvent("teamplay_round_start", Event_RoundStart);
	HookEvent("player_spawn", Event_PlayerSpawn);
	HookEvent("player_death", Event_PlayerDeath);
	HookEvent("player_team", Event_PlayerTeam);
	
	//late-load execute
	g_iRedCounter = GetRedCount();
}

public Action Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
{
	//Resets the counter when new round starts
	g_iRedCounter = GetRedCount();
}

//Don't think this event is necessary unless map or admin respawns players
//Just a precaution i guess, so it doesn't bug out if you do respawn
public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
	int client = GetClientOfUserId(event.GetInt("userid"));
	
	if (TF2_GetClientTeam(client) != TFTeam_Red)
		return Plugin_Continue;
	
	g_iRedCounter++;
	return Plugin_Continue;
}

public Action Event_PlayerDeath(Event event, const char[] name, bool dontBroadcast)
{
	int client = GetClientOfUserId(event.GetInt("userid"));
	
	if (TF2_GetClientTeam(client) != TFTeam_Red)
		return Plugin_Continue;
		
	FindLastPlayer();
	
	return Plugin_Continue;
}

public Action Event_PlayerTeam(Event event, const char[] name, bool dontBroadcast)
{
	int client = GetClientOfUserId(event.GetInt("userid"));
	
	if (TF2_GetClientTeam(client) != TFTeam_Red)
	{
		g_iRedCounter++;
		return Plugin_Continue;
	}
	
	if (!IsPlayerAlive(client))
		return Plugin_Continue;
	
	FindLastPlayer();
	
	return Plugin_Continue;
}

void FindLastPlayer()
{
	if (--g_iRedCounter == 1)
	{
		for (int i = 1; i <= MaxClients; i++)
		{
			if (!IsClientInGame(i) || !IsPlayerAlive(i) || TF2_GetClientTeam(i) != TFTeam_Red)
				continue;
			TF2_AddCondition(i, TFCond_Kritzkrieged, TFCondDuration_Infinite);
			//Break as we should only be getting 1 player alive on red
			break;
		}
	}
}

//GetClientCount of red team INCLUDING bots
int GetRedCount()
{
	int r;
	for (int i = 1; i <= MaxClients; i++)
	{
		if (!IsClientInGame(i) || TF2_GetClientTeam(i) != TFTeam_Red)
			continue;
		r++;
	}
	return r;
}
Doesn't seem to work. I have the plugins choose one random person on red team after 1 minute has passed, and put that person in blue team. I think this bypasses the counter that detects the amount of players.
__________________
I'm sometimes slow at responding... just be patient.
My favorite quote: "...for I believe in an eye for an eye."
My Website: http://jon-xjonx-nat.jimdo.com/
xjonx is offline
Send a message via Skype™ to xjonx
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 11-21-2016 , 00:13   Re: [REQ/IDEA][TF2]Plugin requests (ideas?)
Reply With Quote #8

Okay, a little lazy to try and fix what's wrong so here is another one that is less efficient and uses a repeating timer to get the count of alive red players every 0.5 seconds.

Code:
#pragma semicolon 1

#define PLUGIN_AUTHOR "Tak (Chaosxk)"
#define PLUGIN_VERSION "1.0"

#include <sourcemod>
#include <tf2_stocks>

#pragma newdecls required

public Plugin myinfo = 
{
	name = "[TF2] One man standing ~ Crits",
	author = PLUGIN_AUTHOR,
	description = "1 man on red = Crits",
	version = PLUGIN_VERSION,
	url = "https://forums.alliedmods.net/showthread.php?t=290409"
};

public void OnPluginStart()
{
	CreateTimer(0.5, Timer_GetCount, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
}

public Action Timer_GetCount(Handle hTimer)
{
	int count, client;
	
	for (int i = 1; i <= MaxClients; i++)
	{
		if (!IsClientInGame(i) || !IsPlayerAlive(i) || TF2_GetClientTeam(i) != TFTeam_Red)
			continue;
		client = i;
		count++;
	}
	
	if (count == 1)
	{
		TF2_AddCondition(client, TFCond_Kritzkrieged, TFCondDuration_Infinite);
	}
}
__________________
Chaosxk is offline
xjonx
Member
Join Date: Nov 2016
Location: Builders League UnitedHQ
Old 11-23-2016 , 02:53   Re: [REQ/IDEA][TF2]Plugin requests (ideas?)
Reply With Quote #9

Quote:
Originally Posted by Chaosxk View Post
Okay, a little lazy to try and fix what's wrong so here is another one that is less efficient and uses a repeating timer to get the count of alive red players every 0.5 seconds.

Code:
#pragma semicolon 1

#define PLUGIN_AUTHOR "Tak (Chaosxk)"
#define PLUGIN_VERSION "1.0"

#include <sourcemod>
#include <tf2_stocks>

#pragma newdecls required

public Plugin myinfo = 
{
	name = "[TF2] One man standing ~ Crits",
	author = PLUGIN_AUTHOR,
	description = "1 man on red = Crits",
	version = PLUGIN_VERSION,
	url = "https://forums.alliedmods.net/showthread.php?t=290409"
};

public void OnPluginStart()
{
	CreateTimer(0.5, Timer_GetCount, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
}

public Action Timer_GetCount(Handle hTimer)
{
	int count, client;
	
	for (int i = 1; i <= MaxClients; i++)
	{
		if (!IsClientInGame(i) || !IsPlayerAlive(i) || TF2_GetClientTeam(i) != TFTeam_Red)
			continue;
		client = i;
		count++;
	}
	
	if (count == 1)
	{
		TF2_AddCondition(client, TFCond_Kritzkrieged, TFCondDuration_Infinite);
	}
}
Tested it, still, doesn't work. I'm using this plugin. I know it's unapproved, but is the only one that works with other plugins I'm using. Plus it isn't unapproved for a bad reason, just that it doesn't the same thing as another plugin wich doesn't work for me.
__________________
I'm sometimes slow at responding... just be patient.
My favorite quote: "...for I believe in an eye for an eye."
My Website: http://jon-xjonx-nat.jimdo.com/
xjonx is offline
Send a message via Skype™ to xjonx
Chaosxk
Veteran Member
Join Date: Aug 2010
Location: Westeros
Old 11-23-2016 , 16:48   Re: [REQ/IDEA][TF2]Plugin requests (ideas?)
Reply With Quote #10

It works fine for me even with the plugin you linked.

FYI the code i posted counts BOTS as alive red players. So if you have a bot on red team then it will count it as a player.

Just to make sure, when there are 1 player on red team (INCLUDING BOTS) that is still alive then give them crits?
At least that is what i wrote and tested.
__________________

Last edited by Chaosxk; 11-23-2016 at 16:48.
Chaosxk 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 14:03.


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