plugins/include/cstrike.inc
author Drifter <rgr_02@comcast.net>
Sun May 27 18:48:22 2012 -0400 (2012-05-27)
changeset 3528 7dfcbcec0f96
parent 3519 a116c415c73e
child 3529 7ca97cd589bc
permissions -rw-r--r--
Added new CSRoundEnd entries for CS:GO (r=psychonic).
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
     5  * =============================================================================
     6  *
     7  * This file is part of the SourceMod/SourcePawn SDK.
     8  *
     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.
    12  * 
    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
    16  * details.
    17  *
    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/>.
    20  *
    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>.
    29  *
    30  * Version: $Id$
    31  */
    32 
    33 #if defined _cstrike_included
    34   #endinput
    35 #endif
    36 #define _cstrike_included
    37 
    38 #define CS_TEAM_NONE		0	/**< No team yet. */
    39 #define CS_TEAM_SPECTATOR	1	/**< Spectators. */
    40 #define CS_TEAM_T 			2	/**< Terrorists. */
    41 #define CS_TEAM_CT			3	/**< Counter-Terrorists. */
    42 
    43 #define CS_SLOT_PRIMARY		0	/**< Primary weapon slot. */
    44 #define CS_SLOT_SECONDARY	1	/**< Secondary weapon slot. */
    45 #define CS_SLOT_GRENADE		3	/**< Grenade slot (will only return one grenade). */
    46 #define CS_SLOT_C4			4	/**< C4 slot. */
    47 
    48 enum CSRoundEndReason
    49 {
    50 	CSRoundEnd_TargetBombed = 0,           // Target Successfully Bombed!
    51 	CSRoundEnd_VIPEscaped,                 // The VIP has escaped!
    52 	CSRoundEnd_VIPKilled,                  // VIP has been assassinated!
    53 	CSRoundEnd_TerroristsEscaped,          // The terrorists have escaped!
    54 	CSRoundEnd_CTStoppedEscape,            // The CTs have prevented most of the terrorists from escaping!
    55 	CSRoundEnd_TerroristsStopped,          // Escaping terrorists have all been neutralized!
    56 	CSRoundEnd_BombDefused,                // The bomb has been defused!
    57 	CSRoundEnd_CTWin,                      // Counter-Terrorists Win!
    58 	CSRoundEnd_TerroristWin,               // Terrorists Win!
    59 	CSRoundEnd_Draw,                       // Round Draw!
    60 	CSRoundEnd_HostagesRescued,            // All Hostages have been rescued!
    61 	CSRoundEnd_TargetSaved,                // Target has been saved!
    62 	CSRoundEnd_HostagesNotRescued,         // Hostages have not been rescued!
    63 	CSRoundEnd_TerroristsNotEscaped,       // Terrorists have not escaped!
    64 	CSRoundEnd_VIPNotEscaped,              // VIP has not escaped!
    65 	CSRoundEnd_GameStart                   // Game Commencing!
    66 	
    67 	// The below only exist on CS:GO
    68 	CSRoundEnd_TerroristsSurrender,        // Terrorists Surrender
    69 	CSRoundEnd_CTSurrender,                // CTs Surrender
    70 };
    71 
    72 enum CSWeaponID
    73 {
    74 	CSWeapon_NONE = 0,
    75 	CSWeapon_P228,
    76 	CSWeapon_GLOCK,
    77 	CSWeapon_SCOUT,
    78 	CSWeapon_HEGRENADE,
    79 	CSWeapon_XM1014,
    80 	CSWeapon_C4,
    81 	CSWeapon_MAC10,
    82 	CSWeapon_AUG,
    83 	CSWeapon_SMOKEGRENADE,
    84 	CSWeapon_ELITE,
    85 	CSWeapon_FIVESEVEN,
    86 	CSWeapon_UMP45,
    87 	CSWeapon_SG550,
    88 	CSWeapon_GALIL,
    89 	CSWeapon_FAMAS,
    90 	CSWeapon_USP,
    91 	CSWeapon_AWP,
    92 	CSWeapon_MP5NAVY,
    93 	CSWeapon_M249,
    94 	CSWeapon_M3,
    95 	CSWeapon_M4A1,
    96 	CSWeapon_TMP,
    97 	CSWeapon_G3SG1,
    98 	CSWeapon_FLASHBANG,
    99 	CSWeapon_DEAGLE,
   100 	CSWeapon_SG552,
   101 	CSWeapon_AK47,
   102 	CSWeapon_KNIFE,
   103 	CSWeapon_P90,
   104 	CSWeapon_SHIELD,
   105 	CSWeapon_KEVLAR,
   106 	CSWeapon_ASSAULTSUIT,
   107 	CSWeapon_NIGHTVISION,
   108 	CSWeapon_GALILAR,
   109 	CSWeapon_BIZON,
   110 	CSWeapon_MAG7,
   111 	CSWeapon_NEGEV,
   112 	CSWeapon_SAWEDOFF,
   113 	CSWeapon_TEC9,
   114 	CSWeapon_TASER,
   115 	CSWeapon_HKP2000,
   116 	CSWeapon_MP7,
   117 	CSWeapon_MP9,
   118 	CSWeapon_NOVA,
   119 	CSWeapon_P250,
   120 	CSWeapon_SCAR17,
   121 	CSWeapon_SCAR20,
   122 	CSWeapon_SG556,
   123 	CSWeapon_SSG08,
   124 	CSWeapon_KNIFE_GG,
   125 	CSWeapon_MOLOTOV,
   126 	CSWeapon_DECOY,
   127 	CSWeapon_INCGRENADE,
   128 	CSWeapon_DEFUSER
   129 };
   130 
   131 /**
   132  * Called when a player attempts to purchase an item.
   133  * Return Plugin_Continue to allow the purchase or return a
   134  * higher action to deny.
   135  *
   136  * @param client	Client index
   137  * @param weapon	User input for weapon name
   138  */
   139 forward Action:CS_OnBuyCommand(client, const String:weapon[]);
   140 
   141 /**
   142  * Called when CSWeaponDrop is called
   143  * Return Plugin_Continue to allow the call or return a
   144  * higher action to deny.
   145  *
   146  * @param client	Client index
   147  * @param weapon	Weapon index
   148  */
   149 forward Action:CS_OnCSWeaponDrop(client, weaponIndex);
   150 
   151 /**
   152  * Called when game retrieves a weapon's price for a player.
   153  * Return Plugin_Continue to use default value or return a higher
   154  * action to use a newly-set price.
   155  * 
   156  * @note This can be called multiple times per weapon purchase
   157  * 
   158  * @param client	Client index
   159  * @param weapon	Weapon classname
   160  * @param price		Buffer param for the price of the weapon
   161  *
   162  * @note			Not all "weapons" call GetWeaponPrice. Example: c4, knife, vest, vest helmet, night vision.
   163  */
   164 forward Action:CS_OnGetWeaponPrice(client, const String:weapon[], &price);
   165 
   166 /**
   167  * Called when TerminateRound is called.
   168  * Return Plugin_Continue to ignore, return Plugin_Changed to continue,
   169  * using the given delay and reason, or return Plugin_Handled or a higher
   170  * action to block TerminateRound from firing.
   171  *
   172  * @param delay		Time (in seconds) until new round starts
   173  * @param reason	Reason for round end
   174  */
   175 forward Action:CS_OnTerminateRound(&Float:delay, &CSRoundEndReason:reason);
   176 
   177 /**
   178  * Respawns a player.
   179  *
   180  * @param client		Player's index.
   181  * @noreturn
   182  * @error			Invalid client index, client not in game.
   183  */
   184 native CS_RespawnPlayer(client);
   185 
   186 /**
   187  * Switches the player's team.
   188  *
   189  * @param client		Player's index.
   190  * @param team			Team index.
   191  * @noreturn
   192  * @error			Invalid client index, client not in game.
   193  */
   194 native CS_SwitchTeam(client, team);
   195 
   196 /**
   197  * Forces a player to drop or toss their weapon
   198  *
   199  * @param client		Player's index.
   200  * @param weaponIndex	Index of weapon to drop.
   201  * @param toss			True to toss weapon (with velocity) or false to just drop weapon
   202  * @param blockhook		Set to true to stop the corresponding CS_OnCSWeaponDrop
   203  * 
   204  * @noreturn
   205  * @error				Invalid client index, client not in game, or invalid weapon index.
   206  */
   207 native CS_DropWeapon(client, weaponIndex, bool:toss, bool:blockhook = false);
   208 
   209 /**
   210  * Forces round to end with a reason
   211  *
   212  * @param delay			Time (in seconds) to delay before new round starts
   213  * @param reason		Reason for the round ending
   214  * @param blockhook		Set to true to stop the corresponding CS_OnTerminateRound
   215  *						forward from being called.
   216  * @noreturn
   217  */
   218 native CS_TerminateRound(Float:delay, CSRoundEndReason:reason, bool:blockhook = false);
   219  
   220 /**
   221  * Gets a weapon name from a weapon alias
   222  *
   223  * @param alias			Weapons alias to get weapon name for.
   224  * @param weapon		Buffer to store weapons name
   225  * @param size			Size of buffer to store the weapons name.
   226  * @noreturn
   227  *
   228  * @note				Will set the buffer to the original alias if it is not an alias to a weapon.
   229  */
   230 native CS_GetTranslatedWeaponAlias(const String:alias[], String:weapon[], size);
   231  
   232 /**
   233  * Gets a weapon's price
   234  *
   235  * @param client		Client to check weapon price for.
   236  * @param id			Weapon id for the weapon to check
   237  * @param defaultprice	Set to true to get defaultprice.
   238  * @return				Returns price of the weapon (even if modified)
   239  *
   240  * @error				Invalid client, failing to get weapon info, or failing to get price offset.
   241  * @note				c4, knife and shield will always return 0. vest, vest helmet and night vision will always return default price.
   242  */
   243 native CS_GetWeaponPrice(client, CSWeaponID:id, bool:defaultprice = false);
   244  
   245 /**
   246  * Gets a clients clan tag
   247  * @param client		Client index to get clan tag for.
   248  * @param buffer		Buffer to store clients clan tag in.
   249  * @param size			Size of the buffer.
   250  * @return				Number of non-null bytes written.
   251  *
   252  * @error				Invalid client.
   253  * @note				Only supported on CS:S. Writes 0-length string on CS:GO.
   254  */
   255 native CS_GetClientClanTag(client, String:buffer[], size);
   256 
   257 /**
   258  * Sets a clients clan tag
   259  * @param client		Client index to set clan tag for.
   260  * @param tag			Tag to set clients clan tag as.
   261  * @noreturn
   262  *
   263  * @error				Invalid client.
   264  * @note				Only supported on CS:S. Has no effect on CS:GO.
   265  */
   266 native CS_SetClientClanTag(client, const String:tag[]);
   267  
   268 /**
   269  * Gets a weaponID from a alias
   270  * @param alias			Weapon alias to attempt to get an id for.
   271  * @return				Returns a weapon id or 0 if failed to find a match.
   272  *
   273  * @note For best results use CS_GetTranslatedWeaponAlias on the weapon name before passing it.
   274  */
   275 native CS_AliasToWeaponID(const String:alias[]);
   276 
   277 /**
   278  * Do not edit below this line!
   279  */
   280 public Extension:__ext_cstrike = 
   281 {
   282 	name = "cstrike",
   283 	file = "games/game.cstrike.ext",
   284 	autoload = 0,
   285 #if defined REQUIRE_EXTENSIONS
   286 	required = 1,
   287 #else
   288 	required = 0,
   289 #endif
   290 };
   291 
   292 #if !defined REQUIRE_EXTENSIONS
   293 public __ext_cstrike_SetNTVOptional()
   294 {
   295 	MarkNativeAsOptional("CS_RespawnPlayer");
   296 	MarkNativeAsOptional("CS_SwitchTeam");
   297 	MarkNativeAsOptional("CS_DropWeapon");
   298 	MarkNativeAsOptional("CS_TerminateRound");
   299 	MarkNativeAsOptional("CS_GetTranslatedWeaponAlias");
   300 	MarkNativeAsOptional("CS_GetWeaponPrice");
   301 	MarkNativeAsOptional("CS_GetClientClanTag");
   302 	MarkNativeAsOptional("CS_SetClientClanTag");
   303 	MakrNativeAsOptional("CS_AliasToWeaponID");
   304 }
   305 #endif
   306