Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sdktools>
- #include <vip_core>
- public Plugin myinfo = {name = "VIP_WeaponPack | Weapon set", author = "Drumanid", version = "2.0 [ FINAL ? ]", url = "http://vk.com/drumanid | http://hlmod.ru"}
- #pragma newdecls required
- #pragma semicolon 1
- int g_iRounds;
- int g_iRound[MAXPLAYERS+1];
- #define VIP_WEAPONPACK "Weaponpack"
- ConVar c_RoundMenu;
- ConVar c_RoundLimit;
- Handle kv;
- char MenuName[PLATFORM_MAX_PATH];
- //======================================================================================================================================================================
- // Registration
- //======================================================================================================================================================================
- public void OnPluginStart()
- {
- RegConsoleCmd("wp", WeaponMenuCmd);
- HookEvent("round_start", RoundStart, EventHookMode_Pre);
- c_RoundMenu = CreateConVar("c_RoundMenu", "0", "1 - Turn on / 0 - Switch off | Displays a menu at the beginning of the round for VIP players");
- c_RoundLimit = CreateConVar("c_RoundLimit", "1", "0 - Can always be used | How many rounds to prevent a VIP player from using again WeaponPack");
- if(VIP_IsVIPLoaded())
- {
- VIP_OnVIPLoaded();
- }
- kv = CreateKeyValues("WeaponPack");
- if(FileToKeyValues(kv, "addons/sourcemod/data/vip/modules/WeaponPack.ini"))
- {
- PrintToServer("| VIP | WeaponPack.ini uploaded successfully!");
- }
- else
- {
- PrintToServer("No found: addons/sourcemod/data/vip/modules/WeaponPack.ini");
- LogError("No found: addons/sourcemod/data/vip/modules/WeaponPack.ini");
- }
- AutoExecConfig(true, "VIP_WeaponPack", "vip");
- }
- //======================================================================================================================================================================
- // We issue the menu "Do you want" at the beginning of each round to the VIP player
- //======================================================================================================================================================================
- public Action RoundStart(Handle event, const char[] name, bool dontBroadcast)
- {
- if(GetConVarInt(c_RoundMenu) == 1)
- {
- for(int i = 1; i <= MaxClients; i++)
- {
- if(IsClientInGame(i))
- {
- if(VIP_IsClientVIP(i) && VIP_IsClientFeatureUse(i, VIP_WEAPONPACK))
- {
- RoundMenu(i);
- }
- }
- }
- }
- }
- public int RoundMenu(int client)
- {
- char map[PLATFORM_MAX_PATH];
- GetCurrentMap(map, sizeof(map));
- if((strncmp(map, "35hp_", 5) == 0) || (strncmp(map, "awp_", 4) == 0))
- {
- return;
- }
- else
- {
- if(GameRules_GetProp("m_bWarmupPeriod") == 1)
- {
- return;
- }
- else
- {
- g_iRounds = GetRound();
- if(g_iRounds < 2)
- {
- return;
- }
- }
- if(IsPlayerAlive(client))
- {
- if(g_iRound[client] > g_iRounds)
- {
- PrintToChat(client, " \x07The weapon set will be available through: \x04%i\x07 round(s)!", g_iRound[client] - g_iRounds);
- return;
- }
- else
- {
- Panel hPanel = new Panel();
- hPanel.SetTitle( "Do you want to use WeaponPack?\n \n");
- hPanel.DrawItem("Yes");
- hPanel.DrawItem("No");
- hPanel.Send(client, SelectMenu, 0);
- delete hPanel;
- }
- }
- }
- }
- public int SelectMenu(Menu hPanel, MenuAction action, int client, int option)
- {
- if(action == MenuAction_Select && option == 1)
- {
- WeaponMenu(client);
- }
- }
- //======================================================================================================================================================================
- // Register the module in the VIP system
- //======================================================================================================================================================================
- public void VIP_OnVIPLoaded()
- {
- VIP_RegisterFeature(VIP_WEAPONPACK, BOOL, SELECTABLE, OnSelectItem);
- }
- public bool OnSelectItem(int client, const char[] sFeatureName)
- {
- WeaponMenu(client);
- return;
- }
- //======================================================================================================================================================================
- // Checking and running the !wp command
- //======================================================================================================================================================================
- public Action WeaponMenuCmd(int client, int args)
- {
- if(client > 0 && args < 1 && VIP_IsClientVIP(client) && VIP_IsClientFeatureUse(client, VIP_WEAPONPACK))
- {
- WeaponMenu(client);
- }
- return Plugin_Handled;
- }
- //======================================================================================================================================================================
- // Execute menu items
- //======================================================================================================================================================================
- public int SelectWeapon(Handle menu, MenuAction action, int client, int option)
- {
- switch(action)
- {
- case MenuAction_End:
- {
- CloseHandle(menu);
- }
- case MenuAction_Select:
- {
- GetMenuItem(menu, option, MenuName, sizeof(MenuName));
- KvRewind(kv);
- if(KvJumpToKey(kv, MenuName, false))
- {
- char sBuffer[64];
- if(KvGotoFirstSubKey(kv, false))
- {
- g_iRound[client] = g_iRounds + GetConVarInt(c_RoundLimit);
- do
- {
- KvGetSectionName(kv, sBuffer, sizeof(sBuffer));
- if(!StrEqual(sBuffer, "weapon"))
- {
- continue;
- }
- KvGetString(kv, NULL_STRING, sBuffer, sizeof(sBuffer));
- GivePlayerItem(client, sBuffer);
- }
- while(KvGotoNextKey(kv, false));
- }
- }
- }
- }
- }
- //======================================================================================================================================================================
- // The menu itself
- //======================================================================================================================================================================
- public int WeaponMenu(int client)
- {
- char map[PLATFORM_MAX_PATH];
- GetCurrentMap(map, sizeof(map));
- if((strncmp(map, "35hp_", 5) == 0) || (strncmp(map, "awp_", 4) == 0))
- {
- PrintToChat(client, " \x07You can't pick up a set of weapons on this map!");
- ClientCommand(client,"play buttons/weapon_cant_buy.wav");
- return;
- }
- else
- {
- if(GameRules_GetProp("m_bWarmupPeriod") == 1)
- {
- PrintToChat(client, " \x07You can not take a set of weapons during the warm-up!");
- ClientCommand(client,"play buttons/weapon_cant_buy.wav");
- return;
- }
- else
- {
- g_iRounds = GetRound();
- if(g_iRounds < 2)
- {
- PrintToChat(client, " \x07You cannot take a set of weapons in \x02first\x07 round!");
- ClientCommand(client,"play buttons/weapon_cant_buy.wav");
- return;
- }
- }
- if(IsPlayerAlive(client))
- {
- if(g_iRound[client] > g_iRounds)
- {
- PrintToChat(client, " \x07It will be possible to take again through \x04%i\x07 round(s)!", g_iRound[client] - g_iRounds);
- ClientCommand(client,"play buttons/weapon_cant_buy.wav");
- return;
- }
- else
- {
- Handle menu = CreateMenu(SelectWeapon);
- SetMenuTitle(menu, "★ Weapon Pack Menu ★");
- KvRewind(kv);
- if(KvGotoFirstSubKey(kv))
- {
- do
- {
- if(KvGetSectionName(kv, MenuName, sizeof(MenuName)))
- {
- if(GetClientTeam(client) == KvGetNum(kv, "Team", 0) || KvGetNum(kv, "Team", 0) == 0)
- {
- AddMenuItem(menu, MenuName, MenuName);
- }
- }
- }
- while(KvGotoNextKey(kv));
- }
- SetMenuExitButton(menu, true);
- DisplayMenu(menu, client, 0);
- }
- }
- else
- {
- PrintToChat(client, " \x07You must be alive in order to take a set of weapons!");
- ClientCommand(client,"play buttons/weapon_cant_buy.wav");
- }
- }
- }
- public void OnClientPostAdminCheck(int client)
- {
- g_iRound[client] = 0;
- }
- //======================================================================================================================================================================
- // Checking the rounds
- //======================================================================================================================================================================
- stock int GetRound()
- {
- static ConVar mp_halftime, mp_maxrounds;
- if(!mp_halftime)
- {
- mp_halftime = FindConVar("mp_halftime");
- mp_maxrounds = FindConVar("mp_maxrounds");
- }
- int total_score = GetTeamScore(2) + GetTeamScore(3) + 1;
- if (mp_halftime.IntValue == 1)
- {
- int halftimer = mp_maxrounds.IntValue/2;
- if(halftimer < total_score) return total_score - mp_maxrounds.IntValue/2;
- }
- return total_score;
- }
- //======================================================================================================================================================================
- // Unloading a module
- //======================================================================================================================================================================
- public void OnPluginEnd()
- {
- if(CanTestFeatures() && GetFeatureStatus(FeatureType_Native, "VIP_WEAPONPACK") == FeatureStatus_Available)
- {
- VIP_UnregisterFeature(VIP_WEAPONPACK);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement