Fixed base plugins using GetMaxClients() instead of MaxClients (
bug 3985, r=dvander).
3 * =============================================================================
4 * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
5 * =============================================================================
7 * This file is part of the SourceMod/SourcePawn SDK.
9 * This program is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU General Public License, version 3.0, as published by the
11 * Free Software Foundation.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18 * You should have received a copy of the GNU General Public License along with
19 * this program. If not, see <http://www.gnu.org/licenses/>.
21 * As a special exception, AlliedModders LLC gives you permission to link the
22 * code of this program (as well as its derivative works) to "Half-Life 2," the
23 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
24 * by the Valve Corporation. You must obey the GNU General Public License in
25 * all respects for all other code used. Additionally, AlliedModders LLC grants
26 * this exception to all derivative works. AlliedModders LLC defines further
27 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
28 * or <http://www.sourcemod.net/license.php>.
33 #if defined _tf2_stocks_included
36 #define _tf2_stocks_included
46 TFResource_TotalScore,
49 TFResource_Dominations,
51 TFResource_BuildingsDestroyed,
54 TFResource_HealPoints,
57 TFResource_ResupplyPoints,
58 TFResource_KillAssists,
60 TFResource_PlayerClass
63 static const String:TFResourceNames[TFResourceType][] =
73 "m_iBuildingsDestroyed",
86 * Get's a Clients current class.
88 * @param client Player's index.
89 * @return Current TFClassType of player.
90 * @error Invalid client index.
92 stock TFClassType:TF2_GetPlayerClass(client)
94 return TFClassType:GetEntProp(client, Prop_Send, "m_iClass");
98 * Set's a Clients class.
100 * Note: If setting player class in a player spawn hook weapons should be set to false.
102 * @param client Player's index.
103 * @param class TFClassType class symbol.
104 * @param weapons This paramater is ignored.
105 * @param persistant If true changes the players desired class so the change stays after death.
107 * @error Invalid client index.
109 stock TF2_SetPlayerClass(client, TFClassType:class, bool:weapons=true, bool:persistant=true)
111 SetEntProp(client, Prop_Send, "m_iClass", _:class);
115 SetEntProp(client, Prop_Send, "m_iDesiredPlayerClass", _:class);
120 * Retrieves client data from the resource entity
122 * @param client Player's index.
123 * @param type ResourceType constant
124 * @return Value or -1 on failure.
125 * @error Invalid client index, client not in game or failed to find resource entity.
127 stock TF2_GetPlayerResourceData(client, TFResourceType:type)
129 if (!IsClientConnected(client))
134 new offset = FindSendPropInfo("CTFPlayerResource", TFResourceNames[type]);
141 new entity = TF2_GetResourceEntity();
148 return GetEntData(entity, offset + (client*4));
152 * Sets client data in the resource entity
154 * Note: The game overwrites these values every frame, so changing them will have very little effect.
156 * @param client Player's index.
157 * @param type ResourceType constant
158 * @param value Value to set.
159 * @return Value or -1 on failure.
160 * @error Invalid client index, client not in game or failed to find resource entity.
162 stock bool:TF2_SetPlayerResourceData(client, TFResourceType:type, any:value)
164 if (!IsClientConnected(client))
169 new offset = FindSendPropInfo("CTFPlayerResource", TFResourceNames[type]);
176 new entity = TF2_GetResourceEntity();
183 SetEntData(entity, offset + (client*4), value);
189 * Removes all weapons from a client's weapon slot
191 * @param client Player's index.
192 * @param slot Slot index (0-5)
194 * @error Invalid client, invalid slot or lack of mod support
196 stock TF2_RemoveWeaponSlot(client, slot)
199 while ((weaponIndex = GetPlayerWeaponSlot(client, slot)) != -1)
201 RemovePlayerItem(client, weaponIndex);
202 RemoveEdict(weaponIndex);
207 * Removes all weapons from a client
209 * @param client Player's index.
212 stock TF2_RemoveAllWeapons(client)
214 for (new i = 0; i <= 5; i++)
216 TF2_RemoveWeaponSlot(client, i);