commit
4a23e7ebd9
2 changed files with 406 additions and 0 deletions
@ -0,0 +1,152 @@ |
|||
#include <sourcemod> |
|||
#include <tf2> |
|||
#include <tf2_stocks> |
|||
#include <clients> |
|||
#include <sdktools_functions> |
|||
|
|||
#define AFA_VERSION "1.5.8" |
|||
|
|||
new bool:temp_disabled = false |
|||
new Handle:h_enabled, Handle:h_time, Handle:h_admins_only; |
|||
new Float:client_orgin[101][3]; |
|||
new Float:client_angels[101][3]; |
|||
new Handle:h_sudden_death, Handle:h_re, Handle:h_teleport_enabled, |
|||
Handle:h_flag, Handle:h_tags; |
|||
new AdminFlag:cflag; |
|||
|
|||
public Plugin:myinfo = |
|||
{ |
|||
name = "Autorespawn for Admins", |
|||
author = "Chefe", |
|||
description = "Respawn(&Teleport) Admins/Players in a varaible amount of time.", |
|||
version = AFA_VERSION, |
|||
url = "http://forums.alliedmods.net/showthread.php?t=110918" |
|||
} |
|||
|
|||
public OnPluginStart() |
|||
{ |
|||
HookEvent("player_death", Event_PlayerDeath) |
|||
HookEvent("teamplay_round_win", Event_TeamplayRoundWin) |
|||
HookEvent("teamplay_round_start", Event_TeamplayRoundStart) |
|||
HookEvent("teamplay_suddendeath_begin", Event_SuddendeathBegin) |
|||
h_enabled = CreateConVar("sm_instant_enabled", "1", "Enable or Disable Instant Respawn for Admins."); |
|||
h_time = CreateConVar("sm_instant_time", "0.1", "Set the Instant Respawn Time for Admins.", _, true, 0.1); |
|||
h_admins_only = CreateConVar("sm_instant_admins_only", "0", "Set is instant respawn only enabled for admins or for all."); |
|||
h_sudden_death = CreateConVar("sm_instant_sudeath", "0", "Enable or Disable the Respawn in Sudden Death."); |
|||
h_re = CreateConVar("sm_instant_re", "1", "Enable or Disable the Respawn on Roundend"); |
|||
h_teleport_enabled = CreateConVar("sm_instant_teleport", "0", "Enable or Disable teleport Player to ther old Position"); |
|||
h_flag = CreateConVar("sm_instant_flag", "z", "Set the flag witch admins must have to use instant respawn."); |
|||
CreateConVar("sm_instant_version", AFA_VERSION, "Autorespawn Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD); |
|||
|
|||
AutoExecConfig(true); |
|||
|
|||
new String:flagcvar[1]; |
|||
GetConVarString(h_flag, flagcvar, sizeof(flagcvar)); |
|||
FindFlagByChar(flagcvar[0], cflag); |
|||
|
|||
h_tags = FindConVar("sv_tags"); |
|||
HookConVarChange(h_tags, OnTagsChange); |
|||
CheckForPluginTag(h_tags, "respawntimes"); |
|||
} |
|||
|
|||
CheckForPluginTag(Handle:convar, String:tag[]) |
|||
{ |
|||
new String:oldtags[256]; |
|||
GetConVarString(convar, oldtags, sizeof(oldtags)); |
|||
|
|||
if (StrContains(oldtags, tag, false) == -1) |
|||
{ |
|||
new String:newtags[256]; |
|||
Format(newtags, sizeof(newtags), "%s,%s", oldtags, tag); |
|||
|
|||
SetConVarString(convar, newtags, _, true); |
|||
} |
|||
} |
|||
|
|||
RemovePluginTag(Handle:convar, String:tag[]) |
|||
{ |
|||
new String:oldtags[256]; |
|||
GetConVarString(convar, oldtags, sizeof(oldtags)); |
|||
|
|||
if (StrContains(oldtags, tag, false) != -1) |
|||
{ |
|||
ReplaceString(oldtags, sizeof(oldtags), tag, "", false); |
|||
|
|||
SetConVarString(convar, oldtags, _, true); |
|||
} |
|||
} |
|||
|
|||
public OnPluginEnd() |
|||
{ |
|||
RemovePluginTag(h_tags, "respawntimes"); |
|||
} |
|||
|
|||
public OnTagsChange(Handle:cvar, const String:oldVal[], const String:newVal[]) |
|||
{ |
|||
CheckForPluginTag(h_tags, "respawntimes"); |
|||
} |
|||
|
|||
public Event_SuddendeathBegin(Handle:event,const String:name[],bool:dontBroadcast) |
|||
{ |
|||
if (!GetConVarBool(h_sudden_death)) |
|||
{ |
|||
temp_disabled = true; |
|||
} |
|||
} |
|||
|
|||
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) |
|||
{ |
|||
new client_userid = GetEventInt(event, "userid"); |
|||
new client = GetClientOfUserId(client_userid); |
|||
|
|||
new AdminId:admin_id = GetUserAdmin(client); |
|||
|
|||
if (GetConVarBool(h_teleport_enabled)) |
|||
{ |
|||
GetClientAbsOrigin(client, client_orgin[client]); |
|||
GetClientAbsAngles(client, client_angels[client]); |
|||
} |
|||
|
|||
new Float:time = GetConVarFloat(h_time); |
|||
new death_flags = GetEventInt(event, "death_flags"); |
|||
|
|||
if (GetConVarBool(h_admins_only)) |
|||
{ |
|||
if (admin_id != INVALID_ADMIN_ID && IsClientInGame(client) && GetConVarBool(h_enabled) && !temp_disabled && !(death_flags & 32) && GetAdminFlag(admin_id, cflag, AdmAccessMode:Access_Effective)) |
|||
{ |
|||
CreateTimer(time, RespawnClient, client) |
|||
} |
|||
} |
|||
else |
|||
{ |
|||
if (IsClientInGame(client) && GetConVarBool(h_enabled) && !temp_disabled && !(death_flags & 32)) |
|||
{ |
|||
CreateTimer(time, RespawnClient, client) |
|||
} |
|||
} |
|||
} |
|||
|
|||
public Event_TeamplayRoundWin(Handle:event, const String:name[], bool:dontBroadcast) |
|||
{ |
|||
if (!GetConVarBool(h_re)) |
|||
{ |
|||
temp_disabled = true; |
|||
} |
|||
} |
|||
|
|||
public Event_TeamplayRoundStart(Handle:event, const String:name[], bool:dontBroadcast) |
|||
{ |
|||
temp_disabled = false; |
|||
} |
|||
|
|||
public Action:RespawnClient(Handle:timer, any:client) |
|||
{ |
|||
if (IsClientInGame(client)) |
|||
{ |
|||
TF2_RespawnPlayer(client); |
|||
if (GetConVarBool(h_teleport_enabled)) |
|||
{ |
|||
TeleportEntity(client, client_orgin[client], client_angels[client], NULL_VECTOR); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,254 @@ |
|||
#pragma semicolon 1 |
|||
|
|||
#include <sourcemod> |
|||
#include <tf2_stocks> |
|||
|
|||
// Global Definitions |
|||
#define PLUGIN_VERSION "1.0.2" |
|||
|
|||
#define cDefault 0x01 |
|||
#define cLightGreen 0x03 |
|||
#define cGreen 0x04 |
|||
#define cDarkGreen 0x05 |
|||
|
|||
new bool:isHooked = false; |
|||
|
|||
new Handle:cvarEnable; |
|||
new Handle:cvarClass; |
|||
new Handle:cvarEngy; |
|||
new Handle:cvarMelee; |
|||
|
|||
bool g_PlayerSpawned[101] = {false, ...}; |
|||
|
|||
public Plugin:myinfo = |
|||
{ |
|||
name = "ClassChooser", |
|||
author = "bl4nk", |
|||
description = "Choose a class to spawn everyone as", |
|||
version = PLUGIN_VERSION, |
|||
url = "http://forums.alliedmods.net" |
|||
}; |
|||
|
|||
public OnPluginStart() |
|||
{ |
|||
CreateConVar("sm_classchooser_version", PLUGIN_VERSION, "ClassChooser Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY); |
|||
cvarEnable = CreateConVar("sm_classchooser_enable", "1", "Enables/Disables the ClassChooser plugin", FCVAR_PLUGIN, true, 0.0, true, 1.0); |
|||
cvarClass = CreateConVar("sm_classchooser_class", "random", "Class for people to spawn as", FCVAR_PLUGIN); |
|||
cvarEngy = CreateConVar("sm_classchooser_engineer_tools", "1", "Enables/Disables building tools as the engineer class", FCVAR_PLUGIN, true, 0.0, true, 1.0); |
|||
cvarMelee = CreateConVar("sm_classchooser_melee", "0", "Enables/Disables melee only mode", FCVAR_PLUGIN, true, 0.0, true, 1.0); |
|||
|
|||
CreateTimer(3.0, OnPluginStart_Delayed); |
|||
} |
|||
|
|||
public OnClientDisconnect(int client) { |
|||
g_PlayerSpawned[client] = false; |
|||
} |
|||
|
|||
public Action:OnPluginStart_Delayed(Handle:timer) |
|||
{ |
|||
if (GetConVarInt(cvarEnable)) |
|||
{ |
|||
isHooked = true; |
|||
HookEvent("player_spawn", event_PlayerSpawn); |
|||
HookEvent("player_death", Event_PlayerDeath); |
|||
HookEvent("player_changeclass", Event_PlayerChangeClass); |
|||
HookEvent("teamplay_round_active", event_RoundStart); |
|||
HookEvent("teamplay_round_win", event_RoundEnd); |
|||
|
|||
LogMessage("[ClassChooser] - Loaded"); |
|||
} |
|||
|
|||
HookConVarChange(cvarEnable, CvarChange); |
|||
HookConVarChange(cvarMelee, CvarChange); |
|||
} |
|||
|
|||
public CvarChange(Handle:convar, const String:oldValue[], const String:newValue[]) |
|||
{ |
|||
if (convar == cvarEnable) |
|||
{ |
|||
if (!GetConVarInt(cvarEnable)) |
|||
{ |
|||
if (isHooked) |
|||
{ |
|||
isHooked = false; |
|||
UnhookEvent("player_spawn", event_PlayerSpawn); |
|||
UnhookEvent("player_death", Event_PlayerDeath); |
|||
UnhookEvent("player_changeclass", Event_PlayerChangeClass); |
|||
UnhookEvent("teamplay_round_active", event_RoundStart); |
|||
UnhookEvent("teamplay_round_win", event_RoundEnd); |
|||
|
|||
ChangeResupplyState(1); |
|||
|
|||
if (GetConVarInt(cvarMelee)) |
|||
PrintToChatAll("%c[SM] %cMelee only mode %cdisabled%c!", cGreen, cDefault, cLightGreen, cDefault); |
|||
} |
|||
} |
|||
else if (!isHooked) |
|||
{ |
|||
isHooked = true; |
|||
HookEvent("player_spawn", event_PlayerSpawn); |
|||
HookEvent("player_death", Event_PlayerDeath); |
|||
HookEvent("player_changeclass", Event_PlayerChangeClass); |
|||
HookEvent("teamplay_round_active", event_RoundStart); |
|||
HookEvent("teamplay_round_win", event_RoundEnd); |
|||
|
|||
if (GetConVarInt(cvarMelee)) |
|||
{ |
|||
MeleeStrip(); |
|||
ChangeResupplyState(0); |
|||
PrintToChatAll("%c[SM] %cMelee only mode %cenabled%c!", cGreen, cDefault, cLightGreen, cDefault); |
|||
} |
|||
} |
|||
} |
|||
else if (convar == cvarMelee) |
|||
{ |
|||
if (GetConVarInt(cvarEnable)) |
|||
{ |
|||
if (GetConVarInt(cvarMelee)) |
|||
{ |
|||
MeleeStrip(); |
|||
ChangeResupplyState(0); |
|||
PrintToChatAll("%c[SM] %cMelee only mode %cenabled%c!", cGreen, cDefault, cLightGreen, cDefault); |
|||
} |
|||
else |
|||
{ |
|||
ChangeResupplyState(1); |
|||
PrintToChatAll("%c[SM] %cMelee only mode %cdisabled%c!", cGreen, cDefault, cLightGreen, cDefault); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
public Action:event_PlayerSpawn(Handle:event, const String:name[], bool:dontBroadcast) |
|||
{ |
|||
new client = GetClientOfUserId(GetEventInt(event, "userid")); |
|||
|
|||
if(g_PlayerSpawned[client]) return; |
|||
else g_PlayerSpawned[client] = true; |
|||
|
|||
decl String:cvarString[32]; |
|||
GetConVarString(cvarClass, cvarString, sizeof(cvarString)); |
|||
|
|||
new TFClassType:class = TF2_GetClass(cvarString); |
|||
if (!IsPlayerAlive(client)) return; |
|||
|
|||
switch (class) |
|||
{ |
|||
case TFClass_Unknown: |
|||
{ |
|||
if (strcmp(cvarString, "random") == 0) |
|||
{ |
|||
new TFClassType:random = TFClassType:GetRandomInt(1, 9); |
|||
TF2_SetPlayerClass(client, random, false); |
|||
TF2_RespawnPlayer(client); |
|||
|
|||
if (random == TFClass_Engineer && !GetConVarInt(cvarEngy) && !GetConVarInt(cvarMelee)) |
|||
CreateTimer(0.1, timer_EngyRemove, client); |
|||
} |
|||
} |
|||
case TFClass_Engineer: |
|||
{ |
|||
TF2_SetPlayerClass(client, class, false); |
|||
TF2_RespawnPlayer(client); |
|||
|
|||
if (!GetConVarInt(cvarEngy) && !GetConVarInt(cvarMelee)) |
|||
CreateTimer(0.1, timer_EngyRemove, client); |
|||
} |
|||
default: |
|||
{ |
|||
TF2_SetPlayerClass(client, class, false); |
|||
TF2_RespawnPlayer(client); |
|||
} |
|||
} |
|||
|
|||
if (GetConVarInt(cvarMelee)) |
|||
CreateTimer(0.1, timer_Melee, client); |
|||
} |
|||
|
|||
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) |
|||
{ |
|||
int client = GetClientOfUserId(GetEventInt(event, "userid")); |
|||
g_PlayerSpawned[client] = false; |
|||
} |
|||
|
|||
public Event_PlayerChangeClass(Handle:event, const String:name[], bool:dontBroadcast) |
|||
{ |
|||
int client = GetClientOfUserId(GetEventInt(event, "userid")); |
|||
g_PlayerSpawned[client] = false; |
|||
} |
|||
|
|||
public Action:event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast) |
|||
if (GetConVarInt(cvarMelee)) |
|||
ChangeResupplyState(0); |
|||
|
|||
public Action:event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast) |
|||
ChangeResupplyState(1); |
|||
|
|||
public Action:timer_EngyRemove(Handle:timer, any:client) |
|||
{ |
|||
TF2_RemoveWeaponSlot(client, 3); |
|||
TF2_RemoveWeaponSlot(client, 4); |
|||
} |
|||
|
|||
public Action:timer_Melee(Handle:timer, any:client) |
|||
RemoveWeaponsToMelee(client); |
|||
|
|||
stock RemoveWeaponsToMelee(client) |
|||
{ |
|||
if (IsClientConnected(client) && IsClientInGame(client) && IsPlayerAlive(client)) |
|||
{ |
|||
for (new i = 0; i <= 5; i++) |
|||
{ |
|||
if (i == 2) |
|||
continue; |
|||
|
|||
TF2_RemoveWeaponSlot(client, i); |
|||
} |
|||
} |
|||
} |
|||
|
|||
stock MeleeStrip() |
|||
{ |
|||
new maxplayers = GetMaxClients(); |
|||
for (new i = 1; i <= maxplayers; i++) |
|||
RemoveWeaponsToMelee(i); |
|||
} |
|||
|
|||
stock ChangeResupplyState(mode) |
|||
{ |
|||
new maxents = GetMaxEntities(); |
|||
new maxplayers = GetMaxClients(); |
|||
for (new i = maxplayers + 1; i <= maxents; i++) |
|||
{ |
|||
if (!IsValidEntity(i)) |
|||
return; |
|||
|
|||
decl String:classname[32]; |
|||
GetEdictClassname(i, classname, sizeof(classname)); |
|||
|
|||
if (strcmp(classname, "func_regenerate") == 0) |
|||
{ |
|||
switch (mode) |
|||
{ |
|||
case 0: |
|||
{ |
|||
AcceptEntityInput(i, "Disable"); |
|||
continue; |
|||
} |
|||
case 1: |
|||
{ |
|||
AcceptEntityInput(i, "Enable"); |
|||
continue; |
|||
} |
|||
case 2: |
|||
{ |
|||
AcceptEntityInput(i, "Toggle"); |
|||
continue; |
|||
} |
|||
} |
|||
|
|||
LogError("Invalid state used for ChangeResupplyState()"); |
|||
break; |
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue