plugins/basecomm/natives.sp
author Ruben Gonzalez <drifter01620@gmail.com>
Thu May 22 09:49:27 2014 -0400 (2014-05-22)
changeset 4378 568f4497ef4a
parent 3340 7eb2b72e42d8
permissions -rw-r--r--
Update CS:GO team score gamedata.
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod Basecomm
     5  * Part of Basecomm plugin, menu and other functionality.
     6  *
     7  * SourceMod (C)2004-2011 AlliedModders LLC.  All rights reserved.
     8  * =============================================================================
     9  *
    10  * This program is free software; you can redistribute it and/or modify it under
    11  * the terms of the GNU General Public License, version 3.0, as published by the
    12  * Free Software Foundation.
    13  * 
    14  * This program is distributed in the hope that it will be useful, but WITHOUT
    15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    16  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    17  * details.
    18  *
    19  * You should have received a copy of the GNU General Public License along with
    20  * this program.  If not, see <http://www.gnu.org/licenses/>.
    21  *
    22  * As a special exception, AlliedModders LLC gives you permission to link the
    23  * code of this program (as well as its derivative works) to "Half-Life 2," the
    24  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    25  * by the Valve Corporation.  You must obey the GNU General Public License in
    26  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    27  * this exception to all derivative works.  AlliedModders LLC defines further
    28  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    29  * or <http://www.sourcemod.net/license.php>.
    30  *
    31  * Version: $Id$
    32  */
    33  
    34  public Native_IsClientGagged(Handle:hPlugin, numParams)
    35 {
    36 	new client = GetNativeCell(1);
    37 	if (client < 1 || client > MaxClients)
    38 	{
    39 		return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index %d", client);
    40 	}
    41 	
    42 	if (!IsClientInGame(client))
    43 	{
    44 		return ThrowNativeError(SP_ERROR_NATIVE, "Client %d is not in game", client);
    45 	}
    46 	
    47 	return g_Gagged[client];
    48 }
    49 
    50 public Native_IsClientMuted(Handle:hPlugin, numParams)
    51 {
    52 	new client = GetNativeCell(1);
    53 	if (client < 1 || client > MaxClients)
    54 	{
    55 		return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index %d", client);
    56 	}
    57 	
    58 	if (!IsClientInGame(client))
    59 	{
    60 		return ThrowNativeError(SP_ERROR_NATIVE, "Client %d is not in game", client);
    61 	}
    62 	
    63 	return g_Muted[client];
    64 }
    65 
    66 public Native_SetClientGag(Handle:hPlugin, numParams)
    67 {
    68 	new client = GetNativeCell(1);
    69 	if (client < 1 || client > MaxClients)
    70 	{
    71 		return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index %d", client);
    72 	}
    73 	
    74 	if (!IsClientInGame(client))
    75 	{
    76 		return ThrowNativeError(SP_ERROR_NATIVE, "Client %d is not in game", client);
    77 	}
    78 	
    79 	new bool:gagState = GetNativeCell(2);
    80 	
    81 	if (gagState)
    82 	{
    83 		if (g_Gagged[client])
    84 		{
    85 			return false;
    86 		}
    87 		
    88 		PerformGag(-1, client, true);
    89 	}
    90 	else
    91 	{
    92 		if (!g_Gagged[client])
    93 		{
    94 			return false;
    95 		}
    96 		
    97 		PerformUnGag(-1, client, true);
    98 	}
    99 	
   100 	return true;
   101 }
   102 
   103 public Native_SetClientMute(Handle:hPlugin, numParams)
   104 {
   105 	new client = GetNativeCell(1);
   106 	if (client < 1 || client > MaxClients)
   107 	{
   108 		return ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index %d", client);
   109 	}
   110 	
   111 	if (!IsClientInGame(client))
   112 	{
   113 		return ThrowNativeError(SP_ERROR_NATIVE, "Client %d is not in game", client);
   114 	}
   115 	
   116 	new bool:muteState = GetNativeCell(2);
   117 	
   118 	if (muteState)
   119 	{
   120 		if (g_Muted[client])
   121 		{
   122 			return false;
   123 		}
   124 		
   125 		PerformMute(-1, client, true);
   126 	}
   127 	else
   128 	{
   129 		if (!g_Muted[client])
   130 		{
   131 			return false;
   132 		}
   133 		
   134 		PerformUnMute(-1, client, true);
   135 	}
   136 	
   137 	return true;
   138 }