1.1 --- a/plugins/include/tf2_stocks.inc Sat Feb 07 22:01:09 2009 -0500
1.2 +++ b/plugins/include/tf2_stocks.inc Sat Feb 07 22:05:04 2009 -0500
1.3 @@ -1,219 +1,219 @@
1.4 -/**
1.5 - * vim: set ts=4 :
1.6 - * =============================================================================
1.7 - * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
1.8 - * =============================================================================
1.9 - *
1.10 - * This file is part of the SourceMod/SourcePawn SDK.
1.11 - *
1.12 - * This program is free software; you can redistribute it and/or modify it under
1.13 - * the terms of the GNU General Public License, version 3.0, as published by the
1.14 - * Free Software Foundation.
1.15 - *
1.16 - * This program is distributed in the hope that it will be useful, but WITHOUT
1.17 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.18 - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1.19 - * details.
1.20 - *
1.21 - * You should have received a copy of the GNU General Public License along with
1.22 - * this program. If not, see <http://www.gnu.org/licenses/>.
1.23 - *
1.24 - * As a special exception, AlliedModders LLC gives you permission to link the
1.25 - * code of this program (as well as its derivative works) to "Half-Life 2," the
1.26 - * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
1.27 - * by the Valve Corporation. You must obey the GNU General Public License in
1.28 - * all respects for all other code used. Additionally, AlliedModders LLC grants
1.29 - * this exception to all derivative works. AlliedModders LLC defines further
1.30 - * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
1.31 - * or <http://www.sourcemod.net/license.php>.
1.32 - *
1.33 - * Version: $Id$
1.34 - */
1.35 -
1.36 -#if defined _tf2_stocks_included
1.37 - #endinput
1.38 -#endif
1.39 -#define _tf2_stocks_included
1.40 -
1.41 -#include <tf2>
1.42 -#include <sdktools>
1.43 -
1.44 -enum TFResourceType
1.45 -{
1.46 - TFResource_Ping,
1.47 - TFResource_Score,
1.48 - TFResource_Deaths,
1.49 - TFResource_TotalScore,
1.50 - TFResource_Captures,
1.51 - TFResource_Defenses,
1.52 - TFResource_Dominations,
1.53 - TFResource_Revenge,
1.54 - TFResource_BuildingsDestroyed,
1.55 - TFResource_Headshots,
1.56 - TFResource_Backstabs,
1.57 - TFResource_HealPoints,
1.58 - TFResource_Invulns,
1.59 - TFResource_Teleports,
1.60 - TFResource_ResupplyPoints,
1.61 - TFResource_KillAssists,
1.62 - TFResource_MaxHealth,
1.63 - TFResource_PlayerClass
1.64 -};
1.65 -
1.66 -static const String:TFResourceNames[TFResourceType][] =
1.67 -{
1.68 - "m_iPing",
1.69 - "m_iScore",
1.70 - "m_iDeaths",
1.71 - "m_iTotalScore",
1.72 - "m_iCaptures",
1.73 - "m_iDefenses",
1.74 - "m_iDominations",
1.75 - "m_iRevenge",
1.76 - "m_iBuildingsDestroyed",
1.77 - "m_iHeadshots",
1.78 - "m_iBackstabs",
1.79 - "m_iHealPoints",
1.80 - "m_iInvulns",
1.81 - "m_iTeleports",
1.82 - "m_iResupplyPoints",
1.83 - "m_iKillAssists",
1.84 - "m_iMaxHealth",
1.85 - "m_iPlayerClass"
1.86 -};
1.87 -
1.88 -/**
1.89 - * Get's a Clients current class.
1.90 - *
1.91 - * @param client Player's index.
1.92 - * @param class TFClassType to change to.
1.93 - * @noreturn
1.94 - * @error Invalid client index.
1.95 - */
1.96 -stock TFClassType:TF2_GetPlayerClass(client)
1.97 -{
1.98 - return TFClassType:GetEntProp(client, Prop_Send, "m_iClass");
1.99 -}
1.100 -
1.101 -/**
1.102 - * Set's a Clients class.
1.103 - *
1.104 - * Note: If setting player class in a player spawn hook weapons should be set to false.
1.105 - *
1.106 - * @param client Player's index.
1.107 - * @param class TFClassType class symbol.
1.108 - * @param weapons This paramater is ignored.
1.109 - * @param persistant If true changes the players desired class so the change stays after death.
1.110 - * @noreturn
1.111 - * @error Invalid client index.
1.112 - */
1.113 -stock TF2_SetPlayerClass(client, TFClassType:class, bool:weapons=true, bool:persistant=true)
1.114 -{
1.115 - SetEntProp(client, Prop_Send, "m_iClass", _:class);
1.116 -
1.117 - if (persistant)
1.118 - {
1.119 - SetEntProp(client, Prop_Send, "m_iDesiredPlayerClass", _:class);
1.120 - }
1.121 -}
1.122 -
1.123 -/**
1.124 - * Retrieves client data from the resource entity
1.125 - *
1.126 - * @param client Player's index.
1.127 - * @param type ResourceType constant
1.128 - * @return Value or -1 on failure.
1.129 - * @error Invalid client index, client not in game or failed to find resource entity.
1.130 - */
1.131 -stock TF2_GetPlayerResourceData(client, TFResourceType:type)
1.132 -{
1.133 - if (!IsClientConnected(client))
1.134 - {
1.135 - return -1;
1.136 - }
1.137 -
1.138 - new offset = FindSendPropInfo("CTFPlayerResource", TFResourceNames[type]);
1.139 -
1.140 - if (offset < 1)
1.141 - {
1.142 - return -1;
1.143 - }
1.144 -
1.145 - new entity = TF2_GetResourceEntity();
1.146 -
1.147 - if (entity == -1)
1.148 - {
1.149 - return -1;
1.150 - }
1.151 -
1.152 - return GetEntData(entity, offset + (client*4));
1.153 -}
1.154 -
1.155 -/**
1.156 - * Sets client data in the resource entity
1.157 - *
1.158 - * Note: The game overwrites these values every frame, so changing them will have very little effect.
1.159 - *
1.160 - * @param client Player's index.
1.161 - * @param type ResourceType constant
1.162 - * @param value Value to set.
1.163 - * @return Value or -1 on failure.
1.164 - * @error Invalid client index, client not in game or failed to find resource entity.
1.165 - */
1.166 -stock bool:TF2_SetPlayerResourceData(client, TFResourceType:type, any:value)
1.167 -{
1.168 - if (!IsClientConnected(client))
1.169 - {
1.170 - return false;
1.171 - }
1.172 -
1.173 - new offset = FindSendPropInfo("CTFPlayerResource", TFResourceNames[type]);
1.174 -
1.175 - if (offset < 1)
1.176 - {
1.177 - return false;
1.178 - }
1.179 -
1.180 - new entity = TF2_GetResourceEntity();
1.181 -
1.182 - if (entity == -1)
1.183 - {
1.184 - return false;
1.185 - }
1.186 -
1.187 - SetEntData(entity, offset + (client*4), value);
1.188 -
1.189 - return true;
1.190 -}
1.191 -
1.192 -/**
1.193 - * Removes all weapons from a client's weapon slot
1.194 - *
1.195 - * @param client Player's index.
1.196 - * @param slot Slot index (0-5)
1.197 - * @noreturn
1.198 - * @error Invalid client, invalid slot or lack of mod support
1.199 - */
1.200 -stock TF2_RemoveWeaponSlot(client, slot)
1.201 -{
1.202 - new weaponIndex;
1.203 - while ((weaponIndex = GetPlayerWeaponSlot(client, slot)) != -1)
1.204 - {
1.205 - RemovePlayerItem(client, weaponIndex);
1.206 - RemoveEdict(weaponIndex);
1.207 - }
1.208 -}
1.209 -
1.210 -/**
1.211 - * Removes all weapons from a client
1.212 - *
1.213 - * @param client Player's index.
1.214 - * @noreturn
1.215 - */
1.216 -stock TF2_RemoveAllWeapons(client)
1.217 -{
1.218 - for (new i = 0; i <= 5; i++)
1.219 - {
1.220 - TF2_RemoveWeaponSlot(client, i);
1.221 - }
1.222 -}
1.223 +/**
1.224 + * vim: set ts=4 :
1.225 + * =============================================================================
1.226 + * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
1.227 + * =============================================================================
1.228 + *
1.229 + * This file is part of the SourceMod/SourcePawn SDK.
1.230 + *
1.231 + * This program is free software; you can redistribute it and/or modify it under
1.232 + * the terms of the GNU General Public License, version 3.0, as published by the
1.233 + * Free Software Foundation.
1.234 + *
1.235 + * This program is distributed in the hope that it will be useful, but WITHOUT
1.236 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.237 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1.238 + * details.
1.239 + *
1.240 + * You should have received a copy of the GNU General Public License along with
1.241 + * this program. If not, see <http://www.gnu.org/licenses/>.
1.242 + *
1.243 + * As a special exception, AlliedModders LLC gives you permission to link the
1.244 + * code of this program (as well as its derivative works) to "Half-Life 2," the
1.245 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
1.246 + * by the Valve Corporation. You must obey the GNU General Public License in
1.247 + * all respects for all other code used. Additionally, AlliedModders LLC grants
1.248 + * this exception to all derivative works. AlliedModders LLC defines further
1.249 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
1.250 + * or <http://www.sourcemod.net/license.php>.
1.251 + *
1.252 + * Version: $Id$
1.253 + */
1.254 +
1.255 +#if defined _tf2_stocks_included
1.256 + #endinput
1.257 +#endif
1.258 +#define _tf2_stocks_included
1.259 +
1.260 +#include <tf2>
1.261 +#include <sdktools>
1.262 +
1.263 +enum TFResourceType
1.264 +{
1.265 + TFResource_Ping,
1.266 + TFResource_Score,
1.267 + TFResource_Deaths,
1.268 + TFResource_TotalScore,
1.269 + TFResource_Captures,
1.270 + TFResource_Defenses,
1.271 + TFResource_Dominations,
1.272 + TFResource_Revenge,
1.273 + TFResource_BuildingsDestroyed,
1.274 + TFResource_Headshots,
1.275 + TFResource_Backstabs,
1.276 + TFResource_HealPoints,
1.277 + TFResource_Invulns,
1.278 + TFResource_Teleports,
1.279 + TFResource_ResupplyPoints,
1.280 + TFResource_KillAssists,
1.281 + TFResource_MaxHealth,
1.282 + TFResource_PlayerClass
1.283 +};
1.284 +
1.285 +static const String:TFResourceNames[TFResourceType][] =
1.286 +{
1.287 + "m_iPing",
1.288 + "m_iScore",
1.289 + "m_iDeaths",
1.290 + "m_iTotalScore",
1.291 + "m_iCaptures",
1.292 + "m_iDefenses",
1.293 + "m_iDominations",
1.294 + "m_iRevenge",
1.295 + "m_iBuildingsDestroyed",
1.296 + "m_iHeadshots",
1.297 + "m_iBackstabs",
1.298 + "m_iHealPoints",
1.299 + "m_iInvulns",
1.300 + "m_iTeleports",
1.301 + "m_iResupplyPoints",
1.302 + "m_iKillAssists",
1.303 + "m_iMaxHealth",
1.304 + "m_iPlayerClass"
1.305 +};
1.306 +
1.307 +/**
1.308 + * Get's a Clients current class.
1.309 + *
1.310 + * @param client Player's index.
1.311 + * @return Current TFClassType of player.
1.312 + * @error Invalid client index.
1.313 + */
1.314 +stock TFClassType:TF2_GetPlayerClass(client)
1.315 +{
1.316 + return TFClassType:GetEntProp(client, Prop_Send, "m_iClass");
1.317 +}
1.318 +
1.319 +/**
1.320 + * Set's a Clients class.
1.321 + *
1.322 + * Note: If setting player class in a player spawn hook weapons should be set to false.
1.323 + *
1.324 + * @param client Player's index.
1.325 + * @param class TFClassType class symbol.
1.326 + * @param weapons This paramater is ignored.
1.327 + * @param persistant If true changes the players desired class so the change stays after death.
1.328 + * @noreturn
1.329 + * @error Invalid client index.
1.330 + */
1.331 +stock TF2_SetPlayerClass(client, TFClassType:class, bool:weapons=true, bool:persistant=true)
1.332 +{
1.333 + SetEntProp(client, Prop_Send, "m_iClass", _:class);
1.334 +
1.335 + if (persistant)
1.336 + {
1.337 + SetEntProp(client, Prop_Send, "m_iDesiredPlayerClass", _:class);
1.338 + }
1.339 +}
1.340 +
1.341 +/**
1.342 + * Retrieves client data from the resource entity
1.343 + *
1.344 + * @param client Player's index.
1.345 + * @param type ResourceType constant
1.346 + * @return Value or -1 on failure.
1.347 + * @error Invalid client index, client not in game or failed to find resource entity.
1.348 + */
1.349 +stock TF2_GetPlayerResourceData(client, TFResourceType:type)
1.350 +{
1.351 + if (!IsClientConnected(client))
1.352 + {
1.353 + return -1;
1.354 + }
1.355 +
1.356 + new offset = FindSendPropInfo("CTFPlayerResource", TFResourceNames[type]);
1.357 +
1.358 + if (offset < 1)
1.359 + {
1.360 + return -1;
1.361 + }
1.362 +
1.363 + new entity = TF2_GetResourceEntity();
1.364 +
1.365 + if (entity == -1)
1.366 + {
1.367 + return -1;
1.368 + }
1.369 +
1.370 + return GetEntData(entity, offset + (client*4));
1.371 +}
1.372 +
1.373 +/**
1.374 + * Sets client data in the resource entity
1.375 + *
1.376 + * Note: The game overwrites these values every frame, so changing them will have very little effect.
1.377 + *
1.378 + * @param client Player's index.
1.379 + * @param type ResourceType constant
1.380 + * @param value Value to set.
1.381 + * @return Value or -1 on failure.
1.382 + * @error Invalid client index, client not in game or failed to find resource entity.
1.383 + */
1.384 +stock bool:TF2_SetPlayerResourceData(client, TFResourceType:type, any:value)
1.385 +{
1.386 + if (!IsClientConnected(client))
1.387 + {
1.388 + return false;
1.389 + }
1.390 +
1.391 + new offset = FindSendPropInfo("CTFPlayerResource", TFResourceNames[type]);
1.392 +
1.393 + if (offset < 1)
1.394 + {
1.395 + return false;
1.396 + }
1.397 +
1.398 + new entity = TF2_GetResourceEntity();
1.399 +
1.400 + if (entity == -1)
1.401 + {
1.402 + return false;
1.403 + }
1.404 +
1.405 + SetEntData(entity, offset + (client*4), value);
1.406 +
1.407 + return true;
1.408 +}
1.409 +
1.410 +/**
1.411 + * Removes all weapons from a client's weapon slot
1.412 + *
1.413 + * @param client Player's index.
1.414 + * @param slot Slot index (0-5)
1.415 + * @noreturn
1.416 + * @error Invalid client, invalid slot or lack of mod support
1.417 + */
1.418 +stock TF2_RemoveWeaponSlot(client, slot)
1.419 +{
1.420 + new weaponIndex;
1.421 + while ((weaponIndex = GetPlayerWeaponSlot(client, slot)) != -1)
1.422 + {
1.423 + RemovePlayerItem(client, weaponIndex);
1.424 + RemoveEdict(weaponIndex);
1.425 + }
1.426 +}
1.427 +
1.428 +/**
1.429 + * Removes all weapons from a client
1.430 + *
1.431 + * @param client Player's index.
1.432 + * @noreturn
1.433 + */
1.434 +stock TF2_RemoveAllWeapons(client)
1.435 +{
1.436 + for (new i = 0; i <= 5; i++)
1.437 + {
1.438 + TF2_RemoveWeaponSlot(client, i);
1.439 + }
1.440 +}
1.441 +