Skip to content

Instantly share code, notes, and snippets.

@Hexer10
Created January 30, 2017 14:41
Show Gist options
  • Save Hexer10/c21816efa0c10c7bcabb9a43c7c3dc4f to your computer and use it in GitHub Desktop.
Save Hexer10/c21816efa0c10c7bcabb9a43c7c3dc4f to your computer and use it in GitHub Desktop.
//Defines
#include <sourcemod>
#include <sdktools>
#include <cstrike>
#include <autoexecconfig>
#include <mystocks>
#include <colorvariables>
#include <menu-stocks>
#undef REQUIRE_PLUGIN
#undef REQUIRE_EXTENSIONS
#tryinclude <myjailbreaknew>
#tryinclude <lastrequest>
#define REQUIRE_EXTENSIONS
#define REQUIRE_PLUGIN
//Compiler Options
#pragma newdecls required
#pragma semicolon 1
//Defines
#define Life "#life"
#define Armour "#armour"
#define Nade "#nade"
#define Smoke "#smoke"
#define Speed "#speed"
#define Gravity "#gravity"
#define Regen "#regen"
#define Bhop "#bhop"
#define Weap "#weap"
#define DEBUG
#define PLUGIN_AUTHOR "Hexah"
#define PLUGIN_VER "1.00"
//Chars
char sFlagNeeded[32];
//Bools
bool b_Use[MAXPLAYERS + 1] = false;
bool b_Regen[MAXPLAYERS + 1] = false;
bool b_bhop[MAXPLAYERS + 1] = false;
bool b_EnablePlugin = false;
bool b_IsMYJBAvaible = false;
//Handle
Handle h_Regen[MAXPLAYERS + 1];
//Int
//int iMaxUse[MAXPLAYERS + 2];
//int iOldUse;
//Convars bool
ConVar cv_bEnableVipMenu;
ConVar cv_bMenuLife;
ConVar cv_bMenuGravity;
ConVar cv_bMenuArmour;
ConVar cv_bMenuRegen;
ConVar cv_bMenuSpeed;
ConVar cv_bMenuNade;
ConVar cv_bMenuSmoke;
ConVar cv_bStopTimer;
ConVar cv_bMenuBhop;
ConVar cv_bMenuWeap;
ConVar cv_bDisableLR;
ConVar cv_DisableOnEventday;
//ConVars int
ConVar cv_iVipSpawnHP;
ConVar cv_iRegenMaxHP;
ConVar cv_iRegenHP;
ConVar cv_iLifeHP;
ConVar cv_iArmour;
//ConVar cv_iMenuUse;
//ConVars float
ConVar cv_fVipSpawnArmour;
ConVar cv_fHpTimer;
ConVar cv_fSpeed;
ConVar cv_fGravity;
ConVar cv_sFlagNeeded;
ConVar cv_sWeapon;
//Plugin info
public Plugin myinfo =
{
name = "VipBonus",
author = PLUGIN_AUTHOR,
description = "Provide some bonuses and VipMenu to VIPs",
version = PLUGIN_VER,
url = "sourcemod.net"
};
//Start
public void OnPluginStart()
{
LoadTranslations("VipMenu.phrares");
//Convars
AutoExecConfig_SetFile("VipBonus");
AutoExecConfig_SetCreateFile(true);
cv_sFlagNeeded = AutoExecConfig_CreateConVar("sm_VipFlag", "a", "Flag needed to be VIP");
cv_iVipSpawnHP = AutoExecConfig_CreateConVar("sm_EnableVipSpawnHP", "70", "How much +HP shoud have Vips on Spawn, 0 = disabled", 0, true, 0.0, false);
cv_fVipSpawnArmour = AutoExecConfig_CreateConVar("sm_EnableVipSpawnArmour", "70", "How much armour shoud have Vips on Spawn, 0 = disabled", 0, true, 0.0, false);
cv_bEnableVipMenu = AutoExecConfig_CreateConVar("sm_EnableVipMenu", "1", "Shoud VipMenu be enabled?", 0, true, 0.0, true, 1.0);
//cv_iMenuUse = AutoExecConfig_CreateConVar("sm_VipMenuUse", "1", "How much time can VipMenu used (reset on respawn)?", 0, true, 0.0, true, 1.0); WorkInProgress
cv_bMenuLife = AutoExecConfig_CreateConVar("sm_MenuLife", "1", "Shoud life enabled in VipMenu?", 0, true, 0.0, true, 1.0);
cv_bMenuGravity = AutoExecConfig_CreateConVar("sm_MenuGravity", "1", "Shoud gravity enabled in VipMenu?", 0, true, 0.0, true, 1.0);
cv_bMenuArmour = AutoExecConfig_CreateConVar("sm_MenuArmour", "1", "Shoud Armour enabled in VipMenu?", 0, true, 0.0, true, 1.0);
cv_bMenuRegen = AutoExecConfig_CreateConVar("sm_MenuRegen", "1", "Shoud Regeneration enabled in VipMenu?", 0, true, 0.0, true, 1.0);
cv_bMenuSpeed = AutoExecConfig_CreateConVar("sm_MenuSpeed", "1", "Shoud Speed enabled in VipMenu?", 0, true, 0.0, true, 1.0);
cv_bMenuNade = AutoExecConfig_CreateConVar("sm_MenuNade", "1", "Shoud HE nade enabled in VipMenu?", 0, true, 0.0, true, 1.0);
cv_bMenuSmoke = AutoExecConfig_CreateConVar("sm_MenuSmoke", "1", "Shoud smoke enabled in VipMenu?", 0, true, 0.0, true, 1.0);
cv_bMenuBhop = AutoExecConfig_CreateConVar("sm_MenuBhop", "1", "Shoud Bhop enabled in VipMenu?", 0, true, 0.0, true, 1.0);
cv_bMenuWeap = AutoExecConfig_CreateConVar("sm_MenuWeapon", "1", "Shoud Weapon enabled in VipMenu?", 0, true, 0.0, true, 1.0);
cv_iLifeHP = AutoExecConfig_CreateConVar("sm_BLifeHP", "50", "How much +HP get with life?");
cv_iArmour = AutoExecConfig_CreateConVar("sm_BArmour", "50", "How much armour get with armour?");
cv_fSpeed = AutoExecConfig_CreateConVar("sm_BSpeed", "1.5", "How much Speed get with speed?");
cv_fGravity = AutoExecConfig_CreateConVar("sm_BGravity", "0.5", "How much Speed get with speed?");
cv_iRegenMaxHP = AutoExecConfig_CreateConVar("sm_RegenMaxHP", "200", "Max HP to get with regen?");
cv_fHpTimer = AutoExecConfig_CreateConVar("sm_RegenInt", "1.0", "How long shoud be regeneration interval?");
cv_iRegenHP = AutoExecConfig_CreateConVar("sm_HpRegen", "10", "How much hp get for regenerate?");
cv_bStopTimer = AutoExecConfig_CreateConVar("sm_RegenStop", "1", "Shoud regen stop when receaced the max hp or continue when get lower hp than max?", 0, true, 0.0,
true, 1.0);
cv_sWeapon = AutoExecConfig_CreateConVar("sm_MenuWeapon", "usp", "What weapon shoud get using VipMenu");
cv_bDisableLR = AutoExecConfig_CreateConVar("sm_DisableVipLR", "1", "Shoud VipMenu disabled on LR?", 0, true, 0.0, true, 1.0);
cv_DisableOnEventday = AutoExecConfig_CreateConVar("sm_DisableVipLR", "0", "Shoud VipMenu disabled on MyJailBreak eventdays?", 0, true, 0.0, true, 1.0);
AutoExecConfig_ExecuteFile();
AutoExecConfig_CleanFile();
//Commands
RegConsoleCmd("sm_vipmenu", Command_VipMenu);
RegAdminCmd("sm_resetvipmenu", Command_ResMenu, ADMFLAG_CONFIG);
//Hooks
HookEvent("player_spawn", Event_PlayerSpawn);
HookEvent("round_start", Event_RoundStart);
//Misc
cv_sFlagNeeded.GetString(sFlagNeeded, sizeof(sFlagNeeded));
}
/********************************************************************************************************************************
COMMANDS
*********************************************************************************************************************************/
public Action Command_ResMenu(int client, int args)
{
char arg1[32];
GetCmdArg(1, arg1, sizeof(arg1));
char target_name[MAX_TARGET_LENGTH];
int target_list[MAXPLAYERS], target_count;
bool tn_is_ml;
if ((target_count = ProcessTargetString(
arg1,
client,
target_list,
MAXPLAYERS,
COMMAND_FILTER_ALIVE, /* Only allow alive players */
target_name,
sizeof(target_name),
tn_is_ml)) <= 0)
{
/* This function replies to the admin with a failure message */
ReplyToTargetError(client, target_count);
}
for (int i = 0; i < target_count; i++)
{
b_Use[target_list[i]] = false;
b_Regen[target_list[i]] = false;
b_bhop[target_list[i]] = false;
}
return Plugin_Handled;
}
public Action Command_VipMenu(int client, int args)
{
if (!CheckVipFlag(client, sFlagNeeded))
{
CReplyToCommand(client, "%t %t", "%t", "Prefix", "Not_Vip");
}
if (!cv_bEnableVipMenu.BoolValue)
{
CReplyToCommand(client, "%t %t", "Prefix", "Plugin_Disable");
}
else if (!IsPlayerAlive(client)) //Alive check
{
CReplyToCommand(client, "%t %t", "Prefix", "Player_Death");
}
else if (b_Use[client])
{
CReplyToCommand(client, "%t %t", "Prefix", "Menu_Already");
}
else //Client is valid
{
vmenu(client);
}
return Plugin_Handled;
}
/********************************************************************************************************************************
EVENTS
*********************************************************************************************************************************/
public void Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast) //VIP BONUSES ON SPAWN & RESET VIP BOOLS (MENU USES)
{
int client = GetClientOfUserId(event.GetInt("userid"));
b_Use[client] = false;
b_Regen[client] = false;
b_bhop[client] = false;
if (CheckVipFlag(client, sFlagNeeded)) //Perm check
{
if (cv_DisableOnEventday)
{
if (b_IsMYJBAvaible && MyJailbreak_IsEventDayRunning())
{
b_EnablePlugin = true;
cv_bEnableVipMenu.BoolValue = false;
}
else
{
SetEntProp(client, Prop_Send, "m_ArmorValue", cv_fVipSpawnArmour.IntValue);
int i_SpawnHealth = GetClientHealth(client);
SetEntityHealth(client, i_SpawnHealth + cv_iVipSpawnHP.IntValue);
}
}
}
}
public void Event_RoundStart(Event event, const char[] name, bool dontBroadcast) //RESET BOOLS ON ROUNDSTART AFTER EVENTDAY
{
if (b_EnablePlugin)
{
cv_bEnableVipMenu.BoolValue = true;
b_EnablePlugin = false;
}
}
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon) //BUNNY HOP
{
int water = GetEntProp(client, Prop_Data, "m_nWaterLevel");
if (IsPlayerAlive(client))
{
if (GetEntityFlags(client) & FL_ONGROUND)
{
return;
}
else
{
if (buttons & IN_JUMP)
{
if (water <= 1)
{
if (!(GetEntityMoveType(client) & MOVETYPE_LADDER))
{
SetEntPropFloat(client, Prop_Send, "m_flStamina", 0.0);
if (!(GetEntityFlags(client) & FL_ONGROUND) && b_bhop[client])buttons &= ~IN_JUMP;
}
}
}
}
}
}
public int OnAvailableLR(int Announced) //DISABLE ITEMS ON LASTREQEST
{
if (cv_bDisableLR.BoolValue)
{
LoopClients(client)
{
if (IsPlayerAlive(client))
{
b_Use[client] = true;
b_Regen[client] = false;
b_bhop[client] = false;
}
}
}
}
public void OnAllPluginsLoaded()
{
b_IsMYJBAvaible = LibraryExists("myjailbreak");
}
/********************************************************************************************************************************
MENU
*********************************************************************************************************************************/
void vmenu(int client) //MENU
{
Menu menu = CreateMenu(hMenu, MENU_ACTIONS_ALL);
menu.SetTitle("..:VipMenu::.");
if (cv_bMenuLife.BoolValue)
{
//menu.AddItem("Life", "+HP");
AddMenuItemFormat(menu, "Life", ITEMDRAW_DEFAULT, "%t", "Menu_Life");
}
if (cv_bMenuArmour.BoolValue)
{
//menu.AddItem("Armour", "+Armour");
AddMenuItemFormat(menu, "Armour", ITEMDRAW_DEFAULT, "%t", "Menu_Armour");
}
if (cv_bMenuNade.BoolValue)
{
// menu.AddItem("Nade", "Prendi 1 nade");
AddMenuItemFormat(menu, "Nade", ITEMDRAW_DEFAULT, "%t", "Menu_Granade");
}
if (cv_bMenuSmoke.BoolValue)
{
// menu.AddItem("Smoke", "Prendi 1 smoke");
AddMenuItemFormat(menu, "Smoke", ITEMDRAW_DEFAULT, "%t", "Menu_Smoke");
}
if (cv_bMenuSpeed.BoolValue)
{
// menu.AddItem("Speed", "+Velocita'");
AddMenuItemFormat(menu, "Speed", ITEMDRAW_DEFAULT, "%t", "Menu_Speed");
}
if (cv_bMenuGravity.BoolValue)
{
// menu.AddItem("Gravity", "-Gravita'");
AddMenuItemFormat(menu, "Gravity", ITEMDRAW_DEFAULT, "%t", "Menu_Gravity");
}
if (cv_bMenuRegen.BoolValue)
{
// menu.AddItem("Regen", "Rigenerazione");
AddMenuItemFormat(menu, "Regen", ITEMDRAW_DEFAULT, "%t", "Menu_Regen");
}
if (cv_bMenuBhop.BoolValue)
{
// menu.AddItem("Bhop", "Bhop");
AddMenuItemFormat(menu, "Bhop", ITEMDRAW_DEFAULT, "%t", "Menu_Bhop");
}
if (cv_bMenuWeap.BoolValue)
{
// menu.AddItem("Weap", "+Usp");
AddMenuItemFormat(menu, "Weap", ITEMDRAW_DEFAULT, "%t", "Menu_Weapon");
}
menu.ExitButton = true;
menu.Display(client, MENU_TIME_FOREVER);
}
public int hMenu(Handle menu, MenuAction action, int client, int param2) //MENU HANDLER
{
if (action == MenuAction_Select)
{
char info[128];
GetMenuItem(menu, param2, info, sizeof(info));
if (strcmp(info, "Life") == 0)
{
CPrintToChat(client, "%t %t", "Prefix", "Get_Life");
int iClientHealth = GetClientHealth(client);
SetEntProp(client, Prop_Send, "m_iHealth", cv_iLifeHP.IntValue + iClientHealth);
b_Use[client] = true;
}
else if (strcmp(info, "Armour") == 0)
{
CPrintToChat(client, "%t %t", "Prefix", "Get_Armour");
SetEntProp(client, Prop_Send, "m_ArmorValue", cv_iArmour.IntValue);
b_Use[client] = true;
}
else if (strcmp(info, "Nade") == 0)
{
CPrintToChat(client, "%t %t", "Prefix", "Get_Nade");
GivePlayerItem(client, "weapon_hegrenade");
b_Use[client] = true;
}
else if (strcmp(info, "Smoke") == 0)
{
CPrintToChat(client, "%t %t", "Prefix", "Get_Smoke");
GivePlayerItem(client, "weapon_smokegrenade");
b_Use[client] = true;
}
else if (strcmp(info, "Speed") == 0)
{
CPrintToChat(client, "%t %t", "Prefix", "Get_Speed");
SetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue", cv_fSpeed.FloatValue);
b_Use[client] = true;
}
else if (strcmp(info, "Gravity") == 0)
{
CPrintToChat(client, "%t %t", "Prefix", "Get_Gravity");
SetEntityGravity(client, cv_fGravity.FloatValue);
b_Use[client] = true;
}
else if (strcmp(info, "Regen") == 0)
{
CPrintToChat(client, "%t %t", "Prefix", "Get_Regen");
b_Regen[client] = true;
h_Regen[client] = CreateTimer(cv_fHpTimer.FloatValue, Timer_Regen, client, TIMER_REPEAT);
b_Use[client] = true;
}
else if (strcmp(info, "Bhop") == 0)
{
CPrintToChat(client, "%t %t", "Prefix", "Get_Bhop");
b_bhop[client] = true;
b_Use[client] = true;
}
else if (strcmp(info, "Weap") == 0)
{
b_Use[client] = true;
char sWeapon[32];
cv_sWeapon.GetString(sWeapon, sizeof(sWeapon));
if (GivePlayerItem(client, sWeapon) == -1)
{
if (StrContains(sWeapon, "weapon_", false) != 0) {
Format(sWeapon, sizeof(sWeapon), "weapon_%s", sWeapon);
PrintToChat(client, "%t %t", "Prefix", "Get_Weapon");
}
else
{
PrintToConsole(client, "%t %t", "Prefix", "Weapon_not_found");
PrintToServer("%t %t", "Prefix", "Weapon_not_found");
}
}
}
}
else if (action == MenuAction_End)
{
delete menu;
}
}
/********************************************************************************************************************************
TIMERS
*********************************************************************************************************************************/
public Action Timer_Regen(Handle timer, any client) //REGENERATION TIMER
{
int i_Health = GetClientHealth(client);
if (IsValidClientVip(client))
{
if (cv_iRegenMaxHP.IntValue < i_Health)
{
if (!cv_bStopTimer)
KillTimer(h_Regen[client]);
}
else if (b_Regen[client])
{
SetEntityHealth(client, i_Health + cv_iRegenHP.IntValue);
}
}
}
stock bool IsValidClientVip(int client) //IS VALID CLIENT
{
if (!(!IsClientInGame(client) || !IsPlayerAlive(client) || IsFakeClient(client) || GetClientTeam(client) < 2 || IsClientSourceTV(client) || IsClientReplay(client)))
{
return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment