1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/plugins/basecomm/natives.sp Wed Jul 06 22:34:21 2011 -0400
1.3 @@ -0,0 +1,138 @@
1.4 +/**
1.5 + * vim: set ts=4 :
1.6 + * =============================================================================
1.7 + * SourceMod Basecomm
1.8 + * Part of Basecomm plugin, menu and other functionality.
1.9 + *
1.10 + * SourceMod (C)2004-2011 AlliedModders LLC. All rights reserved.
1.11 + * =============================================================================
1.12 + *
1.13 + * This program is free software; you can redistribute it and/or modify it under
1.14 + * the terms of the GNU General Public License, version 3.0, as published by the
1.15 + * Free Software Foundation.
1.16 + *
1.17 + * This program is distributed in the hope that it will be useful, but WITHOUT
1.18 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.19 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1.20 + * details.
1.21 + *
1.22 + * You should have received a copy of the GNU General Public License along with
1.23 + * this program. If not, see <http://www.gnu.org/licenses/>.
1.24 + *
1.25 + * As a special exception, AlliedModders LLC gives you permission to link the
1.26 + * code of this program (as well as its derivative works) to "Half-Life 2," the
1.27 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
1.28 + * by the Valve Corporation. You must obey the GNU General Public License in
1.29 + * all respects for all other code used. Additionally, AlliedModders LLC grants
1.30 + * this exception to all derivative works. AlliedModders LLC defines further
1.31 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
1.32 + * or <http://www.sourcemod.net/license.php>.
1.33 + *
1.34 + * Version: $Id$
1.35 + */
1.36 +
1.37 + public Native_IsClientGagged(Handle:hPlugin, numParams)
1.38 +{
1.39 + new client = GetNativeCell(1);
1.40 + if (client < 1 || client > MaxClients)
1.41 + {
1.42 + return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index %d", client);
1.43 + }
1.44 +
1.45 + if (!IsClientInGame(client))
1.46 + {
1.47 + return ThrowNativeError(SP_ERROR_NATIVE, "Client %d is not in game", client);
1.48 + }
1.49 +
1.50 + return g_Gagged[client];
1.51 +}
1.52 +
1.53 +public Native_IsClientMuted(Handle:hPlugin, numParams)
1.54 +{
1.55 + new client = GetNativeCell(1);
1.56 + if (client < 1 || client > MaxClients)
1.57 + {
1.58 + return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index %d", client);
1.59 + }
1.60 +
1.61 + if (!IsClientInGame(client))
1.62 + {
1.63 + return ThrowNativeError(SP_ERROR_NATIVE, "Client %d is not in game", client);
1.64 + }
1.65 +
1.66 + return g_Muted[client];
1.67 +}
1.68 +
1.69 +public Native_SetClientGag(Handle:hPlugin, numParams)
1.70 +{
1.71 + new client = GetNativeCell(1);
1.72 + if (client < 1 || client > MaxClients)
1.73 + {
1.74 + return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index %d", client);
1.75 + }
1.76 +
1.77 + if (!IsClientInGame(client))
1.78 + {
1.79 + return ThrowNativeError(SP_ERROR_NATIVE, "Client %d is not in game", client);
1.80 + }
1.81 +
1.82 + new bool:gagState = GetNativeCell(2);
1.83 +
1.84 + if (gagState)
1.85 + {
1.86 + if (g_Gagged[client])
1.87 + {
1.88 + return false;
1.89 + }
1.90 +
1.91 + PerformGag(-1, client, true);
1.92 + }
1.93 + else
1.94 + {
1.95 + if (!g_Gagged[client])
1.96 + {
1.97 + return false;
1.98 + }
1.99 +
1.100 + PerformUnGag(-1, client, true);
1.101 + }
1.102 +
1.103 + return true;
1.104 +}
1.105 +
1.106 +public Native_SetClientMute(Handle:hPlugin, numParams)
1.107 +{
1.108 + new client = GetNativeCell(1);
1.109 + if (client < 1 || client > MaxClients)
1.110 + {
1.111 + return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index %d", client);
1.112 + }
1.113 +
1.114 + if (!IsClientInGame(client))
1.115 + {
1.116 + return ThrowNativeError(SP_ERROR_NATIVE, "Client %d is not in game", client);
1.117 + }
1.118 +
1.119 + new bool:muteState = GetNativeCell(2);
1.120 +
1.121 + if (muteState)
1.122 + {
1.123 + if (g_Muted[client])
1.124 + {
1.125 + return false;
1.126 + }
1.127 +
1.128 + PerformMute(-1, client, true);
1.129 + }
1.130 + else
1.131 + {
1.132 + if (!g_Muted[client])
1.133 + {
1.134 + return false;
1.135 + }
1.136 +
1.137 + PerformUnMute(-1, client, true);
1.138 + }
1.139 +
1.140 + return true;
1.141 +}