|
Member
Join Date: Nov 2016
Location: Builders League UnitedHQ
|
11-20-2016
, 17:52
Re: [REQ/IDEA][TF2]Plugin requests (ideas?)
|
#7
|
Quote:
Originally Posted by Chaosxk
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/
|
|
|
|