From 816bdc8102e29c3c66fda164a8846eb13d4d614c Mon Sep 17 00:00:00 2001 From: David Anderson Date: Tue, 3 Jul 2007 19:03:14 +0000 Subject: [PATCH] added request amb515 --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401039 --- core/smn_player.cpp | 24 ++++++++++++++++++++++++ plugins/include/clients.inc | 12 ++++++++++++ 2 files changed, 36 insertions(+) diff --git a/core/smn_player.cpp b/core/smn_player.cpp index 494e8add..43bfdc98 100644 --- a/core/smn_player.cpp +++ b/core/smn_player.cpp @@ -973,10 +973,34 @@ static cell_t KickClient(IPluginContext *pContext, const cell_t *params) return 1; } +static cell_t ChangeClientTeam(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->IsInGame()) { + return pContext->ThrowNativeError("Client %d is not in game", client); + } + + IPlayerInfo *pInfo = pPlayer->GetPlayerInfo(); + if (!pInfo) + { + return pContext->ThrowNativeError("IPlayerInfo not supported by game"); + } + + pInfo->ChangeTeam(params[2]); + + return 1; +} + REGISTER_NATIVES(playernatives) { {"AddUserFlags", AddUserFlags}, {"CanUserTarget", CanUserTarget}, + {"ChangeClientTeam", ChangeClientTeam}, {"GetClientAuthString", sm_GetClientAuthStr}, {"GetClientCount", sm_GetClientCount}, {"GetClientInfo", sm_GetClientInfo}, diff --git a/plugins/include/clients.inc b/plugins/include/clients.inc index df81bafa..f168344e 100644 --- a/plugins/include/clients.inc +++ b/plugins/include/clients.inc @@ -514,3 +514,15 @@ native GetClientOfUserId(userid); * @error Invalid client index, or client not connected. */ native KickClient(client, const String:format[]="", any:...); + +/** + * Changes a client's team through the mod's generic team changing function. + * On CS:S, this will kill the player. + * + * @param client Client index. + * @param team Mod-specific team index. + * @noreturn + * @error Invalid client index, client not connected, or lack of + * mod support. + */ +native ChangeClientTeam(client, team);