core/smn_player.cpp
author David Anderson <dvander@alliedmods.net>
Sun Jun 17 18:48:46 2007 +0000 (2007-06-17)
changeset 972 63d848bccec5
parent 924 330f478a2d1d
child 992 77133031b0d2
permissions -rw-r--r--
fixed bug amb401
dvander@370
     1
/**
ds@653
     2
 * vim: set ts=4 :
dvander@370
     3
 * ===============================================================
dvander@370
     4
 * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
dvander@370
     5
 * ===============================================================
dvander@370
     6
 *
dvander@370
     7
 * This file is not open source and may not be copied without explicit
dvander@370
     8
 * written permission of AlliedModders LLC.  This file may not be redistributed 
dvander@370
     9
 * in whole or significant part.
dvander@370
    10
 * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
dvander@370
    11
 *
dvander@370
    12
 * Version: $Id$
dvander@370
    13
 */
dvander@370
    14
dvander@591
    15
#include "PlayerManager.h"
dvander@458
    16
#include "AdminCache.h"
faluco@280
    17
#include "sm_stringutil.h"
dvander@910
    18
#include "HalfLife2.h"
dvander@910
    19
#include "sourcemod.h"
faluco@682
    20
#include <inetchannelinfo.h>
dvander@924
    21
#include "ChatTriggers.h"
faluco@242
    22
dvander@923
    23
ConVar sm_show_activity("sm_show_activity", "13", FCVAR_SPONLY|FCVAR_PROTECTED, "Activity display setting (see sourcemod.cfg)");
dvander@910
    24
faluco@260
    25
static cell_t sm_GetClientCount(IPluginContext *pCtx, const cell_t *params)
faluco@242
    26
{
faluco@242
    27
	if (params[1])
faluco@242
    28
	{
dvander@448
    29
		return g_Players.NumPlayers();
faluco@242
    30
	}
faluco@242
    31
dvander@448
    32
	int maxplayers = g_Players.MaxClients();
faluco@242
    33
	int count = 0;
faluco@242
    34
	for (int i=1; i<=maxplayers; ++i)
faluco@242
    35
	{
dvander@448
    36
		CPlayer *pPlayer = g_Players.GetPlayerByIndex(i);
dvander@435
    37
		if ((pPlayer->IsConnected()) && !(pPlayer->IsInGame()))
faluco@242
    38
		{
faluco@242
    39
			count++;
faluco@242
    40
		}
faluco@242
    41
	}
faluco@242
    42
dvander@448
    43
	return (g_Players.NumPlayers() + count);
faluco@242
    44
}
faluco@242
    45
faluco@260
    46
static cell_t sm_GetMaxClients(IPluginContext *pCtx, const cell_t *params)
faluco@242
    47
{
dvander@448
    48
	return g_Players.MaxClients();
faluco@242
    49
}
faluco@242
    50
faluco@260
    51
static cell_t sm_GetClientName(IPluginContext *pCtx, const cell_t *params)
faluco@242
    52
{
faluco@242
    53
	int index = params[1];
dvander@448
    54
	if ((index < 1) || (index > g_Players.GetMaxClients()))
faluco@242
    55
	{
ds@470
    56
		return pCtx->ThrowNativeError("Invalid client index %d", index);
faluco@242
    57
	}
faluco@242
    58
dvander@448
    59
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(index);
dvander@435
    60
	if (!pPlayer->IsConnected())
faluco@260
    61
	{
ds@470
    62
		return pCtx->ThrowNativeError("Client %d is not connected", index);
faluco@260
    63
	}
faluco@260
    64
dvander@435
    65
	pCtx->StringToLocalUTF8(params[2], static_cast<size_t>(params[3]), pPlayer->GetName(), NULL);
faluco@242
    66
	return 1;
faluco@242
    67
}
faluco@242
    68
faluco@260
    69
static cell_t sm_GetClientIP(IPluginContext *pCtx, const cell_t *params)
faluco@242
    70
{
faluco@242
    71
	int index = params[1];
dvander@448
    72
	if ((index < 1) || (index > g_Players.GetMaxClients()))
faluco@242
    73
	{
ds@470
    74
		return pCtx->ThrowNativeError("Invalid client index %d", index);
faluco@242
    75
	}
faluco@242
    76
dvander@448
    77
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(index);
dvander@435
    78
	if (!pPlayer->IsConnected())
faluco@260
    79
	{
ds@470
    80
		return pCtx->ThrowNativeError("Client %d is not connected", index);
faluco@260
    81
	}
faluco@260
    82
faluco@280
    83
	char buf[64], *ptr;
dvander@435
    84
	strcpy(buf, pPlayer->GetIPAddress());
faluco@280
    85
faluco@280
    86
	if (params[4] && (ptr = strchr(buf, ':')))
faluco@280
    87
	{
faluco@280
    88
		*ptr = '\0';
faluco@280
    89
	}
faluco@280
    90
faluco@280
    91
	pCtx->StringToLocal(params[2], static_cast<size_t>(params[3]), buf);
faluco@242
    92
	return 1;
faluco@242
    93
}
faluco@242
    94
faluco@260
    95
static cell_t sm_GetClientAuthStr(IPluginContext *pCtx, const cell_t *params)
faluco@242
    96
{
faluco@242
    97
	int index = params[1];
dvander@448
    98
	if ((index < 1) || (index > g_Players.GetMaxClients()))
faluco@242
    99
	{
ds@470
   100
		return pCtx->ThrowNativeError("Invalid client index %d", index);
faluco@242
   101
	}
faluco@242
   102
dvander@448
   103
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(index);
dvander@435
   104
	if (!pPlayer->IsConnected())
faluco@260
   105
	{
ds@470
   106
		return pCtx->ThrowNativeError("Client %d is not connected", index);
faluco@260
   107
	}
faluco@260
   108
dvander@449
   109
	if (!pPlayer->IsAuthorized())
dvander@449
   110
	{
dvander@449
   111
		return 0;
dvander@449
   112
	}
dvander@449
   113
dvander@435
   114
	pCtx->StringToLocal(params[2], static_cast<size_t>(params[3]), pPlayer->GetAuthString());
dvander@449
   115
faluco@242
   116
	return 1;
faluco@242
   117
}
faluco@242
   118
ds@784
   119
static cell_t sm_IsClientConnected(IPluginContext *pCtx, const cell_t *params)
faluco@242
   120
{
faluco@242
   121
	int index = params[1];
dvander@448
   122
	if ((index < 1) || (index > g_Players.GetMaxClients()))
faluco@242
   123
	{
ds@470
   124
		return pCtx->ThrowNativeError("Invalid client index %d", index);
faluco@242
   125
	}
faluco@242
   126
dvander@448
   127
	return (g_Players.GetPlayerByIndex(index)->IsConnected()) ? 1 : 0;
faluco@242
   128
}
faluco@242
   129
ds@784
   130
static cell_t sm_IsClientInGame(IPluginContext *pCtx, const cell_t *params)
faluco@242
   131
{
faluco@242
   132
	int index = params[1];
dvander@448
   133
	if ((index < 1) || (index > g_Players.GetMaxClients()))
faluco@242
   134
	{
ds@470
   135
		return pCtx->ThrowNativeError("Invalid client index %d", index);
faluco@242
   136
	}
faluco@242
   137
dvander@448
   138
	return (g_Players.GetPlayerByIndex(index)->IsInGame()) ? 1 : 0;
faluco@242
   139
}
faluco@242
   140
ds@784
   141
static cell_t sm_IsClientAuthorized(IPluginContext *pCtx, const cell_t *params)
faluco@242
   142
{
faluco@242
   143
	int index = params[1];
dvander@448
   144
	if ((index < 1) || (index > g_Players.GetMaxClients()))
faluco@242
   145
	{
ds@470
   146
		return pCtx->ThrowNativeError("Invalid client index %d", index);
faluco@242
   147
	}
faluco@242
   148
dvander@448
   149
	return (g_Players.GetPlayerByIndex(index)->IsAuthorized()) ? 1 : 0;
faluco@242
   150
}
faluco@242
   151
ds@784
   152
static cell_t sm_IsClientFakeClient(IPluginContext *pCtx, const cell_t *params)
faluco@242
   153
{
faluco@242
   154
	int index = params[1];
dvander@448
   155
	if ((index < 1) || (index > g_Players.GetMaxClients()))
faluco@242
   156
	{
ds@470
   157
		return pCtx->ThrowNativeError("Invalid client index %d", index);
faluco@260
   158
	}
faluco@260
   159
dvander@448
   160
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(index);
dvander@435
   161
	if (!pPlayer->IsConnected())
faluco@260
   162
	{
ds@470
   163
		return pCtx->ThrowNativeError("Client %d is not connected", index);
faluco@242
   164
	}
faluco@242
   165
dvander@435
   166
	return (pPlayer->IsFakeClient()) ? 1 : 0;
faluco@260
   167
}
faluco@260
   168
dvander@456
   169
static cell_t sm_GetClientInfo(IPluginContext *pContext, const cell_t *params)
dvander@456
   170
{
dvander@456
   171
	int client = params[1];
dvander@456
   172
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
dvander@456
   173
	if (!pPlayer)
dvander@456
   174
	{
ds@470
   175
		return pContext->ThrowNativeError("Invalid client index %d", client);
dvander@456
   176
	}
dvander@456
   177
	if (!pPlayer->IsConnected())
dvander@456
   178
	{
ds@470
   179
		return pContext->ThrowNativeError("Client %d is not connected", client);
dvander@456
   180
	}
dvander@456
   181
dvander@456
   182
	char *key;
dvander@456
   183
	pContext->LocalToString(params[2], &key);
dvander@456
   184
dvander@456
   185
	const char *val = engine->GetClientConVarValue(client, key);
dvander@456
   186
	if (!val)
dvander@456
   187
	{
dvander@456
   188
		return false;
dvander@456
   189
	}
dvander@456
   190
dvander@456
   191
	pContext->StringToLocalUTF8(params[3], params[4], val, NULL);
dvander@456
   192
	return 1;
dvander@456
   193
}
dvander@456
   194
dvander@458
   195
static cell_t SetUserAdmin(IPluginContext *pContext, const cell_t *params)
dvander@458
   196
{
dvander@458
   197
	int client = params[1];
dvander@458
   198
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
dvander@458
   199
	if (!pPlayer)
dvander@458
   200
	{
ds@470
   201
		return pContext->ThrowNativeError("Invalid client index %d", client);
dvander@458
   202
	}
dvander@458
   203
	if (!pPlayer->IsConnected())
dvander@458
   204
	{
ds@470
   205
		return pContext->ThrowNativeError("Client %d is not connected", client);
dvander@458
   206
	}
dvander@458
   207
	if (!g_Admins.IsValidAdmin(params[2]))
dvander@458
   208
	{
ds@470
   209
		return pContext->ThrowNativeError("AdminId %x is not valid", params[2]);
dvander@458
   210
	}
dvander@458
   211
dvander@458
   212
	pPlayer->SetAdminId(params[2], params[3] ? true : false);
dvander@458
   213
dvander@458
   214
	return 1;
dvander@458
   215
}
dvander@458
   216
dvander@458
   217
static cell_t GetUserAdmin(IPluginContext *pContext, const cell_t *params)
dvander@458
   218
{
dvander@458
   219
	int client = params[1];
dvander@458
   220
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
dvander@458
   221
	if (!pPlayer)
dvander@458
   222
	{
ds@470
   223
		return pContext->ThrowNativeError("Invalid client index %d", client);
dvander@458
   224
	}
dvander@458
   225
	if (!pPlayer->IsConnected())
dvander@458
   226
	{
ds@470
   227
		return pContext->ThrowNativeError("Client %d is not connected", client);
dvander@458
   228
	}
dvander@458
   229
dvander@458
   230
	return pPlayer->GetAdminId();
dvander@458
   231
}
dvander@458
   232
dvander@458
   233
static cell_t AddUserFlags(IPluginContext *pContext, const cell_t *params)
dvander@458
   234
{
dvander@458
   235
	int client = params[1];
dvander@458
   236
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
dvander@458
   237
	if (!pPlayer)
dvander@458
   238
	{
ds@470
   239
		return pContext->ThrowNativeError("Invalid client index %d", client);
dvander@458
   240
	}
dvander@458
   241
	if (!pPlayer->IsConnected())
dvander@458
   242
	{
ds@470
   243
		return pContext->ThrowNativeError("Client %d is not connected", client);
dvander@458
   244
	}
dvander@458
   245
dvander@458
   246
	AdminId id;
dvander@458
   247
	if ((id=pPlayer->GetAdminId()) == INVALID_ADMIN_ID)
dvander@458
   248
	{
dvander@458
   249
		id = g_Admins.CreateAdmin(NULL);
dvander@458
   250
		pPlayer->SetAdminId(id, true);
dvander@458
   251
	}
dvander@458
   252
dvander@458
   253
	cell_t *addr;
dvander@458
   254
	for (int i=2; i<=params[0]; i++)
dvander@458
   255
	{
dvander@458
   256
		pContext->LocalToPhysAddr(params[i], &addr);
dvander@458
   257
		g_Admins.SetAdminFlag(id, (AdminFlag)*addr, true);
dvander@458
   258
	}
dvander@458
   259
dvander@458
   260
	return 1;
dvander@458
   261
}
dvander@458
   262
dvander@458
   263
static cell_t RemoveUserFlags(IPluginContext *pContext, const cell_t *params)
dvander@458
   264
{
dvander@458
   265
	int client = params[1];
dvander@458
   266
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
dvander@458
   267
	if (!pPlayer)
dvander@458
   268
	{
ds@470
   269
		return pContext->ThrowNativeError("Invalid client index %d", client);
dvander@458
   270
	}
dvander@458
   271
	if (!pPlayer->IsConnected())
dvander@458
   272
	{
ds@470
   273
		return pContext->ThrowNativeError("Client %d is not connected", client);
dvander@458
   274
	}
dvander@458
   275
	
dvander@458
   276
	AdminId id;
dvander@458
   277
	if ((id=pPlayer->GetAdminId()) == INVALID_ADMIN_ID)
dvander@458
   278
	{
dvander@458
   279
		return 0;
dvander@458
   280
	}
dvander@458
   281
dvander@458
   282
	cell_t *addr;
dvander@458
   283
	for (int i=2; i<=params[0]; i++)
dvander@458
   284
	{
dvander@458
   285
		pContext->LocalToPhysAddr(params[i], &addr);
dvander@458
   286
		g_Admins.SetAdminFlag(id, (AdminFlag)*addr, false);
dvander@458
   287
	}
dvander@458
   288
dvander@458
   289
	return 1;
dvander@458
   290
}
dvander@458
   291
dvander@458
   292
static cell_t SetUserFlagBits(IPluginContext *pContext, const cell_t *params)
dvander@458
   293
{
dvander@458
   294
	int client = params[1];
dvander@458
   295
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
dvander@458
   296
	if (!pPlayer)
dvander@458
   297
	{
ds@470
   298
		return pContext->ThrowNativeError("Invalid client index %d", client);
dvander@458
   299
	}
dvander@458
   300
	if (!pPlayer->IsConnected())
dvander@458
   301
	{
ds@470
   302
		return pContext->ThrowNativeError("Client %d is not connected", client);
dvander@458
   303
	}
dvander@458
   304
dvander@458
   305
	AdminId id;
dvander@458
   306
	if ((id=pPlayer->GetAdminId()) == INVALID_ADMIN_ID)
dvander@458
   307
	{
dvander@458
   308
		id = g_Admins.CreateAdmin(NULL);
dvander@458
   309
		pPlayer->SetAdminId(id, true);
dvander@458
   310
	}
dvander@458
   311
dvander@458
   312
	g_Admins.SetAdminFlags(id, Access_Effective, params[2]);
dvander@458
   313
dvander@458
   314
	return 1;
dvander@458
   315
}
dvander@458
   316
dvander@458
   317
static cell_t GetUserFlagBits(IPluginContext *pContext, const cell_t *params)
dvander@458
   318
{
dvander@458
   319
	int client = params[1];
dvander@458
   320
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
dvander@458
   321
	if (!pPlayer)
dvander@458
   322
	{
ds@470
   323
		return pContext->ThrowNativeError("Invalid client index %d", client);
dvander@458
   324
	}
dvander@458
   325
	if (!pPlayer->IsConnected())
dvander@458
   326
	{
ds@470
   327
		return pContext->ThrowNativeError("Client %d is not connected", client);
dvander@458
   328
	}
dvander@458
   329
dvander@458
   330
	AdminId id;
dvander@458
   331
	if ((id=pPlayer->GetAdminId()) == INVALID_ADMIN_ID)
dvander@458
   332
	{
dvander@458
   333
		return 0;
dvander@458
   334
	}
dvander@458
   335
dvander@458
   336
	return g_Admins.GetAdminFlags(id, Access_Effective);
dvander@458
   337
}
dvander@458
   338
dvander@460
   339
static cell_t GetClientUserId(IPluginContext *pContext, const cell_t *params)
dvander@460
   340
{
dvander@460
   341
	int client = params[1];
dvander@460
   342
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
dvander@460
   343
	if (!pPlayer)
dvander@460
   344
	{
ds@470
   345
		return pContext->ThrowNativeError("Invalid client index %d", client);
dvander@460
   346
	}
dvander@460
   347
	if (!pPlayer->IsConnected())
dvander@460
   348
	{
ds@470
   349
		return pContext->ThrowNativeError("Client %d is not connected", client);
dvander@460
   350
	}
dvander@460
   351
dvander@460
   352
	return engine->GetPlayerUserId(pPlayer->GetEdict());
dvander@460
   353
}
dvander@460
   354
dvander@540
   355
static cell_t CanUserTarget(IPluginContext *pContext, const cell_t *params)
dvander@540
   356
{
dvander@540
   357
	int client = params[1];
dvander@540
   358
	int target = params[2];
dvander@540
   359
dvander@540
   360
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
dvander@540
   361
	if (!pPlayer)
dvander@540
   362
	{
dvander@540
   363
		return pContext->ThrowNativeError("Player %d is not a valid client", client);
dvander@540
   364
	} else if (!pPlayer->IsConnected()) {
dvander@540
   365
		return pContext->ThrowNativeError("Player %d is not connected", client);
dvander@540
   366
	}
dvander@540
   367
dvander@540
   368
	CPlayer *pTarget = g_Players.GetPlayerByIndex(target);
dvander@540
   369
	if (!pTarget)
dvander@540
   370
	{
dvander@540
   371
		return pContext->ThrowNativeError("Player %d is not a valid client", target);
dvander@540
   372
	} else if (!pTarget->IsConnected()) {
dvander@540
   373
		return pContext->ThrowNativeError("Player %d is not connected", target);
dvander@540
   374
	}
dvander@540
   375
dvander@540
   376
	return g_Admins.CanAdminTarget(pPlayer->GetAdminId(), pTarget->GetAdminId()) ? 1 : 0;
dvander@540
   377
}
dvander@540
   378
dvander@644
   379
static cell_t GetClientTeam(IPluginContext *pContext, const cell_t *params)
dvander@644
   380
{
dvander@644
   381
	int client = params[1];
dvander@644
   382
dvander@644
   383
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
dvander@644
   384
	if (!pPlayer)
dvander@644
   385
	{
dvander@644
   386
		return pContext->ThrowNativeError("Player %d is not a valid client", client);
dvander@644
   387
	} else if (!pPlayer->IsInGame()) {
dvander@644
   388
		return pContext->ThrowNativeError("Player %d is not in game", client);
dvander@644
   389
	}
dvander@644
   390
dvander@644
   391
	IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
dvander@644
   392
	if (!pInfo)
dvander@644
   393
	{
dvander@644
   394
		return pContext->ThrowNativeError("IPlayerInfo not supported by game");
dvander@644
   395
	}
dvander@644
   396
dvander@644
   397
	return pInfo->GetTeamIndex();
dvander@644
   398
}
dvander@644
   399
faluco@658
   400
static cell_t GetFragCount(IPluginContext *pContext, const cell_t *params)
faluco@658
   401
{
faluco@658
   402
	int client = params[1];
faluco@658
   403
faluco@658
   404
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
faluco@658
   405
	if (!pPlayer)
faluco@658
   406
	{
faluco@658
   407
		return pContext->ThrowNativeError("Player %d is not a valid client", client);
faluco@658
   408
	} else if (!pPlayer->IsInGame()) {
faluco@658
   409
		return pContext->ThrowNativeError("Player %d is not in game", client);
faluco@658
   410
	}
faluco@658
   411
faluco@658
   412
	IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
faluco@658
   413
	if (!pInfo)
faluco@658
   414
	{
faluco@658
   415
		return pContext->ThrowNativeError("IPlayerInfo not supported by game");
faluco@658
   416
	}
faluco@658
   417
faluco@658
   418
	return pInfo->GetFragCount();
faluco@658
   419
}
faluco@658
   420
faluco@658
   421
static cell_t GetDeathCount(IPluginContext *pContext, const cell_t *params)
faluco@658
   422
{
faluco@658
   423
	int client = params[1];
faluco@658
   424
faluco@658
   425
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
faluco@658
   426
	if (!pPlayer)
faluco@658
   427
	{
faluco@658
   428
		return pContext->ThrowNativeError("Player %d is not a valid client", client);
faluco@658
   429
	} else if (!pPlayer->IsInGame()) {
faluco@658
   430
		return pContext->ThrowNativeError("Player %d is not in game", client);
faluco@658
   431
	}
faluco@658
   432
faluco@658
   433
	IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
faluco@658
   434
	if (!pInfo)
faluco@658
   435
	{
faluco@658
   436
		return pContext->ThrowNativeError("IPlayerInfo not supported by game");
faluco@658
   437
	}
faluco@658
   438
faluco@658
   439
	return pInfo->GetDeathCount();
faluco@658
   440
}
faluco@658
   441
faluco@658
   442
static cell_t GetArmorValue(IPluginContext *pContext, const cell_t *params)
faluco@658
   443
{
faluco@658
   444
	int client = params[1];
faluco@658
   445
faluco@658
   446
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
faluco@658
   447
	if (!pPlayer)
faluco@658
   448
	{
faluco@658
   449
		return pContext->ThrowNativeError("Player %d is not a valid client", client);
faluco@658
   450
	} else if (!pPlayer->IsInGame()) {
faluco@658
   451
		return pContext->ThrowNativeError("Player %d is not in game", client);
faluco@658
   452
	}
faluco@658
   453
faluco@658
   454
	IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
faluco@658
   455
	if (!pInfo)
faluco@658
   456
	{
faluco@658
   457
		return pContext->ThrowNativeError("IPlayerInfo not supported by game");
faluco@658
   458
	}
faluco@658
   459
faluco@658
   460
	return pInfo->GetArmorValue();
faluco@658
   461
}
faluco@658
   462
faluco@658
   463
static cell_t GetAbsOrigin(IPluginContext *pContext, const cell_t *params)
faluco@658
   464
{
faluco@658
   465
	int client = params[1];
faluco@658
   466
faluco@658
   467
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
faluco@658
   468
	if (!pPlayer)
faluco@658
   469
	{
faluco@658
   470
		return pContext->ThrowNativeError("Player %d is not a valid client", client);
faluco@658
   471
	} else if (!pPlayer->IsInGame()) {
faluco@658
   472
		return pContext->ThrowNativeError("Player %d is not in game", client);
faluco@658
   473
	}
faluco@658
   474
faluco@658
   475
	IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
faluco@658
   476
	if (!pInfo)
faluco@658
   477
	{
faluco@658
   478
		return pContext->ThrowNativeError("IPlayerInfo not supported by game");
faluco@658
   479
	}
faluco@658
   480
faluco@658
   481
	cell_t *pVec;
faluco@658
   482
	pContext->LocalToPhysAddr(params[2], &pVec);
faluco@658
   483
faluco@658
   484
	Vector vec = pInfo->GetAbsOrigin();
faluco@658
   485
	pVec[0] = sp_ftoc(vec.x);
faluco@658
   486
	pVec[1] = sp_ftoc(vec.y);
faluco@658
   487
	pVec[2] = sp_ftoc(vec.z);
faluco@658
   488
faluco@658
   489
	return 1;
faluco@658
   490
}
faluco@658
   491
faluco@658
   492
static cell_t GetAbsAngles(IPluginContext *pContext, const cell_t *params)
faluco@658
   493
{
faluco@658
   494
	int client = params[1];
faluco@658
   495
faluco@658
   496
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
faluco@658
   497
	if (!pPlayer)
faluco@658
   498
	{
faluco@658
   499
		return pContext->ThrowNativeError("Player %d is not a valid client", client);
faluco@658
   500
	} else if (!pPlayer->IsInGame()) {
faluco@658
   501
		return pContext->ThrowNativeError("Player %d is not in game", client);
faluco@658
   502
	}
faluco@658
   503
faluco@658
   504
	IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
faluco@658
   505
	if (!pInfo)
faluco@658
   506
	{
faluco@658
   507
		return pContext->ThrowNativeError("IPlayerInfo not supported by game");
faluco@658
   508
	}
faluco@658
   509
faluco@658
   510
	cell_t *pAng;
faluco@658
   511
	pContext->LocalToPhysAddr(params[2], &pAng);
faluco@658
   512
faluco@658
   513
	QAngle ang = pInfo->GetAbsAngles();
faluco@658
   514
	pAng[0] = sp_ftoc(ang.x);
faluco@658
   515
	pAng[1] = sp_ftoc(ang.y);
faluco@658
   516
	pAng[2] = sp_ftoc(ang.z);
faluco@658
   517
faluco@658
   518
	return 1;
faluco@658
   519
}
faluco@658
   520
faluco@658
   521
static cell_t GetPlayerMins(IPluginContext *pContext, const cell_t *params)
faluco@658
   522
{
faluco@658
   523
	int client = params[1];
faluco@658
   524
faluco@658
   525
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
faluco@658
   526
	if (!pPlayer)
faluco@658
   527
	{
faluco@658
   528
		return pContext->ThrowNativeError("Player %d is not a valid client", client);
faluco@658
   529
	} else if (!pPlayer->IsInGame()) {
faluco@658
   530
		return pContext->ThrowNativeError("Player %d is not in game", client);
faluco@658
   531
	}
faluco@658
   532
faluco@658
   533
	IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
faluco@658
   534
	if (!pInfo)
faluco@658
   535
	{
faluco@658
   536
		return pContext->ThrowNativeError("IPlayerInfo not supported by game");
faluco@658
   537
	}
faluco@658
   538
faluco@658
   539
	cell_t *pVec;
faluco@658
   540
	pContext->LocalToPhysAddr(params[2], &pVec);
faluco@658
   541
faluco@658
   542
	Vector vec = pInfo->GetPlayerMins();
faluco@658
   543
	pVec[0] = sp_ftoc(vec.x);
faluco@658
   544
	pVec[1] = sp_ftoc(vec.y);
faluco@658
   545
	pVec[2] = sp_ftoc(vec.z);
faluco@658
   546
faluco@658
   547
	return 1;
faluco@658
   548
}
faluco@658
   549
faluco@658
   550
static cell_t GetPlayerMaxs(IPluginContext *pContext, const cell_t *params)
faluco@658
   551
{
faluco@658
   552
	int client = params[1];
faluco@658
   553
faluco@658
   554
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
faluco@658
   555
	if (!pPlayer)
faluco@658
   556
	{
faluco@658
   557
		return pContext->ThrowNativeError("Player %d is not a valid client", client);
faluco@658
   558
	} else if (!pPlayer->IsInGame()) {
faluco@658
   559
		return pContext->ThrowNativeError("Player %d is not in game", client);
faluco@658
   560
	}
faluco@658
   561
faluco@658
   562
	IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
faluco@658
   563
	if (!pInfo)
faluco@658
   564
	{
faluco@658
   565
		return pContext->ThrowNativeError("IPlayerInfo not supported by game");
faluco@658
   566
	}
faluco@658
   567
faluco@658
   568
	cell_t *pVec;
faluco@658
   569
	pContext->LocalToPhysAddr(params[2], &pVec);
faluco@658
   570
faluco@658
   571
	Vector vec = pInfo->GetPlayerMaxs();
faluco@658
   572
	pVec[0] = sp_ftoc(vec.x);
faluco@658
   573
	pVec[1] = sp_ftoc(vec.y);
faluco@658
   574
	pVec[2] = sp_ftoc(vec.z);
faluco@658
   575
faluco@658
   576
	return 1;
faluco@658
   577
}
faluco@658
   578
faluco@658
   579
static cell_t GetWeaponName(IPluginContext *pContext, const cell_t *params)
faluco@658
   580
{
faluco@658
   581
	int client = params[1];
faluco@658
   582
faluco@658
   583
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
faluco@658
   584
	if (!pPlayer)
faluco@658
   585
	{
faluco@658
   586
		return pContext->ThrowNativeError("Player %d is not a valid client", client);
faluco@658
   587
	} else if (!pPlayer->IsInGame()) {
faluco@658
   588
		return pContext->ThrowNativeError("Player %d is not in game", client);
faluco@658
   589
	}
faluco@658
   590
faluco@658
   591
	IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
faluco@658
   592
	if (!pInfo)
faluco@658
   593
	{
faluco@658
   594
		return pContext->ThrowNativeError("IPlayerInfo not supported by game");
faluco@658
   595
	}
faluco@658
   596
faluco@756
   597
	const char *weapon = pInfo->GetWeaponName();
faluco@756
   598
	pContext->StringToLocalUTF8(params[2], static_cast<size_t>(params[3]), weapon ? weapon : "", NULL);
faluco@658
   599
faluco@658
   600
	return 1;
faluco@658
   601
}
faluco@658
   602
faluco@658
   603
static cell_t GetModelName(IPluginContext *pContext, const cell_t *params)
faluco@658
   604
{
faluco@658
   605
	int client = params[1];
faluco@658
   606
faluco@658
   607
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
faluco@658
   608
	if (!pPlayer)
faluco@658
   609
	{
faluco@658
   610
		return pContext->ThrowNativeError("Player %d is not a valid client", client);
faluco@658
   611
	} else if (!pPlayer->IsInGame()) {
faluco@658
   612
		return pContext->ThrowNativeError("Player %d is not in game", client);
faluco@658
   613
	}
faluco@658
   614
faluco@658
   615
	IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
faluco@658
   616
	if (!pInfo)
faluco@658
   617
	{
faluco@658
   618
		return pContext->ThrowNativeError("IPlayerInfo not supported by game");
faluco@658
   619
	}
faluco@658
   620
faluco@756
   621
	const char *model = pInfo->GetModelName();
faluco@756
   622
	pContext->StringToLocalUTF8(params[2], static_cast<size_t>(params[3]), model ? model : "", NULL);
faluco@658
   623
faluco@658
   624
	return 1;
faluco@658
   625
}
faluco@658
   626
faluco@658
   627
static cell_t GetHealth(IPluginContext *pContext, const cell_t *params)
faluco@658
   628
{
faluco@658
   629
	int client = params[1];
faluco@658
   630
faluco@658
   631
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
faluco@658
   632
	if (!pPlayer)
faluco@658
   633
	{
faluco@658
   634
		return pContext->ThrowNativeError("Player %d is not a valid client", client);
faluco@658
   635
	} else if (!pPlayer->IsInGame()) {
faluco@658
   636
		return pContext->ThrowNativeError("Player %d is not in game", client);
faluco@658
   637
	}
faluco@658
   638
faluco@658
   639
	IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
faluco@658
   640
	if (!pInfo)
faluco@658
   641
	{
faluco@658
   642
		return pContext->ThrowNativeError("IPlayerInfo not supported by game");
faluco@658
   643
	}
faluco@658
   644
faluco@658
   645
	return pInfo->GetHealth();
faluco@658
   646
}
faluco@658
   647
faluco@682
   648
static cell_t GetTimeConnected(IPluginContext *pContext, const cell_t *params)
faluco@682
   649
{
faluco@682
   650
	int client = params[1];
faluco@682
   651
faluco@682
   652
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
faluco@682
   653
	if (!pPlayer)
faluco@682
   654
	{
faluco@682
   655
		return pContext->ThrowNativeError("Player %d is not a valid client", client);
faluco@682
   656
	} else if (!pPlayer->IsInGame()) {
faluco@682
   657
		return pContext->ThrowNativeError("Player %d is not in game", client);
faluco@682
   658
	} else if (pPlayer->IsFakeClient()) {
faluco@682
   659
		return pContext->ThrowNativeError("Player %d is a bot", client);
faluco@682
   660
	}
faluco@682
   661
faluco@682
   662
	INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
faluco@682
   663
faluco@682
   664
	return sp_ftoc(pInfo->GetTimeConnected());
faluco@682
   665
}
faluco@682
   666
faluco@682
   667
static cell_t GetDataRate(IPluginContext *pContext, const cell_t *params)
faluco@682
   668
{
faluco@682
   669
	int client = params[1];
faluco@682
   670
faluco@682
   671
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
faluco@682
   672
	if (!pPlayer)
faluco@682
   673
	{
faluco@682
   674
		return pContext->ThrowNativeError("Player %d is not a valid client", client);
faluco@682
   675
	} else if (!pPlayer->IsInGame()) {
faluco@682
   676
		return pContext->ThrowNativeError("Player %d is not in game", client);
faluco@682
   677
	} else if (pPlayer->IsFakeClient()) {
faluco@682
   678
		return pContext->ThrowNativeError("Player %d is a bot", client);
faluco@682
   679
	}
faluco@682
   680
faluco@682
   681
	INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
faluco@682
   682
faluco@682
   683
	return pInfo->GetDataRate();
faluco@682
   684
}
faluco@682
   685
faluco@682
   686
static cell_t IsTimingOut(IPluginContext *pContext, const cell_t *params)
faluco@682
   687
{
faluco@682
   688
	int client = params[1];
faluco@682
   689
faluco@682
   690
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
faluco@682
   691
	if (!pPlayer)
faluco@682
   692
	{
faluco@682
   693
		return pContext->ThrowNativeError("Player %d is not a valid client", client);
faluco@682
   694
	} else if (!pPlayer->IsInGame()) {
faluco@682
   695
		return pContext->ThrowNativeError("Player %d is not in game", client);
faluco@682
   696
	} else if (pPlayer->IsFakeClient()) {
faluco@682
   697
		return pContext->ThrowNativeError("Player %d is a bot", client);
faluco@682
   698
	}
faluco@682
   699
faluco@682
   700
	INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
faluco@682
   701
faluco@682
   702
	return pInfo->IsTimingOut() ? 1 : 0;
faluco@682
   703
}
faluco@682
   704
faluco@682
   705
static cell_t GetLatency(IPluginContext *pContext, const cell_t *params)
faluco@682
   706
{
faluco@682
   707
	int client = params[1];
faluco@682
   708
faluco@682
   709
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
faluco@682
   710
	if (!pPlayer)
faluco@682
   711
	{
faluco@682
   712
		return pContext->ThrowNativeError("Player %d is not a valid client", client);
faluco@682
   713
	} else if (!pPlayer->IsInGame()) {
faluco@682
   714
		return pContext->ThrowNativeError("Player %d is not in game", client);
faluco@682
   715
	} else if (pPlayer->IsFakeClient()) {
faluco@682
   716
		return pContext->ThrowNativeError("Player %d is a bot", client);
faluco@682
   717
	}
faluco@682
   718
faluco@682
   719
	INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
faluco@682
   720
faluco@682
   721
	return sp_ftoc(pInfo->GetLatency(params[2]));
faluco@682
   722
}
faluco@682
   723
faluco@682
   724
static cell_t GetAvgLatency(IPluginContext *pContext, const cell_t *params)
faluco@682
   725
{
faluco@682
   726
	int client = params[1];
faluco@682
   727
faluco@682
   728
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
faluco@682
   729
	if (!pPlayer)
faluco@682
   730
	{
faluco@682
   731
		return pContext->ThrowNativeError("Player %d is not a valid client", client);
faluco@682
   732
	} else if (!pPlayer->IsInGame()) {
faluco@682
   733
		return pContext->ThrowNativeError("Player %d is not in game", client);
faluco@682
   734
	} else if (pPlayer->IsFakeClient()) {
faluco@682
   735
		return pContext->ThrowNativeError("Player %d is a bot", client);
faluco@682
   736
	}
faluco@682
   737
faluco@682
   738
	INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
faluco@682
   739
faluco@682
   740
	return sp_ftoc(pInfo->GetAvgLatency(params[2]));
faluco@682
   741
}
faluco@682
   742
faluco@682
   743
static cell_t GetAvgLoss(IPluginContext *pContext, const cell_t *params)
faluco@682
   744
{
faluco@682
   745
	int client = params[1];
faluco@682
   746
faluco@682
   747
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
faluco@682
   748
	if (!pPlayer)
faluco@682
   749
	{
faluco@682
   750
		return pContext->ThrowNativeError("Player %d is not a valid client", client);
faluco@682
   751
	} else if (!pPlayer->IsInGame()) {
faluco@682
   752
		return pContext->ThrowNativeError("Player %d is not in game", client);
faluco@682
   753
	} else if (pPlayer->IsFakeClient()) {
faluco@682
   754
		return pContext->ThrowNativeError("Player %d is a bot", client);
faluco@682
   755
	}
faluco@682
   756
faluco@682
   757
	INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
faluco@682
   758
faluco@682
   759
	return sp_ftoc(pInfo->GetAvgLoss(params[2]));
faluco@682
   760
}
faluco@682
   761
faluco@682
   762
static cell_t GetAvgChoke(IPluginContext *pContext, const cell_t *params)
faluco@682
   763
{
faluco@682
   764
	int client = params[1];
faluco@682
   765
faluco@682
   766
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
faluco@682
   767
	if (!pPlayer)
faluco@682
   768
	{
faluco@682
   769
		return pContext->ThrowNativeError("Player %d is not a valid client", client);
faluco@682
   770
	} else if (!pPlayer->IsInGame()) {
faluco@682
   771
		return pContext->ThrowNativeError("Player %d is not in game", client);
faluco@682
   772
	} else if (pPlayer->IsFakeClient()) {
faluco@682
   773
		return pContext->ThrowNativeError("Player %d is a bot", client);
faluco@682
   774
	}
faluco@682
   775
faluco@682
   776
	INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
faluco@682
   777
faluco@682
   778
	return sp_ftoc(pInfo->GetAvgChoke(params[2]));
faluco@682
   779
}
faluco@682
   780
faluco@682
   781
static cell_t GetAvgData(IPluginContext *pContext, const cell_t *params)
faluco@682
   782
{
faluco@682
   783
	int client = params[1];
faluco@682
   784
faluco@682
   785
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
faluco@682
   786
	if (!pPlayer)
faluco@682
   787
	{
faluco@682
   788
		return pContext->ThrowNativeError("Player %d is not a valid client", client);
faluco@682
   789
	} else if (!pPlayer->IsInGame()) {
faluco@682
   790
		return pContext->ThrowNativeError("Player %d is not in game", client);
faluco@682
   791
	} else if (pPlayer->IsFakeClient()) {
faluco@682
   792
		return pContext->ThrowNativeError("Player %d is a bot", client);
faluco@682
   793
	}
faluco@682
   794
faluco@682
   795
	INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
faluco@682
   796
faluco@682
   797
	return sp_ftoc(pInfo->GetAvgData(params[2]));
faluco@682
   798
}
faluco@682
   799
faluco@682
   800
static cell_t GetAvgPackets(IPluginContext *pContext, const cell_t *params)
faluco@682
   801
{
faluco@682
   802
	int client = params[1];
faluco@682
   803
faluco@682
   804
	CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
faluco@682
   805
	if (!pPlayer)
faluco@682
   806
	{
faluco@682
   807
		return pContext->ThrowNativeError("Player %d is not a valid client", client);
faluco@682
   808
	} else if (!pPlayer->IsInGame()) {
faluco@682
   809
		return pContext->ThrowNativeError("Player %d is not in game", client);
faluco@682
   810
	} else if (pPlayer->IsFakeClient()) {
faluco@682
   811
		return pContext->ThrowNativeError("Player %d is a bot", client);
faluco@682
   812
	}
faluco@682
   813
faluco@682
   814
	INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
faluco@682
   815
faluco@682
   816
	return sp_ftoc(pInfo->GetAvgPackets(params[2]));
faluco@682
   817
}
faluco@682
   818
faluco@682
   819
static cell_t GetClientOfUserId(IPluginContext *pContext, const cell_t *params)
faluco@682
   820
{
faluco@682
   821
	return g_Players.GetClientOfUserId(params[1]);
faluco@682
   822
}
faluco@682
   823
dvander@910
   824
static cell_t ShowActivity(IPluginContext *pContext, const cell_t *params)
dvander@910
   825
{
dvander@924
   826
	char message[255];
dvander@924
   827
	char buffer[255];
dvander@910
   828
	int value = sm_show_activity.GetInt();
dvander@924
   829
	unsigned int replyto = g_ChatTriggers.GetReplyTo();
dvander@910
   830
	int client = params[1];
dvander@910
   831
dvander@910
   832
	const char *name = "Console";
dvander@910
   833
	const char *sign = "ADMIN";
dvander@924
   834
	bool display_in_chat = false;
dvander@910
   835
	if (client != 0)
dvander@910
   836
	{
dvander@910
   837
		CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
dvander@910
   838
		if (!pPlayer || !pPlayer->IsConnected())
dvander@910
   839
		{
dvander@910
   840
			return pContext->ThrowNativeError("Client index %d is invalid", client);
dvander@910
   841
		}
dvander@910
   842
		name = pPlayer->GetName();
dvander@910
   843
		AdminId id = pPlayer->GetAdminId();
dvander@910
   844
		if (id == INVALID_ADMIN_ID
dvander@910
   845
			|| !g_Admins.GetAdminFlag(id, Admin_Generic, Access_Effective))
dvander@910
   846
		{
dvander@910
   847
			sign = "PLAYER";
dvander@910
   848
		}
dvander@924
   849
dvander@924
   850
		/* Display the message to the client? */
dvander@924
   851
		if (replyto == SM_REPLY_CONSOLE)
dvander@924
   852
		{
dvander@924
   853
			g_SourceMod.SetGlobalTarget(client);
dvander@924
   854
			g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
dvander@924
   855
			UTIL_Format(message, sizeof(message), "[SM] %s\n", buffer);
dvander@924
   856
			engine->ClientPrintf(pPlayer->GetEdict(), message);
dvander@924
   857
			display_in_chat = true;
dvander@924
   858
		}
dvander@924
   859
	} else {
dvander@924
   860
		g_SourceMod.SetGlobalTarget(LANG_SERVER);
dvander@924
   861
		g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
dvander@924
   862
		UTIL_Format(message, sizeof(message), "[SM] %s\n", buffer);
dvander@924
   863
		META_CONPRINT(message);
dvander@910
   864
	}
dvander@910
   865
dvander@924
   866
	if (!value)
dvander@924
   867
	{
dvander@924
   868
		return 1;
dvander@924
   869
	}
dvander@924
   870
dvander@910
   871
	int maxClients = g_Players.GetMaxClients();
dvander@910
   872
	for (int i=1; i<=maxClients; i++)
dvander@910
   873
	{
dvander@910
   874
		CPlayer *pPlayer = g_Players.GetPlayerByIndex(i);
dvander@924
   875
		if (!pPlayer->IsInGame() 
dvander@924
   876
			|| pPlayer->IsFakeClient()
dvander@924
   877
			|| (display_in_chat && i == client))
dvander@910
   878
		{
dvander@910
   879
			continue;
dvander@910
   880
		}
dvander@910
   881
		AdminId id = pPlayer->GetAdminId();
dvander@910
   882
		g_SourceMod.SetGlobalTarget(i);
dvander@910
   883
		if (id == INVALID_ADMIN_ID
dvander@910
   884
			|| !g_Admins.GetAdminFlag(id, Admin_Generic, Access_Effective))
dvander@910
   885
		{
dvander@910
   886
			/* Treat this as a normal user */
dvander@910
   887
			if ((value & 1) || (value & 2))
dvander@910
   888
			{
dvander@910
   889
				const char *newsign = sign;
dvander@910
   890
				if (value & 2)
dvander@910
   891
				{
dvander@910
   892
					newsign = name;
dvander@910
   893
				}
dvander@910
   894
				g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
dvander@910
   895
				UTIL_Format(message, sizeof(message), "[SM] %s: %s", newsign, buffer);
dvander@910
   896
				g_HL2.TextMsg(i, HUD_PRINTTALK, message);
dvander@910
   897
			}
dvander@910
   898
		} else {
dvander@910
   899
			/* Treat this as an admin user */
dvander@910
   900
			bool is_root = g_Admins.GetAdminFlag(id, Admin_Root, Access_Effective);
dvander@910
   901
			if ((value & 4) 
dvander@910
   902
				|| (value & 8)
dvander@910
   903
				|| ((value & 16) && is_root))
dvander@910
   904
			{
dvander@910
   905
				const char *newsign = sign;
dvander@910
   906
				if ((value & 8) || ((value & 16) && is_root))
dvander@910
   907
				{
dvander@910
   908
					newsign = name;
dvander@910
   909
				}
dvander@910
   910
				g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
dvander@910
   911
				UTIL_Format(message, sizeof(message), "[SM] %s: %s", newsign, buffer);
dvander@910
   912
				g_HL2.TextMsg(i, HUD_PRINTTALK, message);
dvander@910
   913
			}
dvander@910
   914
		}
dvander@910
   915
	}
dvander@910
   916
dvander@910
   917
	return 1;
dvander@910
   918
}
dvander@910
   919
faluco@260
   920
REGISTER_NATIVES(playernatives)
faluco@260
   921
{
dvander@644
   922
	{"AddUserFlags",			AddUserFlags},
dvander@644
   923
	{"CanUserTarget",			CanUserTarget},
dvander@644
   924
	{"GetClientAuthString",		sm_GetClientAuthStr},
faluco@260
   925
	{"GetClientCount",			sm_GetClientCount},
dvander@644
   926
	{"GetClientInfo",			sm_GetClientInfo},
faluco@260
   927
	{"GetClientIP",				sm_GetClientIP},
dvander@644
   928
	{"GetClientName",			sm_GetClientName},
dvander@644
   929
	{"GetClientTeam",			GetClientTeam},
dvander@644
   930
	{"GetClientUserId",			GetClientUserId},
dvander@644
   931
	{"GetMaxClients",			sm_GetMaxClients},
dvander@644
   932
	{"GetUserAdmin",			GetUserAdmin},
dvander@644
   933
	{"GetUserFlagBits",			GetUserFlagBits},
ds@784
   934
	{"IsClientAuthorized",		sm_IsClientAuthorized},
ds@784
   935
	{"IsClientConnected",		sm_IsClientConnected},
ds@784
   936
	{"IsFakeClient",			sm_IsClientFakeClient},
ds@784
   937
	{"IsPlayerInGame",			sm_IsClientInGame},			/* Backwards compat shim */
ds@784
   938
	{"IsClientInGame",			sm_IsClientInGame},
dvander@458
   939
	{"RemoveUserFlags",			RemoveUserFlags},
dvander@644
   940
	{"SetUserAdmin",			SetUserAdmin},
dvander@458
   941
	{"SetUserFlagBits",			SetUserFlagBits},
faluco@658
   942
	{"GetClientDeaths",			GetDeathCount},
faluco@658
   943
	{"GetClientFrags",			GetFragCount},
faluco@658
   944
	{"GetClientArmor",			GetArmorValue},
faluco@658
   945
	{"GetClientAbsOrigin",		GetAbsOrigin},
faluco@658
   946
	{"GetClientAbsAngles",		GetAbsAngles},
faluco@658
   947
	{"GetClientMins",			GetPlayerMins},
faluco@658
   948
	{"GetClientMaxs",			GetPlayerMaxs},
faluco@658
   949
	{"GetClientWeapon",			GetWeaponName},
faluco@658
   950
	{"GetClientModel",			GetModelName},
faluco@658
   951
	{"GetClientHealth",			GetHealth},
dvander@691
   952
	{"GetClientTime",			GetTimeConnected},
dvander@691
   953
	{"GetClientDataRate",		GetDataRate},
dvander@691
   954
	{"IsClentTimingOut",		IsTimingOut},
dvander@691
   955
	{"GetClientLatency",		GetLatency},
dvander@691
   956
	{"GetClientAvgLatency",		GetAvgLatency},
dvander@691
   957
	{"GetClientAvgLoss",		GetAvgLoss},
dvander@691
   958
	{"GetClientAvgChoke",		GetAvgChoke},
dvander@691
   959
	{"GetClientAvgData",		GetAvgData},
dvander@691
   960
	{"GetClientAvgPackets",		GetAvgPackets},
faluco@682
   961
	{"GetClientOfUserId",		GetClientOfUserId},
dvander@910
   962
	{"ShowActivity",			ShowActivity},
faluco@260
   963
	{NULL,						NULL}
dvander@351
   964
};