plugins/include/cstrike.inc
author Erik Minekus <erik@minekus.com>
Thu Aug 01 09:26:34 2013 -0400 (2013-08-01)
changeset 3967 ceafb87d38a7
parent 3965 86dedf4462d8
child 4061 fffdcac63ac3
permissions -rw-r--r--
Numerous code documentation fixups (bug 5720, 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 weaponIndex	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  */
   254 native CS_GetClientClanTag(client, String:buffer[], size);
   255 
   256 /**
   257  * Sets a clients clan tag
   258  * @param client		Client index to set clan tag for.
   259  * @param tag			Tag to set clients clan tag as.
   260  * @noreturn
   261  *
   262  * @error				Invalid client.
   263  */
   264 native CS_SetClientClanTag(client, const String:tag[]);
   265 
   266 /**
   267  * Gets a team's score
   268  * @param team			Team index to get score for.
   269  * @return				Returns the internal team score.
   270  *
   271  * @error				Invalid team index.
   272  */
   273 native CS_GetTeamScore(team);
   274 
   275 /**
   276  * Sets a team's score
   277  * @param team			Team index to set score for.
   278  * @param value			Value to set teams score as.
   279  * @noreturn
   280  *
   281  * @error				Invalid team index.
   282  * @note				This will update the scoreboard only after the scoreboard update function is called. Use SetTeamScore plus this to update the scoreboard instantly and save values correctly.
   283  */
   284 native CS_SetTeamScore(team, value);
   285 
   286 /**
   287  * Gets a client's mvp count
   288  * @param client		Client index to get mvp count of.
   289  * @return				Returns the client's internal MVP count.
   290  *
   291  * @error				Invalid client.
   292  */
   293 native CS_GetMVPCount(client);
   294 
   295 /**
   296  * Sets a client's mvp count
   297  * @param client		Client index to set mvp count for.
   298  * @param value			Value to set client's mvp count as.
   299  * @noreturn
   300  *
   301  * @error				Invalid client.
   302  */
   303 native CS_SetMVPCount(client, value);
   304 
   305 /**
   306  * Gets a client's contribution score (CS:GO only)
   307  * @param client		Client index to get score of.
   308  * @return				Returns the client's score.
   309  *
   310  * @error				Invalid client.
   311  */
   312 native CS_GetClientContributionScore(client);
   313 
   314 /**
   315  * Sets a client's contribution score (CS:GO only)
   316  * @param client		Client index to set score for.
   317  * @param value			Value to set client's score as.
   318  * @noreturn
   319  *
   320  * @error				Invalid client.
   321  */
   322 native CS_SetClientContributionScore(client, value);
   323 
   324 /**
   325  * Gets a client's assists (CS:GO only)
   326  * @param client		Client index to get assists of.
   327  * @return				Returns the client's assists.
   328  *
   329  * @error				Invalid client.
   330  */
   331 native CS_GetClientAssists(client);
   332 
   333 /**
   334  * Sets a client's assists (CS:GO only)
   335  * @param client		Client index to set assists for.
   336  * @param value			Value to set client's assists as.
   337  * @noreturn
   338  *
   339  * @error				Invalid client.
   340  */
   341 native CS_SetClientAssists(client, value);
   342 
   343 /**
   344  * Gets a weaponID from a alias
   345  * @param alias			Weapon alias to attempt to get an id for.
   346  * @return				Returns a weapon id or 0 if failed to find a match.
   347  *
   348  * @note For best results use CS_GetTranslatedWeaponAlias on the weapon name before passing it.
   349  */
   350 native CSWeaponID:CS_AliasToWeaponID(const String:alias[]);
   351 
   352 /**
   353  * Gets a alias from a weaponID
   354  * @param weaponID		WeaponID to get alias for.
   355  * @param destination	Destination string to hold the weapon alias.
   356  * @param len			Length of the destination array.
   357  * @return				Returns number of cells written.
   358  */
   359 native CS_WeaponIDToAlias(CSWeaponID:weaponID, String:destination[], len);
   360 
   361 /**
   362  * Returns weather a WeaponID is valid on the current mod (css or csgo)
   363  * @param weaponID		WeaponID to check
   364  * @return				Returns true if its a valid WeaponID false otherwise.
   365  *
   366  * @note This will return false always for CSWeapon_NONE
   367  */
   368 native bool:CS_IsValidWeaponID(CSWeaponID:id);
   369 
   370 /**
   371  * Do not edit below this line!
   372  */
   373 public Extension:__ext_cstrike = 
   374 {
   375 	name = "cstrike",
   376 	file = "games/game.cstrike.ext",
   377 	autoload = 0,
   378 #if defined REQUIRE_EXTENSIONS
   379 	required = 1,
   380 #else
   381 	required = 0,
   382 #endif
   383 };
   384 
   385 #if !defined REQUIRE_EXTENSIONS
   386 public __ext_cstrike_SetNTVOptional()
   387 {
   388 	MarkNativeAsOptional("CS_RespawnPlayer");
   389 	MarkNativeAsOptional("CS_SwitchTeam");
   390 	MarkNativeAsOptional("CS_DropWeapon");
   391 	MarkNativeAsOptional("CS_TerminateRound");
   392 	MarkNativeAsOptional("CS_GetTranslatedWeaponAlias");
   393 	MarkNativeAsOptional("CS_GetWeaponPrice");
   394 	MarkNativeAsOptional("CS_GetClientClanTag");
   395 	MarkNativeAsOptional("CS_SetClientClanTag");
   396 	MarkNativeAsOptional("CS_GetTeamScore");
   397 	MarkNativeAsOptional("CS_SetTeamScore");
   398 	MarkNativeAsOptional("CS_GetMVPCount");
   399 	MarkNativeAsOptional("CS_SetMVPCount");
   400 	MarkNativeAsOptional("CS_GetClientContributionScore");
   401 	MarkNativeAsOptional("CS_SetClientContributionScore");
   402 	MarkNativeAsOptional("CS_GetClientAssists");
   403 	MarkNativeAsOptional("CS_SetClientAssists");
   404 	MarkNativeAsOptional("CS_AliasToWeaponID");
   405 }
   406 #endif
   407