bluebriansimon@3339: /** bluebriansimon@3339: * vim: set ts=4 : bluebriansimon@3339: * ============================================================================= bluebriansimon@3339: * SourceMod SDKTools Extension bluebriansimon@3339: * Copyright (C) 2004-2011 AlliedModders LLC. All rights reserved. bluebriansimon@3339: * ============================================================================= bluebriansimon@3339: * bluebriansimon@3339: * This program is free software; you can redistribute it and/or modify it under bluebriansimon@3339: * the terms of the GNU General Public License, version 3.0, as published by the bluebriansimon@3339: * Free Software Foundation. bluebriansimon@3339: * bluebriansimon@3339: * This program is distributed in the hope that it will be useful, but WITHOUT bluebriansimon@3339: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS bluebriansimon@3339: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more bluebriansimon@3339: * details. bluebriansimon@3339: * bluebriansimon@3339: * You should have received a copy of the GNU General Public License along with bluebriansimon@3339: * this program. If not, see . bluebriansimon@3339: * bluebriansimon@3339: * As a special exception, AlliedModders LLC gives you permission to link the bluebriansimon@3339: * code of this program (as well as its derivative works) to "Half-Life 2," the bluebriansimon@3339: * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software bluebriansimon@3339: * by the Valve Corporation. You must obey the GNU General Public License in bluebriansimon@3339: * all respects for all other code used. Additionally, AlliedModders LLC grants bluebriansimon@3339: * this exception to all derivative works. AlliedModders LLC defines further bluebriansimon@3339: * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007), bluebriansimon@3339: * or . bluebriansimon@3339: * bluebriansimon@3339: * Version: $Id$ bluebriansimon@3339: */ bluebriansimon@3339: bluebriansimon@3339: bluebriansimon@3339: #include "extension.h" bluebriansimon@3339: #include "clientnatives.h" bluebriansimon@3339: #include "iserver.h" bluebriansimon@3339: #include "iclient.h" bluebriansimon@3339: bluebriansimon@3339: static cell_t smn_InactivateClient(IPluginContext *pContext, const cell_t *params) bluebriansimon@3339: { bluebriansimon@3339: IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]); bluebriansimon@3339: bluebriansimon@3339: if (player == NULL) bluebriansimon@3339: { bluebriansimon@3339: return pContext->ThrowNativeError("Invalid client index %d", params[1]); bluebriansimon@3339: } bluebriansimon@3339: bluebriansimon@3339: bluebriansimon@3339: if (!iserver) bluebriansimon@3339: { bluebriansimon@3339: pContext->ThrowNativeError("IServer is null"); bluebriansimon@3339: } bluebriansimon@3339: bluebriansimon@3339: IClient* pClient = iserver->GetClient(params[1] - 1); bluebriansimon@3339: if (pClient) bluebriansimon@3339: { bluebriansimon@3339: pClient->Inactivate(); bluebriansimon@3339: } bluebriansimon@3339: else bluebriansimon@3339: { bluebriansimon@3339: pContext->ThrowNativeError("Could not get IClient for client %d", params[1]); bluebriansimon@3339: } bluebriansimon@3339: bluebriansimon@3339: return 1; bluebriansimon@3339: } bluebriansimon@3339: bluebriansimon@3339: static cell_t smn_ReconnectClient(IPluginContext *pContext, const cell_t *params) bluebriansimon@3339: { bluebriansimon@3339: IGamePlayer *player = playerhelpers->GetGamePlayer(params[1]); bluebriansimon@3339: bluebriansimon@3339: if (player == NULL) bluebriansimon@3339: { bluebriansimon@3339: return pContext->ThrowNativeError("Invalid client index %d", params[1]); bluebriansimon@3339: } bluebriansimon@3339: bluebriansimon@3339: if (!iserver) bluebriansimon@3339: { bluebriansimon@3339: pContext->ThrowNativeError("IServer is null"); bluebriansimon@3339: } bluebriansimon@3339: bluebriansimon@3339: IClient* pClient = iserver->GetClient(params[1] - 1); bluebriansimon@3339: if (pClient) bluebriansimon@3339: { bluebriansimon@3339: pClient->Reconnect(); bluebriansimon@3339: } bluebriansimon@3339: else bluebriansimon@3339: { bluebriansimon@3339: pContext->ThrowNativeError("Could not get IClient for client %d", params[1]); bluebriansimon@3339: } bluebriansimon@3339: return 1; bluebriansimon@3339: } bluebriansimon@3339: bluebriansimon@3339: sp_nativeinfo_t g_ClientNatives[] = bluebriansimon@3339: { bluebriansimon@3339: { "InactivateClient", smn_InactivateClient }, bluebriansimon@3339: { "ReconnectClient", smn_ReconnectClient }, bluebriansimon@3339: { NULL, NULL }, bluebriansimon@3339: };