2009-06-22 06:08:26 +02:00
|
|
|
/*
|
|
|
|
* ============================================================================
|
|
|
|
*
|
2009-07-05 08:49:23 +02:00
|
|
|
* Zombie:Reloaded
|
2009-06-22 06:08:26 +02:00
|
|
|
*
|
|
|
|
* File: zcookies.inc
|
|
|
|
* Type: Module
|
|
|
|
* Description: ZCookies module, allows clients to modify their ZR cookies via menu.
|
|
|
|
*
|
2013-01-12 08:47:36 +01:00
|
|
|
* Copyright (C) 2009-2013 Greyscale, Richard Helgeby
|
2009-06-22 06:08:26 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* ============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create commands specific to ZHP.
|
|
|
|
*/
|
|
|
|
ZCookiesOnCommandsCreate()
|
|
|
|
{
|
|
|
|
// Register ZCookies command.
|
|
|
|
RegConsoleCmd(SAYHOOKS_KEYWORD_ZCOOKIES, ZCookiesCommand, "Toggle all ZR cookies here.");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show ZCookies menu to client.
|
2016-02-06 00:47:47 +01:00
|
|
|
*
|
2009-06-22 06:08:26 +02:00
|
|
|
* @param client The client index.
|
|
|
|
*/
|
|
|
|
ZCookiesMenuMain(client)
|
|
|
|
{
|
|
|
|
// Create menu handle.
|
|
|
|
new Handle:zcookies_menu_main = CreateMenu(ZCookiesMenuMainHandle);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-06-22 06:08:26 +02:00
|
|
|
// Make client global translations target.
|
|
|
|
SetGlobalTransTarget(client);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-12-17 03:13:35 +01:00
|
|
|
decl String:zhpenabled[MENU_LINE_SMALL_LENGTH];
|
|
|
|
decl String:overlayenabled[MENU_LINE_SMALL_LENGTH];
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-06-22 06:08:26 +02:00
|
|
|
// Get the current toggle state of the cookies.
|
2009-08-03 23:55:50 +02:00
|
|
|
ConfigBoolToSetting(CookiesGetClientCookieBool(client, g_hZHPEnabledCookie), zhpenabled, sizeof(zhpenabled), false, client);
|
|
|
|
ConfigBoolToSetting(CookiesGetClientCookieBool(client, g_hOverlayEnabledCookie), overlayenabled, sizeof(overlayenabled), false, client);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-07-28 02:02:49 +02:00
|
|
|
decl String:title[MENU_LINE_TITLE_LENGTH];
|
2009-07-27 22:25:23 +02:00
|
|
|
decl String:zhp[MENU_LINE_REG_LENGTH];
|
|
|
|
decl String:overlay[MENU_LINE_REG_LENGTH];
|
|
|
|
decl String:zmarket[MENU_LINE_REG_LENGTH];
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-06-22 06:08:26 +02:00
|
|
|
// Translate each line into client's language.
|
2009-07-28 02:02:49 +02:00
|
|
|
Format(title, sizeof(title), "%t\n ", "ZCookies Menu main title");
|
2009-06-22 06:08:26 +02:00
|
|
|
Format(zhp, sizeof(zhp), "%t", "ZCookies menu main zhp", zhpenabled);
|
|
|
|
Format(overlay, sizeof(overlay), "%t", "ZCookies menu main overlay", overlayenabled);
|
2009-07-24 00:40:39 +02:00
|
|
|
Format(zmarket, sizeof(zmarket), "%t", "ZCookies zmarket loadout");
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-06-22 06:08:26 +02:00
|
|
|
// Get conditional values for each option.
|
2009-07-24 00:40:39 +02:00
|
|
|
new bool:zhpcvar = GetConVarBool(g_hCvarsList[CVAR_ZHP]); // For ZHP.
|
2009-06-22 06:08:26 +02:00
|
|
|
new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]); // For class overlay.
|
2009-07-24 00:40:39 +02:00
|
|
|
new bool:zmarketenabled = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET]); // For ZMarket loadout.
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-06-22 06:08:26 +02:00
|
|
|
// Add items to menu.
|
2009-07-28 02:02:49 +02:00
|
|
|
SetMenuTitle(zcookies_menu_main, title);
|
2009-06-22 06:08:26 +02:00
|
|
|
AddMenuItem(zcookies_menu_main, "zhp", zhp, MenuGetItemDraw(zhpcvar));
|
|
|
|
AddMenuItem(zcookies_menu_main, "overlay", overlay, MenuGetItemDraw(overlaytoggle));
|
2009-07-24 00:40:39 +02:00
|
|
|
AddMenuItem(zcookies_menu_main, "zmarket", zmarket, MenuGetItemDraw(zmarketenabled));
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-06-22 06:08:26 +02:00
|
|
|
// Create a "Back" button to the main menu.
|
|
|
|
SetMenuExitBackButton(zcookies_menu_main, true);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-06-22 06:08:26 +02:00
|
|
|
// Display menu to client.
|
|
|
|
DisplayMenu(zcookies_menu_main, client, MENU_TIME_FOREVER);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Menu callback (main)
|
|
|
|
* Toggles client cookies.
|
2016-02-06 00:47:47 +01:00
|
|
|
*
|
2009-06-22 06:08:26 +02:00
|
|
|
* @param menu The menu handle.
|
|
|
|
* @param action Action client is doing in menu.
|
|
|
|
* @param client The client index.
|
|
|
|
* @param slot The menu slot selected. (starting from 0)
|
|
|
|
*/
|
|
|
|
public ZCookiesMenuMainHandle(Handle:menu, MenuAction:action, client, slot)
|
|
|
|
{
|
|
|
|
// Client selected an option.
|
|
|
|
if (action == MenuAction_Select)
|
|
|
|
{
|
2009-07-24 00:40:39 +02:00
|
|
|
new bool:resend = true;
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-06-22 06:08:26 +02:00
|
|
|
switch(slot)
|
|
|
|
{
|
|
|
|
// Toggled ZHP.
|
2016-02-12 04:16:59 +01:00
|
|
|
case 0:
|
2009-06-22 06:08:26 +02:00
|
|
|
{
|
|
|
|
ZHPToggle(client);
|
|
|
|
}
|
|
|
|
// Toggled class overlay.
|
2016-02-12 04:16:59 +01:00
|
|
|
case 1:
|
2009-06-22 06:08:26 +02:00
|
|
|
{
|
|
|
|
// If overlay toggle is disabled, then stop.
|
|
|
|
new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]);
|
|
|
|
if (overlaytoggle)
|
|
|
|
{
|
|
|
|
// Toggle current overlay channel, retrieve new value, and update cookie.
|
|
|
|
new bool:overlayenabled = OverlaysClientSetChannelState(client, OVERLAYS_CHANNEL_CLASSES, true, true);
|
|
|
|
CookiesSetClientCookieBool(client, g_hOverlayEnabledCookie, overlayenabled);
|
|
|
|
}
|
|
|
|
}
|
2009-07-24 00:40:39 +02:00
|
|
|
// Opened ZMarket loadout.
|
2016-02-12 04:16:59 +01:00
|
|
|
case 2:
|
2009-07-24 00:40:39 +02:00
|
|
|
{
|
|
|
|
// Show a client their current loadout.
|
|
|
|
ZMarketMenuLoadout(client);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-07-24 00:40:39 +02:00
|
|
|
// Don't resend ZCookies.
|
|
|
|
resend = false;
|
|
|
|
}
|
2009-06-22 06:08:26 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-07-24 00:40:39 +02:00
|
|
|
if (resend)
|
|
|
|
{
|
|
|
|
// Re-send menu.
|
|
|
|
ZCookiesMenuMain(client);
|
|
|
|
}
|
2009-06-22 06:08:26 +02:00
|
|
|
}
|
|
|
|
// Client closed the menu.
|
|
|
|
if (action == MenuAction_Cancel)
|
|
|
|
{
|
|
|
|
// Client hit "Back" button.
|
|
|
|
if (slot == MenuCancel_ExitBack)
|
|
|
|
{
|
|
|
|
// Re-open main menu.
|
|
|
|
ZMenuMain(client);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Client exited menu.
|
|
|
|
if (action == MenuAction_End)
|
|
|
|
{
|
|
|
|
CloseHandle(menu);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Command callback (zcookies)
|
|
|
|
* Toggle all ZR cookies here.
|
2016-02-06 00:47:47 +01:00
|
|
|
*
|
2009-06-22 06:08:26 +02:00
|
|
|
* @param client The client index.
|
|
|
|
* @param argc Argument count.
|
|
|
|
*/
|
|
|
|
public Action:ZCookiesCommand(client, argc)
|
|
|
|
{
|
|
|
|
// If client is console, then stop and tell them this feature is for players only.
|
|
|
|
if (ZRIsConsole(client))
|
|
|
|
{
|
|
|
|
TranslationPrintToServer("Must be player");
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-06-22 06:08:26 +02:00
|
|
|
// Send ZCookies menu.
|
|
|
|
ZCookiesMenuMain(client);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-06-22 06:08:26 +02:00
|
|
|
// This stops the "Unknown command" message in client's console.
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|