Compare commits
13
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
313c555e2e | ||
|
|
e5fed0051b | ||
|
|
c2a86c77fd | ||
|
|
8c534e770b | ||
|
|
2c86e8099a | ||
|
|
03eeb23ab3 | ||
|
|
a9c85d8842 | ||
|
|
850ee60a18 | ||
|
|
7cd130904b | ||
|
|
19019d3a4b | ||
|
|
b31375f087 | ||
|
|
1d999c3984 | ||
|
|
fdcbdb6918 |
+1
-1
@@ -1432,7 +1432,7 @@ bool CHalfLife2::IsMapValid(const char *map)
|
||||
if (!map || !map[0])
|
||||
return false;
|
||||
|
||||
return FindMap(map) != SMFindMapResult::NotFound;
|
||||
return FindMap(map) == SMFindMapResult::Found;
|
||||
}
|
||||
|
||||
#if SOURCE_ENGINE < SE_ORANGEBOX
|
||||
|
||||
+72
-16
@@ -8,7 +8,7 @@
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
*
|
||||
* 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
|
||||
@@ -99,7 +99,7 @@ void BaseMenuStyle::_CancelClientMenu(int client, MenuCancelReason reason, bool
|
||||
|
||||
/* Fire callbacks */
|
||||
mh->OnMenuCancel(menu, client, reason);
|
||||
|
||||
|
||||
/* Only fire end if there's a valid menu */
|
||||
if (menu)
|
||||
{
|
||||
@@ -214,7 +214,7 @@ void BaseMenuStyle::ProcessWatchList()
|
||||
}
|
||||
|
||||
#if defined MENU_DEBUG
|
||||
logger->LogMessage("BaseMenuStyle::ProcessWatchList(%d,%d,%d,%d,%d,%p)",
|
||||
logger->LogMessage("BaseMenuStyle::ProcessWatchList(%d,%d,%d,%d,%d,%p)",
|
||||
m_WatchList.m_Size,
|
||||
m_WatchList.m_FirstLink,
|
||||
m_WatchList.m_FreeNodes,
|
||||
@@ -302,7 +302,7 @@ void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press)
|
||||
ItemSelection type = states.slots[key_press].type;
|
||||
|
||||
/* Check if we should play a sound about the type */
|
||||
if (g_Menus.MenuSoundsEnabled() &&
|
||||
if (g_Menus.MenuSoundsEnabled() &&
|
||||
(!menu || (menu->GetMenuOptionFlags() & MENUFLAG_NO_SOUND) != MENUFLAG_NO_SOUND))
|
||||
{
|
||||
CellRecipientFilter filter;
|
||||
@@ -323,21 +323,21 @@ void BaseMenuStyle::ClientPressedKey(int client, unsigned int key_press)
|
||||
if (pCollideable)
|
||||
{
|
||||
const Vector & pos = pCollideable->GetCollisionOrigin();
|
||||
enginesound->EmitSound(filter,
|
||||
client,
|
||||
CHAN_AUTO,
|
||||
enginesound->EmitSound(filter,
|
||||
client,
|
||||
CHAN_AUTO,
|
||||
#if SOURCE_ENGINE >= SE_PORTAL2
|
||||
sound->c_str(),
|
||||
-1,
|
||||
-1,
|
||||
#endif
|
||||
sound->c_str(),
|
||||
VOL_NORM,
|
||||
ATTN_NORM,
|
||||
VOL_NORM,
|
||||
ATTN_NORM,
|
||||
#if SOURCE_ENGINE >= SE_PORTAL2
|
||||
0,
|
||||
0,
|
||||
#endif
|
||||
0,
|
||||
PITCH_NORM,
|
||||
0,
|
||||
PITCH_NORM,
|
||||
#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS \
|
||||
|| SOURCE_ENGINE == SE_SDK2013 || SOURCE_ENGINE == SE_BMS || SOURCE_ENGINE == SE_TF2 || SOURCE_ENGINE == SE_PVKII
|
||||
0,
|
||||
@@ -604,9 +604,9 @@ bool BaseMenuStyle::RedoClientMenu(int client, ItemOrder order)
|
||||
return true;
|
||||
}
|
||||
|
||||
CBaseMenu::CBaseMenu(IMenuHandler *pHandler, IMenuStyle *pStyle, IdentityToken_t *pOwner) :
|
||||
m_pStyle(pStyle), m_Pagination(7), m_bShouldDelete(false), m_bCancelling(false),
|
||||
m_pOwner(pOwner ? pOwner : g_pCoreIdent), m_bDeleting(false), m_bWillFreeHandle(false),
|
||||
CBaseMenu::CBaseMenu(IMenuHandler *pHandler, IMenuStyle *pStyle, IdentityToken_t *pOwner) :
|
||||
m_pStyle(pStyle), m_Pagination(7), m_bShouldDelete(false), m_bCancelling(false),
|
||||
m_pOwner(pOwner ? pOwner : g_pCoreIdent), m_bDeleting(false), m_bWillFreeHandle(false),
|
||||
m_hHandle(BAD_HANDLE), m_pHandler(pHandler), m_nFlags(MENUFLAG_BUTTON_EXIT)
|
||||
{
|
||||
}
|
||||
@@ -754,6 +754,62 @@ unsigned int CBaseMenu::GetRealItemIndex(int client, unsigned int position)
|
||||
return position;
|
||||
}
|
||||
|
||||
void CBaseMenu::ShufflePerClient(int start, int stop)
|
||||
{
|
||||
// limit map len to 255 items since it's using uint8
|
||||
int length = MIN(GetItemCount(), 255);
|
||||
if (stop >= 0)
|
||||
length = MIN(length, stop);
|
||||
|
||||
for (int i = 1; i < SM_MAXPLAYERS + 1; i++)
|
||||
{
|
||||
// populate per-client map ...
|
||||
m_RandomMaps[i].resize(length);
|
||||
for (int j = 0; j < length; j++)
|
||||
m_RandomMaps[i][j] = j;
|
||||
|
||||
// ... and random shuffle it
|
||||
for (int j = length - 1; j > start; j--)
|
||||
{
|
||||
int x = rand() % (j - start + 1) + start;
|
||||
uint8_t tmp = m_RandomMaps[i][x];
|
||||
m_RandomMaps[i][x] = m_RandomMaps[i][j];
|
||||
m_RandomMaps[i][j] = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CBaseMenu::SetClientMapping(int client, int *array, int length)
|
||||
{
|
||||
length = MIN(length, 255);
|
||||
m_RandomMaps[client].resize(length);
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
m_RandomMaps[client][i] = array[i];
|
||||
}
|
||||
}
|
||||
|
||||
bool CBaseMenu::IsPerClientShuffled()
|
||||
{
|
||||
for (int i = 1; i < SM_MAXPLAYERS + 1; i++)
|
||||
{
|
||||
if(m_RandomMaps[i].length() > 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int CBaseMenu::GetRealItemIndex(int client, unsigned int position)
|
||||
{
|
||||
if (client > 0 && position < m_RandomMaps[client].length())
|
||||
{
|
||||
position = m_RandomMaps[client][position];
|
||||
return m_items[position].index;
|
||||
}
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
unsigned int CBaseMenu::GetItemCount()
|
||||
{
|
||||
return m_items.size();
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
*
|
||||
* 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
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
|
||||
class CBaseMenu;
|
||||
|
||||
class BaseMenuStyle :
|
||||
class BaseMenuStyle :
|
||||
public IMenuStyle,
|
||||
public IClientListener
|
||||
{
|
||||
@@ -113,11 +113,11 @@ public: //IClientListener
|
||||
public: //what derived must implement
|
||||
virtual CBaseMenuPlayer *GetMenuPlayer(int client) =0;
|
||||
virtual void SendDisplay(int client, IMenuPanel *display) =0;
|
||||
public: //what derived may implement
|
||||
virtual bool DoClientMenu(int client,
|
||||
CBaseMenu *menu,
|
||||
public: //what derived may implement
|
||||
virtual bool DoClientMenu(int client,
|
||||
CBaseMenu *menu,
|
||||
unsigned int first_item,
|
||||
IMenuHandler *mh,
|
||||
IMenuHandler *mh,
|
||||
unsigned int time);
|
||||
virtual bool DoClientMenu(int client, IMenuPanel *menu, IMenuHandler *mh, unsigned int time);
|
||||
virtual void AddClientToWatch(int client);
|
||||
|
||||
@@ -217,6 +217,9 @@ void PlayerManager::OnSourceModAllInitialized()
|
||||
SH_ADD_HOOK(ConCommand, Dispatch, pCmd, SH_STATIC(CmdMaxplayersCallback), true);
|
||||
maxplayersCmd = pCmd;
|
||||
}
|
||||
|
||||
gameevents->AddListener(this, "player_connect", true);
|
||||
gameevents->AddListener(this, "player_disconnect", true);
|
||||
}
|
||||
|
||||
void PlayerManager::OnSourceModShutdown()
|
||||
@@ -267,6 +270,8 @@ void PlayerManager::OnSourceModShutdown()
|
||||
{
|
||||
SH_REMOVE_HOOK(ConCommand, Dispatch, maxplayersCmd, SH_STATIC(CmdMaxplayersCallback), true);
|
||||
}
|
||||
|
||||
gameevents->RemoveListener(this);
|
||||
}
|
||||
|
||||
ConfigResult PlayerManager::OnSourceModConfigChanged(const char *key,
|
||||
@@ -1391,6 +1396,11 @@ int PlayerManager::GetNumPlayers()
|
||||
return m_PlayerCount;
|
||||
}
|
||||
|
||||
int PlayerManager::GetNumClients()
|
||||
{
|
||||
return m_ClientCount;
|
||||
}
|
||||
|
||||
int PlayerManager::GetClientOfUserId(int userid)
|
||||
{
|
||||
if (userid < 0 || userid > USHRT_MAX)
|
||||
@@ -1992,6 +2002,27 @@ bool PlayerManager::HandleConVarQuery(QueryCvarCookie_t cookie, int client, EQue
|
||||
}
|
||||
#endif
|
||||
|
||||
/* IGameEventListener2::FireGameEvent */
|
||||
void PlayerManager::FireGameEvent(IGameEvent *pEvent)
|
||||
{
|
||||
const char *name = pEvent->GetName();
|
||||
|
||||
if (strcmp(name, "player_connect") == 0)
|
||||
{
|
||||
const int client = pEvent->GetInt("index") + 1;
|
||||
const int userid = pEvent->GetInt("userid");
|
||||
|
||||
m_ClientCount++;
|
||||
}
|
||||
else if (strcmp(name, "player_disconnect") == 0)
|
||||
{
|
||||
const int userid = pEvent->GetInt("userid");
|
||||
const int client = m_UserIdLookUp[userid];
|
||||
|
||||
m_ClientCount--;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*******************
|
||||
*** PLAYER CODE ***
|
||||
|
||||
@@ -161,7 +161,8 @@ private:
|
||||
|
||||
class PlayerManager :
|
||||
public SMGlobalClass,
|
||||
public IPlayerManager
|
||||
public IPlayerManager,
|
||||
public IGameEventListener2
|
||||
{
|
||||
friend class CPlayer;
|
||||
public:
|
||||
@@ -205,6 +206,7 @@ public: //IPlayerManager
|
||||
IGamePlayer *GetGamePlayer(edict_t *pEdict);
|
||||
int GetMaxClients();
|
||||
int GetNumPlayers();
|
||||
int GetNumClients();
|
||||
int GetClientOfUserId(int userid);
|
||||
bool IsServerActivated();
|
||||
int FilterCommandTarget(IGamePlayer *pAdmin, IGamePlayer *pTarget, int flags);
|
||||
@@ -215,6 +217,8 @@ public: //IPlayerManager
|
||||
int GetClientFromSerial(unsigned int serial);
|
||||
void ClearAdminId(AdminId id);
|
||||
void RecheckAnyAdmins();
|
||||
public: // IGameEventListener2
|
||||
void FireGameEvent(IGameEvent *pEvent);
|
||||
public:
|
||||
inline int MaxClients()
|
||||
{
|
||||
@@ -276,6 +280,7 @@ private:
|
||||
int m_SourceTVUserId;
|
||||
int m_ReplayUserId;
|
||||
bool m_bInCCKVHook;
|
||||
int m_ClientCount;
|
||||
private:
|
||||
static const int NETMSG_TYPE_BITS = 5; // SVC_Print overhead for netmsg type
|
||||
static const int SVC_Print_BufferSize = 2048 - 1; // -1 for terminating \0
|
||||
|
||||
@@ -16,7 +16,7 @@ for cxx in builder.targets:
|
||||
'SM_DEFAULT_THREADER',
|
||||
'SM_LOGIC'
|
||||
]
|
||||
|
||||
|
||||
if binary.compiler.target.platform == 'linux':
|
||||
binary.compiler.postlink += ['-lpthread', '-lrt']
|
||||
elif binary.compiler.target.platform == 'mac':
|
||||
@@ -86,6 +86,7 @@ for cxx in builder.targets:
|
||||
'DatabaseConfBuilder.cpp',
|
||||
'LumpManager.cpp',
|
||||
'smn_entitylump.cpp',
|
||||
'NativeInvoker.cpp',
|
||||
]
|
||||
|
||||
if binary.compiler.target.arch == 'x86_64':
|
||||
|
||||
@@ -0,0 +1,321 @@
|
||||
// vim: set sts=2 ts=8 sw=2 tw=99 et:
|
||||
//
|
||||
// Copyright (C) 2006-2015 AlliedModders LLC
|
||||
//
|
||||
// This file is part of SourcePawn. SourcePawn 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// SourcePawn. If not, see http://www.gnu.org/licenses/.
|
||||
//
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "NativeInvoker.h"
|
||||
|
||||
/********************
|
||||
* FUNCTION CALLING *
|
||||
********************/
|
||||
|
||||
NativeInvoker::NativeInvoker(IPluginContext *pContext, const ke::RefPtr<Native> &native)
|
||||
: context_(pContext),
|
||||
m_curparam(0),
|
||||
m_errorstate(SP_ERROR_NONE),
|
||||
native_(native)
|
||||
{
|
||||
}
|
||||
|
||||
NativeInvoker::~NativeInvoker()
|
||||
{
|
||||
Cancel();
|
||||
}
|
||||
|
||||
bool
|
||||
NativeInvoker::IsRunnable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
IPluginContext *
|
||||
NativeInvoker::GetParentContext()
|
||||
{
|
||||
return context_;
|
||||
}
|
||||
|
||||
int NativeInvoker::PushCell(cell_t cell)
|
||||
{
|
||||
if (m_curparam >= SP_MAX_EXEC_PARAMS)
|
||||
return SetError(SP_ERROR_PARAMS_MAX);
|
||||
|
||||
m_info[m_curparam].marked = false;
|
||||
m_params[m_curparam] = cell;
|
||||
m_curparam++;
|
||||
|
||||
return SP_ERROR_NONE;
|
||||
}
|
||||
|
||||
int
|
||||
NativeInvoker::PushCellByRef(cell_t *cell, int flags)
|
||||
{
|
||||
return PushArray(cell, 1, flags);
|
||||
}
|
||||
|
||||
int
|
||||
NativeInvoker::PushFloat(float number)
|
||||
{
|
||||
cell_t val = sp::FloatCellUnion(number).cell;
|
||||
|
||||
return PushCell(val);
|
||||
}
|
||||
|
||||
int
|
||||
NativeInvoker::PushFloatByRef(float *number, int flags)
|
||||
{
|
||||
return PushCellByRef((cell_t *)number, flags);
|
||||
}
|
||||
|
||||
int
|
||||
NativeInvoker::PushArray(cell_t *inarray, unsigned int cells, int copyback)
|
||||
{
|
||||
if (m_curparam >= SP_MAX_EXEC_PARAMS)
|
||||
{
|
||||
return SetError(SP_ERROR_PARAMS_MAX);
|
||||
}
|
||||
|
||||
ParamInfo *info = &m_info[m_curparam];
|
||||
|
||||
info->flags = inarray ? copyback : 0;
|
||||
info->marked = true;
|
||||
info->size = cells;
|
||||
info->str.is_sz = false;
|
||||
info->orig_addr = inarray;
|
||||
|
||||
m_curparam++;
|
||||
|
||||
return SP_ERROR_NONE;
|
||||
}
|
||||
|
||||
int
|
||||
NativeInvoker::PushString(const char *string)
|
||||
{
|
||||
return _PushString(string, SM_PARAM_STRING_COPY, 0, strlen(string)+1);
|
||||
}
|
||||
|
||||
int
|
||||
NativeInvoker::PushStringEx(char *buffer, size_t length, int sz_flags, int cp_flags)
|
||||
{
|
||||
return _PushString(buffer, sz_flags, cp_flags, length);
|
||||
}
|
||||
|
||||
int
|
||||
NativeInvoker::_PushString(const char *string, int sz_flags, int cp_flags, size_t len)
|
||||
{
|
||||
if (m_curparam >= SP_MAX_EXEC_PARAMS)
|
||||
return SetError(SP_ERROR_PARAMS_MAX);
|
||||
|
||||
ParamInfo *info = &m_info[m_curparam];
|
||||
|
||||
info->marked = true;
|
||||
info->orig_addr = (cell_t *)string;
|
||||
info->flags = cp_flags;
|
||||
info->size = len;
|
||||
info->str.sz_flags = sz_flags;
|
||||
info->str.is_sz = true;
|
||||
|
||||
m_curparam++;
|
||||
|
||||
return SP_ERROR_NONE;
|
||||
}
|
||||
|
||||
void
|
||||
NativeInvoker::Cancel()
|
||||
{
|
||||
if (!m_curparam)
|
||||
return;
|
||||
|
||||
m_errorstate = SP_ERROR_NONE;
|
||||
m_curparam = 0;
|
||||
}
|
||||
|
||||
int
|
||||
NativeInvoker::Execute(cell_t *result, cell_t buffer, cell_t size)
|
||||
{
|
||||
context_->ClearLastNativeError();
|
||||
|
||||
// For backward compatibility, we have to clear the exception state.
|
||||
// Otherwise code like this:
|
||||
//
|
||||
// static cell_t native(cx, params) {
|
||||
// for (auto callback : callbacks) {
|
||||
// callback->Execute();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Could unintentionally leak a pending exception back to the caller,
|
||||
// which wouldn't have happened before the Great Exception Refactoring.
|
||||
|
||||
SourcePawn::ExceptionHandler eh(context_);
|
||||
eh.Debug(!size);
|
||||
|
||||
if (!Invoke(result)) {
|
||||
if(size)
|
||||
context_->StringToLocalUTF8(buffer, size, eh.Message(), NULL);
|
||||
int Err = context_->GetLastNativeError();
|
||||
context_->ClearLastNativeError();
|
||||
return Err;
|
||||
}
|
||||
|
||||
return SP_ERROR_NONE;
|
||||
}
|
||||
|
||||
bool
|
||||
NativeInvoker::Invoke(cell_t *result)
|
||||
{
|
||||
if (!IsRunnable()) {
|
||||
Cancel();
|
||||
context_->ReportErrorNumber(SP_ERROR_NOT_RUNNABLE);
|
||||
return false;
|
||||
}
|
||||
if (int err = m_errorstate) {
|
||||
Cancel();
|
||||
context_->ReportErrorNumber(err);
|
||||
return false;
|
||||
}
|
||||
|
||||
//This is for re-entrancy!
|
||||
cell_t _temp_params[SP_MAX_EXEC_PARAMS + 1];
|
||||
cell_t *temp_params = &_temp_params[1];
|
||||
ParamInfo temp_info[SP_MAX_EXEC_PARAMS];
|
||||
unsigned int numparams = m_curparam;
|
||||
unsigned int i;
|
||||
|
||||
if (numparams)
|
||||
{
|
||||
//Save the info locally, then reset it for re-entrant calls.
|
||||
memcpy(temp_info, m_info, numparams * sizeof(ParamInfo));
|
||||
}
|
||||
m_curparam = 0;
|
||||
|
||||
/* Initialize 0th parameter */
|
||||
_temp_params[0] = numparams;
|
||||
|
||||
/* Browse the parameters and build arrays */
|
||||
bool ok = true;
|
||||
for (i=0; i<numparams; i++) {
|
||||
/* Is this marked as an array? */
|
||||
if (temp_info[i].marked) {
|
||||
if (!temp_info[i].str.is_sz) {
|
||||
/* Allocate a normal/generic array */
|
||||
int err = context_->HeapAlloc(
|
||||
temp_info[i].size,
|
||||
&(temp_info[i].local_addr),
|
||||
&(temp_info[i].phys_addr));
|
||||
if (err != SP_ERROR_NONE) {
|
||||
context_->ReportErrorNumber(err);
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
if (temp_info[i].orig_addr)
|
||||
{
|
||||
memcpy(temp_info[i].phys_addr, temp_info[i].orig_addr, sizeof(cell_t) * temp_info[i].size);
|
||||
}
|
||||
} else {
|
||||
/* Calculate cells required for the string */
|
||||
size_t cells = (temp_info[i].size + sizeof(cell_t) - 1) / sizeof(cell_t);
|
||||
|
||||
/* Allocate the buffer */
|
||||
int err = context_->HeapAlloc(
|
||||
cells,
|
||||
&(temp_info[i].local_addr),
|
||||
&(temp_info[i].phys_addr));
|
||||
if (err != SP_ERROR_NONE) {
|
||||
context_->ReportErrorNumber(err);
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Copy original string if necessary */
|
||||
if ((temp_info[i].str.sz_flags & SM_PARAM_STRING_COPY) && (temp_info[i].orig_addr != NULL))
|
||||
{
|
||||
/* Cut off UTF-8 properly */
|
||||
if (temp_info[i].str.sz_flags & SM_PARAM_STRING_UTF8) {
|
||||
context_->StringToLocalUTF8(
|
||||
temp_info[i].local_addr,
|
||||
temp_info[i].size,
|
||||
(const char *)temp_info[i].orig_addr,
|
||||
NULL);
|
||||
}
|
||||
/* Copy a binary blob */
|
||||
else if (temp_info[i].str.sz_flags & SM_PARAM_STRING_BINARY)
|
||||
{
|
||||
memmove(temp_info[i].phys_addr, temp_info[i].orig_addr, temp_info[i].size);
|
||||
}
|
||||
/* Copy ASCII characters */
|
||||
else
|
||||
{
|
||||
context_->StringToLocal(
|
||||
temp_info[i].local_addr,
|
||||
temp_info[i].size,
|
||||
(const char *)temp_info[i].orig_addr);
|
||||
}
|
||||
}
|
||||
} /* End array/string calculation */
|
||||
/* Update the pushed parameter with the byref local address */
|
||||
temp_params[i] = temp_info[i].local_addr;
|
||||
} else {
|
||||
/* Just copy the value normally */
|
||||
temp_params[i] = m_params[i];
|
||||
}
|
||||
}
|
||||
|
||||
/* Make the call if we can */
|
||||
if (ok)
|
||||
{
|
||||
*result = native_->func()(context_, _temp_params);
|
||||
}
|
||||
|
||||
/* i should be equal to the last valid parameter + 1 */
|
||||
bool docopies = ok;
|
||||
while (i--) {
|
||||
if (!temp_info[i].marked)
|
||||
continue;
|
||||
|
||||
if (docopies && (temp_info[i].flags & SM_PARAM_COPYBACK)) {
|
||||
if (temp_info[i].orig_addr) {
|
||||
if (temp_info[i].str.is_sz) {
|
||||
memcpy(temp_info[i].orig_addr, temp_info[i].phys_addr, temp_info[i].size);
|
||||
|
||||
} else {
|
||||
if (temp_info[i].size == 1) {
|
||||
*temp_info[i].orig_addr = *(temp_info[i].phys_addr);
|
||||
} else {
|
||||
memcpy(temp_info[i].orig_addr,
|
||||
temp_info[i].phys_addr,
|
||||
temp_info[i].size * sizeof(cell_t));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (int err = context_->HeapPop(temp_info[i].local_addr))
|
||||
context_->ReportErrorNumber(err);
|
||||
}
|
||||
|
||||
return context_->GetLastNativeError() == SP_ERROR_NONE;
|
||||
}
|
||||
|
||||
int
|
||||
NativeInvoker::SetError(int err)
|
||||
{
|
||||
m_errorstate = err;
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
int NativeInvoker::CallFunction(const cell_t *params, unsigned int num_params, cell_t *result) { return 0; }
|
||||
funcid_t NativeInvoker::GetFunctionID() { return 0; }
|
||||
int NativeInvoker::Execute2(IPluginContext *ctx, cell_t *result) { return 0; }
|
||||
int NativeInvoker::CallFunction2(IPluginContext *ctx, const cell_t *params, unsigned int num_params, cell_t *result) { return 0; }
|
||||
IPluginRuntime *NativeInvoker::GetParentRuntime() { return NULL; }
|
||||
@@ -0,0 +1,79 @@
|
||||
// vim: set sts=2 ts=8 sw=2 tw=99 et:
|
||||
//
|
||||
// Copyright (C) 2006-2015 AlliedModders LLC
|
||||
//
|
||||
// This file is part of SourcePawn. SourcePawn 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.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License along with
|
||||
// SourcePawn. If not, see http://www.gnu.org/licenses/.
|
||||
//
|
||||
#ifndef _INCLUDE_SOURCEMOD_NATIVE_INVOKER_H_
|
||||
#define _INCLUDE_SOURCEMOD_NATIVE_INVOKER_H_
|
||||
|
||||
#include <sp_vm_api.h>
|
||||
#include <amtl/am-autoptr.h>
|
||||
#include <amtl/am-refcounting.h>
|
||||
#include "Native.h"
|
||||
|
||||
struct ParamInfo
|
||||
{
|
||||
int flags; /* Copy-back flags */
|
||||
bool marked; /* Whether this is marked as being used */
|
||||
cell_t local_addr; /* Local address to free */
|
||||
cell_t *phys_addr; /* Physical address of our copy */
|
||||
cell_t *orig_addr; /* Original address to copy back to */
|
||||
ucell_t size; /* Size of array in bytes */
|
||||
struct {
|
||||
bool is_sz; /* is a string */
|
||||
int sz_flags; /* has sz flags */
|
||||
} str;
|
||||
};
|
||||
|
||||
class NativeInvoker : public IPluginFunction
|
||||
{
|
||||
public:
|
||||
NativeInvoker(IPluginContext *pContext, const ke::RefPtr<Native> &native);
|
||||
virtual ~NativeInvoker();
|
||||
|
||||
public:
|
||||
int PushCell(cell_t cell);
|
||||
int PushCellByRef(cell_t *cell, int flags);
|
||||
int PushFloat(float number);
|
||||
int PushFloatByRef(float *number, int flags);
|
||||
int PushArray(cell_t *inarray, unsigned int cells, int copyback);
|
||||
int PushString(const char *string);
|
||||
int PushStringEx(char *buffer, size_t length, int sz_flags, int cp_flags);
|
||||
int Execute(cell_t *result, cell_t buffer=0, cell_t size=0);
|
||||
void Cancel();
|
||||
int CallFunction(const cell_t *params, unsigned int num_params, cell_t *result);
|
||||
IPluginContext *GetParentContext();
|
||||
bool Invoke(cell_t *result);
|
||||
bool IsRunnable();
|
||||
funcid_t GetFunctionID();
|
||||
int Execute2(IPluginContext *ctx, cell_t *result);
|
||||
int CallFunction2(IPluginContext *ctx,
|
||||
const cell_t *params,
|
||||
unsigned int num_params,
|
||||
cell_t *result);
|
||||
IPluginRuntime *GetParentRuntime();
|
||||
const char *DebugName() {
|
||||
return native_->name();
|
||||
}
|
||||
|
||||
private:
|
||||
int _PushString(const char *string, int sz_flags, int cp_flags, size_t len);
|
||||
int SetError(int err);
|
||||
|
||||
private:
|
||||
IPluginContext *context_;
|
||||
cell_t m_params[SP_MAX_EXEC_PARAMS];
|
||||
ParamInfo m_info[SP_MAX_EXEC_PARAMS];
|
||||
unsigned int m_curparam;
|
||||
int m_errorstate;
|
||||
ke::RefPtr<Native> native_;
|
||||
};
|
||||
|
||||
#endif //_INCLUDE_SOURCEMOD_NATIVE_INVOKER_H_
|
||||
@@ -8,7 +8,7 @@
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
*
|
||||
* 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
|
||||
@@ -36,6 +36,9 @@
|
||||
#include <IHandleSys.h>
|
||||
#include <IForwardSys.h>
|
||||
#include <ISourceMod.h>
|
||||
#include <amtl/am-autoptr.h>
|
||||
#include "ShareSys.h"
|
||||
#include "NativeInvoker.h"
|
||||
|
||||
HandleType_t g_GlobalFwdType = 0;
|
||||
HandleType_t g_PrivateFwdType = 0;
|
||||
@@ -44,8 +47,9 @@ static bool s_CallStarted = false;
|
||||
static ICallable *s_pCallable = NULL;
|
||||
static IPluginFunction *s_pFunction = NULL;
|
||||
static IForward *s_pForward = NULL;
|
||||
static NativeInvoker *s_pInvoker = NULL;
|
||||
|
||||
class ForwardNativeHelpers :
|
||||
class ForwardNativeHelpers :
|
||||
public SMGlobalClass,
|
||||
public IHandleTypeDispatch
|
||||
{
|
||||
@@ -103,6 +107,9 @@ inline void ResetCall()
|
||||
s_pFunction = NULL;
|
||||
s_pForward = NULL;
|
||||
s_pCallable = NULL;
|
||||
if(s_pInvoker)
|
||||
delete s_pInvoker;
|
||||
s_pInvoker = NULL;
|
||||
}
|
||||
|
||||
static cell_t sm_GetFunctionByName(IPluginContext *pContext, const cell_t *params)
|
||||
@@ -148,7 +155,7 @@ static cell_t sm_CreateGlobalForward(IPluginContext *pContext, const cell_t *par
|
||||
{
|
||||
return pContext->ThrowNativeErrorEx(SP_ERROR_PARAMS_MAX, NULL);
|
||||
}
|
||||
|
||||
|
||||
pContext->LocalToString(params[1], &name);
|
||||
|
||||
cell_t *addr;
|
||||
@@ -379,6 +386,27 @@ static cell_t sm_CallStartForward(IPluginContext *pContext, const cell_t *params
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t sm_CallStartNative(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
ResetCall();
|
||||
|
||||
char *name;
|
||||
pContext->LocalToString(params[1], &name);
|
||||
|
||||
ke::RefPtr<Native> pNative = g_ShareSys.FindNative(name);
|
||||
|
||||
if (!pNative)
|
||||
return 0;//pContext->ThrowNativeError("Invalid native \"%s\"", name);
|
||||
|
||||
s_pInvoker = new NativeInvoker(pContext, pNative);
|
||||
|
||||
s_pCallable = static_cast<ICallable *>(s_pInvoker);
|
||||
|
||||
s_CallStarted = true;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t sm_CallPushCell(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
int err;
|
||||
@@ -669,6 +697,39 @@ static cell_t sm_CallFinish(IPluginContext *pContext, const cell_t *params)
|
||||
IForward *pForward = s_pForward;
|
||||
ResetCall();
|
||||
err = pForward->Execute(result, NULL);
|
||||
} else if (s_pInvoker) {
|
||||
err = s_pInvoker->Execute(result);
|
||||
ResetCall();
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
static cell_t sm_CallFinishEx(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
int err = SP_ERROR_NOT_RUNNABLE;
|
||||
cell_t *result;
|
||||
|
||||
if (!s_CallStarted)
|
||||
{
|
||||
return pContext->ThrowNativeError("Cannot finish call when there is no call in progress");
|
||||
}
|
||||
|
||||
pContext->LocalToPhysAddr(params[1], &result);
|
||||
|
||||
// Note: Execute() swallows exceptions, so this is okay.
|
||||
if (s_pFunction)
|
||||
{
|
||||
IPluginFunction *pFunction = s_pFunction;
|
||||
ResetCall();
|
||||
err = pFunction->Execute(result, params[2], params[3]);
|
||||
} else if (s_pForward) {
|
||||
IForward *pForward = s_pForward;
|
||||
ResetCall();
|
||||
err = pForward->Execute(result, NULL);
|
||||
} else if (s_pInvoker) {
|
||||
err = s_pInvoker->Execute(result, params[2], params[3]);
|
||||
ResetCall();
|
||||
}
|
||||
|
||||
return err;
|
||||
@@ -755,6 +816,7 @@ REGISTER_NATIVES(functionNatives)
|
||||
{"RemoveAllFromForward", sm_RemoveAllFromForward},
|
||||
{"Call_StartFunction", sm_CallStartFunction},
|
||||
{"Call_StartForward", sm_CallStartForward},
|
||||
{"Call_StartNative", sm_CallStartNative},
|
||||
{"Call_PushCell", sm_CallPushCell},
|
||||
{"Call_PushCellRef", sm_CallPushCellRef},
|
||||
{"Call_PushFloat", sm_CallPushFloat},
|
||||
@@ -766,6 +828,7 @@ REGISTER_NATIVES(functionNatives)
|
||||
{"Call_PushNullVector", sm_CallPushNullVector},
|
||||
{"Call_PushNullString", sm_CallPushNullString},
|
||||
{"Call_Finish", sm_CallFinish},
|
||||
{"Call_FinishEx", sm_CallFinishEx},
|
||||
{"Call_Cancel", sm_CallCancel},
|
||||
{"RequestFrame", sm_AddFrameAction},
|
||||
|
||||
|
||||
+29
-26
@@ -270,18 +270,7 @@ static cell_t sm_GetClientCount(IPluginContext *pCtx, const cell_t *params)
|
||||
return playerhelpers->GetNumPlayers();
|
||||
}
|
||||
|
||||
int maxplayers = playerhelpers->GetMaxClients();
|
||||
int count = 0;
|
||||
for (int i = 1; i <= maxplayers; ++i)
|
||||
{
|
||||
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(i);
|
||||
if ((pPlayer->IsConnected()) && !(pPlayer->IsInGame()))
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return (playerhelpers->GetNumPlayers() + count);
|
||||
return playerhelpers->GetNumClients();
|
||||
}
|
||||
|
||||
static cell_t sm_GetMaxClients(IPluginContext *pCtx, const cell_t *params)
|
||||
@@ -1471,24 +1460,23 @@ static cell_t IsClientInKickQueue(IPluginContext *pContext, const cell_t *params
|
||||
return pPlayer->IsInKickQueue() ? 1 : 0;
|
||||
}
|
||||
|
||||
cmd_target_info_t g_ProcessTargetString_info;
|
||||
static cell_t ProcessTargetString(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
cmd_target_info_t info;
|
||||
|
||||
pContext->LocalToString(params[1], (char **) &info.pattern);
|
||||
info.admin = params[2];
|
||||
pContext->LocalToPhysAddr(params[3], &info.targets);
|
||||
info.max_targets = params[4];
|
||||
info.flags = params[5];
|
||||
pContext->LocalToString(params[6], &info.target_name);
|
||||
info.target_name_maxlength = params[7];
|
||||
pContext->LocalToString(params[1], (char **) &g_ProcessTargetString_info.pattern);
|
||||
g_ProcessTargetString_info.admin = params[2];
|
||||
pContext->LocalToPhysAddr(params[3], &g_ProcessTargetString_info.targets);
|
||||
g_ProcessTargetString_info.max_targets = params[4];
|
||||
g_ProcessTargetString_info.flags = params[5];
|
||||
pContext->LocalToString(params[6], &g_ProcessTargetString_info.target_name);
|
||||
g_ProcessTargetString_info.target_name_maxlength = params[7];
|
||||
|
||||
cell_t *tn_is_ml;
|
||||
pContext->LocalToPhysAddr(params[8], &tn_is_ml);
|
||||
|
||||
playerhelpers->ProcessCommandTarget(&info);
|
||||
playerhelpers->ProcessCommandTarget(&g_ProcessTargetString_info);
|
||||
|
||||
if (info.target_name_style == COMMAND_TARGETNAME_ML)
|
||||
if (g_ProcessTargetString_info.target_name_style == COMMAND_TARGETNAME_ML)
|
||||
{
|
||||
*tn_is_ml = 1;
|
||||
}
|
||||
@@ -1497,16 +1485,30 @@ static cell_t ProcessTargetString(IPluginContext *pContext, const cell_t *params
|
||||
*tn_is_ml = 0;
|
||||
}
|
||||
|
||||
if (info.num_targets == 0)
|
||||
if (g_ProcessTargetString_info.num_targets == 0)
|
||||
{
|
||||
return info.reason;
|
||||
return g_ProcessTargetString_info.reason;
|
||||
}
|
||||
else
|
||||
{
|
||||
return info.num_targets;
|
||||
return g_ProcessTargetString_info.num_targets;
|
||||
}
|
||||
}
|
||||
|
||||
static cell_t GetLastProcessTargetString(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
cell_t *admin, *flags;
|
||||
|
||||
pContext->StringToLocalUTF8(params[1], params[2], g_ProcessTargetString_info.pattern, NULL);
|
||||
pContext->LocalToPhysAddr(params[3], &admin);
|
||||
pContext->LocalToPhysAddr(params[4], &flags);
|
||||
|
||||
*admin = g_ProcessTargetString_info.admin;
|
||||
*flags = g_ProcessTargetString_info.flags;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static cell_t FormatActivitySource(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
int value;
|
||||
@@ -1658,6 +1660,7 @@ REGISTER_NATIVES(playernatives)
|
||||
{ "NotifyPostAdminCheck", NotifyPostAdminCheck },
|
||||
{ "IsClientInKickQueue", IsClientInKickQueue },
|
||||
{ "ProcessTargetString", ProcessTargetString },
|
||||
{ "GetLastProcessTargetString", GetLastProcessTargetString },
|
||||
{ "FormatActivitySource", FormatActivitySource },
|
||||
{ "GetClientSerial", sm_GetClientSerial },
|
||||
{ "GetClientFromSerial", sm_GetClientFromSerial },
|
||||
|
||||
@@ -827,6 +827,16 @@ static cell_t sm_RegAdminCmd(IPluginContext *pContext, const cell_t *params)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t sm_IsCommandCallback(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
const ICommandArgs *pCmd = g_HL2.PeekCommandStack();
|
||||
|
||||
if (!pCmd)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static cell_t sm_GetCmdArgs(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
const ICommandArgs *pCmd = g_HL2.PeekCommandStack();
|
||||
@@ -1549,6 +1559,7 @@ REGISTER_NATIVES(consoleNatives)
|
||||
{"GetConVarDefault", GetConVarDefault},
|
||||
{"RegServerCmd", sm_RegServerCmd},
|
||||
{"RegConsoleCmd", sm_RegConsoleCmd},
|
||||
{"IsCommandCallback", sm_IsCommandCallback},
|
||||
{"GetCmdArgString", sm_GetCmdArgString},
|
||||
{"GetCmdArgs", sm_GetCmdArgs},
|
||||
{"GetCmdArg", sm_GetCmdArg},
|
||||
|
||||
@@ -356,6 +356,27 @@ static cell_t GetAvgPackets(IPluginContext *pContext, const cell_t *params)
|
||||
return sp_ftoc(value);
|
||||
}
|
||||
|
||||
static cell_t sm_GetClientIClient(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
int client = params[1];
|
||||
|
||||
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
|
||||
if (!pPlayer)
|
||||
{
|
||||
return pContext->ThrowNativeError("Client index %d is invalid", client);
|
||||
}
|
||||
else if (!pPlayer->IsConnected())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client %d is not connected", client);
|
||||
}
|
||||
else if (pPlayer->IsFakeClient())
|
||||
{
|
||||
return pContext->ThrowNativeError("Client %d is a bot", client);
|
||||
}
|
||||
|
||||
return (cell_t)pPlayer->GetIClient();
|
||||
}
|
||||
|
||||
static cell_t RunAdminCacheChecks(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
int client = params[1];
|
||||
@@ -392,6 +413,7 @@ REGISTER_NATIVES(playernatives)
|
||||
{"GetClientAvgChoke", GetAvgChoke},
|
||||
{"GetClientAvgData", GetAvgData},
|
||||
{"GetClientAvgPackets", GetAvgPackets},
|
||||
{"GetClientIClient", sm_GetClientIClient },
|
||||
{"RunAdminCacheChecks", RunAdminCacheChecks},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
@@ -112,6 +112,7 @@ IServerTools *servertools = NULL;
|
||||
|
||||
// global hooks and forwards
|
||||
IForward *g_pOnEntityCreated = NULL;
|
||||
IForward *g_pOnEntitySpawned = NULL;
|
||||
IForward *g_pOnEntityDestroyed = NULL;
|
||||
|
||||
#ifdef GAMEDESC_CAN_CHANGE
|
||||
@@ -255,6 +256,7 @@ bool SDKHooks::SDK_OnLoad(char *error, size_t maxlength, bool late)
|
||||
plsys->AddPluginsListener(&g_Interface);
|
||||
|
||||
g_pOnEntityCreated = forwards->CreateForward("OnEntityCreated", ET_Ignore, 2, NULL, Param_Cell, Param_String);
|
||||
g_pOnEntitySpawned = forwards->CreateForward("OnEntitySpawned", ET_Ignore, 2, NULL, Param_Cell, Param_String);
|
||||
g_pOnEntityDestroyed = forwards->CreateForward("OnEntityDestroyed", ET_Ignore, 1, NULL, Param_Cell);
|
||||
#ifdef GAMEDESC_CAN_CHANGE
|
||||
g_pOnGetGameNameDescription = forwards->CreateForward("OnGetGameDescription", ET_Hook, 2, NULL, Param_String);
|
||||
@@ -361,6 +363,7 @@ void SDKHooks::SDK_OnUnload()
|
||||
#endif
|
||||
|
||||
forwards->ReleaseForward(g_pOnEntityCreated);
|
||||
forwards->ReleaseForward(g_pOnEntitySpawned);
|
||||
forwards->ReleaseForward(g_pOnEntityDestroyed);
|
||||
#ifdef GAMEDESC_CAN_CHANGE
|
||||
forwards->ReleaseForward(g_pOnGetGameNameDescription);
|
||||
@@ -441,6 +444,7 @@ void SDKHooks::OnClientPutInServer(int client)
|
||||
CBaseEntity *pPlayer = gamehelpers->ReferenceToEntity(client);
|
||||
|
||||
HandleEntityCreated(pPlayer, client, gamehelpers->EntityToReference(pPlayer));
|
||||
HandleEntitySpawned(pPlayer, client, gamehelpers->EntityToReference(pPlayer));
|
||||
}
|
||||
|
||||
void SDKHooks::OnClientDisconnecting(int client)
|
||||
@@ -935,6 +939,27 @@ void SDKHooks::OnEntityCreated(CBaseEntity *pEntity)
|
||||
}
|
||||
}
|
||||
|
||||
void SDKHooks::OnEntitySpawned(CBaseEntity *pEntity)
|
||||
{
|
||||
// Call OnEntitySpawned forward
|
||||
int ref = gamehelpers->EntityToReference(pEntity);
|
||||
int index = gamehelpers->ReferenceToIndex(ref);
|
||||
|
||||
// This can be -1 for player ents before any players have connected
|
||||
if ((unsigned)index == INVALID_EHANDLE_INDEX || (index > 0 && index <= playerhelpers->GetMaxClients()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsEntityIndexInRange(index))
|
||||
{
|
||||
g_pSM->LogError(myself, "SDKHooks::OnEntitySpawned - Got entity index out of range (%d)", index);
|
||||
return;
|
||||
}
|
||||
|
||||
HandleEntitySpawned(pEntity, index, ref);
|
||||
}
|
||||
|
||||
#ifdef GAMEDESC_CAN_CHANGE
|
||||
const char *SDKHooks::Hook_GetGameDescription()
|
||||
{
|
||||
@@ -1861,6 +1886,32 @@ void SDKHooks::HandleEntityCreated(CBaseEntity *pEntity, int index, cell_t ref)
|
||||
m_EntityCache[index] = ref;
|
||||
}
|
||||
|
||||
void SDKHooks::HandleEntitySpawned(CBaseEntity *pEntity, int index, cell_t ref)
|
||||
{
|
||||
if (g_pOnEntitySpawned->GetFunctionCount() || m_EntListeners.size())
|
||||
{
|
||||
cell_t bcompatRef = gamehelpers->EntityToBCompatRef(pEntity);
|
||||
const char *pName = gamehelpers->GetEntityClassname(pEntity);
|
||||
if (!pName)
|
||||
pName = "";
|
||||
|
||||
// Send OnEntitySpawned to SM listeners
|
||||
for (SourceHook::List<ISMEntityListener *>::iterator iter = m_EntListeners.begin(); iter != m_EntListeners.end(); iter++)
|
||||
{
|
||||
ISMEntityListener *pListener = (*iter);
|
||||
pListener->OnEntitySpawned(pEntity, pName);
|
||||
}
|
||||
|
||||
// Call OnEntitySpawned forward
|
||||
if (g_pOnEntitySpawned->GetFunctionCount())
|
||||
{
|
||||
g_pOnEntitySpawned->PushCell(bcompatRef);
|
||||
g_pOnEntitySpawned->PushString(pName);
|
||||
g_pOnEntitySpawned->Execute(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SDKHooks::HandleEntityDeleted(CBaseEntity *pEntity)
|
||||
{
|
||||
cell_t bcompatRef = gamehelpers->EntityToBCompatRef(pEntity);
|
||||
|
||||
@@ -249,6 +249,7 @@ public: // IFeatureProvider
|
||||
|
||||
public: // IEntityListener
|
||||
virtual void OnEntityCreated(CBaseEntity *pEntity);
|
||||
virtual void OnEntitySpawned(CBaseEntity *pEntity);
|
||||
virtual void OnEntityDeleted(CBaseEntity *pEntity);
|
||||
|
||||
public: // IClientListener
|
||||
@@ -342,6 +343,7 @@ public:
|
||||
|
||||
private:
|
||||
void HandleEntityCreated(CBaseEntity *pEntity, int index, cell_t ref);
|
||||
void HandleEntitySpawned(CBaseEntity *pEntity, int index, cell_t ref);
|
||||
void HandleEntityDeleted(CBaseEntity *pEntity);
|
||||
void Unhook(CBaseEntity *pEntity);
|
||||
void Unhook(IPluginContext *pContext);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
*
|
||||
* 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
|
||||
@@ -70,7 +70,7 @@ cell_t Native_Hook(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
pContext->ThrowNativeError("Hook type not valid for this type of entity (%i/%s)", entity, pClassname);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -105,7 +105,7 @@ cell_t Native_TakeDamage(IPluginContext *pContext, const cell_t *params)
|
||||
CBaseEntity *pVictim = gamehelpers->ReferenceToEntity(params[1]);
|
||||
if (!pVictim)
|
||||
return pContext->ThrowNativeError("Invalid entity index %d for victim", params[1]);
|
||||
|
||||
|
||||
CBaseEntity *pInflictor = gamehelpers->ReferenceToEntity(params[2]);
|
||||
if (!pInflictor)
|
||||
return pContext->ThrowNativeError("Invalid entity index %d for inflictor", params[2]);
|
||||
@@ -173,9 +173,15 @@ cell_t Native_TakeDamage(IPluginContext *pContext, const cell_t *params)
|
||||
vecDamagePosition = vec3_origin;
|
||||
}
|
||||
|
||||
CTakeDamageInfoHack info(pInflictor, pAttacker, flDamage, iDamageType, pWeapon, vecDamageForce, vecDamagePosition);
|
||||
int iDamageCustom = 0;
|
||||
if (params[0] >= 9)
|
||||
{
|
||||
iDamageCustom = params[9];
|
||||
}
|
||||
|
||||
if (params[0] < 9 || params[9] != 0)
|
||||
CTakeDamageInfoHack info(pInflictor, pAttacker, flDamage, iDamageType, pWeapon, vecDamageForce, vecDamagePosition, iDamageCustom);
|
||||
|
||||
if (params[0] < 10 || params[9] != 0)
|
||||
{
|
||||
SH_MCALL(pVictim, OnTakeDamage)((CTakeDamageInfoHack&)info);
|
||||
}
|
||||
@@ -188,7 +194,7 @@ cell_t Native_TakeDamage(IPluginContext *pContext, const cell_t *params)
|
||||
if (!g_pGameConf->GetOffset("OnTakeDamage", &offset))
|
||||
{
|
||||
return pContext->ThrowNativeError("Could not find OnTakeDamage offset");
|
||||
}
|
||||
}
|
||||
|
||||
PassInfo pass[2];
|
||||
pass[0].type = PassType_Object;
|
||||
@@ -225,7 +231,7 @@ cell_t Native_DropWeapon(IPluginContext *pContext, const cell_t *params)
|
||||
IGamePlayer *pGamePlayer = playerhelpers->GetGamePlayer(gamehelpers->ReferenceToIndex(params[1]));
|
||||
if (!pGamePlayer || !pGamePlayer->IsInGame())
|
||||
return pContext->ThrowNativeError("Client index %d not in game", params[1]);
|
||||
|
||||
|
||||
CBaseEntity *pWeapon = gamehelpers->ReferenceToEntity(params[2]);
|
||||
if (!pWeapon)
|
||||
return pContext->ThrowNativeError("Invalid entity index %d for weapon", params[2]);
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
CTakeDamageInfo::CTakeDamageInfo(){}
|
||||
|
||||
CTakeDamageInfoHack::CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *pAttacker, float flDamage, int bitsDamageType, CBaseEntity *pWeapon, Vector vecDamageForce, Vector vecDamagePosition )
|
||||
CTakeDamageInfoHack::CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *pAttacker, float flDamage, int bitsDamageType, CBaseEntity *pWeapon, Vector vecDamageForce, Vector vecDamagePosition, int iDamageCustom )
|
||||
{
|
||||
m_hInflictor = pInflictor;
|
||||
if ( pAttacker )
|
||||
@@ -64,9 +64,9 @@ CTakeDamageInfoHack::CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *
|
||||
m_iAmmoType = -1;
|
||||
|
||||
#if SOURCE_ENGINE < SE_ORANGEBOX
|
||||
m_iCustomKillType = 0;
|
||||
m_iCustomKillType = iDamageCustom;
|
||||
#else
|
||||
m_iDamageCustom = 0;
|
||||
m_iDamageCustom = iDamageCustom;
|
||||
#endif
|
||||
|
||||
#if SOURCE_ENGINE == SE_CSS || SOURCE_ENGINE == SE_HL2DM || SOURCE_ENGINE == SE_DODS || SOURCE_ENGINE == SE_SDK2013 \
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
*
|
||||
* 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
|
||||
@@ -58,7 +58,7 @@
|
||||
class CTakeDamageInfoHack : public CTakeDamageInfo
|
||||
{
|
||||
public:
|
||||
CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *pAttacker, float flDamage, int bitsDamageType, CBaseEntity *pWeapon, Vector vecDamageForce, Vector vecDamagePosition );
|
||||
CTakeDamageInfoHack( CBaseEntity *pInflictor, CBaseEntity *pAttacker, float flDamage, int bitsDamageType, CBaseEntity *pWeapon, Vector vecDamageForce, Vector vecDamagePosition, int iDamageCustom=0);
|
||||
int GetAttacker() const;
|
||||
void SetAttacker(CBaseEntity *pAttacker);
|
||||
inline int GetInflictor() const { return m_hInflictor.IsValid() ? m_hInflictor.GetEntryIndex() : -1; }
|
||||
|
||||
@@ -512,7 +512,7 @@ bool SDKTools::ProcessCommandTarget(cmd_target_info_t *info)
|
||||
IPlayerInfo *plinfo = player->GetPlayerInfo();
|
||||
if (plinfo == NULL)
|
||||
continue;
|
||||
if (plinfo->GetTeamIndex() == 1 &&
|
||||
if ((plinfo->GetTeamIndex() == 0 || plinfo->GetTeamIndex() == 1) &&
|
||||
playerhelpers->FilterCommandTarget(pAdmin, player, info->flags) ==
|
||||
COMMAND_TARGET_VALID)
|
||||
{
|
||||
|
||||
+3
-2
@@ -1,4 +1,4 @@
|
||||
# vim: set ts=8 sts=2 sw=2 tw=99 et ft=python:
|
||||
# vim: set ts=8 sts=2 sw=2 tw=99 et ft=python:
|
||||
import os
|
||||
|
||||
files = [
|
||||
@@ -25,7 +25,8 @@ files = [
|
||||
'mapchooser.sp',
|
||||
'randomcycle.sp',
|
||||
'sql-admin-manager.sp',
|
||||
'admin-flatfile.sp'
|
||||
'admin-flatfile.sp',
|
||||
'DynamicTargeting.sp'
|
||||
]
|
||||
|
||||
spcomp_argv = [
|
||||
|
||||
@@ -0,0 +1,266 @@
|
||||
#pragma semicolon 1
|
||||
#define PLUGIN_VERSION "1.0"
|
||||
|
||||
#include <sourcemod>
|
||||
#include <DynamicTargeting>
|
||||
|
||||
#pragma newdecls required
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "Dynamic Targeting",
|
||||
author = "BotoX",
|
||||
description = "",
|
||||
version = PLUGIN_VERSION,
|
||||
url = ""
|
||||
}
|
||||
|
||||
char g_PlayerNames[MAXPLAYERS + 1][MAX_NAME_LENGTH];
|
||||
Handle g_PlayerData[MAXPLAYERS + 1];
|
||||
|
||||
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
||||
{
|
||||
CreateNative("AmbiguousMenu", Native_AmbiguousMenu);
|
||||
RegPluginLibrary("DynamicTargeting");
|
||||
|
||||
return APLRes_Success;
|
||||
}
|
||||
|
||||
public void OnClientDisconnect(int client)
|
||||
{
|
||||
if(g_PlayerData[client] != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(g_PlayerData[client]);
|
||||
g_PlayerData[client] = INVALID_HANDLE;
|
||||
}
|
||||
}
|
||||
|
||||
int CreateAmbiguousMenu(int client, const char[] sCommand, const char[] sArgString, const char[] sPattern, int FilterFlags)
|
||||
{
|
||||
Menu menu = new Menu(MenuHandler_AmbiguousMenu, MenuAction_Select|MenuAction_Cancel|MenuAction_End|MenuAction_DrawItem|MenuAction_DisplayItem);
|
||||
menu.ExitButton = true;
|
||||
|
||||
char sTitle[32 + MAX_TARGET_LENGTH];
|
||||
FormatEx(sTitle, sizeof(sTitle), "Target \"%s\" is ambiguous.", sPattern);
|
||||
menu.SetTitle(sTitle);
|
||||
|
||||
int Players = 0;
|
||||
int[] aClients = new int[MaxClients + 1];
|
||||
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if(!IsClientConnected(i) || i == client)
|
||||
continue;
|
||||
|
||||
if(FilterFlags & COMMAND_FILTER_NO_BOTS && IsFakeClient(i))
|
||||
continue;
|
||||
|
||||
if(!(FilterFlags & COMMAND_FILTER_CONNECTED) && !IsClientInGame(i))
|
||||
continue;
|
||||
|
||||
if(FilterFlags & COMMAND_FILTER_ALIVE && !IsPlayerAlive(i))
|
||||
continue;
|
||||
|
||||
if(FilterFlags & COMMAND_FILTER_DEAD && IsPlayerAlive(i))
|
||||
continue;
|
||||
|
||||
// insert player names into g_PlayerNames array
|
||||
GetClientName(i, g_PlayerNames[i], sizeof(g_PlayerNames[]));
|
||||
|
||||
if(StrContains(g_PlayerNames[i], sPattern, false) != -1)
|
||||
aClients[Players++] = i;
|
||||
}
|
||||
|
||||
// sort aClients array by player name
|
||||
SortCustom1D(aClients, Players, SortByPlayerName);
|
||||
|
||||
// insert players sorted
|
||||
char sUserId[12];
|
||||
char sDisp[MAX_NAME_LENGTH + 16];
|
||||
for(int i = 0; i < Players; i++)
|
||||
{
|
||||
IntToString(GetClientUserId(aClients[i]), sUserId, sizeof(sUserId));
|
||||
|
||||
FormatEx(sDisp, sizeof(sDisp), "%s (%s)", g_PlayerNames[aClients[i]], sUserId);
|
||||
menu.AddItem(sUserId, sDisp);
|
||||
}
|
||||
|
||||
DataPack pack = new DataPack();
|
||||
pack.WriteString(sCommand);
|
||||
pack.WriteString(sArgString);
|
||||
pack.WriteString(sPattern);
|
||||
pack.WriteCell(FilterFlags);
|
||||
|
||||
if(g_PlayerData[client] != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(g_PlayerData[client]);
|
||||
g_PlayerData[client] = INVALID_HANDLE;
|
||||
}
|
||||
CancelClientMenu(client);
|
||||
|
||||
g_PlayerData[client] = pack;
|
||||
menu.Display(client, MENU_TIME_FOREVER);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int MenuHandler_AmbiguousMenu(Menu menu, MenuAction action, int param1, int param2)
|
||||
{
|
||||
switch(action)
|
||||
{
|
||||
case MenuAction_End:
|
||||
{
|
||||
CloseHandle(menu);
|
||||
}
|
||||
case MenuAction_Cancel:
|
||||
{
|
||||
if(g_PlayerData[param1] != INVALID_HANDLE)
|
||||
{
|
||||
CloseHandle(g_PlayerData[param1]);
|
||||
g_PlayerData[param1] = INVALID_HANDLE;
|
||||
}
|
||||
}
|
||||
case MenuAction_Select:
|
||||
{
|
||||
int Style;
|
||||
char sItem[32];
|
||||
char sDisp[MAX_NAME_LENGTH + 16];
|
||||
menu.GetItem(param2, sItem, sizeof(sItem), Style, sDisp, sizeof(sDisp));
|
||||
|
||||
int UserId = StringToInt(sItem);
|
||||
int client = GetClientOfUserId(UserId);
|
||||
if(!client)
|
||||
{
|
||||
PrintToChat(param1, "\x04[DynamicTargeting]\x01 Player no longer available.");
|
||||
menu.DisplayAt(param1, GetMenuSelectionPosition(), MENU_TIME_FOREVER);
|
||||
return 0;
|
||||
}
|
||||
|
||||
DataPack pack = view_as<DataPack>(g_PlayerData[param1]);
|
||||
pack.Reset();
|
||||
|
||||
char sCommand[128];
|
||||
pack.ReadString(sCommand, sizeof(sCommand));
|
||||
|
||||
char sArgString[256];
|
||||
pack.ReadString(sArgString, sizeof(sArgString));
|
||||
|
||||
char sPattern[MAX_TARGET_LENGTH];
|
||||
pack.ReadString(sPattern, sizeof(sPattern));
|
||||
|
||||
int Result = ReCallAmbiguous(param1, client, sCommand, sArgString, sPattern);
|
||||
|
||||
return Result;
|
||||
}
|
||||
case MenuAction_DrawItem:
|
||||
{
|
||||
int Style;
|
||||
char sItem[32];
|
||||
menu.GetItem(param2, sItem, sizeof(sItem), Style);
|
||||
|
||||
int UserId = StringToInt(sItem);
|
||||
int client = GetClientOfUserId(UserId);
|
||||
if(!client) // Player disconnected
|
||||
return ITEMDRAW_DISABLED;
|
||||
|
||||
return Style;
|
||||
}
|
||||
case MenuAction_DisplayItem:
|
||||
{
|
||||
int Style;
|
||||
char sItem[32];
|
||||
char sDisp[MAX_NAME_LENGTH + 16];
|
||||
menu.GetItem(param2, sItem, sizeof(sItem), Style, sDisp, sizeof(sDisp));
|
||||
|
||||
if(!sItem[0])
|
||||
return 0;
|
||||
|
||||
char sBuffer[MAX_NAME_LENGTH + 16];
|
||||
int UserId = StringToInt(sItem);
|
||||
int client = GetClientOfUserId(UserId);
|
||||
if(!client) // Player disconnected
|
||||
return 0;
|
||||
|
||||
GetClientName(client, g_PlayerNames[client], sizeof(g_PlayerNames[]));
|
||||
FormatEx(sBuffer, sizeof(sBuffer), "%s (%d)", g_PlayerNames[client], UserId);
|
||||
|
||||
if(!StrEqual(sDisp, sBuffer))
|
||||
return RedrawMenuItem(sBuffer);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ReCallAmbiguous(int client, int newClient, const char[] sCommand, const char[] sArgString, const char[] sPattern)
|
||||
{
|
||||
char sTarget[16];
|
||||
FormatEx(sTarget, sizeof(sTarget), "#%d", GetClientUserId(newClient));
|
||||
|
||||
char sNewArgString[256];
|
||||
strcopy(sNewArgString, sizeof(sNewArgString), sArgString);
|
||||
|
||||
char sPart[256];
|
||||
int CurrentIndex = 0;
|
||||
int NextIndex = 0;
|
||||
|
||||
while(NextIndex != -1 && CurrentIndex < sizeof(sNewArgString))
|
||||
{
|
||||
NextIndex = BreakString(sNewArgString[CurrentIndex], sPart, sizeof(sPart));
|
||||
|
||||
if(StrEqual(sPart, sPattern))
|
||||
{
|
||||
ReplaceStringEx(sNewArgString[CurrentIndex], sizeof(sNewArgString) - CurrentIndex, sPart, sTarget);
|
||||
break;
|
||||
}
|
||||
|
||||
CurrentIndex += NextIndex;
|
||||
}
|
||||
|
||||
FakeClientCommandEx(client, "%s %s", sCommand, sNewArgString);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public int Native_AmbiguousMenu(Handle plugin, int numParams)
|
||||
{
|
||||
int client = GetNativeCell(1);
|
||||
|
||||
if(client > MaxClients || client <= 0)
|
||||
{
|
||||
ThrowNativeError(SP_ERROR_NATIVE, "Client is not valid.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!IsClientInGame(client))
|
||||
{
|
||||
ThrowNativeError(SP_ERROR_NATIVE, "Client is not in-game.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(IsFakeClient(client))
|
||||
{
|
||||
ThrowNativeError(SP_ERROR_NATIVE, "Client is fake-client.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
char sCommand[128];
|
||||
GetNativeString(2, sCommand, sizeof(sCommand));
|
||||
|
||||
char sArgString[256];
|
||||
GetNativeString(3, sArgString, sizeof(sArgString));
|
||||
|
||||
char sPattern[MAX_TARGET_LENGTH];
|
||||
GetNativeString(4, sPattern, sizeof(sPattern));
|
||||
|
||||
int FilterFlags = GetNativeCell(5);
|
||||
|
||||
return CreateAmbiguousMenu(client, sCommand, sArgString, sPattern, FilterFlags);
|
||||
}
|
||||
|
||||
public int SortByPlayerName(int elem1, int elem2, const int[] array, Handle hndl)
|
||||
{
|
||||
return strcmp(g_PlayerNames[elem1], g_PlayerNames[elem2], false);
|
||||
}
|
||||
+14
-41
@@ -34,6 +34,7 @@
|
||||
#pragma semicolon 1
|
||||
|
||||
#include <sourcemod>
|
||||
#include <basecomm>
|
||||
|
||||
#pragma newdecls required
|
||||
|
||||
@@ -81,6 +82,9 @@ public void OnPluginStart()
|
||||
|
||||
public Action OnClientSayCommand(int client, const char[] command, const char[] sArgs)
|
||||
{
|
||||
if (client <= 0 || BaseComm_IsClientGagged(client))
|
||||
return Plugin_Continue;
|
||||
|
||||
int startidx;
|
||||
if (sArgs[startidx] != CHAT_SYMBOL)
|
||||
return Plugin_Continue;
|
||||
@@ -89,51 +93,20 @@ public Action OnClientSayCommand(int client, const char[] command, const char[]
|
||||
|
||||
if (strcmp(command, "say", false) == 0)
|
||||
{
|
||||
if (sArgs[startidx] != CHAT_SYMBOL) // sm_say alias
|
||||
{
|
||||
if (!CheckCommandAccess(client, "sm_say", ADMFLAG_CHAT))
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
SendChatToAll(client, sArgs[startidx]);
|
||||
LogAction(client, -1, "\"%L\" triggered sm_say (text %s)", client, sArgs[startidx]);
|
||||
|
||||
return Plugin_Stop;
|
||||
}
|
||||
|
||||
startidx++;
|
||||
|
||||
if (sArgs[startidx] != CHAT_SYMBOL) // sm_psay alias
|
||||
{
|
||||
if (!CheckCommandAccess(client, "sm_psay", ADMFLAG_CHAT))
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
char arg[64];
|
||||
|
||||
int len = BreakString(sArgs[startidx], arg, sizeof(arg));
|
||||
int target = FindTarget(client, arg, true, false);
|
||||
|
||||
if (target == -1 || len == -1)
|
||||
return Plugin_Stop;
|
||||
|
||||
SendPrivateChat(client, target, sArgs[startidx+len]);
|
||||
|
||||
return Plugin_Stop;
|
||||
}
|
||||
|
||||
startidx++;
|
||||
|
||||
// sm_csay alias
|
||||
if (!CheckCommandAccess(client, "sm_csay", ADMFLAG_CHAT))
|
||||
if (!CheckCommandAccess(client, "sm_psay_chat", ADMFLAG_CHAT))
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
DisplayCenterTextToAll(client, sArgs[startidx]);
|
||||
LogAction(client, -1, "\"%L\" triggered sm_csay (text %s)", client, sArgs[startidx]);
|
||||
char arg[64];
|
||||
|
||||
int len = BreakString(sArgs[startidx], arg, sizeof(arg));
|
||||
int target = FindTarget(client, arg, true, false);
|
||||
|
||||
if (target == -1 || len == -1)
|
||||
return Plugin_Stop;
|
||||
|
||||
SendPrivateChat(client, target, sArgs[startidx+len]);
|
||||
|
||||
return Plugin_Stop;
|
||||
}
|
||||
|
||||
+121
-127
@@ -10,7 +10,7 @@
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
*
|
||||
* 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
|
||||
@@ -45,7 +45,7 @@ void DisplayGagTypesMenu(int client)
|
||||
{
|
||||
Menu menu = new Menu(MenuHandler_GagTypes);
|
||||
int target = playerstate[client].gagTarget;
|
||||
|
||||
|
||||
char title[100];
|
||||
Format(title, sizeof(title), "%T: %N", "Choose Type", client, target);
|
||||
menu.SetTitle(title);
|
||||
@@ -65,7 +65,7 @@ void DisplayGagTypesMenu(int client)
|
||||
AddTranslatedMenuItem(menu, "1", "UnMute Player", client);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!playerstate[target].isGagged)
|
||||
{
|
||||
if(CheckCommandAccess(client, "sm_gag", ADMFLAG_CHAT, false))
|
||||
@@ -80,7 +80,7 @@ void DisplayGagTypesMenu(int client)
|
||||
AddTranslatedMenuItem(menu, "3", "UnGag Player", client);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!playerstate[target].isMuted || !playerstate[target].isGagged)
|
||||
{
|
||||
if(CheckCommandAccess(client, "sm_silence", ADMFLAG_CHAT, false))
|
||||
@@ -95,7 +95,7 @@ void DisplayGagTypesMenu(int client)
|
||||
AddTranslatedMenuItem(menu, "5", "UnSilence Player", client);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
menu.Display(client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
@@ -109,18 +109,18 @@ void AddTranslatedMenuItem(Menu menu, const char[] opt, const char[] phrase, int
|
||||
void DisplayGagPlayerMenu(int client)
|
||||
{
|
||||
Menu menu = new Menu(MenuHandler_GagPlayer);
|
||||
|
||||
|
||||
char title[100];
|
||||
Format(title, sizeof(title), "%T:", "Gag/Mute player", client);
|
||||
menu.SetTitle(title);
|
||||
menu.ExitBackButton = true;
|
||||
|
||||
|
||||
AddTargetsToMenu(menu, client, true, false);
|
||||
|
||||
|
||||
menu.Display(client, MENU_TIME_FOREVER);
|
||||
}
|
||||
|
||||
public void AdminMenu_Gag(TopMenu topmenu,
|
||||
public void AdminMenu_Gag(TopMenu topmenu,
|
||||
TopMenuAction action,
|
||||
TopMenuObject object_id,
|
||||
int param,
|
||||
@@ -154,7 +154,7 @@ public int MenuHandler_GagPlayer(Menu menu, MenuAction action, int param1, int p
|
||||
{
|
||||
char info[32];
|
||||
int userid, target;
|
||||
|
||||
|
||||
menu.GetItem(param2, info, sizeof(info));
|
||||
userid = StringToInt(info);
|
||||
|
||||
@@ -193,12 +193,12 @@ public int MenuHandler_GagTypes(Menu menu, MenuAction action, int param1, int pa
|
||||
{
|
||||
char info[32];
|
||||
CommType type;
|
||||
|
||||
|
||||
menu.GetItem(param2, info, sizeof(info));
|
||||
type = view_as<CommType>(StringToInt(info));
|
||||
|
||||
|
||||
int target = playerstate[param1].gagTarget;
|
||||
|
||||
|
||||
char name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
@@ -207,42 +207,48 @@ public int MenuHandler_GagTypes(Menu menu, MenuAction action, int param1, int pa
|
||||
case CommType_Mute:
|
||||
{
|
||||
if(CheckCommandAccess(param1, "sm_mute", ADMFLAG_CHAT, false)){
|
||||
PerformMute(param1, target);
|
||||
PerformMute(target);
|
||||
LogAction(param1, target, "\"%L\" muted \"%L\"", param1, target);
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Muted target", "_s", name);
|
||||
}
|
||||
}
|
||||
case CommType_UnMute:
|
||||
{
|
||||
if(CheckCommandAccess(param1, "sm_unmute", ADMFLAG_CHAT, false)){
|
||||
PerformUnMute(param1, target);
|
||||
PerformUnMute(target);
|
||||
LogAction(param1, target, "\"%L\" unmuted \"%L\"", param1, target);
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Unmuted target", "_s", name);
|
||||
}
|
||||
}
|
||||
case CommType_Gag:
|
||||
{
|
||||
if(CheckCommandAccess(param1, "sm_gag", ADMFLAG_CHAT, false)){
|
||||
PerformGag(param1, target);
|
||||
PerformGag(target);
|
||||
LogAction(param1, target, "\"%L\" gagged \"%L\"", param1, target);
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Gagged target", "_s", name);
|
||||
}
|
||||
}
|
||||
case CommType_UnGag:
|
||||
{
|
||||
if(CheckCommandAccess(param1, "sm_ungag", ADMFLAG_CHAT, false)){
|
||||
PerformUnGag(param1, target);
|
||||
PerformUnGag(target);
|
||||
LogAction(param1, target, "\"%L\" ungagged \"%L\"", param1, target);
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Ungagged target", "_s", name);
|
||||
}
|
||||
}
|
||||
case CommType_Silence:
|
||||
{
|
||||
if(CheckCommandAccess(param1, "sm_silence", ADMFLAG_CHAT, false)){
|
||||
PerformSilence(param1, target);
|
||||
PerformSilence(target);
|
||||
LogAction(param1, target, "\"%L\" silenced \"%L\"", param1, target);
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Silenced target", "_s", name);
|
||||
}
|
||||
}
|
||||
case CommType_UnSilence:
|
||||
{
|
||||
if(CheckCommandAccess(param1, "sm_unsilence", ADMFLAG_CHAT, false)){
|
||||
PerformUnSilence(param1, target);
|
||||
PerformUnSilence(target);
|
||||
LogAction(param1, target, "\"%L\" unsilenced \"%L\"", param1, target);
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Unsilenced target", "_s", name);
|
||||
}
|
||||
}
|
||||
@@ -252,20 +258,15 @@ public int MenuHandler_GagTypes(Menu menu, MenuAction action, int param1, int pa
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PerformMute(int client, int target, bool silent=false)
|
||||
void PerformMute(int target)
|
||||
{
|
||||
playerstate[target].isMuted = true;
|
||||
SetClientListeningFlags(target, VOICE_MUTED);
|
||||
|
||||
|
||||
FireOnClientMute(target, true);
|
||||
|
||||
if (!silent)
|
||||
{
|
||||
LogAction(client, target, "\"%L\" muted \"%L\"", client, target);
|
||||
}
|
||||
}
|
||||
|
||||
void PerformUnMute(int client, int target, bool silent=false)
|
||||
void PerformUnMute(int target)
|
||||
{
|
||||
playerstate[target].isMuted = false;
|
||||
if (g_Cvar_Deadtalk.IntValue == 1 && !IsPlayerAlive(target))
|
||||
@@ -280,67 +281,50 @@ void PerformUnMute(int client, int target, bool silent=false)
|
||||
{
|
||||
SetClientListeningFlags(target, VOICE_NORMAL);
|
||||
}
|
||||
|
||||
|
||||
FireOnClientMute(target, false);
|
||||
|
||||
if (!silent)
|
||||
{
|
||||
LogAction(client, target, "\"%L\" unmuted \"%L\"", client, target);
|
||||
}
|
||||
}
|
||||
|
||||
void PerformGag(int client, int target, bool silent=false)
|
||||
void PerformGag(int target)
|
||||
{
|
||||
playerstate[target].isGagged = true;
|
||||
FireOnClientGag(target, true);
|
||||
|
||||
if (!silent)
|
||||
{
|
||||
LogAction(client, target, "\"%L\" gagged \"%L\"", client, target);
|
||||
}
|
||||
}
|
||||
|
||||
void PerformUnGag(int client, int target, bool silent=false)
|
||||
void PerformUnGag(int target)
|
||||
{
|
||||
playerstate[target].isGagged = false;
|
||||
FireOnClientGag(target, false);
|
||||
|
||||
if (!silent)
|
||||
{
|
||||
LogAction(client, target, "\"%L\" ungagged \"%L\"", client, target);
|
||||
}
|
||||
}
|
||||
|
||||
void PerformSilence(int client, int target)
|
||||
void PerformSilence(int target)
|
||||
{
|
||||
if (!playerstate[target].isGagged)
|
||||
{
|
||||
playerstate[target].isGagged = true;
|
||||
FireOnClientGag(target, true);
|
||||
}
|
||||
|
||||
|
||||
if (!playerstate[target].isMuted)
|
||||
{
|
||||
playerstate[target].isMuted = true;
|
||||
SetClientListeningFlags(target, VOICE_MUTED);
|
||||
FireOnClientMute(target, true);
|
||||
}
|
||||
|
||||
LogAction(client, target, "\"%L\" silenced \"%L\"", client, target);
|
||||
}
|
||||
|
||||
void PerformUnSilence(int client, int target)
|
||||
void PerformUnSilence(int target)
|
||||
{
|
||||
if (playerstate[target].isGagged)
|
||||
{
|
||||
playerstate[target].isGagged = false;
|
||||
FireOnClientGag(target, false);
|
||||
}
|
||||
|
||||
|
||||
if (playerstate[target].isMuted)
|
||||
{
|
||||
playerstate[target].isMuted = false;
|
||||
|
||||
|
||||
if (g_Cvar_Deadtalk.IntValue == 1 && !IsPlayerAlive(target))
|
||||
{
|
||||
SetClientListeningFlags(target, VOICE_LISTENALL);
|
||||
@@ -355,30 +339,28 @@ void PerformUnSilence(int client, int target)
|
||||
}
|
||||
FireOnClientMute(target, false);
|
||||
}
|
||||
|
||||
LogAction(client, target, "\"%L\" unsilenced \"%L\"", client, target);
|
||||
}
|
||||
|
||||
public Action Command_Mute(int client, int args)
|
||||
{
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_mute <player>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
|
||||
char arg[64];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
|
||||
char target_name[MAX_TARGET_LENGTH];
|
||||
int target_list[MAXPLAYERS], target_count;
|
||||
bool tn_is_ml;
|
||||
|
||||
|
||||
if ((target_count = ProcessTargetString(
|
||||
arg,
|
||||
client,
|
||||
target_list,
|
||||
MAXPLAYERS,
|
||||
client,
|
||||
target_list,
|
||||
MAXPLAYERS,
|
||||
0,
|
||||
target_name,
|
||||
sizeof(target_name),
|
||||
@@ -391,42 +373,44 @@ public Action Command_Mute(int client, int args)
|
||||
for (int i = 0; i < target_count; i++)
|
||||
{
|
||||
int target = target_list[i];
|
||||
|
||||
PerformMute(client, target);
|
||||
|
||||
PerformMute(target);
|
||||
}
|
||||
|
||||
|
||||
if (tn_is_ml)
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Muted target", target_name);
|
||||
LogAction(client, -1, "\"%L\" muted \"%s\"", client, target_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Muted target", "_s", target_name);
|
||||
LogAction(client, target_list[0], "\"%L\" muted \"%L\"", client, target_list[0]);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action Command_Gag(int client, int args)
|
||||
{
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_gag <player>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
|
||||
char arg[64];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
|
||||
char target_name[MAX_TARGET_LENGTH];
|
||||
int target_list[MAXPLAYERS], target_count;
|
||||
bool tn_is_ml;
|
||||
|
||||
|
||||
if ((target_count = ProcessTargetString(
|
||||
arg,
|
||||
client,
|
||||
target_list,
|
||||
MAXPLAYERS,
|
||||
client,
|
||||
target_list,
|
||||
MAXPLAYERS,
|
||||
0,
|
||||
target_name,
|
||||
sizeof(target_name),
|
||||
@@ -439,42 +423,44 @@ public Action Command_Gag(int client, int args)
|
||||
for (int i = 0; i < target_count; i++)
|
||||
{
|
||||
int target = target_list[i];
|
||||
|
||||
PerformGag(client, target);
|
||||
|
||||
PerformGag(target);
|
||||
}
|
||||
|
||||
|
||||
if (tn_is_ml)
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Gagged target", target_name);
|
||||
LogAction(client, -1, "\"%L\" gagged \"%s\"", client, target_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Gagged target", "_s", target_name);
|
||||
LogAction(client, target_list[0], "\"%L\" gagged \"%L\"", client, target_list[0]);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action Command_Silence(int client, int args)
|
||||
{
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_silence <player>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
|
||||
char arg[64];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
|
||||
char target_name[MAX_TARGET_LENGTH];
|
||||
int target_list[MAXPLAYERS], target_count;
|
||||
bool tn_is_ml;
|
||||
|
||||
|
||||
if ((target_count = ProcessTargetString(
|
||||
arg,
|
||||
client,
|
||||
target_list,
|
||||
MAXPLAYERS,
|
||||
client,
|
||||
target_list,
|
||||
MAXPLAYERS,
|
||||
0,
|
||||
target_name,
|
||||
sizeof(target_name),
|
||||
@@ -487,42 +473,44 @@ public Action Command_Silence(int client, int args)
|
||||
for (int i = 0; i < target_count; i++)
|
||||
{
|
||||
int target = target_list[i];
|
||||
|
||||
PerformSilence(client, target);
|
||||
|
||||
PerformSilence(target);
|
||||
}
|
||||
|
||||
|
||||
if (tn_is_ml)
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Silenced target", target_name);
|
||||
LogAction(client, -1, "\"%L\" silenced \"%s\"", client, target_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Silenced target", "_s", target_name);
|
||||
LogAction(client, target_list[0], "\"%L\" silenced \"%L\"", client, target_list[0]);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action Command_Unmute(int client, int args)
|
||||
{
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_unmute <player>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
|
||||
char arg[64];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
|
||||
char target_name[MAX_TARGET_LENGTH];
|
||||
int target_list[MAXPLAYERS], target_count;
|
||||
bool tn_is_ml;
|
||||
|
||||
|
||||
if ((target_count = ProcessTargetString(
|
||||
arg,
|
||||
client,
|
||||
target_list,
|
||||
MAXPLAYERS,
|
||||
client,
|
||||
target_list,
|
||||
MAXPLAYERS,
|
||||
0,
|
||||
target_name,
|
||||
sizeof(target_name),
|
||||
@@ -535,15 +523,17 @@ public Action Command_Unmute(int client, int args)
|
||||
for (int i = 0; i < target_count; i++)
|
||||
{
|
||||
int target = target_list[i];
|
||||
|
||||
|
||||
if (!playerstate[target].isMuted)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
PerformUnMute(client, target);
|
||||
|
||||
PerformUnMute(target);
|
||||
}
|
||||
|
||||
|
||||
LogAction(client, -1, "\"%L\" unmuted \"%s\"", client, target_name);
|
||||
|
||||
if (tn_is_ml)
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Unmuted target", target_name);
|
||||
@@ -552,30 +542,30 @@ public Action Command_Unmute(int client, int args)
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Unmuted target", "_s", target_name);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action Command_Ungag(int client, int args)
|
||||
{
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_ungag <player>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
|
||||
char arg[64];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
|
||||
char target_name[MAX_TARGET_LENGTH];
|
||||
int target_list[MAXPLAYERS], target_count;
|
||||
bool tn_is_ml;
|
||||
|
||||
|
||||
if ((target_count = ProcessTargetString(
|
||||
arg,
|
||||
client,
|
||||
target_list,
|
||||
MAXPLAYERS,
|
||||
client,
|
||||
target_list,
|
||||
MAXPLAYERS,
|
||||
0,
|
||||
target_name,
|
||||
sizeof(target_name),
|
||||
@@ -588,42 +578,44 @@ public Action Command_Ungag(int client, int args)
|
||||
for (int i = 0; i < target_count; i++)
|
||||
{
|
||||
int target = target_list[i];
|
||||
|
||||
PerformUnGag(client, target);
|
||||
|
||||
PerformUnGag(target);
|
||||
}
|
||||
|
||||
|
||||
if (tn_is_ml)
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Ungagged target", target_name);
|
||||
LogAction(client, -1, "\"%L\" ungagged \"%s\"", client, target_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Ungagged target", "_s", target_name);
|
||||
LogAction(client, target_list[0], "\"%L\" ungagged \"%L\"", client, target_list[0]);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
public Action Command_Unsilence(int client, int args)
|
||||
{
|
||||
{
|
||||
if (args < 1)
|
||||
{
|
||||
ReplyToCommand(client, "[SM] Usage: sm_unsilence <player>");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
|
||||
char arg[64];
|
||||
GetCmdArg(1, arg, sizeof(arg));
|
||||
|
||||
|
||||
char target_name[MAX_TARGET_LENGTH];
|
||||
int target_list[MAXPLAYERS], target_count;
|
||||
bool tn_is_ml;
|
||||
|
||||
|
||||
if ((target_count = ProcessTargetString(
|
||||
arg,
|
||||
client,
|
||||
target_list,
|
||||
MAXPLAYERS,
|
||||
client,
|
||||
target_list,
|
||||
MAXPLAYERS,
|
||||
0,
|
||||
target_name,
|
||||
sizeof(target_name),
|
||||
@@ -636,18 +628,20 @@ public Action Command_Unsilence(int client, int args)
|
||||
for (int i = 0; i < target_count; i++)
|
||||
{
|
||||
int target = target_list[i];
|
||||
|
||||
PerformUnSilence(client, target);
|
||||
|
||||
PerformUnSilence(target);
|
||||
}
|
||||
|
||||
|
||||
if (tn_is_ml)
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Unsilenced target", target_name);
|
||||
LogAction(client, -1, "\"%L\" unsilenced \"%s\"", client, target_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Unsilenced target", "_s", target_name);
|
||||
LogAction(client, target_list[0], "\"%L\" unsilenced \"%L\"", client, target_list[0]);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public int Native_SetClientGag(Handle hPlugin, int numParams)
|
||||
return false;
|
||||
}
|
||||
|
||||
PerformGag(-1, client, true);
|
||||
PerformGag(client);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -94,7 +94,7 @@ public int Native_SetClientGag(Handle hPlugin, int numParams)
|
||||
return false;
|
||||
}
|
||||
|
||||
PerformUnGag(-1, client, true);
|
||||
PerformUnGag(client);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -122,7 +122,7 @@ public int Native_SetClientMute(Handle hPlugin, int numParams)
|
||||
return false;
|
||||
}
|
||||
|
||||
PerformMute(-1, client, true);
|
||||
PerformMute(client);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -131,7 +131,7 @@ public int Native_SetClientMute(Handle hPlugin, int numParams)
|
||||
return false;
|
||||
}
|
||||
|
||||
PerformUnMute(-1, client, true);
|
||||
PerformUnMute(client);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -31,10 +31,8 @@
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
void PerformKick(int client, int target, const char[] reason)
|
||||
void PerformKick(int target, const char[] reason)
|
||||
{
|
||||
LogAction(client, target, "\"%L\" kicked \"%L\" (reason \"%s\")", client, target, reason);
|
||||
|
||||
if (reason[0] == '\0')
|
||||
{
|
||||
KickClient(target, "%t", "Kicked by admin");
|
||||
@@ -110,7 +108,8 @@ public int MenuHandler_Kick(Menu menu, MenuAction action, int param1, int param2
|
||||
char name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Kicked target", "_s", name);
|
||||
PerformKick(param1, target, "");
|
||||
PerformKick(target, "");
|
||||
LogAction(param1, target, "\"%L\" kicked \"%L\"", param1, target);
|
||||
}
|
||||
|
||||
/* Re-draw the menu if they're still valid */
|
||||
@@ -203,13 +202,22 @@ public Action Command_Kick(int client, int args)
|
||||
}
|
||||
else
|
||||
{
|
||||
PerformKick(client, target_list[i], reason);
|
||||
PerformKick(target_list[i], reason);
|
||||
}
|
||||
}
|
||||
|
||||
if (kick_self)
|
||||
{
|
||||
PerformKick(client, client, reason);
|
||||
PerformKick(client, reason);
|
||||
}
|
||||
|
||||
if (tn_is_ml)
|
||||
{
|
||||
LogAction(client, -1, "\"%L\" kicked \"%s\" (reason \"%s\")", client, target_name, reason);
|
||||
}
|
||||
else
|
||||
{
|
||||
LogAction(client, target_list[0], "\"%L\" kicked \"%L\" (reason \"%s\")", client, target_list[0], reason);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -45,6 +45,11 @@ public int MenuHandler_ChangeMap(Menu menu, MenuAction action, int param1, int p
|
||||
char map[PLATFORM_MAX_PATH];
|
||||
|
||||
menu.GetItem(param2, map, sizeof(map));
|
||||
|
||||
if (!map[0])
|
||||
{
|
||||
GetCurrentMap(map, sizeof(map));
|
||||
}
|
||||
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Changing map", map);
|
||||
|
||||
@@ -158,6 +163,8 @@ int LoadMapList(Menu menu)
|
||||
|
||||
char map_name[PLATFORM_MAX_PATH];
|
||||
int map_count = GetArraySize(g_map_array);
|
||||
|
||||
menu.AddItem("", "Restart Current Map");
|
||||
|
||||
for (int i = 0; i < map_count; i++)
|
||||
{
|
||||
|
||||
@@ -59,18 +59,12 @@ void KillAllBeacons()
|
||||
}
|
||||
}
|
||||
|
||||
void PerformBeacon(int client, int target)
|
||||
void PerformBeacon(int target)
|
||||
{
|
||||
if (g_BeaconSerial[target] == 0)
|
||||
{
|
||||
CreateBeacon(target);
|
||||
LogAction(client, target, "\"%L\" set a beacon on \"%L\"", client, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
KillBeacon(target);
|
||||
LogAction(client, target, "\"%L\" removed a beacon on \"%L\"", client, target);
|
||||
}
|
||||
}
|
||||
|
||||
public Action Timer_Beacon(Handle timer, any value)
|
||||
@@ -184,8 +178,9 @@ public int MenuHandler_Beacon(Menu menu, MenuAction action, int param1, int para
|
||||
char name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
PerformBeacon(param1, target);
|
||||
PerformBeacon(target);
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Toggled beacon on target", "_s", name);
|
||||
LogAction(param1, target, "\"%L\" toggled beacon on \"%L\"", param1, target);
|
||||
}
|
||||
|
||||
/* Re-draw the menu if they're still valid */
|
||||
@@ -229,16 +224,18 @@ public Action Command_Beacon(int client, int args)
|
||||
|
||||
for (int i = 0; i < target_count; i++)
|
||||
{
|
||||
PerformBeacon(client, target_list[i]);
|
||||
PerformBeacon(target_list[i]);
|
||||
}
|
||||
|
||||
if (tn_is_ml)
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Toggled beacon on target", target_name);
|
||||
LogAction(client, -1, "\"%L\" toggled beacon on \"%s\"", client, target_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Toggled beacon on target", "_s", target_name);
|
||||
LogAction(client, target_list[0], "\"%L\" toggled beacon on \"%L\"", client, target_list[0]);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
int g_BlindTarget[MAXPLAYERS+1];
|
||||
|
||||
void PerformBlind(int client, int target, int amount)
|
||||
void PerformBlind(int target, int amount)
|
||||
{
|
||||
int targets[2];
|
||||
targets[0] = target;
|
||||
@@ -75,8 +75,6 @@ void PerformBlind(int client, int target, int amount)
|
||||
}
|
||||
|
||||
EndMessage();
|
||||
|
||||
LogAction(client, target, "\"%L\" set blind on \"%L\" (amount \"%d\")", client, target, amount);
|
||||
}
|
||||
|
||||
public void AdminMenu_Blind(TopMenu topmenu,
|
||||
@@ -211,7 +209,8 @@ public int MenuHandler_Amount(Menu menu, MenuAction action, int param1, int para
|
||||
char name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
PerformBlind(param1, target, amount);
|
||||
PerformBlind(target, amount);
|
||||
LogAction(param1, target, "\"%L\" set blind on \"%L\", amount %d.", param1, target, amount);
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Set blind on target", "_s", name, amount);
|
||||
}
|
||||
|
||||
@@ -276,16 +275,18 @@ public Action Command_Blind(int client, int args)
|
||||
|
||||
for (int i = 0; i < target_count; i++)
|
||||
{
|
||||
PerformBlind(client, target_list[i], amount);
|
||||
PerformBlind(target_list[i], amount);
|
||||
}
|
||||
|
||||
if (tn_is_ml)
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Set blind on target", target_name);
|
||||
LogAction(client, -1, "\"%L\" set blind on \"%s\", amount %d.", client, target_name, amount);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Set blind on target", "_s", target_name);
|
||||
LogAction(client, target_list[0], "\"%L\" set blind on \"%L\", amount %d.", client, target_list[0], amount);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
|
||||
@@ -106,7 +106,7 @@ void KillAllDrugs()
|
||||
}
|
||||
}
|
||||
|
||||
void PerformDrug(int client, int target, int toggle)
|
||||
void PerformDrug(int target, int toggle)
|
||||
{
|
||||
switch (toggle)
|
||||
{
|
||||
@@ -115,12 +115,10 @@ void PerformDrug(int client, int target, int toggle)
|
||||
if (g_DrugTimers[target] == null)
|
||||
{
|
||||
CreateDrug(target);
|
||||
LogAction(client, target, "\"%L\" drugged \"%L\"", client, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
KillDrug(target);
|
||||
LogAction(client, target, "\"%L\" undrugged \"%L\"", client, target);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,7 +127,6 @@ void PerformDrug(int client, int target, int toggle)
|
||||
if (g_DrugTimers[target] == null)
|
||||
{
|
||||
CreateDrug(target);
|
||||
LogAction(client, target, "\"%L\" drugged \"%L\"", client, target);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,7 +135,6 @@ void PerformDrug(int client, int target, int toggle)
|
||||
if (g_DrugTimers[target] != null)
|
||||
{
|
||||
KillDrug(target);
|
||||
LogAction(client, target, "\"%L\" undrugged \"%L\"", client, target);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -268,7 +264,8 @@ public int MenuHandler_Drug(Menu menu, MenuAction action, int param1, int param2
|
||||
char name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
PerformDrug(param1, target, 2);
|
||||
PerformDrug(target, 2);
|
||||
LogAction(param1, target, "\"%L\" toggled drugs on \"%L\"", param1, target);
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Toggled drug on target", "_s", name);
|
||||
}
|
||||
|
||||
@@ -328,16 +325,18 @@ public Action Command_Drug(int client, int args)
|
||||
|
||||
for (int i = 0; i < target_count; i++)
|
||||
{
|
||||
PerformDrug(client, target_list[i], toggle);
|
||||
PerformDrug(target_list[i], toggle);
|
||||
}
|
||||
|
||||
if (tn_is_ml)
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Toggled drug on target", target_name);
|
||||
LogAction(client, -1, "\"%L\" toggled drugs on \"%s\"", client, target_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Toggled drug on target", "_s", target_name);
|
||||
LogAction(client, target_list[0], "\"%L\" toggled drugs on \"%L\"", client, target_list[0]);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
|
||||
@@ -64,24 +64,16 @@ void KillAllFireBombs()
|
||||
}
|
||||
}
|
||||
|
||||
void PerformBurn(int client, int target, float seconds)
|
||||
{
|
||||
IgniteEntity(target, seconds);
|
||||
LogAction(client, target, "\"%L\" ignited \"%L\" (seconds \"%f\")", client, target, seconds);
|
||||
}
|
||||
|
||||
void PerformFireBomb(int client, int target)
|
||||
{
|
||||
if (g_FireBombSerial[client] == 0)
|
||||
{
|
||||
CreateFireBomb(target);
|
||||
LogAction(client, target, "\"%L\" set a FireBomb on \"%L\"", client, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
KillFireBomb(target);
|
||||
SetEntityRenderColor(client, 255, 255, 255, 255);
|
||||
LogAction(client, target, "\"%L\" removed a FireBomb on \"%L\"", client, target);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -306,7 +298,8 @@ public int MenuHandler_Burn(Menu menu, MenuAction action, int param1, int param2
|
||||
{
|
||||
char name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
PerformBurn(param1, target, 20.0);
|
||||
IgniteEntity(target, 20.0);
|
||||
LogAction(param1, target, "\"%L\" ignited \"%L\" (seconds \"20\")", param1, target);
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Set target on fire", "_s", name);
|
||||
}
|
||||
|
||||
@@ -355,6 +348,7 @@ public int MenuHandler_FireBomb(Menu menu, MenuAction action, int param1, int pa
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
PerformFireBomb(param1, target);
|
||||
LogAction(param1, target, "\"%L\" toggled FireBomb on \"%L\"", param1, target);
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Toggled FireBomb on target", "_s", name);
|
||||
}
|
||||
|
||||
@@ -410,16 +404,18 @@ public Action Command_Burn(int client, int args)
|
||||
|
||||
for (int i = 0; i < target_count; i++)
|
||||
{
|
||||
PerformBurn(client, target_list[i], seconds);
|
||||
IgniteEntity(target_list[i], seconds);
|
||||
}
|
||||
|
||||
if (tn_is_ml)
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Set target on fire", target_name);
|
||||
LogAction(client, -1, "\"%L\" ignited \"%s\" (seconds \"%f\")", client, target_name, seconds);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Set target on fire", "_s", target_name);
|
||||
LogAction(client, target_list[0], "\"%L\" ignited \"%L\" (seconds \"%f\")", client, target_list[0], seconds);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
@@ -462,10 +458,12 @@ public Action Command_FireBomb(int client, int args)
|
||||
if (tn_is_ml)
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Toggled FireBomb on target", target_name);
|
||||
LogAction(client, -1, "\"%L\" toggled FireBomb on \"%s\"", client, target_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Toggled FireBomb on target", "_s", target_name);
|
||||
LogAction(client, target_list[0], "\"%L\" toggled FireBomb on \"%L\"", client, target_list[0]);
|
||||
}
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
@@ -33,12 +33,6 @@
|
||||
|
||||
int g_GravityTarget[MAXPLAYERS+1];
|
||||
|
||||
void PerformGravity(int client, int target, float amount)
|
||||
{
|
||||
SetEntityGravity(target, amount);
|
||||
LogAction(client, target, "\"%L\" set gravity on \"%L\" (amount \"%f\")", client, target, amount);
|
||||
}
|
||||
|
||||
public void AdminMenu_Gravity(TopMenu topmenu,
|
||||
TopMenuAction action,
|
||||
TopMenuObject object_id,
|
||||
@@ -169,7 +163,8 @@ public int MenuHandler_GravityAmount(Menu menu, MenuAction action, int param1, i
|
||||
char name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
PerformGravity(param1, target, amount);
|
||||
SetEntityGravity(target, amount);
|
||||
LogAction(param1, target, "\"%L\" set gravity on \"%L\" to %f.", param1, target, amount);
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Set gravity on target", "_s", name, amount);
|
||||
}
|
||||
|
||||
@@ -229,16 +224,18 @@ public Action Command_Gravity(int client, int args)
|
||||
|
||||
for (int i = 0; i < target_count; i++)
|
||||
{
|
||||
PerformGravity(client, target_list[i], amount);
|
||||
SetEntityGravity(target_list[i], amount);
|
||||
}
|
||||
|
||||
if (tn_is_ml)
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Set gravity on target", target_name);
|
||||
LogAction(client, -1, "\"%L\" set gravity on \"%s\" to %f.", client, target_name, amount);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Set gravity on target", "_s", target_name);
|
||||
LogAction(client, target_list[0], "\"%L\" set gravity on \"%L\" to %f.", client, target_list[0], amount);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
|
||||
+11
-17
@@ -125,24 +125,12 @@ void KillAllFreezes()
|
||||
}
|
||||
}
|
||||
|
||||
void PerformFreeze(int client, int target, int time)
|
||||
{
|
||||
FreezeClient(target, time);
|
||||
LogAction(client, target, "\"%L\" froze \"%L\"", client, target);
|
||||
}
|
||||
|
||||
void PerformFreezeBomb(int client, int target)
|
||||
void PerformFreezeBomb(int target)
|
||||
{
|
||||
if (g_FreezeBombSerial[target] != 0)
|
||||
{
|
||||
KillFreezeBomb(target);
|
||||
LogAction(client, target, "\"%L\" removed a FreezeBomb on \"%L\"", client, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
CreateFreezeBomb(target);
|
||||
LogAction(client, target, "\"%L\" set a FreezeBomb on \"%L\"", client, target);
|
||||
}
|
||||
}
|
||||
|
||||
public Action Timer_Freeze(Handle timer, any value)
|
||||
@@ -421,7 +409,8 @@ public int MenuHandler_Freeze(Menu menu, MenuAction action, int param1, int para
|
||||
char name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
PerformFreeze(param1, target, g_Cvar_FreezeDuration.IntValue);
|
||||
FreezeClient(target, g_Cvar_FreezeDuration.IntValue);
|
||||
LogAction(param1, target, "\"%L\" froze \"%L\"", param1, target);
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Froze target", "_s", name);
|
||||
}
|
||||
|
||||
@@ -469,7 +458,8 @@ public int MenuHandler_FreezeBomb(Menu menu, MenuAction action, int param1, int
|
||||
char name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
PerformFreezeBomb(param1, target);
|
||||
PerformFreezeBomb(target);
|
||||
LogAction(param1, target, "\"%L\" toggled FreezeBomb on \"%L\"", param1, target);
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Toggled FreezeBomb on target", "_s", name);
|
||||
}
|
||||
|
||||
@@ -522,16 +512,18 @@ public Action Command_Freeze(int client, int args)
|
||||
|
||||
for (int i = 0; i < target_count; i++)
|
||||
{
|
||||
PerformFreeze(client, target_list[i], seconds);
|
||||
FreezeClient(target_list[i], seconds);
|
||||
}
|
||||
|
||||
if (tn_is_ml)
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Froze target", target_name);
|
||||
LogAction(client, -1, "\"%L\" froze \"%s\"", client, target_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Froze target", "_s", target_name);
|
||||
LogAction(client, target_list[0], "\"%L\" froze \"%L\"", client, target_list[0]);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
@@ -568,16 +560,18 @@ public Action Command_FreezeBomb(int client, int args)
|
||||
|
||||
for (int i = 0; i < target_count; i++)
|
||||
{
|
||||
PerformFreezeBomb(client, target_list[i]);
|
||||
PerformFreezeBomb(target_list[i]);
|
||||
}
|
||||
|
||||
if (tn_is_ml)
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Toggled FreezeBomb on target", target_name);
|
||||
LogAction(client, -1, "\"%L\" toggled FreezeBomb on \"%s\"", client, target_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Toggled FreezeBomb on target", "_s", target_name);
|
||||
LogAction(client, target_list[0], "\"%L\" toggled FreezeBomb on \"%L\"", client, target_list[0]);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
void PerformNoClip(int client, int target)
|
||||
void PerformNoClip(int target)
|
||||
{
|
||||
MoveType movetype = GetEntityMoveType(target);
|
||||
|
||||
@@ -43,8 +43,6 @@ void PerformNoClip(int client, int target)
|
||||
{
|
||||
SetEntityMoveType(target, MOVETYPE_WALK);
|
||||
}
|
||||
|
||||
LogAction(client, target, "\"%L\" toggled noclip on \"%L\"", client, target);
|
||||
}
|
||||
|
||||
public void AdminMenu_NoClip(TopMenu topmenu,
|
||||
@@ -112,7 +110,8 @@ public int MenuHandler_NoClip(Menu menu, MenuAction action, int param1, int para
|
||||
char name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
PerformNoClip(param1, target);
|
||||
PerformNoClip(target);
|
||||
LogAction(param1, target, "\"%L\" toggled noclip on \"%L\"", param1, target);
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Toggled noclip on target", "_s", name);
|
||||
}
|
||||
|
||||
@@ -157,16 +156,18 @@ public Action Command_NoClip(int client, int args)
|
||||
|
||||
for (int i = 0; i < target_count; i++)
|
||||
{
|
||||
PerformNoClip(client, target_list[i]);
|
||||
PerformNoClip(target_list[i]);
|
||||
}
|
||||
|
||||
if (tn_is_ml)
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Toggled noclip on target", target_name);
|
||||
LogAction(client, -1, "\"%L\" toggled noclip on \"%s\"", client, target_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Toggled noclip on target", "_s", target_name);
|
||||
LogAction(client, target_list[0], "\"%L\" toggled noclip on \"%L\"", client, target_list[0]);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
|
||||
@@ -68,13 +68,11 @@ void PerformTimeBomb(int client, int target)
|
||||
if (g_TimeBombSerial[target] == 0)
|
||||
{
|
||||
CreateTimeBomb(target);
|
||||
LogAction(client, target, "\"%L\" set a TimeBomb on \"%L\"", client, target);
|
||||
}
|
||||
else
|
||||
{
|
||||
KillTimeBomb(target);
|
||||
SetEntityRenderColor(client, 255, 255, 255, 255);
|
||||
LogAction(client, target, "\"%L\" removed a TimeBomb on \"%L\"", client, target);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,6 +277,7 @@ public int MenuHandler_TimeBomb(Menu menu, MenuAction action, int param1, int pa
|
||||
GetClientName(target, name, sizeof(name));
|
||||
|
||||
PerformTimeBomb(param1, target);
|
||||
LogAction(param1, target, "\"%L\" toggled TimeBomb on \"%L\"", param1, target);
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Toggled TimeBomb on target", "_s", name);
|
||||
}
|
||||
|
||||
@@ -329,10 +328,12 @@ public Action Command_TimeBomb(int client, int args)
|
||||
if (tn_is_ml)
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Toggled TimeBomb on target", target_name);
|
||||
LogAction(client, -1, "\"%L\" toggled TimeBomb on \"%s\"", client, target_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Toggled TimeBomb on target", "_s", target_name);
|
||||
LogAction(client, target_list[0], "\"%L\" toggled TimeBomb on \"%L\"", client, target_list[0]);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
#if defined _DynamicTargeting_Included
|
||||
#endinput
|
||||
#endif
|
||||
#define _DynamicTargeting_Included
|
||||
|
||||
native int AmbiguousMenu(int client, char[] sCommand, char[] sArgString, char[] sPattern, int FilterFlags);
|
||||
|
||||
public SharedPlugin __pl_DynamicTargeting =
|
||||
{
|
||||
name = "DynamicTargeting",
|
||||
file = "DynamicTargeting.smx",
|
||||
#if defined REQUIRE_PLUGIN
|
||||
required = 1,
|
||||
#else
|
||||
required = 0,
|
||||
#endif
|
||||
};
|
||||
|
||||
#if !defined REQUIRE_PLUGIN
|
||||
public __pl_DynamicTargeting_SetNTVOptional()
|
||||
{
|
||||
MarkNativeAsOptional("AmbiguousMenu");
|
||||
}
|
||||
#endif
|
||||
@@ -770,6 +770,15 @@ native float GetClientAvgData(int client, NetFlow flow);
|
||||
*/
|
||||
native float GetClientAvgPackets(int client, NetFlow flow);
|
||||
|
||||
/**
|
||||
* Returns the client's baseserver IClient pointer.
|
||||
*
|
||||
* @param client Player's index.
|
||||
* @return IClient address.
|
||||
* @error Invalid client index, client not connected, or fake client.
|
||||
*/
|
||||
native Address GetClientIClient(int client);
|
||||
|
||||
/**
|
||||
* Translates an userid index to the real player index.
|
||||
*
|
||||
|
||||
@@ -84,6 +84,25 @@ native int ProcessTargetString(const char[] pattern,
|
||||
int tn_maxlength,
|
||||
bool &tn_is_ml);
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves arguments that were passed to the last ProcessTargetString call.
|
||||
*
|
||||
* @param pattern Buffer to store the pattern.
|
||||
* @param p_maxlen Maximum length of the pattern buffer.
|
||||
* @param admin OUTPUT: Admin performing the action, or 0 if the server.
|
||||
* @param filter_flags OUTPUT: Filter flags.
|
||||
* @noreturn
|
||||
*/
|
||||
native void GetLastProcessTargetString(char[] pattern,
|
||||
int p_maxlen,
|
||||
int &admin,
|
||||
int &filter_flags);
|
||||
|
||||
#undef REQUIRE_PLUGIN
|
||||
#include <DynamicTargeting>
|
||||
#define REQUIRE_PLUGIN
|
||||
|
||||
/**
|
||||
* Replies to a client with a given message describing a targetting
|
||||
* failure reason.
|
||||
@@ -93,7 +112,7 @@ native int ProcessTargetString(const char[] pattern,
|
||||
* @param client Client index, or 0 for server.
|
||||
* @param reason COMMAND_TARGET reason.
|
||||
*/
|
||||
stock void ReplyToTargetError(int client, int reason)
|
||||
stock void ReplyToTargetError(int client, int reason, bool dynamic=true)
|
||||
{
|
||||
switch (reason)
|
||||
{
|
||||
@@ -128,6 +147,34 @@ stock void ReplyToTargetError(int client, int reason)
|
||||
case COMMAND_TARGET_AMBIGUOUS:
|
||||
{
|
||||
ReplyToCommand(client, "[SM] %t", "More than one client matched");
|
||||
|
||||
if(dynamic &&
|
||||
GetFeatureStatus(FeatureType_Native, "GetLastProcessTargetString") == FeatureStatus_Available &&
|
||||
LibraryExists("DynamicTargeting"))
|
||||
{
|
||||
if(GetFeatureStatus(FeatureType_Native, "IsCommandCallback") == FeatureStatus_Available &&
|
||||
!IsCommandCallback())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
char sCommand[128];
|
||||
GetCmdArg(0, sCommand, sizeof(sCommand));
|
||||
|
||||
char sArgString[256];
|
||||
GetCmdArgString(sArgString, sizeof(sArgString));
|
||||
|
||||
char pattern[MAX_TARGET_LENGTH];
|
||||
int admin;
|
||||
int filter_flags;
|
||||
|
||||
GetLastProcessTargetString(pattern, sizeof(pattern), admin, filter_flags);
|
||||
|
||||
if(!admin || !IsClientInGame(admin) || IsFakeClient(admin))
|
||||
return;
|
||||
|
||||
AmbiguousMenu(admin, sCommand, sArgString, pattern, filter_flags);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -420,7 +420,14 @@ native void RegAdminCmd(const char[] cmd,
|
||||
const char[] description="",
|
||||
const char[] group="",
|
||||
int flags=0);
|
||||
|
||||
|
||||
/**
|
||||
* Returns whether there is a command callback available.
|
||||
*
|
||||
* @return True if called from inside a command callback.
|
||||
*/
|
||||
native bool IsCommandCallback();
|
||||
|
||||
/**
|
||||
* Returns the number of arguments from the current console or server command.
|
||||
* @note Unlike the HL2 engine call, this does not include the command itself.
|
||||
|
||||
@@ -311,6 +311,9 @@ public void __ext_core_SetNTVOptional()
|
||||
MarkNativeAsOptional("Protobuf.ReadRepeatedMessage");
|
||||
MarkNativeAsOptional("Protobuf.AddMessage");
|
||||
|
||||
MarkNativeAsOptional("IsCommandCallback");
|
||||
MarkNativeAsOptional("GetLastProcessTargetString");
|
||||
|
||||
VerifyCoreVersion();
|
||||
}
|
||||
|
||||
|
||||
@@ -293,6 +293,17 @@ native void Call_StartForward(Handle fwd);
|
||||
*/
|
||||
native void Call_StartFunction(Handle plugin, Function func);
|
||||
|
||||
/**
|
||||
* Starts a call to a native.
|
||||
*
|
||||
* @note Cannot be used during an incomplete call.
|
||||
*
|
||||
* @param name Name of the native.
|
||||
* @return True on success, false otherwise.
|
||||
* @error Invalid function, or called before another call has completed.
|
||||
*/
|
||||
native bool Call_StartNative(const char[] name);
|
||||
|
||||
/**
|
||||
* Pushes a cell onto the current call.
|
||||
*
|
||||
@@ -416,6 +427,20 @@ native void Call_PushNullString();
|
||||
*/
|
||||
native int Call_Finish(any &result=0);
|
||||
|
||||
/**
|
||||
* Completes a call to a function or forward's call list.
|
||||
* Catches exceptions thrown by the native.
|
||||
*
|
||||
* @note Cannot be used before a call has been started.
|
||||
*
|
||||
* @param result Return value of function or forward's call list.
|
||||
* @param exception Buffer to store the exception in.
|
||||
* @param maxlength Maximum length of the buffer.
|
||||
* @return SP_ERROR_NONE on success, any other integer on failure.
|
||||
* @error Called before a call has been started.
|
||||
*/
|
||||
native int Call_FinishEx(any &result=0, char[] exception, int maxlength);
|
||||
|
||||
/**
|
||||
* Cancels a call to a function or forward's call list.
|
||||
*
|
||||
|
||||
@@ -348,6 +348,14 @@ typeset SDKHookCB
|
||||
*/
|
||||
forward void OnEntityCreated(int entity, const char[] classname);
|
||||
|
||||
/**
|
||||
* When an entity is spawned
|
||||
*
|
||||
* @param entity Entity index
|
||||
* @param classname Class name
|
||||
*/
|
||||
forward void OnEntitySpawned(int entity, const char[] classname);
|
||||
|
||||
/**
|
||||
* When an entity is destroyed
|
||||
*
|
||||
@@ -420,12 +428,13 @@ native void SDKUnhook(int entity, SDKHookType type, SDKHookCB callback);
|
||||
* @param weapon Weapon index (orangebox and later) or -1 for unspecified
|
||||
* @param damageForce Velocity of damage force
|
||||
* @param damagePosition Origin of damage
|
||||
* @param damageCustom User custom
|
||||
* @param bypassHooks If true, bypass SDK hooks on OnTakeDamage
|
||||
* @error Invalid entity, attacker, inflictor, or weapon entity.
|
||||
*/
|
||||
native void SDKHooks_TakeDamage(int entity, int inflictor, int attacker,
|
||||
float damage, int damageType=DMG_GENERIC, int weapon=-1,
|
||||
const float damageForce[3]=NULL_VECTOR, const float damagePosition[3]=NULL_VECTOR,
|
||||
const float damageForce[3]=NULL_VECTOR, const float damagePosition[3]=NULL_VECTOR, int damageCustom=0,
|
||||
bool bypassHooks = true);
|
||||
|
||||
/**
|
||||
|
||||
@@ -47,6 +47,92 @@ struct Plugin
|
||||
public const char[] url; /**< Plugin URL */
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns whether a library exists. This function should be considered
|
||||
* expensive; it should only be called on plugin to determine availability
|
||||
* of resources. Use OnLibraryAdded()/OnLibraryRemoved() to detect changes
|
||||
* in optional resources.
|
||||
*
|
||||
* @param name Library name of a plugin or extension.
|
||||
* @return True if exists, false otherwise.
|
||||
*/
|
||||
native bool LibraryExists(const char[] name);
|
||||
|
||||
/**
|
||||
* Feature types.
|
||||
*/
|
||||
enum FeatureType
|
||||
{
|
||||
/**
|
||||
* A native function call.
|
||||
*/
|
||||
FeatureType_Native,
|
||||
|
||||
/**
|
||||
* A named capability. This is distinctly different from checking for a
|
||||
* native, because the underlying functionality could be enabled on-demand
|
||||
* to improve loading time. Thus a native may appear to exist, but it might
|
||||
* be part of a set of features that are not compatible with the current game
|
||||
* or version of SourceMod.
|
||||
*/
|
||||
FeatureType_Capability
|
||||
};
|
||||
|
||||
/**
|
||||
* Feature statuses.
|
||||
*/
|
||||
enum FeatureStatus
|
||||
{
|
||||
/**
|
||||
* Feature is available for use.
|
||||
*/
|
||||
FeatureStatus_Available,
|
||||
|
||||
/**
|
||||
* Feature is not available.
|
||||
*/
|
||||
FeatureStatus_Unavailable,
|
||||
|
||||
/**
|
||||
* Feature is not known at all.
|
||||
*/
|
||||
FeatureStatus_Unknown
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns whether "GetFeatureStatus" will work. Using this native
|
||||
* or this function will not cause SourceMod to fail loading on older versions,
|
||||
* however, GetFeatureStatus will only work if this function returns true.
|
||||
*
|
||||
* @return True if GetFeatureStatus will work, false otherwise.
|
||||
*/
|
||||
stock bool CanTestFeatures()
|
||||
{
|
||||
return LibraryExists("__CanTestFeatures__");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether a feature exists, and if so, whether it is usable.
|
||||
*
|
||||
* @param type Feature type.
|
||||
* @param name Feature name.
|
||||
* @return Feature status.
|
||||
*/
|
||||
native FeatureStatus GetFeatureStatus(FeatureType type, const char[] name);
|
||||
|
||||
/**
|
||||
* Requires that a given feature is available. If it is not, SetFailState()
|
||||
* is called with the given message.
|
||||
*
|
||||
* @param type Feature type.
|
||||
* @param name Feature name.
|
||||
* @param fmt Message format string, or empty to use default.
|
||||
* @param ... Message format parameters, if any.
|
||||
*/
|
||||
native void RequireFeature(FeatureType type, const char[] name,
|
||||
const char[] fmt="", any ...);
|
||||
|
||||
|
||||
#include <core>
|
||||
#include <float>
|
||||
#include <vector>
|
||||
@@ -641,80 +727,6 @@ forward bool OnClientFloodCheck(int client);
|
||||
*/
|
||||
forward void OnClientFloodResult(int client, bool blocked);
|
||||
|
||||
/**
|
||||
* Feature types.
|
||||
*/
|
||||
enum FeatureType
|
||||
{
|
||||
/**
|
||||
* A native function call.
|
||||
*/
|
||||
FeatureType_Native,
|
||||
|
||||
/**
|
||||
* A named capability. This is distinctly different from checking for a
|
||||
* native, because the underlying functionality could be enabled on-demand
|
||||
* to improve loading time. Thus a native may appear to exist, but it might
|
||||
* be part of a set of features that are not compatible with the current game
|
||||
* or version of SourceMod.
|
||||
*/
|
||||
FeatureType_Capability
|
||||
};
|
||||
|
||||
/**
|
||||
* Feature statuses.
|
||||
*/
|
||||
enum FeatureStatus
|
||||
{
|
||||
/**
|
||||
* Feature is available for use.
|
||||
*/
|
||||
FeatureStatus_Available,
|
||||
|
||||
/**
|
||||
* Feature is not available.
|
||||
*/
|
||||
FeatureStatus_Unavailable,
|
||||
|
||||
/**
|
||||
* Feature is not known at all.
|
||||
*/
|
||||
FeatureStatus_Unknown
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns whether "GetFeatureStatus" will work. Using this native
|
||||
* or this function will not cause SourceMod to fail loading on older versions,
|
||||
* however, GetFeatureStatus will only work if this function returns true.
|
||||
*
|
||||
* @return True if GetFeatureStatus will work, false otherwise.
|
||||
*/
|
||||
stock bool CanTestFeatures()
|
||||
{
|
||||
return LibraryExists("__CanTestFeatures__");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether a feature exists, and if so, whether it is usable.
|
||||
*
|
||||
* @param type Feature type.
|
||||
* @param name Feature name.
|
||||
* @return Feature status.
|
||||
*/
|
||||
native FeatureStatus GetFeatureStatus(FeatureType type, const char[] name);
|
||||
|
||||
/**
|
||||
* Requires that a given feature is available. If it is not, SetFailState()
|
||||
* is called with the given message.
|
||||
*
|
||||
* @param type Feature type.
|
||||
* @param name Feature name.
|
||||
* @param fmt Message format string, or empty to use default.
|
||||
* @param ... Message format parameters, if any.
|
||||
*/
|
||||
native void RequireFeature(FeatureType type, const char[] name,
|
||||
const char[] fmt="", any ...);
|
||||
|
||||
/**
|
||||
* Represents how many bytes we can read from an address with one load
|
||||
*/
|
||||
|
||||
@@ -33,10 +33,8 @@
|
||||
|
||||
char g_NewName[MAXPLAYERS+1][MAX_NAME_LENGTH];
|
||||
|
||||
void PerformRename(int client, int target)
|
||||
void PerformRename(int target)
|
||||
{
|
||||
LogAction(client, target, "\"%L\" renamed \"%L\" (to \"%s\")", client, target, g_NewName[target]);
|
||||
|
||||
SetClientName(target, g_NewName[target]);
|
||||
|
||||
g_NewName[target][0] = '\0';
|
||||
@@ -109,7 +107,8 @@ public int MenuHandler_Rename(Menu menu, MenuAction action, int param1, int para
|
||||
|
||||
RandomizeName(target);
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Renamed target", "_s", name);
|
||||
PerformRename(param1, target);
|
||||
LogAction(param1, target, "\"%L\" renamed \"%L\" to \"%s\")", param1, target, g_NewName[target]);
|
||||
PerformRename(target);
|
||||
}
|
||||
DisplayRenameTargetMenu(param1);
|
||||
}
|
||||
@@ -170,12 +169,14 @@ public Action Command_Rename(int client, int args)
|
||||
if (tn_is_ml)
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Renamed target", target_name);
|
||||
LogAction(client, -1, "\"%L\" renamed \"%s\" to \"%s\")", client, target_name, arg2);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Renamed target", "_s", target_name);
|
||||
LogAction(client, target_list[0], "\"%L\" renamed \"%L\" to \"%s\")", client, target_list[0], arg2);
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < target_count; i++)
|
||||
{
|
||||
if (randomize)
|
||||
@@ -193,7 +194,7 @@ public Action Command_Rename(int client, int args)
|
||||
Format(g_NewName[target_list[i]], MAX_NAME_LENGTH, "%s", arg2);
|
||||
}
|
||||
}
|
||||
PerformRename(client, target_list[i]);
|
||||
PerformRename(target_list[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -33,12 +33,6 @@
|
||||
|
||||
int g_SlapDamage[MAXPLAYERS+1];
|
||||
|
||||
void PerformSlap(int client, int target, int damage)
|
||||
{
|
||||
LogAction(client, target, "\"%L\" slapped \"%L\" (damage \"%d\")", client, target, damage);
|
||||
SlapPlayer(target, damage, true);
|
||||
}
|
||||
|
||||
void DisplaySlapDamageMenu(int client)
|
||||
{
|
||||
Menu menu = new Menu(MenuHandler_SlapDamage);
|
||||
@@ -153,7 +147,8 @@ public int MenuHandler_Slap(Menu menu, MenuAction action, int param1, int param2
|
||||
{
|
||||
char name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
PerformSlap(param1, target, g_SlapDamage[param1]);
|
||||
SlapPlayer(target, g_SlapDamage[param1]);
|
||||
LogAction(param1, target, "\"%L\" slapped \"%L\" (damage \"%d\")", param1, target, g_SlapDamage[param1]);
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Slapped target", "_s", name);
|
||||
}
|
||||
|
||||
@@ -206,16 +201,18 @@ public Action Command_Slap(int client, int args)
|
||||
|
||||
for (int i = 0; i < target_count; i++)
|
||||
{
|
||||
PerformSlap(client, target_list[i], damage);
|
||||
SlapPlayer(target_list[i], damage);
|
||||
}
|
||||
|
||||
if (tn_is_ml)
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Slapped target", target_name);
|
||||
LogAction(client, -1, "\"%L\" slapped \"%s\" (damage \"%d\")", client, target_name, damage);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Slapped target", "_s", target_name);
|
||||
LogAction(client, target_list[0], "\"%L\" slapped \"%L\" (damage \"%d\")", client, target_list[0], damage);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
|
||||
@@ -31,12 +31,6 @@
|
||||
* Version: $Id$
|
||||
*/
|
||||
|
||||
void PerformSlay(int client, int target)
|
||||
{
|
||||
LogAction(client, target, "\"%L\" slayed \"%L\"", client, target);
|
||||
ForcePlayerSuicide(target);
|
||||
}
|
||||
|
||||
void DisplaySlayMenu(int client)
|
||||
{
|
||||
Menu menu = new Menu(MenuHandler_Slay);
|
||||
@@ -105,7 +99,8 @@ public int MenuHandler_Slay(Menu menu, MenuAction action, int param1, int param2
|
||||
{
|
||||
char name[MAX_NAME_LENGTH];
|
||||
GetClientName(target, name, sizeof(name));
|
||||
PerformSlay(param1, target);
|
||||
ForcePlayerSuicide(target);
|
||||
LogAction(param1, target, "\"%L\" slayed \"%L\"", param1, target);
|
||||
ShowActivity2(param1, "[SM] ", "%t", "Slayed target", "_s", name);
|
||||
}
|
||||
|
||||
@@ -146,16 +141,18 @@ public Action Command_Slay(int client, int args)
|
||||
|
||||
for (int i = 0; i < target_count; i++)
|
||||
{
|
||||
PerformSlay(client, target_list[i]);
|
||||
ForcePlayerSuicide(target_list[i]);
|
||||
}
|
||||
|
||||
if (tn_is_ml)
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Slayed target", target_name);
|
||||
LogAction(client, -1, "\"%L\" slayed \"%s\"", client, target_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Slayed target", "_s", target_name);
|
||||
LogAction(client, target_list[0], "\"%L\" slayed \"%L\"", client, target_list[0]);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
|
||||
+8
-7
@@ -10,7 +10,7 @@
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
*
|
||||
* 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
|
||||
@@ -76,7 +76,7 @@ public Action Command_Play(int client, int args)
|
||||
|
||||
char SoundPath[PLATFORM_MAX_PATH];
|
||||
BreakString(Arguments[len], SoundPath, sizeof(SoundPath));
|
||||
|
||||
|
||||
/* Remove all double and single quotes out of the path */
|
||||
ReplaceString(SoundPath, sizeof(SoundPath), "\"", "");
|
||||
ReplaceString(SoundPath, sizeof(SoundPath), "'", "");
|
||||
@@ -89,11 +89,11 @@ public Action Command_Play(int client, int args)
|
||||
ReplyToCommand(client, "[SM] Invalid filename");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
|
||||
char target_name[MAX_TARGET_LENGTH];
|
||||
int target_list[MAXPLAYERS], target_count;
|
||||
bool tn_is_ml;
|
||||
|
||||
|
||||
if ((target_count = ProcessTargetString(
|
||||
Arg,
|
||||
client,
|
||||
@@ -107,20 +107,21 @@ public Action Command_Play(int client, int args)
|
||||
ReplyToTargetError(client, target_count);
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < target_count; i++)
|
||||
{
|
||||
ClientCommand(target_list[i], "playgamesound \"%s\"", SoundPath);
|
||||
LogAction(client, target_list[i], "\"%L\" played sound on \"%L\" (file \"%s\")", client, target_list[i], SoundPath);
|
||||
}
|
||||
|
||||
|
||||
if (tn_is_ml)
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Played sound to target", target_name);
|
||||
LogAction(client, -1, "\"%L\" played sound on \"%s\" (file \"%s\")", client, target_name, Arguments[len]);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowActivity2(client, "[SM] ", "%t", "Played sound to target", "_s", target_name);
|
||||
LogAction(client, target_list[0], "\"%L\" played sound on \"%L\" (file \"%s\")", client, target_list[0], Arguments[len]);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
* This program is free software; you can redistribute it and/or modify it under
|
||||
* the terms of the GNU General Public License, version 3.0, as published by the
|
||||
* Free Software Foundation.
|
||||
*
|
||||
*
|
||||
* 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
|
||||
@@ -38,6 +38,11 @@
|
||||
#define DETOUR_MEMBER_CALL(name) (this->*name##_Actual)
|
||||
#define DETOUR_STATIC_CALL(name) (name##_Actual)
|
||||
|
||||
#define DETOUR_MEMBER_MCALL_CALLBACK(name, classptr) \
|
||||
((name##Class *)classptr->*(&name##Class::name))
|
||||
#define DETOUR_MEMBER_MCALL_ORIGINAL(name, classptr) \
|
||||
((name##Class *)classptr->*(name##Class::name##_Actual))
|
||||
|
||||
#define DETOUR_DECL_STATIC0(name, ret) \
|
||||
ret (*name##_Actual)(void) = NULL; \
|
||||
ret name(void)
|
||||
@@ -74,6 +79,14 @@ ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5na
|
||||
ret (*name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type) = NULL; \
|
||||
ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name)
|
||||
|
||||
#define DETOUR_DECL_STATIC9(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name, p5type, p5name, p6type, p6name, p7type, p7name, p8type, p8name, p9type, p9name) \
|
||||
ret (*name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type) = NULL; \
|
||||
ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name)
|
||||
|
||||
#define DETOUR_DECL_STATIC10(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name, p5type, p5name, p6type, p6name, p7type, p7name, p8type, p8name, p9type, p9name, p10type, p10name) \
|
||||
ret (*name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type, p10type) = NULL; \
|
||||
ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name, p10type p10name)
|
||||
|
||||
#define DETOUR_DECL_MEMBER0(name, ret) \
|
||||
class name##Class \
|
||||
{ \
|
||||
@@ -164,6 +177,65 @@ public: \
|
||||
ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type) = NULL; \
|
||||
ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name)
|
||||
|
||||
#define DETOUR_DECL_MEMBER9(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name, p5type, p5name, p6type, p6name, p7type, p7name, p8type, p8name, p9type, p9name) \
|
||||
class name##Class \
|
||||
{ \
|
||||
public: \
|
||||
ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name); \
|
||||
static ret (name##Class::* name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type); \
|
||||
}; \
|
||||
ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type) = NULL; \
|
||||
ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name)
|
||||
|
||||
#define DETOUR_DECL_MEMBER10(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name, p5type, p5name, p6type, p6name, p7type, p7name, p8type, p8name, p9type, p9name, p10type, p10name) \
|
||||
class name##Class \
|
||||
{ \
|
||||
public: \
|
||||
ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name, p10type p10name); \
|
||||
static ret (name##Class::* name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type, p10type); \
|
||||
}; \
|
||||
ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type, p10type) = NULL; \
|
||||
ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name, p10type p10name)
|
||||
|
||||
#define DETOUR_DECL_MEMBER11(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name, p5type, p5name, p6type, p6name, p7type, p7name, p8type, p8name, p9type, p9name, p10type, p10name, p11type, p11name) \
|
||||
class name##Class \
|
||||
{ \
|
||||
public: \
|
||||
ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name, p10type p10name, p11type p11name); \
|
||||
static ret (name##Class::* name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type, p10type, p11type); \
|
||||
}; \
|
||||
ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type, p10type, p11type) = NULL; \
|
||||
ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name, p10type p10name, p11type p11name)
|
||||
|
||||
#define DETOUR_DECL_MEMBER12(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name, p5type, p5name, p6type, p6name, p7type, p7name, p8type, p8name, p9type, p9name, p10type, p10name, p11type, p11name, p12type, p12name) \
|
||||
class name##Class \
|
||||
{ \
|
||||
public: \
|
||||
ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name, p10type p10name, p11type p11name, p12type p12name); \
|
||||
static ret (name##Class::* name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type, p10type, p11type, p12type); \
|
||||
}; \
|
||||
ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type, p10type, p11type, p12type) = NULL; \
|
||||
ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name, p10type p10name, p11type p11name, p12type p12name)
|
||||
|
||||
#define DETOUR_DECL_MEMBER13(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name, p5type, p5name, p6type, p6name, p7type, p7name, p8type, p8name, p9type, p9name, p10type, p10name, p11type, p11name, p12type, p12name, p13type, p13name) \
|
||||
class name##Class \
|
||||
{ \
|
||||
public: \
|
||||
ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name, p10type p10name, p11type p11name, p12type p12name, p13type p13name); \
|
||||
static ret (name##Class::* name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type, p10type, p11type, p12type, p13type); \
|
||||
}; \
|
||||
ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type, p10type, p11type, p12type, p13type) = NULL; \
|
||||
ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name, p10type p10name, p11type p11name, p12type p12name, p13type p13name)
|
||||
|
||||
#define DETOUR_DECL_MEMBER14(name, ret, p1type, p1name, p2type, p2name, p3type, p3name, p4type, p4name, p5type, p5name, p6type, p6name, p7type, p7name, p8type, p8name, p9type, p9name, p10type, p10name, p11type, p11name, p12type, p12name, p13type, p13name, p14type, p14name) \
|
||||
class name##Class \
|
||||
{ \
|
||||
public: \
|
||||
ret name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name, p10type p10name, p11type p11name, p12type p12name, p13type p13name, p14type p14name); \
|
||||
static ret (name##Class::* name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type, p10type, p11type, p12type, p13type, p14type); \
|
||||
}; \
|
||||
ret (name##Class::* name##Class::name##_Actual)(p1type, p2type, p3type, p4type, p5type, p6type, p7type, p8type, p9type, p10type, p11type, p12type, p13type, p14type) = NULL; \
|
||||
ret name##Class::name(p1type p1name, p2type p2name, p3type p3name, p4type p4name, p5type p5name, p6type p6name, p7type p7name, p8type p8name, p9type p9name, p10type p10name, p11type p11name, p12type p12name, p13type p13name, p14type p14name)
|
||||
|
||||
#define GET_MEMBER_CALLBACK(name) (void *)GetCodeAddress(&name##Class::name)
|
||||
#define GET_MEMBER_TRAMPOLINE(name) (void **)(&name##Class::name##_Actual)
|
||||
@@ -213,6 +285,27 @@ protected:
|
||||
CDetour(void*callbackfunction, void **trampoline, void *pAddress);
|
||||
private:
|
||||
SafetyHookInline m_hook{};
|
||||
|
||||
/* These create/delete the allocated memory */
|
||||
bool CreateDetour();
|
||||
void DeleteDetour();
|
||||
|
||||
bool enabled;
|
||||
bool detoured;
|
||||
|
||||
patch_t detour_restore;
|
||||
/* Address of the detoured function */
|
||||
void *detour_address;
|
||||
/* Address of the allocated trampoline function */
|
||||
void *detour_trampoline;
|
||||
/* Address of the callback handler */
|
||||
void *detour_callback;
|
||||
/* The function pointer used to call our trampoline */
|
||||
void **trampoline;
|
||||
|
||||
const char *signame;
|
||||
ISourcePawnEngine *spengine;
|
||||
IGameConfig *gameconf;
|
||||
};
|
||||
|
||||
class CDetourManager
|
||||
|
||||
@@ -551,10 +551,17 @@ namespace SourceMod
|
||||
/**
|
||||
* @brief Returns the number of players currently connected.
|
||||
*
|
||||
* @return Current number of connected clients.
|
||||
* @return Current number of connected players.
|
||||
*/
|
||||
virtual int GetNumPlayers() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the number of clients currently connected.
|
||||
*
|
||||
* @return Current number of connected clients.
|
||||
*/
|
||||
virtual int GetNumClients() =0;
|
||||
|
||||
/**
|
||||
* @brief Returns the client index by its userid.
|
||||
*
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include <IShareSys.h>
|
||||
|
||||
#define SMINTERFACE_SDKHOOKS_NAME "ISDKHooks"
|
||||
#define SMINTERFACE_SDKHOOKS_VERSION 1
|
||||
#define SMINTERFACE_SDKHOOKS_VERSION 2
|
||||
|
||||
class CBaseEntity;
|
||||
|
||||
@@ -71,6 +71,16 @@ namespace SourceMod
|
||||
virtual void OnEntityDestroyed(CBaseEntity *pEntity)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief When an entity is spawned
|
||||
*
|
||||
* @param pEntity CBaseEntity entity.
|
||||
* @param classname Entity classname.
|
||||
*/
|
||||
virtual void OnEntitySpawned(CBaseEntity *pEntity, const char *classname)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
Submodule sourcepawn updated: d59a51b574...04eafd8863
Reference in New Issue
Block a user