/* * ============================================================================ * * Zombie:Reloaded * * File: cookies.inc * Type: Module * Description: Client cookie API. * * Copyright (C) 2009 Greyscale, Richard Helgeby * * 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 . * * ============================================================================ */ /** * Cookies module init function. */ CookiesInit() { // Forward event to modules. ClassOnCookiesCreate(); WeaponsOnCookiesCreate(); ZHPOnCookiesCreate(); } /** * Accepts a bools for setting client cookies. * * @param client The client index. * @param cookie The handle to the cookie. * @param cookievalue The bool value to set cookie as. */ CookiesSetClientCookieBool(client, Handle:cookie, bool:cookievalue) { // Convert bool to string. decl String:strCookievalue[8]; ZRBoolToString(cookievalue, strCookievalue, sizeof(strCookievalue)); // Set the converted string to the cookie. SetClientCookie(client, cookie, strCookievalue); } /** * Returns a cookie value as a bool. * * @param client The client index. * @param cookie The handle to the cookie. */ bool:CookiesGetClientCookieBool(client, Handle:cookie) { // Get cookie string. decl String:cookievalue[8]; GetClientCookie(client, cookie, cookievalue, sizeof(cookievalue)); // Return string casted into an int, then to bool. return bool:StringToInt(cookievalue); }