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