plugins/include/cstrike.inc
author Drifter <rgr_02@comcast.net>
Tue Jun 28 20:32:55 2011 -0400 (2011-06-28)
changeset 3324 e981678907dd
parent 3322 d4c2b9f0e915
child 3359 7c8cc9db0328
permissions -rw-r--r--
Added new CS_GetWeaponPrice native to cstrike extension (bug 4985, 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 
    68 enum CSWeaponID
    69 {
    70     CSWeapon_NONE,
    71     CSWeapon_P228,
    72     CSWeapon_GLOCK,
    73     CSWeapon_SCOUT,
    74     CSWeapon_HEGRENADE,
    75     CSWeapon_XM1014,
    76     CSWeapon_C4,
    77     CSWeapon_MAC10,
    78     CSWeapon_AUG,
    79     CSWeapon_SMOKEGRENADE,
    80     CSWeapon_ELITE,
    81     CSWeapon_FIVESEVEN,
    82     CSWeapon_UMP45,
    83     CSWeapon_SG550,
    84     CSWeapon_GALIL,
    85     CSWeapon_FAMAS,
    86     CSWeapon_USP,
    87     CSWeapon_AWP,
    88     CSWeapon_MP5NAVY,
    89     CSWeapon_M249,
    90     CSWeapon_M3,
    91     CSWeapon_M4A1,
    92     CSWeapon_TMP,
    93     CSWeapon_G3SG1,
    94     CSWeapon_FLASHBANG,
    95     CSWeapon_DEAGLE,
    96     CSWeapon_SG552,
    97     CSWeapon_AK47,
    98     CSWeapon_KNIFE,
    99     CSWeapon_P90,
   100     CSWeapon_SHIELD,
   101     CSWeapon_KEVLAR,
   102     CSWeapon_ASSAULTSUIT,
   103     CSWeapon_NIGHTVISION
   104 };
   105 /**
   106  * Called when a player attempts to purchase an item.
   107  * Return Plugin_Continue to allow the purchase or return a
   108  * higher action to deny.
   109  *
   110  * @param client	Client index
   111  * @param weapon	User input for weapon name
   112  */
   113 forward Action:CS_OnBuyCommand(client, const String:weapon[]);
   114 
   115 /**
   116  * Called when CSWeaponDrop is called
   117  * Return Plugin_Continue to allow the call or return a
   118  * higher action to deny.
   119  *
   120  * @param client	Client index
   121  * @param weapon	Weapon index
   122  */
   123 forward Action:CS_OnCSWeaponDrop(client, weaponIndex);
   124 
   125 /**
   126  * Called when game retrieves a weapon's price for a player.
   127  * Return Plugin_Continue to use default value or return a higher
   128  * action to use a newly-set price.
   129  * 
   130  * @note This can be called multiple times per weapon purchase
   131  * 
   132  * @param client	Client index
   133  * @param weapon	Weapon classname
   134  * @param price		Buffer param for the price of the weapon
   135  *
   136  * @note			Not all "weapons" call GetWeaponPrice. Example: c4, knife, vest, vest helmet, night vision.
   137  */
   138 forward Action:CS_OnGetWeaponPrice(client, const String:weapon[], &price);
   139 
   140 /**
   141  * Called when TerminateRound is called.
   142  * Return Plugin_Continue to ignore, return Plugin_Changed to continue,
   143  * using the given delay and reason, or return Plugin_Handled or a higher
   144  * action to block TerminateRound from firing.
   145  *
   146  * @param delay		Time (in seconds) until new round starts
   147  * @param reason	Reason for round end
   148  */
   149 forward Action:CS_OnTerminateRound(&Float:delay, &CSRoundEndReason:reason);
   150 
   151 /**
   152  * Respawns a player.
   153  *
   154  * @param client		Player's index.
   155  * @noreturn
   156  * @error			Invalid client index, client not in game.
   157  */
   158 native CS_RespawnPlayer(client);
   159 
   160 /**
   161  * Switches the player's team.
   162  *
   163  * @param client		Player's index.
   164  * @param team			Team index.
   165  * @noreturn
   166  * @error			Invalid client index, client not in game.
   167  */
   168 native CS_SwitchTeam(client, team);
   169 
   170 /**
   171  * Forces a player to drop or toss their weapon
   172  *
   173  * @param client		Player's index.
   174  * @param weaponIndex	Index of weapon to drop.
   175  * @param toss			True to toss weapon (with velocity) or false to just drop weapon
   176  * @param blockhook		Set to true to stop the corresponding CS_OnCSWeaponDrop
   177  * 
   178  * @noreturn
   179  * @error				Invalid client index, client not in game, or invalid weapon index.
   180  */
   181 native CS_DropWeapon(client, weaponIndex, bool:toss, bool:blockhook = false);
   182 
   183 /**
   184  * Forces round to end with a reason
   185  *
   186  * @param delay			Time (in seconds) to delay before new round starts
   187  * @param reason		Reason for the round ending
   188  * @param blockhook		Set to true to stop the corresponding CS_OnTerminateRound
   189  *						forward from being called.
   190  * @noreturn
   191  */
   192  native CS_TerminateRound(Float:delay, CSRoundEndReason:reason, bool:blockhook = false);
   193  
   194  /**
   195  * Gets a weapon name from a weapon alias
   196  *
   197  * @param alias			Weapons alias to get weapon name for.
   198  * @param weapon		Buffer to store weapons name
   199  * @param size			Size of buffer to store the weapons name.
   200  * @noreturn
   201  *
   202  * @note				Will set the buffer to the original alias if it is not an alias to a weapon.
   203  */
   204  native CS_GetTranslatedWeaponAlias(const String:alias[], String:weapon[], size);
   205  
   206   /**
   207  * Gets a weapon's price
   208  *
   209  * @param client		Client to check weapon price for.
   210  * @param id			Weapon id for the weapon to check
   211  * @param defaultprice	Set to true to get defaultprice.
   212  * @return				Returns price of the weapon (even if modified)
   213  *
   214  * @error				Invalid client, failing to get weapon info, or failing to get price offset.
   215  * @note				Not all "weapons" will return their default price. Example: c4, knife, vest, vest helmet, night vision.
   216  */
   217  native CS_GetWeaponPrice(client, CSWeaponID:id, bool:defaultprice=false);
   218  
   219 /**
   220  * Do not edit below this line!
   221  */
   222 public Extension:__ext_cstrike = 
   223 {
   224 	name = "cstrike",
   225 	file = "games/game.cstrike.ext",
   226 	autoload = 0,
   227 #if defined REQUIRE_EXTENSIONS
   228 	required = 1,
   229 #else
   230 	required = 0,
   231 #endif
   232 };
   233 
   234 #if !defined REQUIRE_EXTENSIONS
   235 public __ext_cstrike_SetNTVOptional()
   236 {
   237 	MarkNativeAsOptional("CS_RespawnPlayer");
   238 	MarkNativeAsOptional("CS_SwitchTeam");
   239 	MarkNativeAsOptional("CS_DropWeapon");
   240 	MarkNativeAsOptional("CS_TerminateRound");
   241 	MarkNativeAsOptional("CS_GetTranslatedWeaponAlias");
   242 	MarkNativeAsOptional("CS_GetWeaponPrice");
   243 }
   244 #endif
   245