2014-08-04 09:54:24 +00:00
|
|
|
// vim: set ts=4 sw=4 tw=99 noet:
|
|
|
|
//
|
|
|
|
// AMX Mod X, based on AMX Mod by Aleksander Naszko ("OLO").
|
|
|
|
// Copyright (C) The AMX Mod X Development Team.
|
|
|
|
//
|
|
|
|
// This software is licensed under the GNU General Public License, version 3 or higher.
|
|
|
|
// Additional exceptions apply. For full license details, see LICENSE.txt or visit:
|
|
|
|
// https://alliedmods.net/amxmodx-license
|
|
|
|
|
|
|
|
//
|
|
|
|
// Counter-Strike Module
|
|
|
|
//
|
|
|
|
|
2014-05-28 23:19:52 +00:00
|
|
|
#include "amxxmodule.h"
|
2016-01-22 23:09:04 +00:00
|
|
|
#include <amtl/am-algorithm.h>
|
2018-08-26 15:18:39 +00:00
|
|
|
#include <amtl/am-string.h>
|
2014-05-28 23:19:52 +00:00
|
|
|
|
2015-07-03 17:28:26 +00:00
|
|
|
extern int MessageIdTextMsg;
|
|
|
|
|
2015-07-04 13:51:16 +00:00
|
|
|
bool UTIL_IsPlayer(edict_t *pPlayer)
|
2014-05-28 23:19:52 +00:00
|
|
|
{
|
2018-08-26 15:18:39 +00:00
|
|
|
return pPlayer && strcmp(STRING(pPlayer->v.classname), "player") == 0;
|
2014-05-28 23:19:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void UTIL_TextMsg_Generic(edict_t* pPlayer, const char* message)
|
|
|
|
{
|
2015-07-03 17:28:26 +00:00
|
|
|
MESSAGE_BEGIN(MSG_ONE, MessageIdTextMsg, nullptr, pPlayer);
|
2015-07-03 15:42:40 +00:00
|
|
|
WRITE_BYTE(HUD_PRINTCENTER); // 1 = console, 2 = console, 3 = chat, 4 = center, 5 = radio
|
|
|
|
WRITE_STRING(message);
|
2014-05-28 23:19:52 +00:00
|
|
|
MESSAGE_END();
|
2014-06-01 20:24:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool UTIL_CheckForPublic(const char *publicname)
|
|
|
|
{
|
|
|
|
AMX* amx;
|
|
|
|
int iFunctionIndex;
|
|
|
|
int i = 0;
|
|
|
|
char blah[64];
|
|
|
|
|
2018-08-26 15:18:39 +00:00
|
|
|
ke::SafeStrcpy(blah, sizeof(blah), publicname);
|
2014-06-01 20:24:52 +00:00
|
|
|
|
2015-07-03 15:42:40 +00:00
|
|
|
while ((amx = MF_GetScriptAmx(i++)))
|
2014-06-01 20:24:52 +00:00
|
|
|
{
|
|
|
|
if (MF_AmxFindPublic(amx, blah, &iFunctionIndex) == AMX_ERR_NONE)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-04 13:51:16 +00:00
|
|
|
return false;
|
2014-07-04 08:33:55 +00:00
|
|
|
}
|
2016-01-22 23:09:04 +00:00
|
|
|
|
|
|
|
void UTIL_StringToLower(const char *str, char *buffer, size_t maxlength)
|
|
|
|
{
|
|
|
|
auto length = ke::Min(strlen(str), maxlength - 1);
|
|
|
|
|
|
|
|
for (size_t i = 0; i < length; ++i)
|
|
|
|
{
|
|
|
|
if (str[i] >= 'A' && str[i] <= 'Z')
|
|
|
|
{
|
|
|
|
buffer[i] = tolower(str[i]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
buffer[i] = str[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
buffer[length] = '\0';
|
|
|
|
}
|