2009-04-29 01:58:41 +02:00
|
|
|
/*
|
|
|
|
* ============================================================================
|
|
|
|
*
|
2009-07-05 08:49:23 +02:00
|
|
|
* Zombie:Reloaded
|
2009-04-29 01:58:41 +02:00
|
|
|
*
|
2009-06-12 05:51:26 +02:00
|
|
|
* File: sayhooks.inc
|
|
|
|
* Type: Core
|
|
|
|
* Description: Hook plugin say commands and redirect to their handling module.
|
|
|
|
*
|
|
|
|
* 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 <http://www.gnu.org/licenses/>.
|
2009-04-29 01:58:41 +02:00
|
|
|
*
|
|
|
|
* ============================================================================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2009-06-17 23:32:46 +02:00
|
|
|
* @section SM core config info.
|
2009-04-29 01:58:41 +02:00
|
|
|
*/
|
2009-06-17 23:32:46 +02:00
|
|
|
#define SAYHOOKS_CORE_KVNAME "Core"
|
|
|
|
#define SAYHOOKS_CORE_KVPATH "configs/core.cfg"
|
|
|
|
#define SAYHOOKS_CHAT_PUBLIC_DEFAULT "!"
|
|
|
|
#define SAYHOOKS_CHAT_SILENT_DEFAULT "/"
|
2009-04-29 01:58:41 +02:00
|
|
|
/**
|
|
|
|
* @endsection
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
|
|
|
|
2009-04-30 07:36:57 +02:00
|
|
|
/**
|
2009-06-17 23:32:46 +02:00
|
|
|
* Max number of characters in a chat text string.
|
2009-04-30 07:36:57 +02:00
|
|
|
*/
|
2009-06-17 23:32:46 +02:00
|
|
|
#define SAYHOOKS_MAX_CHAT_LENGTH 192
|
|
|
|
|
2009-04-30 07:36:57 +02:00
|
|
|
/**
|
2009-06-17 23:32:46 +02:00
|
|
|
* @section Say command key words.
|
2009-04-30 07:36:57 +02:00
|
|
|
*/
|
2009-06-17 23:32:46 +02:00
|
|
|
#define SAYHOOKS_KEYWORD_ZMENU "zmenu"
|
|
|
|
#define SAYHOOKS_KEYWORD_ZADMIN "zadmin"
|
|
|
|
#define SAYHOOKS_KEYWORD_ZCLASS "zclass"
|
2009-06-22 06:08:26 +02:00
|
|
|
#define SAYHOOKS_KEYWORD_ZCOOKIES "zcookies"
|
2009-06-17 23:32:46 +02:00
|
|
|
#define SAYHOOKS_KEYWORD_ZSPAWN "zspawn"
|
|
|
|
#define SAYHOOKS_KEYWORD_ZTELE "ztele"
|
|
|
|
#define SAYHOOKS_KEYWORD_ZHP "zhp"
|
|
|
|
#define SAYHOOKS_KEYWORD_ZMARKET "zmarket"
|
2009-04-29 01:58:41 +02:00
|
|
|
/**
|
2009-06-17 23:32:46 +02:00
|
|
|
* @endsection
|
2009-04-29 01:58:41 +02:00
|
|
|
*/
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2009-04-29 01:58:41 +02:00
|
|
|
/**
|
2009-06-17 23:32:46 +02:00
|
|
|
* Hack function to get the public chat trigger value.
|
2009-04-29 01:58:41 +02:00
|
|
|
*
|
2009-06-17 23:32:46 +02:00
|
|
|
* @param trigger The string to store value in.
|
|
|
|
* @param maxlen The maximum length of the string.
|
2009-04-29 01:58:41 +02:00
|
|
|
*/
|
2009-06-17 23:32:46 +02:00
|
|
|
SayHooksGetPublicChatTrigger(String:trigger[], maxlen)
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
2009-06-17 23:32:46 +02:00
|
|
|
// Create kv handle.
|
|
|
|
new Handle:kvCore = CreateKeyValues(SAYHOOKS_CORE_KVNAME);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2009-06-17 23:32:46 +02:00
|
|
|
// Build path to file.
|
|
|
|
decl String:filepath[PLATFORM_MAX_PATH];
|
|
|
|
BuildPath(Path_SM, filepath, PLATFORM_MAX_PATH, SAYHOOKS_CORE_KVPATH);
|
2009-05-06 05:31:48 +02:00
|
|
|
|
2009-06-17 23:32:46 +02:00
|
|
|
// Load kv into memory.
|
|
|
|
new bool:success = FileToKeyValues(kvCore, filepath);
|
2009-03-30 21:40:56 +02:00
|
|
|
|
2009-06-17 23:32:46 +02:00
|
|
|
// If the file couldn't be loaded, then return the default value.
|
|
|
|
if (!success)
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
2009-06-17 23:32:46 +02:00
|
|
|
strcopy(trigger, maxlen, SAYHOOKS_CHAT_PUBLIC_DEFAULT);
|
|
|
|
return;
|
2009-04-16 08:08:58 +02:00
|
|
|
}
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2009-06-17 23:32:46 +02:00
|
|
|
// Rewind and find value.
|
|
|
|
KvRewind(kvCore);
|
|
|
|
KvGetString(kvCore, "PublicChatTrigger", trigger, maxlen, SAYHOOKS_CHAT_PUBLIC_DEFAULT);
|
2009-05-06 05:31:48 +02:00
|
|
|
|
2009-06-17 23:32:46 +02:00
|
|
|
// If trigger is disabled, then display as "N/A".
|
|
|
|
if (!trigger[0])
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
2009-06-17 23:32:46 +02:00
|
|
|
strcopy(trigger, maxlen, "N/A");
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
2009-06-26 02:47:37 +02:00
|
|
|
|
|
|
|
// Close the handle.
|
|
|
|
CloseHandle(kvCore);
|
2009-04-30 07:36:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-06-17 23:32:46 +02:00
|
|
|
* Hack function to get the silent chat trigger value.
|
2009-04-30 07:36:57 +02:00
|
|
|
*
|
2009-06-17 23:32:46 +02:00
|
|
|
* @param trigger The string to store value in.
|
|
|
|
* @param maxlen The maximum length of the string.
|
2009-04-30 07:36:57 +02:00
|
|
|
*/
|
2009-06-17 23:32:46 +02:00
|
|
|
SayHooksGetSilentChatTrigger(String:trigger[], maxlen)
|
2009-04-30 07:36:57 +02:00
|
|
|
{
|
2009-06-17 23:32:46 +02:00
|
|
|
// Create kv handle.
|
|
|
|
new Handle:kvCore = CreateKeyValues(SAYHOOKS_CORE_KVNAME);
|
2009-04-30 07:36:57 +02:00
|
|
|
|
2009-06-17 23:32:46 +02:00
|
|
|
// Build path to file.
|
|
|
|
decl String:filepath[PLATFORM_MAX_PATH];
|
|
|
|
BuildPath(Path_SM, filepath, PLATFORM_MAX_PATH, SAYHOOKS_CORE_KVPATH);
|
|
|
|
|
|
|
|
// Load kv into memory.
|
|
|
|
new bool:success = FileToKeyValues(kvCore, filepath);
|
|
|
|
|
|
|
|
// If the file couldn't be loaded, then return the default value.
|
|
|
|
if (!success)
|
2009-04-30 07:36:57 +02:00
|
|
|
{
|
2009-06-17 23:32:46 +02:00
|
|
|
strcopy(trigger, maxlen, SAYHOOKS_CHAT_SILENT_DEFAULT);
|
|
|
|
return;
|
2009-04-30 07:36:57 +02:00
|
|
|
}
|
2009-06-17 23:32:46 +02:00
|
|
|
|
|
|
|
// Rewind and find value.
|
|
|
|
KvRewind(kvCore);
|
|
|
|
KvGetString(kvCore, "SilentChatTrigger", trigger, maxlen, SAYHOOKS_CHAT_SILENT_DEFAULT);
|
|
|
|
|
|
|
|
// If trigger is disabled, then display as "N/A".
|
|
|
|
if (!trigger[0])
|
2009-04-30 07:36:57 +02:00
|
|
|
{
|
2009-06-17 23:32:46 +02:00
|
|
|
strcopy(trigger, maxlen, "N/A");
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
2009-06-26 02:47:37 +02:00
|
|
|
|
|
|
|
// Close the handle.
|
|
|
|
CloseHandle(kvCore);
|
2009-06-17 23:32:46 +02:00
|
|
|
}
|