Advertisement
FlacoBey

Untitled

Jun 14th, 2019
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 38.86 KB | None | 0 0
  1. #if defined _l4d_stocks_included
  2.  #endinput
  3. #endif
  4. #define _l4d_stocks_included
  5.  
  6. #include <sdktools>
  7. #include <l4d_weapon_stocks>
  8.  
  9. /* Spawn state bit flags */
  10. #define L4D_SPAWNFLAG_CANSPAWN          (0 << 0)
  11. #define L4D_SPAWNFLAG_DISABLED          (1 << 0)
  12. #define L4D_SPAWNFLAG_WAITFORSURVIVORS  (1 << 1)
  13. #define L4D_SPAWNFLAG_WAITFORFINALE     (1 << 2)
  14. #define L4D_SPAWNFLAG_WAITFORTANKTODIE  (1 << 3)
  15. #define L4D_SPAWNFLAG_SURVIVORESCAPED   (1 << 4)
  16. #define L4D_SPAWNFLAG_DIRECTORTIMEOUT   (1 << 5)
  17. #define L4D_SPAWNFLAG_WAITFORNEXTWAVE   (1 << 6)
  18. #define L4D_SPAWNFLAG_CANBESEEN         (1 << 7)
  19. #define L4D_SPAWNFLAG_TOOCLOSE          (1 << 8)
  20. #define L4D_SPAWNFLAG_RESTRICTEDAREA    (1 << 9)
  21. #define L4D_SPAWNFLAG_BLOCKED           (1 << 10)
  22.  
  23. /* Weapon upgrade bit flags */
  24. #define L4D2_WEPUPGFLAG_NONE            (0 << 0)
  25. #define L4D2_WEPUPGFLAG_INCENDIARY      (1 << 0)
  26. #define L4D2_WEPUPGFLAG_EXPLOSIVE       (1 << 1)
  27. #define L4D2_WEPUPGFLAG_LASER           (1 << 2)
  28.  
  29. /* Instructor Hint bit flags */
  30. #define L4D2_IHFLAG_NONE                (0 << 0)
  31. #define L4D2_IHFLAG_PULSE_SLOW          (1 << 0)
  32. #define L4D2_IHFLAG_PULSE_FAST          (1 << 1)
  33. #define L4D2_IHFLAG_PULSE_URGENT        (1 << 2)
  34. #define L4D2_IHFLAG_ALPHA_SLOW          (1 << 3)
  35. #define L4D2_IHFLAG_ALPHA_FAST          (1 << 4)
  36. #define L4D2_IHFLAG_ALPHA_URGENT        (1 << 5)
  37. #define L4D2_IHFLAG_SHAKE_NARROW        (1 << 6)
  38. #define L4D2_IHFLAG_SHAKE_WIDE          (1 << 7)
  39. #define L4D2_IHFLAG_STATIC              (1 << 8)
  40.  
  41. /* Survivor intensity -- Equal or less */
  42. #define L4D_SURVIVORINTENSITY_MILD      0.25
  43. #define L4D_SURVIVORINTENSITY_MODERATE  0.50
  44. #define L4D_SURVIVORINTENSITY_HIGH      0.75
  45. #define L4D_SURVIVORINTENSITY_EXTREME   1.00
  46.  
  47. enum L4DTeam
  48. {
  49.     L4DTeam_Unassigned              = 0,
  50.     L4DTeam_Spectator               = 1,
  51.     L4DTeam_Survivor                = 2,
  52.     L4DTeam_Infected                = 3
  53. }
  54.  
  55. enum L4DWeaponSlot
  56. {
  57.     L4DWeaponSlot_Primary           = 0,
  58.     L4DWeaponSlot_Secondary         = 1,
  59.     L4DWeaponSlot_Grenade           = 2,
  60.     L4DWeaponSlot_FirstAid          = 3,
  61.     L4DWeaponSlot_Pills             = 4
  62. }
  63.  
  64. enum L4D2GlowType
  65. {
  66.     L4D2Glow_None                   = 0,
  67.     L4D2Glow_OnUse                  = 1,
  68.     L4D2Glow_OnLookAt               = 2,
  69.     L4D2Glow_Constant               = 3
  70. }
  71.  
  72. enum L4D1ZombieClassType
  73. {
  74.     L4D1ZombieClass_Smoker          = 1,
  75.     L4D1ZombieClass_Boomer          = 2,
  76.     L4D1ZombieClass_Hunter          = 3,
  77.     L4D1ZombieClass_Witch           = 4,
  78.     L4D1ZombieClass_Tank            = 5,
  79.     L4D1ZombieClass_NotInfected     = 6
  80. }
  81.  
  82. enum L4D2ZombieClassType
  83. {
  84.     L4D2ZombieClass_Smoker          = 1,
  85.     L4D2ZombieClass_Boomer          = 2,
  86.     L4D2ZombieClass_Hunter          = 3,
  87.     L4D2ZombieClass_Spitter         = 4,
  88.     L4D2ZombieClass_Jockey          = 5,
  89.     L4D2ZombieClass_Charger         = 6,
  90.     L4D2ZombieClass_Witch           = 7,
  91.     L4D2ZombieClass_Tank            = 8,
  92.     L4D2ZombieClass_NotInfected     = 9
  93. }
  94.  
  95. enum L4D2UseAction
  96. {
  97.     L4D2UseAction_None              = 0, // No use action active
  98.     L4D2UseAction_Healing           = 1, // Includes healing yourself or a teammate.
  99.     L4D2UseAction_Defibing          = 4, // When defib'ing a dead body.
  100.     L4D2UseAction_GettingDefibed    = 5, // When comming back to life from a dead body.
  101.     L4D2UseAction_PouringGas        = 8, // Pouring gas into a generator
  102.     L4D2UseAction_Cola              = 9, // For Dead Center map 2 cola event, when handing over the cola to whitalker.
  103.     L4D2UseAction_Button            = 10 // Such as buttons, timed buttons, generators, etc.
  104.     /* List is not fully done, these are just the ones I have found so far */
  105. }
  106.  
  107. enum L4DResourceType
  108. {
  109.     L4DResource_Ping,
  110.     L4DResource_Score,
  111.     L4DResource_TankTickets,
  112.     L4DResource_Deaths,
  113.     L4DResource_MaxHealth,
  114.     L4DResource_WantsToPlay,
  115.     L4DResource_TankTickets2
  116. }
  117.  
  118. static const String:L4DResourceName[L4DResourceType][] =
  119. {
  120.     "m_iPing",
  121.     "m_iScore",
  122.     "m_iTankTickets",
  123.     "m_iDeaths",
  124.     "m_maxHealth",
  125.     "m_wantsToPlay",
  126.     "m_tankTickets"
  127. };
  128.  
  129. /**
  130.  * Returns zombie player L4D1 zombie class.
  131.  *
  132.  * @param client        Player's index.
  133.  * @return              Current L4D1ZombieClassTypes of player.
  134.  * @error               Invalid client index.
  135.  */
  136. stock L4D1ZombieClassTypes:L4D1_GetPlayerZombieClass(client)
  137. {
  138.     return L4D1ZombieClassType:GetEntProp(client, Prop_Send, "m_zombieClass");
  139. }
  140.  
  141. /**
  142.  * Set zombie player L4D1 zombie class.
  143.  *
  144.  * @param client        Player's index.
  145.  * @param class         L4D1ZombieClassTypes class symbol.
  146.  * @noreturn
  147.  * @error               Invalid client index.
  148.  */
  149. stock L4D1_SetPlayerZombieClass(client, L4D1ZombieClassTypes:class)
  150. {
  151.     SetEntProp(client, Prop_Send, "m_zombieClass", _:class);
  152. }
  153.  
  154. /**
  155.  * Returns zombie player L4D2 zombie class.
  156.  *
  157.  * @param client        Player's index.
  158.  * @return              Current L4D2ZombieClassTypes of player.
  159.  * @error               Invalid client index.
  160.  */
  161. stock L4D2ZombieClassType:L4D2_GetPlayerZombieClass(client)
  162. {
  163.     return L4D2ZombieClassType:GetEntProp(client, Prop_Send, "m_zombieClass");
  164. }
  165.  
  166. /**
  167.  * Set zombie player L4D2 zombie class.
  168.  *
  169.  * @param client        Player's index.
  170.  * @param class         L4D2ZombieClassTypes class symbol.
  171.  * @noreturn
  172.  * @error               Invalid client index.
  173.  */
  174. stock L4D2_SetPlayerZombieClass(client, L4D2ZombieClassType:class)
  175. {
  176.     SetEntProp(client, Prop_Send, "m_zombieClass", _:class);
  177. }
  178.  
  179. /**
  180.  * Returns ghost state of zombie player.
  181.  *
  182.  * @param client        Player index.
  183.  * @return              True if player is ghost, false otherwise.
  184.  * @error               Invalid client index.
  185.  */
  186. stock bool:L4D_IsPlayerGhost(client)
  187. {
  188.     return bool:GetEntProp(client, Prop_Send, "m_isGhost", 1);
  189. }
  190.  
  191. /**
  192.  * Sets ghost state of zombie player.
  193.  *
  194.  * @param client        Player index.
  195.  * @param isGhost       Sets ghost status.
  196.  * @noreturn
  197.  * @error               Invalid client index.
  198.  */
  199. stock L4D_SetPlayerGhostState(client, bool:isGhost)
  200. {
  201.     SetEntProp(client, Prop_Send, "m_isGhost", isGhost, 1);
  202. }
  203.  
  204. /**
  205.  * Returns ghost spawn state of zombie player.
  206.  *
  207.  * @param client        Player index.
  208.  * @return              Player's spawn state bits.
  209.  * @error               Invalid client index.
  210.  */
  211. stock L4D_GetPlayerGhostSpawnState(client)
  212. {
  213.     return GetEntProp(client, Prop_Send, "m_ghostSpawnState");
  214. }
  215.  
  216. /**
  217.  * Set zombie player's ghost spawn state bits.
  218.  *
  219.  * Note: The game updates spawn state bits every frame.
  220.  *
  221.  * @param client        Player index.
  222.  * @param bits          Ghost spawn state bits.
  223.  * @noreturn
  224.  * @error               Invalid client index.
  225.  */
  226. stock L4D_SetPlayerGhostSpawnState(client, bits)
  227. {
  228.     SetEntProp(client, Prop_Send, "m_ghostSpawnState", bits);
  229. }
  230.  
  231. /**
  232.  * Returns whether zombie player is culling.
  233.  *
  234.  * @param client        Player index.
  235.  * @return              True if player is culling, false otherwise.
  236.  */
  237. stock L4D_IsPlayerCulling(client)
  238. {
  239.     return bool:GetEntProp(client, Prop_Send, "m_isCulling", 1);
  240. }
  241.  
  242. /**
  243.  * Set culling state of zombie player.
  244.  *
  245.  * @param client        Player index.
  246.  * @param isCulling     Whether player is culling.
  247.  * @noreturn
  248.  * @error               Invalid client index.
  249.  */
  250. stock L4D_SetPlayerCullingState(client, bool:isCulling)
  251. {
  252.     SetEntProp(client, Prop_Send, "m_isCulling", isCulling, 1);
  253. }
  254.  
  255. /**
  256.  * Returns whether player is incapacitated.
  257.  *
  258.  * Note: A tank player will return true when in dying animation.
  259.  *
  260.  * @param client        Player index.
  261.  * @return              True if incapacitated, false otherwise.
  262.  * @error               Invalid client index.
  263.  */
  264. stock bool:L4D_IsPlayerIncapacitated(client)
  265. {
  266.     return bool:GetEntProp(client, Prop_Send, "m_isIncapacitated", 1);
  267. }
  268.  
  269. /**
  270.  * Set player's incapacitated state.
  271.  *
  272.  * @param client        Player index.
  273.  * @param isIncapacitated Whether the player is incapacitated.
  274.  * @noreturn
  275.  * @error               Invalid client index.
  276.  */
  277. stock L4D_SetPlayerIncapacitatedState(client, bool:isIncapacitated)
  278. {
  279.     SetEntProp(client, Prop_Send, "m_isIncapacitated", isIncapacitated, 1);
  280. }
  281.  
  282. /**
  283.  * Returns survivor player shove penalty.
  284.  *
  285.  * @param client        Player index.
  286.  * @return              Current shove penalty of player.
  287.  */
  288. stock L4D_GetPlayerShovePenalty(client)
  289. {
  290.     return GetEntProp(client, Prop_Send, "m_iShovePenalty");
  291. }
  292.  
  293. /**
  294.  * Set survivor player shove penalty.
  295.  *
  296.  * @param client        Player index.
  297.  * @param shovePenalty  Shove penalty.
  298.  * @noreturn
  299.  * @error               Invalid client index.
  300.  */
  301. stock L4D_SetPlayerShovePenalty(client, shovePenalty)
  302. {
  303.     SetEntProp(client, Prop_Send, "m_iShovePenalty", shovePenalty);
  304. }
  305.  
  306. /**
  307.  * Returns tank player's frustration.
  308.  *
  309.  * @param client        Player index.
  310.  * @return              How frustrated tank player is.
  311.  * @error               Invalid client index.
  312.  */
  313. stock L4D_GetTankFrustration(client)
  314. {
  315.     return GetEntProp(client, Prop_Send, "m_frustration");
  316. }
  317.  
  318. /**
  319.  * Set tank player's frustration.
  320.  *
  321.  * @param client        Player index.
  322.  * @param frustration   How frustrated tank player is.
  323.  * @noreturn
  324.  * @error               Invalid client index.
  325.  */
  326. stock L4D_SetTankFrustration(client, frustration)
  327. {
  328.     SetEntProp(client, Prop_Send, "m_frustration", frustration);
  329. }
  330.  
  331. /**
  332.  * Returns whether survivor player is idle.
  333.  *
  334.  * @param               Player index.
  335.  * @return              True if idle, false otherwise.
  336.  */
  337. stock bool:L4D_IsPlayerIdle(client)
  338. {
  339.     return L4D_GetBotOfIdlePlayer(client) > -1;
  340. }
  341.  
  342. /**
  343.  * Returns survivor bot of idle survivor player.
  344.  *
  345.  * @param client        Player index.
  346.  * @return              Player index of the bot, -1 if not found.
  347.  */
  348. stock L4D_GetBotOfIdlePlayer(client)
  349. {
  350.     new idleClient;
  351.     new offset;
  352.     decl String:netclass[128];
  353.  
  354.     for (new bot = 1; bot <= MaxClients; bot++)
  355.     {
  356.         if (!IsClientInGame(bot) ||
  357.             !IsFakeClient(bot) ||
  358.             L4DTeam:GetClientTeam(bot) != L4DTeam_Survivor ||
  359.             !IsPlayerAlive(bot) ||
  360.             GetClientHealth(bot) < 1)
  361.         {
  362.             continue;
  363.         }
  364.  
  365.         GetEntityNetClass(bot, netclass, 128);
  366.         offset = FindSendPropInfo(netclass, "m_humanSpectatorUserID");
  367.  
  368.         if (offset < 1)
  369.         {
  370.             continue;
  371.         }
  372.  
  373.         idleClient = GetClientOfUserId(GetEntProp(bot, Prop_Send, "m_humanSpectatorUserID"));
  374.  
  375.         if (idleClient == client)
  376.         {
  377.             return bot;
  378.         }
  379.     }
  380.  
  381.     return -1;
  382. }
  383.  
  384. /**
  385.  * Returns idle survivor player of survivor bot.
  386.  *
  387.  * @param bot           Player index of bot.
  388.  * @return              Player index of idle client, -1 if not found.
  389.  * @error               Invalid client index.
  390.  */
  391. stock L4D_GetIdlePlayerOfBot(bot)
  392. {
  393.     decl String:netclass[128];
  394.     GetEntityNetClass(bot, netclass, 128);
  395.     new offset = FindSendPropInfo(netclass, "m_humanSpectatorUserID");
  396.  
  397.     if (offset < 1)
  398.     {
  399.         return -1;
  400.     }
  401.  
  402.     return GetClientOfUserId(GetEntProp(bot, Prop_Send, "m_humanSpectatorUserID"));
  403. }
  404.  
  405. /**
  406.  * Returns resource entity.
  407.  *
  408.  * @return              Entity index of resource entity, -1 if not found.
  409.  */
  410. stock L4D_GetResourceEntity()
  411. {
  412.     return FindEntityByClassname(-1, "terror_player_manager");
  413. }
  414.  
  415. /**
  416.  * Retrieves client data from the resource entity.
  417.  *
  418.  * @param client        Player's index.
  419.  * @param type          ResourceType constant
  420.  * @return              Value or -1 on failure.
  421.  * @error               Invalid client index, client not in game or failed to find resource entity.
  422.  */
  423. stock L4D_GetPlayerResourceData(client, L4DResourceType:type)
  424. {
  425.     if (!IsClientConnected(client))
  426.     {
  427.         return -1;
  428.     }
  429.  
  430.     new offset = FindSendPropInfo("CTerrorPlayerResource", L4DResourceName[type]);
  431.  
  432.     if (offset < 1)
  433.     {
  434.         return -1;
  435.     }
  436.  
  437.     new entity = L4D_GetResourceEntity();
  438.  
  439.     if (entity == -1)
  440.     {
  441.         return -1;
  442.     }
  443.  
  444.     return GetEntData(entity, offset + (client * 4));
  445. }
  446.  
  447. /**
  448.  * Sets client data in the resource entity.
  449.  *
  450.  * Note: The game overwrites these values every frame, so changing them will have very little effect.
  451.  *
  452.  * @param client        Player's index.
  453.  * @param type          ResourceType constant
  454.  * @param value         Value to set.
  455.  * @return              Value or -1 on failure.
  456.  * @error               Invalid client index, client not in game or failed to find resource entity.
  457.  */
  458. stock bool:L4D_SetPlayerResourceData(client, L4DResourceType:type, any:value)
  459. {
  460.     if (!IsClientConnected(client))
  461.     {
  462.         return false;
  463.     }
  464.  
  465.     new offset = FindSendPropInfo("CTerrorPlayerResource", L4DResourceName[type]);
  466.  
  467.     if (offset < 1)
  468.     {
  469.         return false;
  470.     }
  471.  
  472.     new entity = L4D_GetResourceEntity();
  473.  
  474.     if (entity == -1)
  475.     {
  476.         return false;
  477.     }
  478.  
  479.     SetEntData(entity, offset + (client * 4), value);
  480.  
  481.     return true;
  482. }
  483.  
  484. /**
  485.  * Removes the weapon from a client's weapon slot
  486.  *
  487.  * @param client        Player's index.
  488.  * @param slot          Slot index.
  489.  * @noreturn
  490.  * @error               Invalid client or lack of mod support.
  491.  */
  492. stock L4D_RemoveWeaponSlot(client, L4DWeaponSlot:slot)
  493. {
  494.     new weaponIndex;
  495.     while ((weaponIndex = GetPlayerWeaponSlot(client, _:slot)) != -1)
  496.     {
  497.         RemovePlayerItem(client, weaponIndex);
  498.         RemoveEdict(weaponIndex);
  499.     }
  500. }
  501.  
  502. /**
  503.  * Removes all weapons from a client
  504.  *
  505.  * @param client        Player's index.
  506.  * @noreturn
  507.  * @error               Invalid client or lack of mod support.
  508.  */
  509. stock L4D_RemoveAllWeapons(client)
  510. {
  511.     for (new i = 0; i <= 4; i++)
  512.     {
  513.         L4D_RemoveWeaponSlot(client, L4DWeaponSlot:i);
  514.     }
  515. }
  516.  
  517. /**
  518.  * Returns whether the finale is active.
  519.  *
  520.  * Note: Finales can also be on other maps than just the finale map. A perfect
  521.  * example of this is the Swamp Fever map 1 crescendo event. This event is
  522.  * defined as a finale by Valve for some reason.
  523.  *
  524.  * @return              True if finale is active, false otherwise.
  525.  */
  526. stock bool:L4D_IsFinaleActive()
  527. {
  528.     new entity = L4D_GetResourceEntity();
  529.  
  530.     if (entity == -1)
  531.     {
  532.         return false;
  533.     }
  534.  
  535.     return bool:GetEntProp(entity, Prop_Send, "m_isFinale", 1);
  536. }
  537.  
  538. /**
  539.  * Returns whether any survivor have left the safe area.
  540.  *
  541.  * @return              True if any survivor have left safe area, false
  542.  *                      otherwise.
  543.  */
  544. stock bool:L4D_HasAnySurvivorLeftSafeArea()
  545. {
  546.     new entity = L4D_GetResourceEntity();
  547.  
  548.     if (entity == -1)
  549.     {
  550.         return false;
  551.     }
  552.  
  553.     return bool:GetEntProp(entity, Prop_Send, "m_hasAnySurvivorLeftSafeArea", 1);
  554. }
  555.  
  556. /**
  557.  * Returns pending tank player.
  558.  *
  559.  * @return              Player index of pending tank player, -1 if not found.
  560.  */
  561. stock L4D_GetPendingTankPlayer()
  562. {
  563.     new entity = L4D_GetResourceEntity();
  564.  
  565.     if (entity == -1)
  566.     {
  567.         return -1;
  568.     }
  569.  
  570.     return GetEntProp(entity, Prop_Send, "m_pendingTankPlayerIndex");
  571. }
  572.  
  573. /**
  574.  * Set entity glow. This is consider safer and more robust over setting each glow
  575.  * property on their own because glow offset will be check first.
  576.  *
  577.  * @param entity        Entity index.
  578.  * @parma type          Glow type.
  579.  * @param range         Glow max range, 0 for unlimited.
  580.  * @param minRange      Glow min range.
  581.  * @param colorOverride Glow color, RGB.
  582.  * @param flashing      Whether the glow will be flashing.
  583.  * @return              True if glow was set, false if entity does not support
  584.  *                      glow.
  585.  */
  586. stock bool:L4D2_SetEntityGlow(entity, L4D2GlowType:type, range, minRange, colorOverride[3], bool:flashing)
  587. {
  588.     if (!IsValidEntity(entity))
  589.     {
  590.         return false;
  591.     }
  592.  
  593.     decl String:netclass[128];
  594.     GetEntityNetClass(entity, netclass, 128);
  595.  
  596.     new offset = FindSendPropInfo(netclass, "m_iGlowType");
  597.  
  598.     if (offset < 1)
  599.     {
  600.         return false;    
  601.     }
  602.  
  603.     L4D2_SetEntityGlow_Type(entity, type);
  604.     L4D2_SetEntityGlow_Range(entity, range);
  605.     L4D2_SetEntityGlow_MinRange(entity, minRange);
  606.     L4D2_SetEntityGlow_Color(entity, colorOverride);
  607.     L4D2_SetEntityGlow_Flashing(entity, flashing);
  608.     return true;
  609. }
  610.  
  611. /**
  612.  * Set entity glow type.
  613.  *
  614.  * @param entity        Entity index.
  615.  * @parma type          Glow type.
  616.  * @noreturn
  617.  * @error               Invalid entity index or entity does not support glow.
  618.  */
  619. stock L4D2_SetEntityGlow_Type(entity, L4D2GlowType:type)
  620. {
  621.     SetEntProp(entity, Prop_Send, "m_iGlowType", _:type);
  622. }
  623.  
  624. /**
  625.  * Set entity glow range.
  626.  *
  627.  * @param entity        Entity index.
  628.  * @parma range         Glow range.
  629.  * @noreturn
  630.  * @error               Invalid entity index or entity does not support glow.
  631.  */
  632. stock L4D2_SetEntityGlow_Range(entity, range)
  633. {
  634.     SetEntProp(entity, Prop_Send, "m_nGlowRange", range);
  635. }
  636.  
  637. /**
  638.  * Set entity glow min range.
  639.  *
  640.  * @param entity        Entity index.
  641.  * @parma minRange      Glow min range.
  642.  * @noreturn
  643.  * @error               Invalid entity index or entity does not support glow.
  644.  */
  645. stock L4D2_SetEntityGlow_MinRange(entity, minRange)
  646. {
  647.     SetEntProp(entity, Prop_Send, "m_nGlowRangeMin", minRange);
  648. }
  649.  
  650. /**
  651.  * Set entity glow color.
  652.  *
  653.  * @param entity        Entity index.
  654.  * @parma colorOverride Glow color, RGB.
  655.  * @noreturn
  656.  * @error               Invalid entity index or entity does not support glow.
  657.  */
  658. stock L4D2_SetEntityGlow_Color(entity, colorOverride[3])
  659. {
  660.     SetEntProp(entity, Prop_Send, "m_glowColorOverride", colorOverride[0] + (colorOverride[1] * 256) + (colorOverride[2] * 65536));
  661. }
  662.  
  663. /**
  664.  * Set entity glow flashing state.
  665.  *
  666.  * @param entity        Entity index.
  667.  * @parma flashing      Whether glow will be flashing.
  668.  * @noreturn
  669.  * @error               Invalid entity index or entity does not support glow.
  670.  */
  671. stock L4D2_SetEntityGlow_Flashing(entity, bool:flashing)
  672. {
  673.     SetEntProp(entity, Prop_Send, "m_bFlashing", _:flashing);
  674. }
  675.  
  676. /**
  677.  * Returns entity glow type.
  678.  *
  679.  * @param entity        Entity index.
  680.  * @return              L4D2 glow type.
  681.  * @error               Invalid entity index or entity does not support glow.
  682.  */
  683. stock L4D2GlowType:L4D2_GetEntityGlow_Type(entity)
  684. {
  685.     return L4D2GlowType:GetEntProp(entity, Prop_Send, "m_iGlowType");
  686. }
  687.  
  688. /**
  689.  * Returns entity glow range.
  690.  *
  691.  * @param entity        Entity index.
  692.  * @return              Glow range.
  693.  * @error               Invalid entity index or entity does not support glow.
  694.  */
  695. stock L4D2_GetEntityGlow_Range(entity)
  696. {
  697.     return GetEntProp(entity, Prop_Send, "m_nGlowRange");
  698. }
  699.  
  700. /**
  701.  * Returns entity glow min range.
  702.  *
  703.  * @param entity        Entity index.
  704.  * @return              Glow min range.
  705.  * @error               Invalid entity index or entity does not support glow.
  706.  */
  707. stock L4D2_GetEntityGlow_MinRange(entity)
  708. {
  709.     return GetEntProp(entity, Prop_Send, "m_nGlowRangeMin");
  710. }
  711.  
  712. /**
  713.  * Returns entity glow flashing state.
  714.  *
  715.  * @param entity        Entity index.
  716.  * @return              Glow flashing state.
  717.  * @error               Invalid entity index or entity does not support glow.
  718.  */
  719. stock bool:L4D2_GetEntityGlow_Flashing(entity)
  720. {
  721.     return bool:GetEntProp(entity, Prop_Send, "m_bFlashing");
  722. }
  723.  
  724. /**
  725.  * Removes entity glow.
  726.  *
  727.  * @param entity        Entity index.
  728.  * @return              True if glow was removed, false if entity does not
  729.  *                      support glow.
  730.  */
  731. stock bool:L4D2_RemoveEntityGlow(entity)
  732. {
  733.     return L4D2_SetEntityGlow(entity, L4D2Glow_None, 0, 0, { 0, 0, 0 }, false);
  734. }
  735.  
  736. /**
  737.  * Removes entity glow override color.
  738.  *
  739.  * Note: This only removes the override color and reset it to the default glow
  740.  * color.
  741.  *
  742.  * @param entity        Entity index.
  743.  * @noreturn
  744.  * @error               Invalid entity index or entity does not support glow.
  745.  */
  746. stock L4D2_RemoveEntityGlow_Color(entity)
  747. {
  748.     L4D2_SetEntityGlow_Color(entity, { 0, 0, 0 });
  749. }
  750.  
  751. /**
  752.  * Whether survivor glow for player is enabled.
  753.  *
  754.  * @param client        Client index.
  755.  * @return              True if survivor glow is enabled, false otherwise.
  756.  * @error               Invalid client index.
  757.  */
  758. stock bool:L4D2_IsPlayerSurvivorGlowEnable(client)
  759. {
  760.     return bool:GetEntProp(client, Prop_Send, "m_bSurvivorGlowEnabled");
  761. }
  762.  
  763. /**
  764.  * Set survivor glow state for player.
  765.  *
  766.  * @param client        Client index.
  767.  * @param enabled       Whether survivor glow is enabled.
  768.  * @noreturn
  769.  * @error               Invalid client index.
  770.  */
  771. stock L4D2_SetPlayerSurvivorGlowState(client, bool:enabled)
  772. {
  773.     SetEntProp(client, Prop_Send, "m_bSurvivorGlowEnabled", _:enabled);
  774. }
  775.  
  776. /**
  777.  * Return player current revive count.
  778.  *
  779.  * @param client        Client index.
  780.  * @return              Survivor's current revive count.
  781.  * @error               Invalid client index.
  782.  */
  783. stock L4D_GetPlayerReviveCount(client)
  784. {
  785.     return GetEntProp(client, Prop_Send, "m_currentReviveCount");
  786. }
  787.  
  788. /**
  789.  * Set player revive count.
  790.  *
  791.  * @param client        Client index.
  792.  * @param count         Revive count.
  793.  * @noreturn
  794.  * @error               Invalid client index.
  795.  */
  796. stock L4D_SetPlayerReviveCount(client, count)
  797. {
  798.     SetEntProp(client, Prop_Send, "m_currentReviveCount", count);
  799. }
  800.  
  801. /**
  802.  * Return player intensity.
  803.  *
  804.  * Note: Its percentage. 0.0 - Player is calm, 1.0 - Player is stressed.
  805.  *
  806.  * @param client        Client index.
  807.  * @return              Intensity.
  808.  * @error               Invalid client index.
  809.  */
  810. stock Float:L4D_GetPlayerIntensity(client)
  811. {
  812.     /* This format is used to keep consistency with the Director which also
  813.      * uses 0.0 for calm and 1.0 for stressed */
  814.     return float(GetEntProp(client, Prop_Send, "m_clientIntensity")) / 100.0;
  815. }
  816.  
  817. /**
  818.  * Returns average survivor intensity.
  819.  *
  820.  * Note: Its percentage. 0.0 - All survivors is calm, 1.0 - All survivors is
  821.  * stressed.
  822.  *
  823.  * @return              Average intensity level for survivors.
  824.  */
  825. stock Float:L4D_GetAvgSurvivorIntensity()
  826. {
  827.     new intensityTotal = 0;
  828.     new intensityMaxTotal = 0;
  829.  
  830.     for (new client = 1; client <= MaxClients; client++)
  831.     {
  832.         if (!IsClientInGame(client) ||
  833.             L4DTeam:GetClientTeam(client) != L4DTeam_Survivor ||
  834.             !IsPlayerAlive(client) ||
  835.             GetClientHealth(client) < 1)
  836.         {
  837.             continue;
  838.         }
  839.  
  840.         intensityMaxTotal += 100;
  841.         intensityTotal += GetEntProp(client, Prop_Send, "m_clientIntensity");
  842.     }
  843.  
  844.     /* This format is used to keep consistency with the Director which also
  845.      * uses 0.0 for calm and 1.0 for stressed */
  846.     return float(intensityTotal) / float(intensityMaxTotal);
  847. }
  848.  
  849. /**
  850.  * Set player intensity.
  851.  *
  852.  * Note: Its percentage. 0.0 - Player is calm, 1.0 - Player is stressed.
  853.  *
  854.  * @param client        Client index.
  855.  * @param intensity     Intensity.
  856.  * @noreturn
  857.  * @error               Invalid client index.
  858.  */
  859. stock L4D_SetPlayerIntensity(client, Float:intensity)
  860. {
  861.     SetEntProp(client, Prop_Send, "m_clientIntensity", RoundToNearest(intensity * 100.0);
  862. }
  863.  
  864. /**
  865.  * Returns whether player is calm.
  866.  *
  867.  * Note: Player is calm means that the player have not taken damage or
  868.  * fired their weapon for a while. Survivor bots always return false.
  869.  *
  870.  * @param client        Client index.
  871.  * @return              True if player is calm, false otherwise.
  872.  * @error               Invalid client index.
  873.  */
  874. stock bool:L4D_IsPlayerCalm(client)
  875. {
  876.     return bool:GetEntProp(client, Prop_Send, "m_isCalm");
  877. }
  878.  
  879. /**
  880.  * Set player is calm state.
  881.  *
  882.  * Note: Player is calm means that the player have not taken damage or
  883.  * fired their weapon for a while.
  884.  *
  885.  * @param client        Client index.
  886.  * @param isCalm        Whether player is calm.
  887.  * @noreturn
  888.  * @error               Invalid client index.
  889.  */
  890. stock L4D_SetPlayerCalmState(client, bool:isCalm)
  891. {
  892.     SetEntProp(client, Prop_Send, "m_isCalm", _:isCalm);
  893. }
  894.  
  895. /**
  896.  * Returns whether player has visible threats.
  897.  *
  898.  * Note: This function only works on Survivors. Survivors looking upon
  899.  * specials, witch or tank will be marked as has visisble threats. However
  900.  * looking at commons will not be seen as has visible threats. The common has
  901.  * to be awkaen from its slumber before beings seen as a threat.
  902.  *
  903.  * @parma client        Client index.
  904.  * @return              True if player has visible threats, false otherwise.
  905.  * @error               Invalid client index.
  906.  */
  907. stock bool:L4D_HasVisibleThreats(client)
  908. {
  909.     return bool:GetEntProp(client, Prop_Send, "m_hasVisibleThreats");
  910. }
  911.  
  912. /**
  913.  * Returns whether player is on third strike.
  914.  *
  915.  * @param client        Client index.
  916.  * @return              True if on third strike, false otherwise.
  917.  * @error               Invalid client index.
  918.  */
  919. stock bool:L4D_IsPlayerOnThirdStrike(client)
  920. {
  921.     return bool:GetEntProp(client, Prop_Send, "m_bIsOnThirdStrike");
  922. }
  923.  
  924. /**
  925.  * Set player third strike state.
  926.  *
  927.  * @param client        Client index.
  928.  * @param onThirdStrike Whether survivor is on third strike.
  929.  * @noreturn
  930.  * @error               Invalid client index.
  931.  */
  932. stock L4D_SetPlayerThirdStrikeState(client, bool:onThirdStrike)
  933. {
  934.     SetEntProp(client, Prop_Send, "m_bIsOnThirdStrike", _:onThirdStrike);
  935. }
  936.  
  937. /**
  938.  * Returns whether player is going to die.
  939.  *
  940.  * Note: This is not the same as is player on third strike. While on third
  941.  * strike defines whether player should die next time they get incapacitated,
  942.  * this defines whether the survivor should limp when they hit 1hp and make
  943.  * the character vocalize their "I dont think I'm gonna make it" lines.
  944.  *
  945.  * @param client        Client index.
  946.  * @return              True if player is going to die, false otherwise.
  947.  * @error               Invalid client index.
  948.  */
  949. stock bool:L4D_IsPlayerGoingToDie(client)
  950. {
  951.     return bool:GetEntProp(client, Prop_Send, "m_isGoingToDie");
  952. }
  953.  
  954. /**
  955.  * Set player is going to die state.
  956.  *
  957.  * @param client        Client index.
  958.  * @param isGoingToDie  Whether player is going to die.
  959.  * @noreturn
  960.  * @error               Invalid client index.
  961.  */
  962. stock L4D_SetPlayerIsGoingToDie(client, bool:isGoingToDie)
  963. {
  964.     SetEntProp(client, Prop_Send, "m_isGoingToDie", _:isGoingToDie);
  965. }
  966.  
  967. /**
  968.  * Returns whether weapon is upgrade compatible.
  969.  *
  970.  * @param weapon        Weapon entity index.
  971.  * @return              True if compatiable with upgrades, false otherwise.
  972.  * @error               Invalid entity index.
  973.  */
  974. stock bool:L4D2_IsWeaponUpgradeCompatible(weapon)
  975. {
  976.     decl String:netclass[128];
  977.     GetEntityNetClass(weapon, netclass, 128);
  978.     return FindSendPropInfo(netclass, "m_upgradeBitVec") > 0;
  979. }
  980.  
  981. /**
  982.  * Returns upgraded ammo count for weapon.
  983.  *
  984.  * @param weapon        Weapon entity index.
  985.  * @return              Upgraded ammo count.
  986.  * @error               Invalid entity index.
  987.  */
  988. stock L4D2_GetWeaponUpgradeAmmoCount(weapon)
  989. {
  990.     return GetEntProp(weapon, Prop_Send, "m_nUpgradedPrimaryAmmoLoaded");
  991. }
  992.  
  993. /**
  994.  * Set upgraded ammo count in weapon.
  995.  *
  996.  * @param weapon        Weapon entity index.
  997.  * @param count         Upgraded ammo count.
  998.  * @noreturn
  999.  * @error               Invalid entity index.
  1000.  */
  1001. stock L4D2_SetWeaponUpgradeAmmoCount(weapon, count)
  1002. {
  1003.     SetEntProp(weapon, Prop_Send, "m_nUpgradedPrimaryAmmoLoaded", count);
  1004. }
  1005.  
  1006. /**
  1007.  * Returns weapon upgrades of weapon.
  1008.  *
  1009.  * @param weapon        Weapon entity index.
  1010.  * @return              Weapon upgrade bits.
  1011.  * @error               Invalid entity index.
  1012.  */
  1013. stock L4D2_GetWeaponUpgrades(weapon)
  1014. {
  1015.     return GetEntProp(weapon, Prop_Send, "m_upgradeBitVec");
  1016. }
  1017.  
  1018. /**
  1019.  * Set weapon upgrades for weapon.
  1020.  *
  1021.  * @param weapon        Weapon entity index.
  1022.  * @param upgrades      Weapon upgrade bits.
  1023.  * @noreturn
  1024.  * @error               Invalid entity index.
  1025.  */
  1026. stock L4D2_SetWeaponUpgrades(weapon, upgrades)
  1027. {
  1028.     SetEntProp(weapon, Prop_Send, "m_upgradeBitVec", upgrades);
  1029. }
  1030.  
  1031. /**
  1032.  * Returns infected attacker of survivor victim.
  1033.  *
  1034.  * Note: Infected attacker means the infected player that is currently
  1035.  * pinning down the survivor. Such as hunter, smoker, charger and jockey.
  1036.  *
  1037.  * @param client        Survivor client index.
  1038.  * @return              Infected attacker index, -1 if not found.
  1039.  * @error               Invalid client index.
  1040.  */
  1041. stock L4D2_GetInfectedAttacker(client)
  1042. {
  1043.     new attacker;
  1044.  
  1045.     /* Charger */
  1046.     attacker = GetEntPropEnt(client, Prop_Send, "m_pummelAttacker");
  1047.     if (attacker > 0)
  1048.     {
  1049.         return attacker;
  1050.     }
  1051.  
  1052.     attacker = GetEntPropEnt(client, Prop_Send, "m_carryAttacker");
  1053.     if (attacker > 0)
  1054.     {
  1055.         return attacker;
  1056.     }
  1057.  
  1058.     /* Hunter */
  1059.     attacker = GetEntPropEnt(client, Prop_Send, "m_pounceAttacker");
  1060.     if (attacker > 0)
  1061.     {
  1062.         return attacker;
  1063.     }
  1064.  
  1065.     /* Smoker */
  1066.     attacker = GetEntPropEnt(client, Prop_Send, "m_tongueOwner");
  1067.     if (attacker > 0)
  1068.     {
  1069.         return attacker;
  1070.     }
  1071.  
  1072.     /* Jockey */
  1073.     attacker = GetEntPropEnt(client, Prop_Send, "m_jockeyAttacker");
  1074.     if (attacker > 0)
  1075.     {
  1076.         return attacker;
  1077.     }
  1078.  
  1079.     return -1;
  1080. }
  1081.  
  1082. /**
  1083.  * Returns survivor victim of infected attacker.
  1084.  *
  1085.  * Note: Survivor victim means the survivor player that is currently pinned
  1086.  * down by an attacker. Such as hunter, smoker, charger and jockey.
  1087.  *
  1088.  * @param client        Infected client index.
  1089.  * @return              Survivor victim index, -1 if not found.
  1090.  * @error               Invalid client index.
  1091.  */
  1092. stock L4D2_GetSurvivorVictim(client)
  1093. {
  1094.     new victim;
  1095.  
  1096.     /* Charger */
  1097.     victim = GetEntPropEnt(client, Prop_Send, "m_pummelVictim");
  1098.     if (victim > 0)
  1099.     {
  1100.         return victim;
  1101.     }
  1102.  
  1103.     victim = GetEntPropEnt(client, Prop_Send, "m_carryVictim");
  1104.     if (victim > 0)
  1105.     {
  1106.         return victim;
  1107.     }
  1108.  
  1109.     /* Hunter */
  1110.     victim = GetEntPropEnt(client, Prop_Send, "m_pounceVictim");
  1111.     if (victim > 0)
  1112.     {
  1113.         return victim;
  1114.     }
  1115.  
  1116.     /* Smoker */
  1117.     victim = GetEntPropEnt(client, Prop_Send, "m_tongueVictim");
  1118.     if (victim > 0)
  1119.     {
  1120.         return victim;
  1121.     }
  1122.  
  1123.     /* Jockey */
  1124.     victim = GetEntPropEnt(client, Prop_Send, "m_jockeyVictim");
  1125.     if (victim > 0)
  1126.     {
  1127.         return victim;
  1128.     }
  1129.  
  1130.     return -1;
  1131. }
  1132.  
  1133. /**
  1134.  * Returns whether survivor client was present at survival start.
  1135.  *
  1136.  * @param client        Client index.
  1137.  * @return              True if survivor was present at survival start, false
  1138.  *                      otherwise.
  1139.  * @error               Invalid client index.
  1140.  */
  1141. stock bool:L4D2_WasPresentAtSurvivalStart(client)
  1142. {
  1143.     return bool:GetEntProp(client, Prop_Send, "m_bWasPresentAtSurvivalStart");
  1144. }
  1145.  
  1146. /**
  1147.  * Sets whether player was present at survival start.
  1148.  *
  1149.  * @param client        Client index.
  1150.  * @param wasPresent    Whether survivor was present at survival start.
  1151.  * @noreturn
  1152.  * @error               Invalid client index.
  1153.  */
  1154. stock L4D2_SetPresentAtSurvivalStart(client, bool:wasPresent)
  1155. {
  1156.     SetEntProp(client, Prop_Send, "m_bWasPresentAtSurvivalStart", _:wasPresent);
  1157. }
  1158.  
  1159. /**
  1160.  * Returns whether player is using a mounted weapon.
  1161.  *
  1162.  * @param client        Client index.
  1163.  * @return              True if using a mounted weapon, false otherwise.
  1164.  * @error               Invalid client index.
  1165.  */
  1166. stock bool:L4D_IsPlayerUsingMountedWeapon(client)
  1167. {
  1168.     return bool:GetEntProp(client, Prop_Send, "m_usingMountedWeapon");
  1169. }
  1170.  
  1171. /**
  1172.  * Returns player temporarily health.
  1173.  *
  1174.  * Note: This will not work with mutations or campaigns that alters the decay
  1175.  * rate through vscript'ing. If you want to be sure that it works no matter
  1176.  * the mutation, you will have to detour the OnGetScriptValueFloat function.
  1177.  * Doing so you are able to capture the altered decay rate and calulate the
  1178.  * temp health the same way as this function does.
  1179.  *
  1180.  * @param client        Client index.
  1181.  * @return              Player's temporarily health, -1 if unable to get.
  1182.  * @error               Invalid client index or unable to find
  1183.  *                      pain_pills_decay_rate cvar.
  1184.  */
  1185. stock L4D_GetPlayerTempHealth(client)
  1186. {
  1187.     static Handle:painPillsDecayCvar = INVALID_HANDLE;
  1188.     if (painPillsDecayCvar == INVALID_HANDLE)
  1189.     {
  1190.         painPillsDecayCvar = FindConVar("pain_pills_decay_rate");
  1191.         if (painPillsDecayCvar == INVALID_HANDLE)
  1192.         {
  1193.             return -1;
  1194.         }
  1195.     }
  1196.  
  1197.     new tempHealth = RoundToCeil(GetEntPropFloat(client, Prop_Send, "m_healthBuffer") - ((GetGameTime() - GetEntPropFloat(client, Prop_Send, "m_healthBufferTime")) * GetConVarFloat(painPillsDecayCvar))) - 1;
  1198.     return tempHealth < 0 ? 0 : tempHealth;
  1199. }
  1200.  
  1201. /**
  1202.  * Set players temporarily health.
  1203.  *
  1204.  * @param client        Client index.
  1205.  * @param tempHealth    Temporarily health.
  1206.  * @noreturn
  1207.  * @error               Invalid client index.
  1208.  */
  1209. stock L4D_SetPlayerTempHealth(client, tempHealth)
  1210. {
  1211.     SetEntPropFloat(client, Prop_Send, "m_healthBuffer", float(tempHealth));
  1212.     SetEntPropFloat(client, Prop_Send, "m_healthBufferTime", GetGameTime());
  1213. }
  1214.  
  1215. /**
  1216.  * Returns player use action.
  1217.  *
  1218.  * @param client        Client index.
  1219.  * @return              Use action.
  1220.  * @error               Invalid client index.
  1221.  */
  1222. stock L4D2UseAction:L4D2_GetPlayerUseAction(client)
  1223. {
  1224.     return L4D2UseAction:GetEntProp(client, Prop_Send, "m_iCurrentUseAction");
  1225. }
  1226.  
  1227. /**
  1228.  * Returns player use action target.
  1229.  *
  1230.  * @param client        Client index.
  1231.  * @return              Entity index.
  1232.  * @error               Invalid client index.
  1233.  */
  1234. stock L4D2_GetPlayerUseActionTarget(client)
  1235. {
  1236.     return GetEntPropEnt(client, Prop_Send, "m_useActionTarget");
  1237. }
  1238.  
  1239. /**
  1240.  * Returns player use action owner.
  1241.  *
  1242.  * @param client        Client index.
  1243.  * @return              Entity index.
  1244.  * @error               Invalid client index.
  1245.  */
  1246. stock L4D2_GetPlayerUseActionOwner(client)
  1247. {
  1248.     return GetEntPropEnt(client, Prop_Send, "m_useActionOwner");
  1249. }
  1250.  
  1251. /**
  1252.  * Creates an instructor hint.
  1253.  *
  1254.  * Note: Both infected and survivor players will see hint. No more than one at
  1255.  * a time can be shown. The "newest" hint will override the old no matter the
  1256.  * timeout and range. This instructor hint will not be shown if the given
  1257.  * player is dead.
  1258.  *
  1259.  * @param name          Instructor hint name.
  1260.  * @param target        Entity index of target.
  1261.  * @param caption       Caption of hint.
  1262.  * @param color         Color of the caption. RGB format.
  1263.  * @param iconOnScreen  Icon when hint is on screen.
  1264.  * @param iconOffScreen Icon when hint is off screen.
  1265.  * @param binding       Key binding to show.
  1266.  * @param iconOffset    Height offset for icon from target entity's origin.
  1267.  * @param range         Display range of hint. 0 for unlimited range.
  1268.  * @param timeout       Timeout out for hint. 0 will persist until stopped
  1269.  *                      with L4D2_EndInstructorHint.
  1270.  * @param allowNoDrawTarget Whether hint will work with targets that have
  1271.  *                      nodraw set.
  1272.  * @param noOffScreen   Whether when hint is off screen it will show an arrow
  1273.  *                      pointing to target.
  1274.  * @param forceCaption  Whether the hint and icon will show even when occluded
  1275.  *                      a wall.
  1276.  * @param flags         Instructor hint bit flags. See L4D2_IHFLAG_* defines.
  1277.  * @return              True if send, false otherwise.
  1278.  */
  1279. stock bool:L4D2_CreateInstructorHint(const String:name[],
  1280.                                     target = 0,
  1281.                                     const String:caption[],
  1282.                                     color[3] = {255, 255, 255},
  1283.                                     const String:iconOnScreen[] = "icon_tip",
  1284.                                     const String:iconOffScreen[] = "icon_tip",
  1285.                                     const String:binding[] = "",
  1286.                                     Float:iconOffset = 0.0,
  1287.                                     Float:range = 0.0,
  1288.                                     timeout = 0,
  1289.                                     bool:allowNoDrawTarget = true,
  1290.                                     bool:noOffScreen = false,
  1291.                                     bool:forceCaption = false,
  1292.                                     flags = L4D2_IHFLAG_STATIC)
  1293. {
  1294.     new Handle:event = CreateEvent("instructor_server_hint_create", true);
  1295.     if (event == INVALID_HANDLE)
  1296.     {
  1297.         return false;
  1298.     }
  1299.  
  1300.     decl String:finalizedColor[16];
  1301.     Format(finalizedColor, 16, "%d,%d,%d", color[0], color[1], color[2]);
  1302.  
  1303.     SetEventString(event, "hint_name", name);
  1304.     SetEventInt(event, "hint_target", target);
  1305.     SetEventString(event, "hint_caption", caption);
  1306.     SetEventString(event, "hint_color", finalizedColor);
  1307.     SetEventString(event, "hint_icon_onscreen", iconOnScreen);
  1308.     SetEventString(event, "hint_icon_offscreen", iconOffScreen);
  1309.     SetEventString(event, "hint_binding", binding);
  1310.     SetEventFloat(event, "hint_icon_offset", iconOffset);
  1311.     SetEventFloat(event, "hint_range", range);
  1312.     SetEventInt(event, "hint_timeout", timeout);
  1313.     SetEventBool(event, "hint_allow_nodraw_target", allowNoDrawTarget);
  1314.     SetEventBool(event, "hint_nooffscreen", noOffScreen);
  1315.     SetEventBool(event, "hint_forcecaption", forceCaption);
  1316.     SetEventInt(event, "hint_flags", flags);
  1317.     FireEvent(event);
  1318.     return true;
  1319. }
  1320.  
  1321. /**
  1322.  * Stops all instructor hints with name.
  1323.  *
  1324.  * @param name          Name of instructor hint to stop.
  1325.  * @return              True if send, false otherwise.
  1326.  */
  1327. stock bool:L4D2_StopInstructorHint(const String:name[])
  1328. {
  1329.     new Handle:event = CreateEvent("instructor_server_hint_stop", true);
  1330.     if (event == INVALID_HANDLE)
  1331.     {
  1332.         return false;
  1333.     }
  1334.  
  1335.     SetEventString(event, "hint_name", name);
  1336.     FireEvent(event);
  1337.     return true;
  1338. }
  1339.  
  1340. /**
  1341.  * Returns whether shotgun needs to be pumped.
  1342.  *
  1343.  * @parma weapon        Weapon entity index.
  1344.  * @return              True if shotgun needs to be pumped, false otherwise.
  1345.  */
  1346. stock L4D1_GetShotgunNeedPump(weapon)
  1347. {
  1348.     return GetEntProp(weapon, Prop_Send, "m_needPump");
  1349. }
  1350.  
  1351. /**
  1352.  * Sets whether shotgun needs to be pumped.
  1353.  *
  1354.  * @parma weapon        Weapon entity index.
  1355.  * @parma needPump      Whether shotgun needs to be pumped.
  1356.  * @noreturn
  1357.  */
  1358. stock L4D1_SetShotgunNeedPump(weapon, bool:needPump)
  1359. {
  1360.     return SetEntProp(weapon, Prop_Send, "m_needPump", _:needPump);
  1361. }
  1362.  
  1363. /**
  1364.  * Sets custom ability cooldown of client.
  1365.  *
  1366.  * Note: Used for the Infected class abilities.
  1367.  *
  1368.  * @param client        Client index.
  1369.  * @param time          How long before client can use their custom ability.
  1370.  * @return              True if set, false if no ability found.
  1371.  */
  1372. stock bool:L4D2_SetCustomAbilityCooldown(client, Float:time)
  1373. {
  1374.     new ability = GetEntPropEnt(client, Prop_Send, "m_customAbility");
  1375.     if (ability > 0 && IsValidEdict(ability))
  1376.     {
  1377.         SetEntPropFloat(ability, Prop_Send, "m_duration", time);
  1378.         SetEntPropFloat(ability, Prop_Send, "m_timestamp", GetGameTime() + time);
  1379.         return true;
  1380.     }
  1381.     return false;
  1382. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement