You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
296 lines
8.5 KiB
296 lines
8.5 KiB
/* Plugin Template generated by Pawn Studio */ |
|
|
|
#include <sourcemod> |
|
#include <topmenus> |
|
#include <adminmenu> |
|
|
|
new TopMenuObject:obj_dccommands; |
|
new Handle:hAdminMenu = INVALID_HANDLE |
|
new bool:timersetinprogress; |
|
|
|
public Plugin:myinfo = |
|
{ |
|
name = "[L4D2] Left4Control", |
|
author = "Chefe", |
|
description = "Manipulate the L4D2 AI Director & Game Settings", |
|
version = "1.0", |
|
url = "www.the-bos.de" |
|
} |
|
|
|
public OnPluginStart() |
|
{ |
|
/* See if the menu pluginis already ready */ |
|
new Handle:topmenu; |
|
if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != INVALID_HANDLE)) |
|
{ |
|
/* If so, manually fire the callback */ |
|
OnAdminMenuReady(topmenu); |
|
} |
|
} |
|
|
|
public OnLibraryRemoved(const String:name[]) |
|
{ |
|
if (StrEqual(name, "adminmenu")) |
|
{ |
|
hAdminMenu = INVALID_HANDLE; |
|
} |
|
} |
|
|
|
public OnAdminMenuReady(Handle:topmenu) |
|
{ |
|
/* Block us from being called twice */ |
|
if (topmenu == hAdminMenu) |
|
{ |
|
return; |
|
} |
|
else |
|
{ |
|
hAdminMenu = topmenu; |
|
} |
|
|
|
AttachAdminMenu() |
|
} |
|
|
|
AttachAdminMenu() |
|
{ |
|
obj_dccommands = AddToTopMenu(hAdminMenu, "dc_category", TopMenuObject_Category, CategoryHandler, INVALID_TOPMENUOBJECT); |
|
AddToTopMenu(hAdminMenu, "sm_dc_forcepanic", TopMenuObject_Item, AdminMenu_ForcePanicEvent, obj_dccommands, "sm_dc_forcepanic", ADMFLAG_CHEATS); |
|
AddToTopMenu(hAdminMenu, "sm_dc_panicforever", TopMenuObject_Item, AdminMenu_PanicForever, obj_dccommands, "sm_dc_panicforever", ADMFLAG_CHEATS); |
|
AddToTopMenu(hAdminMenu, "sm_dc_forcetank", TopMenuObject_Item, AdminMenu_ForceTank, obj_dccommands, "sm_dc_forcetank", ADMFLAG_CHEATS); |
|
AddToTopMenu(hAdminMenu, "sm_dc_forcewitch", TopMenuObject_Item, AdminMenu_ForceWitch, obj_dccommands, "sm_dc_forcewitch", ADMFLAG_CHEATS); |
|
AddToTopMenu(hAdminMenu, "sm_dc_resetall", TopMenuObject_Item, AdminMenu_ResetAll, obj_dccommands, "sm_dc_resetall", ADMFLAG_CHEATS); |
|
AddToTopMenu(hAdminMenu, "sm_dc_foreregen", TopMenuObject_Item, AdminMenu_ForeRegen, obj_dccommands, "sm_dc_foreregen", ADMFLAG_CHEATS); |
|
AddToTopMenu(hAdminMenu, "sm_dc_forcemob", TopMenuObject_Item, AdminMenu_SpawnMob, obj_dccommands, "sm_dc_spawnmob", ADMFLAG_CHEATS); |
|
} |
|
|
|
public CategoryHandler(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) |
|
{ |
|
if (action == TopMenuAction_DisplayTitle) |
|
{ |
|
Format(buffer, maxlength, "Left4Control:"); |
|
} |
|
else if (action == TopMenuAction_DisplayOption) |
|
{ |
|
Format(buffer, maxlength, "Left4Control"); |
|
} |
|
} |
|
|
|
public AdminMenu_ForcePanicEvent(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) |
|
{ |
|
if (action == TopMenuAction_DisplayOption) |
|
{ |
|
Format(buffer, maxlength, "Force PanicEvent"); |
|
} |
|
else if (action == TopMenuAction_SelectOption) |
|
{ |
|
UnsetCheatCmd("director_force_panic_event"); |
|
ServerCommand("director_force_panic_event"); |
|
|
|
if (!timersetinprogress) |
|
{ |
|
new Handle:pack = CreateDataPack(); |
|
CreateDataTimer(2.0, SetCheatCmdDelay, pack); |
|
timersetinprogress = true; |
|
WritePackString(pack, "director_force_panic_event"); |
|
} |
|
PrintToChat(param, "[DC] Forced Panic Event!"); |
|
RedisplayAdminMenu(hAdminMenu, param); |
|
} |
|
} |
|
|
|
public AdminMenu_PanicForever(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) |
|
{ |
|
if (action == TopMenuAction_DisplayOption) |
|
{ |
|
if (!GetConVarBool(FindConVar("director_panic_forever"))) |
|
{ |
|
Format(buffer, maxlength, "Start Endless Panic Events"); |
|
} |
|
else if (GetConVarBool(FindConVar("director_panic_forever"))) |
|
{ |
|
Format(buffer, maxlength, "End Endless Panic Events"); |
|
} |
|
} |
|
else if (action == TopMenuAction_SelectOption) |
|
{ |
|
UnsetCheatVar(FindConVar("director_panic_forever")); |
|
if (!GetConVarBool(FindConVar("director_panic_forever"))) |
|
{ |
|
ServerCommand("director_panic_forever 1"); |
|
PrintToChat(param, "[DC] Forced endless Panic Event!"); |
|
} |
|
else if (GetConVarBool(FindConVar("director_panic_forever"))) |
|
{ |
|
ServerCommand("director_panic_forever 0"); |
|
PrintToChat(param, "[DC] Unforced endless Panic Event!"); |
|
} |
|
CreateTimer(1.0, SetCheatVarDelay, FindConVar("director_panic_forever")); |
|
RedisplayAdminMenu(hAdminMenu, param); |
|
} |
|
} |
|
|
|
public AdminMenu_ForceTank(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) |
|
{ |
|
if (action == TopMenuAction_DisplayOption) |
|
{ |
|
if (!GetConVarBool(FindConVar("director_force_tank"))) |
|
{ |
|
Format(buffer, maxlength, "Force spawn Tank this round"); |
|
} |
|
else if (GetConVarBool(FindConVar("director_force_tank"))) |
|
{ |
|
Format(buffer, maxlength, "Dont force spawn Tank this round"); |
|
} |
|
} |
|
else if (action == TopMenuAction_SelectOption) |
|
{ |
|
|
|
UnsetCheatVar(FindConVar("director_force_tank")); |
|
if (!GetConVarBool(FindConVar("director_force_tank"))) |
|
{ |
|
ServerCommand("director_force_tank 1"); |
|
PrintToChat(param, "[DC] Forced to spawn a tank this round!"); |
|
} |
|
else if (GetConVarBool(FindConVar("director_force_tank"))) |
|
{ |
|
ServerCommand("director_force_tank 0"); |
|
PrintToChat(param, "[DC] Unforced to spawn a tank this round!"); |
|
} |
|
CreateTimer(1.0, SetCheatVarDelay, FindConVar("director_force_tank")); |
|
RedisplayAdminMenu(hAdminMenu, param); |
|
} |
|
} |
|
|
|
public AdminMenu_ForceWitch(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) |
|
{ |
|
if (action == TopMenuAction_DisplayOption) |
|
{ |
|
if (!GetConVarBool(FindConVar("director_force_witch"))) |
|
{ |
|
Format(buffer, maxlength, "Force spawn witch this round"); |
|
} |
|
else if (GetConVarBool(FindConVar("director_force_witch"))) |
|
{ |
|
Format(buffer, maxlength, "Dont force witch Tank this round"); |
|
} |
|
} |
|
else if (action == TopMenuAction_SelectOption) |
|
{ |
|
|
|
UnsetCheatVar(FindConVar("director_force_witch")); |
|
if (!GetConVarBool(FindConVar("director_force_witch"))) |
|
{ |
|
ServerCommand("director_force_witch 1"); |
|
PrintToChat(param, "[DC] Forced to spawn a witch this round!"); |
|
} |
|
else if (GetConVarBool(FindConVar("director_force_witch"))) |
|
{ |
|
ServerCommand("director_force_witch 0"); |
|
PrintToChat(param, "[DC] Unforced to spawn a witch this round!"); |
|
} |
|
CreateTimer(1.0, SetCheatVarDelay, FindConVar("director_force_witch")); |
|
RedisplayAdminMenu(hAdminMenu, param); |
|
} |
|
} |
|
|
|
public AdminMenu_ResetAll(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) |
|
{ |
|
if (action == TopMenuAction_DisplayOption) |
|
{ |
|
Format(buffer, maxlength, "Reset Settings"); |
|
} |
|
else if (action == TopMenuAction_SelectOption) |
|
{ |
|
|
|
} |
|
} |
|
|
|
public AdminMenu_ForeRegen(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) |
|
{ |
|
if (action == TopMenuAction_DisplayOption) |
|
{ |
|
if (!GetConVarBool(FindConVar("sv_regeneration_force_on"))) |
|
{ |
|
Format(buffer, maxlength, "Start Regeneration"); |
|
} |
|
else if (GetConVarBool(FindConVar("sv_regeneration_force_on"))) |
|
{ |
|
Format(buffer, maxlength, "Stop Regeneration"); |
|
} |
|
} |
|
else if (action == TopMenuAction_SelectOption) |
|
{ |
|
UnsetCheatVar(FindConVar("sv_regeneration_force_on")); |
|
if (!GetConVarBool(FindConVar("sv_regeneration_force_on"))) |
|
{ |
|
ServerCommand("sv_regeneration_force_on 1"); |
|
PrintToChat(param, "[DC] Forced regeneration ON!"); |
|
} |
|
else if (GetConVarBool(FindConVar("sv_regeneration_force_on"))) |
|
{ |
|
ServerCommand("sv_regeneration_force_on 0"); |
|
PrintToChat(param, "[DC] Forced regeneration OFF!"); |
|
} |
|
CreateTimer(1.0, SetCheatVarDelay, FindConVar("sv_regeneration_force_on")); |
|
RedisplayAdminMenu(hAdminMenu, param); |
|
} |
|
} |
|
|
|
public AdminMenu_SpawnMob(Handle:topmenu, TopMenuAction:action, TopMenuObject:object_id, param, String:buffer[], maxlength) |
|
{ |
|
if (action == TopMenuAction_DisplayOption) |
|
{ |
|
Format(buffer, maxlength, "Force Mob"); |
|
} |
|
else if (action == TopMenuAction_SelectOption) |
|
{ |
|
UnsetCheatCmd("z_spawn"); |
|
ServerCommand("z_spawn mob"); |
|
PrintToChat(param, "[DC] Spawned Mob!"); |
|
SetCheatCmd("z_spawn"); |
|
RedisplayAdminMenu(hAdminMenu, param); |
|
} |
|
} |
|
|
|
UnsetCheatVar(Handle:hndl) |
|
{ |
|
new flags = GetConVarFlags(hndl) |
|
flags &= ~FCVAR_CHEAT |
|
SetConVarFlags(hndl, flags) |
|
} |
|
|
|
SetCheatVar(Handle:hndl) |
|
{ |
|
new flags = GetConVarFlags(hndl) |
|
flags |= FCVAR_CHEAT |
|
SetConVarFlags(hndl, flags) |
|
} |
|
|
|
public Action:SetCheatVarDelay(Handle:timer, Handle:convar) |
|
{ |
|
SetCheatVar(convar); |
|
} |
|
|
|
UnsetCheatCmd(String:cmd[]) |
|
{ |
|
new flags = GetCommandFlags(cmd) |
|
flags &= ~FCVAR_CHEAT |
|
SetCommandFlags(cmd, flags) |
|
} |
|
|
|
SetCheatCmd(String:cmd[]) |
|
{ |
|
new flags = GetCommandFlags(cmd) |
|
flags |= FCVAR_CHEAT |
|
SetCommandFlags(cmd, flags) |
|
} |
|
|
|
public Action:SetCheatCmdDelay(Handle:timer, Handle:pack) |
|
{ |
|
new String:cmd[265]; |
|
ResetPack(pack); |
|
ReadPackString(pack, cmd, sizeof(cmd)); |
|
CloseHandle(pack); |
|
timersetinprogress = false; |
|
SetCheatCmd(cmd); |
|
} |