Beispiel #1
0
//-----------------------------------------------------------------------------
// Purpose: called when a client joins a server
//-----------------------------------------------------------------------------
PLUGIN_RESULT CSourcePython::ClientConnect( bool *bAllowConnect, edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen )
{
	CPointer allowConnect = CPointer((unsigned long) bAllowConnect);
	CPointer rejectMessage = CPointer((unsigned long) reject);
	CALL_LISTENERS(ClientConnect, allowConnect, IndexFromEdict(pEntity), pszName, pszAddress, rejectMessage, maxrejectlen);
	return PLUGIN_OVERRIDE;
}
Beispiel #2
0
//-----------------------------------------------------------------------------
// Returns an index from the given UserID.
//-----------------------------------------------------------------------------
bool IndexFromUserid( unsigned int iUserID, unsigned int& output )
{
    edict_t* pEdict;
    if (!EdictFromUserid(iUserID, pEdict))
        return false;

    return IndexFromEdict(pEdict, output);
}
Beispiel #3
0
//-----------------------------------------------------------------------------
// Returns an index instance from the given PlayerInfo instance.
//-----------------------------------------------------------------------------
bool IndexFromPlayerInfo( IPlayerInfo *pPlayerInfo, unsigned int& output )
{
    edict_t* pEdict;
    if (!EdictFromPlayerInfo(pPlayerInfo, pEdict))
        return false;

    return IndexFromEdict(pEdict, output);
}
Beispiel #4
0
//-----------------------------------------------------------------------------
// Returns a UserID from the given Edict instance.
//-----------------------------------------------------------------------------
bool UseridFromEdict( edict_t *pEdict, unsigned int& output )
{
	unsigned int iEntityIndex;
	if (!IndexFromEdict(pEdict, iEntityIndex))
		return false;

	return UseridFromIndex(iEntityIndex, output);
}
Beispiel #5
0
void CSourcePython::OnEdictAllocated( edict_t *edict )
{
	unsigned int iEntityIndex;
	if (!IndexFromEdict(edict, iEntityIndex))
		return;

	CALL_LISTENERS(OnEdictAllocated, iEntityIndex);
}
Beispiel #6
0
void CSourcePython::ClientFullyConnect( edict_t *pEntity )
{
	unsigned int iEntityIndex;
	if (!IndexFromEdict(pEntity, iEntityIndex))
		return;

	CALL_LISTENERS(OnClientFullyConnect, iEntityIndex);
}
Beispiel #7
0
//-----------------------------------------------------------------------------
// Purpose: called on level start
//-----------------------------------------------------------------------------
void CSourcePython::ClientSettingsChanged( edict_t *pEdict )
{
	unsigned int iEntityIndex;
	if (!IndexFromEdict(pEdict, iEntityIndex))
		return;

	CALL_LISTENERS(OnClientSettingsChanged, iEntityIndex);
}
Beispiel #8
0
//-----------------------------------------------------------------------------
// Purpose: called when a cvar value query is finished
//-----------------------------------------------------------------------------
void CSourcePython::OnQueryCvarValueFinished( QueryCvarCookie_t iCookie, edict_t *pPlayerEntity,
	EQueryCvarValueStatus eStatus, const char *pCvarName, const char *pCvarValue )
{
	PythonLog(4, "Cvar query (cookie: %d, status: %d) - name: %s, value: %s", iCookie, eStatus, pCvarName, pCvarValue );
	unsigned int iEntityIndex;
	if (!IndexFromEdict(pPlayerEntity, iEntityIndex))
		return;

	CALL_LISTENERS(OnQueryCvarValueFinished, (int) iCookie, iEntityIndex, eStatus, pCvarName, pCvarValue);
}
Beispiel #9
0
//-----------------------------------------------------------------------------
// Returns an index from the given BaseEntity instance.
//-----------------------------------------------------------------------------
bool IndexFromBaseEntity( CBaseEntity *pBaseEntity, unsigned int& output )
{
    if (!pBaseEntity)
        return false;

    IServerNetworkable *pServerNetworkable = pBaseEntity->GetNetworkable();
    if (!pServerNetworkable)
        return false;

    edict_t* pEdict = pServerNetworkable->GetEdict();
    if (!pEdict || pEdict->IsFree())
        return false;

    return IndexFromEdict(pEdict, output);
}
//-----------------------------------------------------------------------------
// Dispatches a client command.
//-----------------------------------------------------------------------------
PLUGIN_RESULT DispatchClientCommand(edict_t* pEntity, const CCommand &command)
{
	unsigned int iIndex;
	if (!IndexFromEdict(pEntity, iIndex))
		return PLUGIN_CONTINUE;

	// Loop through all registered Client Command Filters
	for(int i = 0; i < s_ClientCommandFilters.m_vecCallables.Count(); i++)
	{
		BEGIN_BOOST_PY()

			// Get the PyObject instance of the callable
			PyObject* pCallable = s_ClientCommandFilters.m_vecCallables[i].ptr();

			// Call the callable and store its return value
			object returnValue = CALL_PY_FUNC(pCallable, boost::ref(command), iIndex);

			// Does the Client Command Filter want to block the command?
			if( !returnValue.is_none() && extract<int>(returnValue) == (int)BLOCK)
			{
				// Block the command
				return PLUGIN_STOP;
			}

		END_BOOST_PY_NORET()
	}

	// Get the command's name
	const char* szCommand = command.Arg(0);

	// Find if the command exists in the mapping
	ClientCommandMap::iterator commandMapIter = g_ClientCommandMap.find(szCommand);
	if( commandMapIter != g_ClientCommandMap.end() )
	{
		// If the command exists, get the CClientCommandManager instance and call its Dispatch method
		CClientCommandManager* pCClientCommandManager = commandMapIter->second;

		// Does the command need to be blocked?
		if( !pCClientCommandManager->Dispatch(command, iIndex))
		{
			// Block the command
			return PLUGIN_STOP;
		}
	}

	return PLUGIN_CONTINUE;
}
Beispiel #11
0
void CSourcePython::OnEdictAllocated( edict_t *edict )
{
	CALL_LISTENERS(OnEdictAllocated, IndexFromEdict(edict));
}
Beispiel #12
0
void CSourcePython::ClientFullyConnect( edict_t *pEntity )
{
	CALL_LISTENERS(ClientFullyConnect, IndexFromEdict(pEntity));
}
Beispiel #13
0
//-----------------------------------------------------------------------------
// Purpose: called on level start
//-----------------------------------------------------------------------------
void CSourcePython::ClientSettingsChanged( edict_t *pEdict )
{
	CALL_LISTENERS(ClientSettingsChanged, IndexFromEdict(pEdict));
}
Beispiel #14
0
//-----------------------------------------------------------------------------
// Purpose: called on
//-----------------------------------------------------------------------------
void CSourcePython::ClientPutInServer( edict_t *pEntity, char const *playername )
{
	CALL_LISTENERS(ClientPutInServer, IndexFromEdict(pEntity), playername);
}
Beispiel #15
0
//-----------------------------------------------------------------------------
// Purpose: called when a client spawns into a server (i.e as they begin to play)
//-----------------------------------------------------------------------------
void CSourcePython::ClientActive( edict_t *pEntity )
{
	CALL_LISTENERS(ClientActive, IndexFromEdict(pEntity));
}