Advertisement
Guest User

Untitled

a guest
Oct 6th, 2019
544
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 141.71 KB | None | 0 0
  1. /* --------------------------------------------------------------------------------------------
  2.  
  3.     "Just Capture The Flag" - by Digi (aka Hunter-Digital)
  4.  
  5.     Thread: http://forums.alliedmods.net/showthread.php?t=132115
  6.  
  7.     Change log below.
  8.  
  9. -------------------------------------------------------------------------------------------- */
  10.  
  11. new const MOD_TITLE[] =         "Just Capture the Flag" /* Please don't modify. */
  12. new const MOD_AUTHOR[] =        "Digi"          /* If you make major changes, add " & YourName" at the end */
  13. new const MOD_VERSION[] =       "1.32c"         /* If you make major changes, add "custom" at the end but do not modify the actual version number! */
  14.  
  15. /*
  16.     Below you can enable/disable each individual feature of this plugin
  17.     NOTE: Remember to compile the plugin again after you modify anything in this file!
  18.  
  19.     -----------------------------------
  20.  
  21.     Description: This uses Orpheu module to make infinite round end and trigger round end on flag captures
  22.     If set to false, ophreu will not be used anymore and rounds could end if all players from one team are dead and round can't end upon flag capture.
  23. */
  24. #define FEATURE_ORPHEU          false
  25.  
  26.  
  27. /*
  28.     Description: This hooks the buy system of the game and changes it, allowing everybody to buy all weapons.
  29.     If set to false, it will disable all buy related stuff like: buy menu, spawn weaopns, special weapons, even C4!
  30.     Disable this if you want to use another plugin that manages buy or doesn't use buy at all (like GunGame)
  31. */
  32. #define FEATURE_BUY         true
  33.  
  34.  
  35. /*
  36.     Description: This allows players to buy and use C4 as a weapon, not an objective, it can be defused tough but the defuser gets a usable C4 back. C4 kills everything in it's radius, including teammates.
  37.     If set to false, C4 usage will be completly disabled so it can't be bought.
  38.  
  39.     Requirements: FEATURE_BUY must be true
  40. */
  41. #define FEATURE_BUYC4           true
  42.  
  43.  
  44. /*
  45.     Description: This allows players to have an adrenaline amount and when it reaches 100, they can use combos.
  46.     If set to false, it will disable all adrenaline stuff, including combos, rewards, buying with adrenaline, everything.
  47. */
  48. #define FEATURE_ADRENALINE      true
  49.  
  50. /* --------------------------------------------------------------------------------------------
  51.     Skip this, advanced configuration more below
  52. */
  53. #if FEATURE_BUY == true && FEATURE_BUYC4 == true
  54. #define FEATURE_C4 true
  55. #else
  56. #define FEATURE_C4 false
  57. #endif
  58.  
  59. #include <amxmodx>
  60. #include <amxmisc>
  61. #include <hamsandwich>
  62.  
  63. #if FEATURE_ORPHEU == true
  64. #include <orpheu_memory>
  65. #include <orpheu>
  66. #endif
  67.  
  68. #include <fakemeta>
  69. #include <cstrike>
  70. #include <engine>
  71. #include <fun>
  72.  
  73. /* --------------------------------------------------------------------------------------------
  74.  
  75.     CVars for .cfg files:
  76.  
  77.         ctf_flagreturn (default 120) - flag auto-return time
  78.         ctf_weaponstay (default 30) - how long do weapons and items stay on ground
  79.         ctf_itempercent (default 30) - chance that items spawn when a player is killed, values from 0 to 100
  80.         ctf_sound_taken (default 1) - toggles if the "flag taken" sounds can be heard
  81.         ctf_sound_dropped (default 1) - toggles if the "flag dropped" sounds can be heard
  82.         ctf_sound_returned (default 1) - toggles if the "flag returned" sounds can be heard
  83.         ctf_sound_score (default 1) - toggles if the "X team scores" sounds can be heard
  84.         ctf_respawntime (default 10) - players respawn time (use -1 to disable respawn)
  85.         ctf_spawnmoney (default 1000) - money bonus when spawning (unless it's a suicide)
  86.         ctf_protection (default 5) - players spawn protection time (use -1 to disable protection)
  87.         ctf_dynamiclights (default 1) - set the default dynamic lights setting, players will still be able to toggle individually using /lights
  88.         ctf_glows (default 1) - set if entities can glow, like when players have flag or an adrenaline combo, weapons start to fade, etc.
  89.         ctf_nospam_flash (default 20) - delay of rebuying two flashbangs in a life
  90.         ctf_nospam_he (default 20) - delay of rebuying a HE grenade in a life
  91.         ctf_nospam_smoke (default 20) - delay of rebuying a smoke grenade in a life
  92.         ctf_spawn_prim (default "m3") - spawning primary weapon, set to "" to disable
  93.         ctf_spawn_sec (default "glock") - spawning secondary weapon, set to "" to disable
  94.         ctf_spawn_knife (default 1) - toggle if players spawn with knife or not
  95.         ctf_sound_taken (default 1) - toggles if the "flag taken" sounds can be heard
  96.         ctf_sound_dropped (default 1) - toggles if the "flag dropped" sounds can be heard
  97.         ctf_sound_returned (default 1) - toggles if the "flag returned" sounds can be heard
  98.         ctf_sound_score (default 1) - toggles if the "X team scores" sounds can be heard
  99.  
  100.     Primary weapons: m3,xm1014,tmp,mac10,mp5,ump45,p90,galil,ak47,famas,m4a1,aug,sg552,awp,scout,sg550,g3sg1,m249,shield
  101.     Secondary weapons: glock,usp,p228,deagle,elites,fiveseven
  102.  
  103.         mp_c4timer (recommended 20) - time before the C4 devices explode
  104.         mp_winlimit - first team who reaches this number wins
  105.         mp_timelimit - time limit for the map (displayed in the round timer)
  106.         mp_startmoney (recommended 3000) - for first spawn money and minimum amount of money
  107.         mp_forcecamera - (0/1 - spectate enemies or not) mod fades to black if this is on and player is in free look (no teammates alive)
  108.         mp_forcechasecam - (0/1/2 - force chase cammera all/team/firstperson) same as above
  109.         mp_autoteambalance - enable/disable auto-team balance (checks at every player death)
  110.  
  111.     Map configurations are made with;
  112.  
  113.         ctf_moveflag red/blue at your position (even if dead/spec)
  114.         ctf_save to save flag origins in maps/<mapname>.ctf
  115.  
  116.     Reward configuration, 0 on all values disables reward/penalty.
  117.  
  118.     [REWARD FOR]                [MONEY] [FRAGS] [ADRENALINE]
  119. */
  120. #define REWARD_RETURN               500,        0,      10
  121. #define REWARD_RETURN_ASSIST            500,        0,      10
  122.  
  123. #define REWARD_CAPTURE              3000,       3,      25
  124. #define REWARD_CAPTURE_ASSIST           3000,       3,      25
  125. #define REWARD_CAPTURE_TEAM         1000,       0,      10
  126.  
  127. #define REWARD_STEAL                1000,       1,      10
  128. #define REWARD_PICKUP               500,        1,      5
  129. #define PENALTY_DROP                -1500,  -1,     -10
  130.  
  131. #define REWARD_KILL             0,      0,      5
  132. #define REWARD_KILLCARRIER          500,        1,      10
  133.  
  134. #define PENALTY_SUICIDE             0,      0,      -20
  135. #define PENALTY_TEAMKILL            0,      0,      -20
  136.  
  137. /*
  138.     Advanced configuration
  139. */
  140.  
  141. const ADMIN_RETURN =                ADMIN_RCON  // access required for admins to return flags (full list in includes/amxconst.inc)
  142. const ADMIN_RETURNWAIT =            15      // time the flag needs to stay dropped before it can be returned by command
  143.  
  144. new const bool:CHAT_SHOW_COMMANDS =     true        // show commands (like /buy) in chat, true or false
  145.  
  146. const ITEM_MEDKIT_GIVE =            25      // medkit award health for picking up
  147.  
  148. new const bool:ITEM_DROP_AMMO =     true        // toggle if killed players drop ammo items
  149. new const bool:ITEM_DROP_MEDKIT =       true        // toggle if killed players drop medkit items
  150.  
  151. #if FEATURE_ADRENALINE == true
  152. new const bool:ITEM_DROP_ADRENALINE =   true        // toggle if killed players drop adrenaline items
  153. const ITEM_ADRENALINE_GIVE =            5       // adrenaline reaward for picking up adrenaline
  154.  
  155. const Float:SPEED_ADRENALINE =      1.3     // speed while using "speed" adrenaline combo (this and SPEED_FLAG are cumulative)
  156.  
  157. const Float:BERSERKER_SPEED1 =      0.7     // primary weapon shooting speed percent while in berserk
  158. const Float:BERSERKER_SPEED2 =      0.3     // secondary weapon shooting speed percent while in berserk
  159. const Float:BERSERKER_DAMAGE =      2.0     // weapon damage percent while in berserk
  160.  
  161. const INSTANTSPAWN_COST =           50      // instant spawn (/spawn) adrenaline cost
  162.  
  163. #endif // FEATURE_ADRENALINE
  164.  
  165. const REGENERATE_EXTRAHP =          50      // extra max HP for regeneration and flag healing
  166.  
  167. const Float:SPEED_FLAG =            0.9     // speed while carying the enemy flag
  168.  
  169. new const Float:BASE_HEAL_DISTANCE =    96.0        // healing distance for flag
  170.  
  171. #if FEATURE_C4 == true
  172.  
  173. new const C4_RADIUS[] =             "600"       // c4 explosion radius (must be string!)
  174. new const C4_DEFUSETIME =           3       // c4 defuse time
  175.  
  176. #endif // FEATURE_C4
  177.  
  178. new const FLAG_SAVELOCATION[] =     "maps/%s.ctf" // you can change where .ctf files are saved/loaded from
  179.  
  180. #define FLAG_IGNORE_BOTS            true        // set to true if you don't want bots to pick up flags
  181.  
  182.  
  183. /*
  184.     Change log:
  185.  
  186.     v1.32c:
  187.         * Changed files: jctf.sma
  188.         - Added ctf_dynamiclights cvar to enable server operators to disable dynamic lights by default, players can still re-enable them individually using /lights
  189.         - Added ctf_glows cvar to enable server operators to disable glows on entities for performance, however it will degrade gameplay due to lack of visual information
  190.  
  191.     v1.32b:
  192.         * Changed files: jctf.sma
  193.         - Fixed rewards beeing default to 0 for steal and capturing flags (my bad).
  194.  
  195.     v1.32:
  196.         * Changes files: jctf.sma
  197.         - Removed forcing of CVars - if you depended on that, use amxx.cfg to store default values of cvars.
  198.         - Added posibility to disable respawn using ctf_respawntime 0.
  199.         - Added posibility to disable spawn protection using ctf_protection 0.
  200.         - Added posibility to disable dropped weapons fading out using ctf_weaponstay 0.
  201.         - Added posibility to disable flag auto-return using ctf_flagreturn 0.
  202.         - Fixed GameName printing CS 1.6 for CZ too, now it detects game name, if's unknown it doesn't write anything.
  203.         - Fixed player rewards still printing if all rewards are 0.
  204.         - Fixed MP3 files printing WAV error messages due to incorrect precaching method.
  205.  
  206.     v1.31:
  207.         * Changed files: jctf.sma, jctf_resources.zip
  208.         - Fixed issue where plugin wouldn't trigger "Round_End" on ctf_flagendround 1 that caused issues with other plugins.
  209.         - Added new orpheu signatures: functions/EndRoundMessage and functions/CHalfLifeMultiplay/UpdateTeamScores.
  210.         - Changed "TeamScore" message to emessage, that way it can be hooked by other plugins.
  211.         - Added updating team scores internally too.
  212.         - Some other minor changes.
  213.  
  214.     v1.3:
  215.         * Changed files: jctf.sma, lang/jctf.txt, jctf_resources.zip
  216.         - Added CVars: ctf_flagendround, ctf_flagcaptureslay and ctf_infiniteround (see thread for descriptions)
  217.         - Changed /help command, it now prints most mod settings and features (which are enabled/disabled)
  218.         - Added new orpheu signatures: functions/InstallGameRules and memory/CGameRulesOffsets (they're in jctf_resources.zip)
  219.         - Changed feature define FEATURE_INFROUND to FEATURE_ORPHEU because it also disables flag capture ending round
  220.         - Changed contents of lang keys: JOIN_NOFEATURES
  221.         - Renamed lang keys: HELP_3_* to HELP_4_* and DEAH_NOFREELOOK to DEATH_NOFREELOOK
  222.         - Added lang keys: DEATH_FLAGCAPTURED, STARTING_NEWROUND, and HELP_3_*
  223.         - Added so that on new round, flags are returned to base (no matter what the reason of new round)
  224.  
  225.     v1.28c:
  226.         * Changed files: jctf.sma
  227.         - Fixed if you reload map with the plugin disabled the rounds will end normally.
  228.  
  229.     v1.28b:
  230.         * Changed files: jctf.sma
  231.         - Fixed a compile error when switching FEATURE_ADRENALINE to false.
  232.  
  233.     v1.28:
  234.         * Changed files: jctf.sma, jctf.txt
  235.         - Fixed buying VGUI issues, plugin now closes buy VGUI and opens custom buy menu without client changes.
  236.         - Removed VGUI related ML keys from jctf.txt.
  237.  
  238.     v1.27:
  239.         * Changed files: jctf.sma, jctf.txt
  240.         - Added FEATURE disabling, you can now toggle individual features from the sma file.
  241.         - Added ctf_flagheal cvar which toggles if flag bases heal teammates.
  242.         - Changed HUD message to Director HUD messages, nicer and have no channel limit
  243.         - Increased char limit for "Freelook mode blocked" ML text from 32 to 48 chars.
  244.         - Rearranged sma configuration variables, you can find them easier on top of the file.
  245.         - Added hints and adrenaline menu to the ML support.
  246.         - Decreased chance that flag gets stuck in a wall (dramatically decreased collision box and added proximity check for pickup)
  247.         - Decreased C4's price from $15000 to $12000 and adrenaline cost from 100 to 80
  248.         - Some minor optimizations
  249.  
  250.     v1.26:
  251.         * Changed files: jctf.sma, jctf.inc(jctf_api.zip), lang/jctf.txt
  252.         - Fixed "ED_Alloc: No free edicts" crashes (hopefully).
  253.         - Added Multilingual support, natives support it too.
  254.         - Added printing of admin commands in chat that obey amx_show_activity.
  255.         - Added a check of players spawning HP and Armor so Booster and flags know how much to heal.
  256.         - Added configurable extra HP the booster heals.
  257.         - Changed armor regeneration from Booster so it no longer sets armor to kevlar+helm if you have kevlar only.
  258.         - Added option to ignore bots from taking flags, default OFF (search sma for // CONFIGURABLE).
  259.         - Added checking of player's team range when touching flag in case it's a spawned spectator.
  260.         - Fixed bots not buying weapons, but be warned, they buy at default prices and without adrenaline.
  261.         - Changed default mp_buytime from 0 to 99999999 so bots can always buy, this doesn't affect players.
  262.         - Added API natives: jctf_get_flagcarrier(id) and jctf_get_team(id)
  263.         - Added FLAG_ADMINRETURN for the jctf_flag() forward, it triggers when an admin returns the flag using command
  264.         - Fixed ctf_moveflag command not showing Y axis in the log
  265.  
  266.     v1.25:
  267.         - Changed ctf_moveflag to support red and blue inputs
  268.         - Fade to black no longer affects spectators
  269.         - Added "ctf_returnflag <red/blue>" admin command that returns the specified flag if it was dropped for at least 15 seconds (configurable)
  270.         - Optimized some minor stuff
  271.  
  272.     v1.24:
  273.         - Changed ctf_weaponstay's default value from 30 to 15 (seconds)
  274.         - Changed ctf_itempercent's default value from 30 to 25 (percent)
  275.         - Added Scout and G3SG1 as special weapons.
  276.         - Added the "configurable" flag in the source for weapon money and adrenaline costs
  277.         - Added configurable weapon and zoom-in running speeds
  278.         - Added cvars for controling sounds: ctf_sound_taken/dropped/returned/score
  279.         - Added how much money/adrenaline you need in the "Not enough money/adrenaline" message
  280.  
  281.     v1.23:
  282.         - plugin no longer disables VGUI menu automatically but it notifies VGUI menu users upon spawn
  283.         - added new in-source configuration: CHAT_SHOW_COMMANDS
  284.  
  285.     v1.22:
  286.         - fixed a bug where you'd get twice the adrenaline when using the jctf_add_adrenaline() native while using a reason
  287.         - fixed adrenaline HUD not updating when using jctf_add_adrenaline()
  288.  
  289.     v1.21:
  290.         - added FLAG_MANUALDROP for jctf_flag() events
  291.         - fixed some example issues in jctf_addon_example.sma
  292.         - updated version check to 1.21 since jctf.inc was altered
  293.         - added a console print upon plugin load with plugin name and version
  294.         - forced to reset jctf_version to the current version if mod is updated while server is running
  295.  
  296.     v1.2:
  297.         - added forwards and natives that other plugins could use
  298.         - added configurable spawning weapons using CVars, they're also forced to reset to prevent unwanted usage between maps
  299.         - minor adjustments in the code to fit the latest modifications
  300.  
  301.     v1.13:
  302.         - fixed some issues with the autoteambalance
  303.         - fixed spawn protection countdown not stop when prematurely disabling protection
  304.         - fixed game name displaying version as number instead of string
  305.         - added mod version in quick help and help console message
  306.         - added checking of mp_forcechasecam too for the fade to black feature
  307.         - fixed the possiblity of not beeing blinded while in freelook after a respawn
  308.  
  309.     v1.12:
  310.         - fixed a bug where transfered people (autoteambalance) would actually block the team they left from beeing joined, the "there are too many CTs/Ts" thing.
  311.         - added fade to black when mp_fadetoblack is disabled and mp_forcecamera is enabled while player is on free view (no teammates alive)
  312.  
  313.     v1.11:
  314.         - fixed a rare bug where players won't respawn after beeing killed
  315.         - some optimizations in code
  316.  
  317.     v1.1:
  318.         - removed previous round-end blocking and added new round blocking method via Orpheu module
  319.         - fixed various possible crashes caused by previous round-end blocking methods
  320.  
  321.     v1.06:
  322.         - changed buy menu text so that items you can't afford are in red text
  323.         - fixed various speed issues with player zooming, shield and flag taking
  324.         - re-done player rendering system and altered some colors and values
  325.         - unforced most mod cvars, only two cvars remain forced
  326.  
  327.     v1.05:
  328.         - fixed round-blocking player deaths's animations
  329.         - changed the sounds of medkit and adrenaline item pickup
  330.         - and of course, other small adjustments
  331.  
  332.     v1.04:
  333.         - other small adjustments here and there
  334.         - removed the spectating bots, now players' deaths are blocked if they'll trigger round end, they wouldn't even notice
  335.         - altered C4 plant radio message to a be compatible with client modifications and other hooks
  336.  
  337.     v1.03:
  338.         - added /help
  339.         - minor adjustments and code moved around
  340.  
  341.     v1.02:
  342.         - fixed items not fading out
  343.         - fixed the simple auto-team balance
  344.         - fixed various possible errors
  345.  
  346.     v1.01:
  347.         - minor fixes of typos and checks
  348.  
  349. -------------------------------------------------------------------------------------------- */
  350.  
  351. new const INFO_TARGET[] =           "info_target"
  352. new const ITEM_CLASSNAME[] =            "ctf_item"
  353. new const WEAPONBOX[] =             "weaponbox"
  354.  
  355. #if FEATURE_C4 == true
  356.  
  357. new const GRENADE[] =               "grenade"
  358.  
  359. #endif // FEATURE_C4
  360.  
  361. new const Float:ITEM_HULL_MIN[3] =      {-1.0, -1.0, 0.0}
  362. new const Float:ITEM_HULL_MAX[3] =      {1.0, 1.0, 10.0}
  363.  
  364. const ITEM_AMMO =                   0
  365. const ITEM_MEDKIT =             1
  366.  
  367. #if FEATURE_ADRENALINE == true
  368.  
  369. const ITEM_ADRENALINE =             2
  370.  
  371. #endif // FEATURE_ADRENALINE
  372.  
  373. new const ITEM_MODEL_AMMO[] =           "models/w_chainammo.mdl"
  374. new const ITEM_MODEL_MEDKIT[] =     "models/w_medkit.mdl"
  375.  
  376. #if FEATURE_ADRENALINE == true
  377.  
  378. new const ITEM_MODEL_ADRENALINE[] =     "models/can.mdl"
  379.  
  380. #endif // FEATURE_ADRENALINE
  381.  
  382. new const BASE_CLASSNAME[] =            "ctf_flagbase"
  383. new const Float:BASE_THINK =            0.25
  384.  
  385. new const FLAG_CLASSNAME[] =            "ctf_flag"
  386. new const FLAG_MODEL[] =            "models/th_jctf.mdl"
  387.  
  388. new const Float:FLAG_THINK =            0.1
  389. const FLAG_SKIPTHINK =              20 /* FLAG_THINK * FLAG_SKIPTHINK = 2.0 seconds ! */
  390.  
  391. new const Float:FLAG_HULL_MIN[3] =      {-2.0, -2.0, 0.0}
  392. new const Float:FLAG_HULL_MAX[3] =      {2.0, 2.0, 16.0}
  393.  
  394. new const Float:FLAG_SPAWN_VELOCITY[3] =    {0.0, 0.0, -500.0}
  395. new const Float:FLAG_SPAWN_ANGLES[3] =  {0.0, 0.0, 0.0}
  396.  
  397. new const Float:FLAG_DROP_VELOCITY[3] = {0.0, 0.0, 50.0}
  398.  
  399. new const Float:FLAG_PICKUPDISTANCE =   80.0
  400.  
  401. const FLAG_LIGHT_RANGE =            12
  402. const FLAG_LIGHT_LIFE =             5
  403. const FLAG_LIGHT_DECAY =            1
  404.  
  405. const FLAG_ANI_DROPPED =            0
  406. const FLAG_ANI_STAND =              1
  407. const FLAG_ANI_BASE =               2
  408.  
  409. const FLAG_HOLD_BASE =              33
  410. const FLAG_HOLD_DROPPED =           34
  411.  
  412. #if FEATURE_ADRENALINE == true
  413.  
  414. const ADRENALINE_SPEED =            1
  415. const ADRENALINE_BERSERK =          2
  416. const ADRENALINE_REGENERATE =           3
  417. const ADRENALINE_INVISIBILITY =     4
  418.  
  419. new const MENU_ADRENALINE[] =           "menu_adrenaline"
  420. new const MENU_KEYS_ADRENALINE =        (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<9)
  421.  
  422. #endif // FEATURE_ADRENALINE
  423.  
  424. #if FEATURE_BUY == true
  425.  
  426. new const WHITESPACE[] =            " "
  427. new const MENU_BUY[] =              "menu_buy"
  428. new const MENU_KEYS_BUY =           (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<6)|(1<<7)|(1<<8)|(1<<9)
  429.  
  430. new const BUY_ITEM_DISABLED[] =     "r"
  431. new const BUY_ITEM_AVAILABLE[] =        "w"
  432.  
  433. #if FEATURE_ADRENALINE == true
  434.  
  435. new const BUY_ITEM_AVAILABLE2[] =       "y"
  436.  
  437. #endif // FEATURE_ADRENALINE
  438.  
  439. #endif // FEATURE_BUY
  440.  
  441. new const SND_GETAMMO[] =           "items/9mmclip1.wav"
  442. new const SND_GETMEDKIT[] =         "items/smallmedkit1.wav"
  443.  
  444. #if FEATURE_ADRENALINE == true
  445.  
  446. new const SND_GETADRENALINE[] =     "items/medshot4.wav"
  447. new const SND_ADRENALINE[] =            "ambience/des_wind3.wav"
  448.  
  449. #endif // FEATURE_ADRENALINE
  450.  
  451. #if FEATURE_C4 == true
  452.  
  453. new const SND_C4DISARMED[] =            "weapons/c4_disarmed.wav"
  454.  
  455. #endif // FEATURE_C4
  456.  
  457. new const CHAT_PREFIX[] =           "^x03[^x04 A.L.B.R^x03 ]^x01 "
  458. new const CONSOLE_PREFIX[] =            "ALBR: "
  459.  
  460. new xMsgSync[1]
  461.  
  462. const FADE_OUT =                    0x0000
  463. const FADE_IN =                 0x0001
  464. const FADE_MODULATE =               0x0002
  465. const FADE_STAY =                   0x0004
  466.  
  467. const m_iUserPrefs =                510
  468. const m_flNextPrimaryAttack =           46
  469. const m_flNextSecondaryAttack =     47
  470.  
  471. new const PLAYER[] =                "player"
  472. new const SEPARATOR[] =             " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
  473. #define NULL                    ""
  474.  
  475. //#define HUD_HINT                  255, 255, 255, 0.15, -0.3, 0, 0.0, 10.0, 2.0, 10.0, 4
  476. #define HUD_HELP                    255, 255, 0, -1.0, 0.2, 2, 0.1, 2.0, 0.01, 2.0, 2
  477. #define HUD_HELP2                   255, 255, 0, -1.0, 0.25, 2, 0.1, 2.0, 0.01, 2.0, 3
  478. #define HUD_ANNOUNCE                -1.0, 0.3, 0, 0.0, 3.0, 0.1, 1.0, 4
  479. #define HUD_RESPAWN             0, 120, 120, 0.02, 0.20, 2, 0.08, 10.0, 0.01, 0.02
  480. #define HUD_PROTECTION              255, 255, 0, -1.0, 0.6, 2, 0.5, 0.1, 0.0, 1.0, 1
  481. #define HUD_ADRENALINE              255, 255, 255, -1.0, -0.1, 0, 0.0, 600.0, 0.0, 0.0, 1
  482.  
  483. #define entity_create(%1)           create_entity(%1)
  484. #define entity_spawn(%1)            DispatchSpawn(%1)
  485. #define entity_think(%1)            call_think(%1)
  486. #define entity_remove(%1)           remove_entity(%1)
  487. #define weapon_remove(%1)           call_think(%1)
  488.  
  489. #define task_set(%1)                set_task(%1)
  490. #define task_remove(%1)             remove_task(%1)
  491.  
  492. #define player_hasFlag(%1)          (g_iFlagHolder[TEAM_RED] == %1 || g_iFlagHolder[TEAM_BLUE] == %1)
  493.  
  494. #define player_allowChangeTeam(%1)      set_pdata_int(%1, 125, get_pdata_int(%1, 125) & ~(1<<8))
  495.  
  496. #define gen_color(%1,%2)            %1 == TEAM_RED ? %2 : 0, 0, %1 == TEAM_RED ? 0 : %2
  497.  
  498. #define get_opTeam(%1)              (%1 == TEAM_BLUE ? TEAM_RED : (%1 == TEAM_RED ? TEAM_BLUE : 0))
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509. enum
  510. {
  511.     x,
  512.     y,
  513.     z
  514. }
  515.  
  516. enum
  517. {
  518.     pitch,
  519.     yaw,
  520.     roll
  521. }
  522.  
  523. enum (+= 64)
  524. {
  525.     TASK_RESPAWN = 64,
  526.     TASK_PROTECTION,
  527.     TASK_DAMAGEPROTECTION,
  528.     TASK_EQUIPAMENT,
  529.     TASK_PUTINSERVER,
  530.     TASK_TEAMBALANCE,
  531.     TASK_ADRENALINE,
  532.     TASK_DEFUSE,
  533.     TASK_CHECKHP
  534. }
  535.  
  536. enum
  537. {
  538.     TEAM_NONE = 0,
  539.     TEAM_RED,
  540.     TEAM_BLUE,
  541.     TEAM_SPEC
  542. }
  543.  
  544. new const g_szCSTeams[][] =
  545. {
  546.     NULL,
  547.     "TERRORIST",
  548.     "CT",
  549.     "SPECTATOR"
  550. }
  551.  
  552. new const g_szTeamName[][] =
  553. {
  554.     NULL,
  555.     "Red",
  556.     "Blue",
  557.     "Spectator"
  558. }
  559.  
  560. new const g_szMLTeamName[][] =
  561. {
  562.     NULL,
  563.     "TEAM_RED",
  564.     "TEAM_BLUE",
  565.     "TEAM_SPEC"
  566. }
  567.  
  568. new const g_szMLFlagTeam[][] =
  569. {
  570.     NULL,
  571.     "FLAG_RED",
  572.     "FLAG_BLUE",
  573.     NULL
  574. }
  575.  
  576. enum
  577. {
  578.     FLAG_STOLEN = 0,
  579.     FLAG_PICKED,
  580.     FLAG_DROPPED,
  581.     FLAG_MANUALDROP,
  582.     FLAG_RETURNED,
  583.     FLAG_CAPTURED,
  584.     FLAG_AUTORETURN,
  585.     FLAG_ADMINRETURN
  586. }
  587.  
  588. enum
  589. {
  590.     EVENT_TAKEN = 0,
  591.     EVENT_DROPPED,
  592.     EVENT_RETURNED,
  593.     EVENT_SCORE,
  594. }
  595.  
  596. new const g_szSounds[][][] =
  597. {
  598.     {NULL, "red_roubada", "blue_roubada"},
  599.     {NULL, "red_dropada", "blue_dropada"},
  600.     {NULL, "red_recuperada", "blue_recuperada"},
  601.     {NULL, "red_win", "blue_win"}
  602. }
  603.  
  604. #if FEATURE_ADRENALINE == true
  605. new const g_szAdrenalineUseML[][] =
  606. {
  607.     NULL,
  608.     "ADR_SPEED",
  609.     "ADR_BERSERK",
  610.     "ADR_REGENERATE",
  611.     "ADR_INVISIBILITY"
  612. }
  613. #endif // FEATURE_ADRENALINE
  614.  
  615. #if FEATURE_BUY == true
  616.  
  617. enum
  618. {
  619.     no_weapon,
  620.     primary,
  621.     secondary,
  622.     he,
  623.     flash,
  624.     smoke,
  625.     armor,
  626.     nvg
  627. }
  628.  
  629. new const g_szRebuyCommands[][] =
  630. {
  631.     NULL,
  632.     "PrimaryWeapon",
  633.     "SecondaryWeapon",
  634.     "HEGrenade",
  635.     "Flashbang",
  636.     "SmokeGrenade",
  637.     "Armor",
  638.     "NightVision"
  639. }
  640.  
  641. #endif // FEATURE_BUY
  642.  
  643. new const g_szRemoveEntities[][] =
  644. {
  645.     "func_buyzone",
  646.     "armoury_entity",
  647.     "func_bomb_target",
  648.     "info_bomb_target",
  649.     "hostage_entity",
  650.     "monster_scientist",
  651.     "func_hostage_rescue",
  652.     "info_hostage_rescue",
  653.     "info_vip_start",
  654.     "func_vip_safetyzone",
  655.     "func_escapezone",
  656.     "info_map_parameters",
  657.     "player_weaponstrip",
  658.     "game_player_equip"
  659. }
  660.  
  661. enum
  662. {
  663.     ZERO = 0,
  664.     W_P228,
  665.     W_SHIELD,
  666.     W_SCOUT,
  667.     W_HEGRENADE,
  668.     W_XM1014,
  669.     W_C4,
  670.     W_MAC10,
  671.     W_AUG,
  672.     W_SMOKEGRENADE,
  673.     W_ELITE,
  674.     W_FIVESEVEN,
  675.     W_UMP45,
  676.     W_SG550,
  677.     W_GALIL,
  678.     W_FAMAS,
  679.     W_USP,
  680.     W_GLOCK18,
  681.     W_AWP,
  682.     W_MP5NAVY,
  683.     W_M249,
  684.     W_M3,
  685.     W_M4A1,
  686.     W_TMP,
  687.     W_G3SG1,
  688.     W_FLASHBANG,
  689.     W_DEAGLE,
  690.     W_SG552,
  691.     W_AK47,
  692.     W_KNIFE,
  693.     W_P90,
  694.     W_VEST,
  695.     W_VESTHELM,
  696.     W_NVG
  697. }
  698.  
  699. new const g_iClip[] =
  700. {
  701.     0,      // (unknown)
  702.     13,     // P228
  703.     0,      // SHIELD (not used)
  704.     10,     // SCOUT
  705.     0,          // HEGRENADE (not used)
  706.     7,          // XM1014
  707.     0,          // C4 (not used)
  708.     30,         // MAC10
  709.     30,         // AUG
  710.     0,          // SMOKEGRENADE (not used)
  711.     30,         // ELITE
  712.     20,         // FIVESEVEN
  713.     25,         // UMP45
  714.     30,         // SG550
  715.     35,         // GALIL
  716.     25,         // FAMAS
  717.     12,         // USP
  718.     20,         // GLOCK18
  719.     10,         // AWP
  720.     30,         // MP5NAVY
  721.     100,        // M249
  722.     8,          // M3
  723.     30,         // M4A1
  724.     30,         // TMP
  725.     20,         // G3SG1
  726.     0,          // FLASHBANG (not used)
  727.     7,          // DEAGLE
  728.     30,         // SG552
  729.     30,         // AK47
  730.     0,          // KNIFE (not used)
  731.     50,         // P90
  732.     0,      // Kevlar (not used)
  733.     0,      // Kevlar + Helm (not used)
  734.     0       // NVG (not used)
  735. }
  736.  
  737. new const g_iBPAmmo[] =
  738. {
  739.     0,      // (unknown)
  740.     52,     // P228
  741.     0,      // SHIELD
  742.     90,     // SCOUT
  743.     0,      // HEGRENADE (not used)
  744.     32,     // XM1014
  745.     0,      // C4 (not used)
  746.     100,        // MAC10
  747.     90,     // AUG
  748.     0,      // SMOKEGRENADE (not used)
  749.     120,        // ELITE
  750.     100,        // FIVESEVEN
  751.     100,        // UMP45
  752.     90,     // SG550
  753.     90,     // GALIL
  754.     90,     // FAMAS
  755.     100,        // USP
  756.     120,        // GLOCK18
  757.     30,     // AWP
  758.     120,        // MP5NAVY
  759.     200,        // M249
  760.     32,     // M3
  761.     90,     // M4A1
  762.     120,        // TMP
  763.     90,     // G3SG1
  764.     0,      // FLASHBANG (not used)
  765.     35,     // DEAGLE
  766.     90,     // SG552
  767.     90,     // AK47
  768.     0,      // KNIFE (not used)
  769.     100,        // P90
  770.     0,      // Kevlar (not used)
  771.     0,      // Kevlar + Helm (not used)
  772.     0       // NVG (not used)
  773. }
  774.  
  775. #if FEATURE_BUY == true
  776.  
  777. new const g_iWeaponPrice[] =
  778. {
  779.     0,      // (unknown)
  780.     600,        // P228
  781.     10000// SHIELD
  782.     6000,       // SCOUT
  783.     300,        // HEGRENADE
  784.     3000,       // XM1014
  785.     20000// C4
  786.     1400,       // MAC10
  787.     3500,       // AUG
  788.     500,        // SMOKEGRENADE
  789.     1000,       // ELITE
  790.     750,        // FIVESEVEN
  791.     1700,       // UMP45
  792.     6000,       // SG550
  793.     2000,       // GALIL
  794.     2250,       // FAMAS
  795.     500,        // USP
  796.     400,        // GLOCK18
  797.     8000,       // AWP
  798.     1500,       // MP5NAVY
  799.     5000,       // M249
  800.     1700,       // M3
  801.     3100,       // M4A1
  802.     1250,       // TMP
  803.     7000,       // G3SG1
  804.     200,        // FLASHBANG
  805.     650,        // DEAGLE
  806.     3500,       // SG552
  807.     2500,       // AK47
  808.     0,      // KNIFE (not used)
  809.     2350,       // P90
  810.     650,        // Kevlar
  811.     1000,       // Kevlar + Helm
  812.     1250        // NVG
  813. }
  814.  
  815. #endif // FEATURE_BUY
  816.  
  817. #if FEATURE_BUY == true && FEATURE_ADRENALINE == true
  818.  
  819. new const g_iWeaponAdrenaline[] =
  820. {
  821.     0,      // (unknown)
  822.     0,      // P228
  823.     50,     // SHIELD
  824.     50,     // SCOUT
  825.     0,      // HEGRENADE
  826.     0,      // XM1014
  827.     80,     // C4
  828.     0,      // MAC10
  829.     0,      // AUG
  830.     0,      // SMOKEGRENADE
  831.     0,      // ELITE
  832.     0,      // FIVESEVEN
  833.     0,      // UMP45
  834.     30,     // SG550
  835.     0,      // GALIL
  836.     0,      // FAMAS
  837.     0,      // USP
  838.     0,      // GLOCK18
  839.     50,     // AWP
  840.     0,      // MP5NAVY
  841.     10,     // M249
  842.     0,      // M3
  843.     0,      // M4A1
  844.     0,      // TMP
  845.     30,     // G3SG1
  846.     0,      // FLASHBANG
  847.     0,      // DEAGLE
  848.     0,      // SG552
  849.     0,      // AK47
  850.     0,      // KNIFE (not used)
  851.     0,      // P90
  852.     0,      // Kevlar
  853.     0,      // Kevlar + Helm
  854.     0       // NVG
  855. }
  856.  
  857. #endif // FEATURE_ADRENALINE
  858.  
  859. new const Float:g_fWeaponRunSpeed[] = // CONFIGURABLE - weapon running speed (edit the numbers in the list)
  860. {
  861.     150.0// Zoomed speed with any weapon
  862.     250.0// P228
  863.     0.0,        // SHIELD (not used)
  864.     260.0// SCOUT
  865.     250.0// HEGRENADE
  866.     240.0// XM1014
  867.     250.0// C4
  868.     250.0// MAC10
  869.     240.0// AUG
  870.     250.0// SMOKEGRENADE
  871.     250.0// ELITE
  872.     250.0// FIVESEVEN
  873.     250.0// UMP45
  874.     210.0// SG550
  875.     240.0// GALIL
  876.     240.0// FAMAS
  877.     250.0// USP
  878.     250.0// GLOCK18
  879.     210.0// AWP
  880.     250.0// MP5NAVY
  881.     220.0// M249
  882.     230.0// M3
  883.     230.0// M4A1
  884.     250.0// TMP
  885.     210.0// G3SG1
  886.     250.0// FLASHBANG
  887.     250.0// DEAGLE
  888.     235.0// SG552
  889.     221.0// AK47
  890.     250.0// KNIFE
  891.     245.0// P90
  892.     0.0,        // Kevlar (not used)
  893.     0.0,        // Kevlar + Helm (not used)
  894.     0.0     // NVG (not used)
  895. }
  896.  
  897. #if FEATURE_BUY == true
  898.  
  899. new const g_iWeaponSlot[] =
  900. {
  901.     0,      // none
  902.     2,      // P228
  903.     1,      // SHIELD
  904.     1,      // SCOUT
  905.     4,      // HEGRENADE
  906.     1,      // XM1014
  907.     5,      // C4
  908.     1,      // MAC10
  909.     1,      // AUG
  910.     4,      // SMOKEGRENADE
  911.     2,      // ELITE
  912.     2,      // FIVESEVEN
  913.     1,      // UMP45
  914.     1,      // SG550
  915.     1,      // GALIL
  916.     1,      // FAMAS
  917.     2,      // USP
  918.     2,      // GLOCK18
  919.     1,      // AWP
  920.     1,      // MP5NAVY
  921.     1,      // M249
  922.     1,      // M3
  923.     1,      // M4A1
  924.     1,      // TMP
  925.     1,      // G3SG1
  926.     4,      // FLASHBANG
  927.     2,      // DEAGLE
  928.     1,      // SG552
  929.     1,      // AK47
  930.     3,      // KNIFE (not used)
  931.     1,      // P90
  932.     0,      // Kevlar
  933.     0,      // Kevlar + Helm
  934.     0       // NVG
  935. }
  936.  
  937. #endif // FEATURE_BUY
  938.  
  939. new const g_szWeaponEntity[][24] =
  940. {
  941.     NULL,
  942.     "weapon_p228",
  943.     "weapon_shield",
  944.     "weapon_scout",
  945.     "weapon_hegrenade",
  946.     "weapon_xm1014",
  947.     "weapon_c4",
  948.     "weapon_mac10",
  949.     "weapon_aug",
  950.     "weapon_smokegrenade",
  951.     "weapon_elite",
  952.     "weapon_fiveseven",
  953.     "weapon_ump45",
  954.     "weapon_sg550",
  955.     "weapon_galil",
  956.     "weapon_famas",
  957.     "weapon_usp",
  958.     "weapon_glock18",
  959.     "weapon_awp",
  960.     "weapon_mp5navy",
  961.     "weapon_m249",
  962.     "weapon_m3",
  963.     "weapon_m4a1",
  964.     "weapon_tmp",
  965.     "weapon_g3sg1",
  966.     "weapon_flashbang",
  967.     "weapon_deagle",
  968.     "weapon_sg552",
  969.     "weapon_ak47",
  970.     "weapon_knife",
  971.     "weapon_p90",
  972.     "item_kevlar",
  973.     "item_assaultsuit",
  974.     NULL
  975. }
  976.  
  977. #if FEATURE_BUY == true
  978.  
  979. new const g_szWeaponCommands[][] =
  980. {
  981.     {NULL,      NULL},
  982.     {"p228",        "228compact"},
  983.     {"shield",      NULL},
  984.     {"scout",       NULL},
  985.     {"hegren",      NULL},
  986.     {"xm1014",      "autoshotgun"},
  987.     {NULL,      NULL},
  988.     {"mac10",       NULL},
  989.     {"aug",     "bullpup"},
  990.     {"sgren",       NULL},
  991.     {"elites",      NULL},
  992.     {"fiveseven",   "fn57"},
  993.     {"ump45",       "sm"},
  994.     {"sg550",       "krieg550"},
  995.     {"galil",       "defender"},
  996.     {"famas",       "clarion"},
  997.     {"usp",     "km45"},
  998.     {"glock",       "9x19mm"},
  999.     {"awp",     "magnum"},
  1000.     {"mp5",     "mp"},
  1001.     {"m249",        NULL},
  1002.     {"m3",      "12gauge"},
  1003.     {"m4a1",        NULL},
  1004.     {"tmp",     NULL},
  1005.     {"g3sg1",       "d3au1"},
  1006.     {"flash",       NULL},
  1007.     {"deagle",      "nighthawk"},
  1008.     {"sg552",       "krieg552"},
  1009.     {"ak47",        "cv47"},
  1010.     {NULL,      NULL},
  1011.     {"p90",     "c90"},
  1012.     {"vest",        NULL},
  1013.     {"vesthelm",    NULL},
  1014.     {"nvgs",        NULL}
  1015. }
  1016.  
  1017. #endif // FEATURE_BUY
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024. new g_iMaxPlayers
  1025. new g_szMap[32]
  1026. new g_szGame[16]
  1027. new g_iTeam[33]
  1028. new g_iScore[3]
  1029. new g_iFlagHolder[3]
  1030. new g_iFlagEntity[3]
  1031. new g_iBaseEntity[3]
  1032. new Float:g_fFlagDropped[3]
  1033.  
  1034. #if FEATURE_BUY == true
  1035.  
  1036. new g_iMenu[33]
  1037. new g_iRebuy[33][8]
  1038. new g_iAutobuy[33][64]
  1039. new g_iRebuyWeapons[33][8]
  1040.  
  1041. new pCvar_ctf_nospam_flash
  1042. new pCvar_ctf_nospam_he
  1043. new pCvar_ctf_nospam_smoke
  1044. new pCvar_ctf_spawn_prim
  1045. new pCvar_ctf_spawn_sec
  1046. new pCvar_ctf_spawn_knife
  1047.  
  1048. new gMsg_BuyClose
  1049.  
  1050. #endif // FEATURE_BUY
  1051.  
  1052. new g_iMaxArmor[33]
  1053. new g_iMaxHealth[33]
  1054. new g_iAdrenaline[33]
  1055. new g_iAdrenalineUse[33]
  1056. new bool:g_bRestarting
  1057. new bool:g_bBot[33]
  1058. new bool:g_bAlive[33]
  1059. new bool:g_bDefuse[33]
  1060. new bool:g_bLights[33]
  1061. new bool:g_bBuyZone[33]
  1062. new bool:g_bSuicide[33]
  1063. new bool:g_bFreeLook[33]
  1064. new bool:g_bAssisted[33][3]
  1065. new bool:g_bProtected[33]
  1066. new bool:g_bRestarted[33]
  1067. new bool:g_bFirstSpawn[33]
  1068.  
  1069. new Float:g_fFlagBase[3][3]
  1070. new Float:g_fFlagLocation[3][3]
  1071. new Float:g_fWeaponSpeed[33]
  1072. new Float:g_fLastDrop[33]
  1073. new Float:g_fLastBuy[33][4]
  1074.  
  1075. new pCvar_ctf_flagcaptureslay
  1076. new pCvar_ctf_flagheal
  1077. new pCvar_ctf_flagreturn
  1078. new pCvar_ctf_respawntime
  1079. new pCvar_ctf_protection
  1080. new pCvar_ctf_dynamiclights
  1081. new pCvar_ctf_glows
  1082. new pCvar_ctf_weaponstay
  1083. new pCvar_ctf_spawnmoney
  1084. new pCvar_ctf_itempercent
  1085.  
  1086. new pCvar_ctf_sound[4]
  1087. new pCvar_mp_winlimit
  1088. new pCvar_mp_startmoney
  1089. new pCvar_mp_fadetoblack
  1090. new pCvar_mp_forcecamera
  1091. new pCvar_mp_forcechasecam
  1092. new pCvar_mp_autoteambalance
  1093.  
  1094. #if FEATURE_C4 == true
  1095.  
  1096. new pCvar_mp_c4timer
  1097.  
  1098. new gMsg_BarTime
  1099. new gMsg_DeathMsg
  1100. new gMsg_SendAudio
  1101.  
  1102. #endif // FEATURE_C4
  1103.  
  1104. new gMsg_SayText
  1105. new gMsg_RoundTime
  1106. new gMsg_ScreenFade
  1107. new gMsg_HostageK
  1108. new gMsg_HostagePos
  1109. new gMsg_ScoreInfo
  1110. new gMsg_ScoreAttrib
  1111. new gMsg_TextMsg
  1112. new gMsg_TeamScore
  1113.  
  1114. new gHook_EntSpawn
  1115.  
  1116. #if FEATURE_ADRENALINE == true
  1117.  
  1118. new gSpr_trail
  1119. new gSpr_blood1
  1120. new gSpr_blood2
  1121.  
  1122. #endif // FEATURE_ADRENALINE
  1123.  
  1124. new gSpr_regeneration
  1125.  
  1126. new g_iForwardReturn
  1127. new g_iFW_flag
  1128.  
  1129.  
  1130. #if FEATURE_ORPHEU == true
  1131.  
  1132. new pCvar_ctf_infiniteround
  1133. new pCvar_ctf_flagendround
  1134.  
  1135. new g_pGameRules
  1136. new bool:g_bLinux
  1137. new OrpheuHook:g_oMapConditions
  1138. new OrpheuHook:g_oWinConditions
  1139. new OrpheuHook:g_oRoundTimeExpired
  1140. new MEMORY_ROUNDTIME[] = "roundTimeCheck"
  1141.  
  1142. #endif // FEATURE_ORPHEU
  1143.  
  1144.  
  1145.  
  1146. public plugin_precache()
  1147. {
  1148.     precache_model(FLAG_MODEL)
  1149.     precache_model(ITEM_MODEL_AMMO)
  1150.     precache_model(ITEM_MODEL_MEDKIT)
  1151.  
  1152. #if FEATURE_ADRENALINE == true
  1153.  
  1154.     precache_model(ITEM_MODEL_ADRENALINE)
  1155.  
  1156.     precache_sound(SND_GETADRENALINE)
  1157.     precache_sound(SND_ADRENALINE)
  1158.  
  1159.     gSpr_trail = precache_model("sprites/zbeam5.spr")
  1160.     gSpr_blood1 = precache_model("sprites/blood.spr")
  1161.     gSpr_blood2 = precache_model("sprites/bloodspray.spr")
  1162.  
  1163. #endif // FEATURE_ADRENALINE
  1164.  
  1165.     precache_sound(SND_GETAMMO)
  1166.     precache_sound(SND_GETMEDKIT)
  1167.  
  1168.     gSpr_regeneration = precache_model("sprites/th_jctf_heal.spr")
  1169.  
  1170.     for(new szSound[64], i = 0; i < sizeof g_szSounds; i++)
  1171.     {
  1172.         for(new t = 1; t <= 2; t++)
  1173.         {
  1174.             formatex(szSound, charsmax(szSound), "sound/csrevo/ctf/%s.mp3", g_szSounds[i][t])
  1175.  
  1176.             precache_generic(szSound)
  1177.         }
  1178.     }
  1179.  
  1180. #if FEATURE_C4 == true
  1181.     precache_sound(SND_C4DISARMED)
  1182.  
  1183.     new ent = entity_create(g_szRemoveEntities[11])
  1184.  
  1185.     if(ent)
  1186.     {
  1187.         DispatchKeyValue(ent, "buying", "0")
  1188.         DispatchKeyValue(ent, "bombradius", C4_RADIUS)
  1189.         DispatchSpawn(ent)
  1190.     }
  1191. #endif // FEATURE_C4
  1192.  
  1193.     gHook_EntSpawn = register_forward(FM_Spawn, "ent_spawn")
  1194.  
  1195.  
  1196. #if FEATURE_ORPHEU == true
  1197.  
  1198.     OrpheuRegisterHook(OrpheuGetFunction("InstallGameRules"), "game_onInstallGameRules", OrpheuHookPost)
  1199.  
  1200. #endif // FEATURE_ORPHEU
  1201. }
  1202.  
  1203. public ent_spawn(ent)
  1204. {
  1205.     if(!is_valid_ent(ent))
  1206.         return FMRES_IGNORED
  1207.  
  1208.     static szClass[32]
  1209.  
  1210.     entity_get_string(ent, EV_SZ_classname, szClass, charsmax(szClass))
  1211.  
  1212.     for(new i = 0; i < sizeof g_szRemoveEntities; i++)
  1213.     {
  1214.         if(equal(szClass, g_szRemoveEntities[i]))
  1215.         {
  1216.             entity_remove(ent)
  1217.  
  1218.             return FMRES_SUPERCEDE
  1219.         }
  1220.     }
  1221.  
  1222.     return FMRES_IGNORED
  1223. }
  1224.  
  1225. public plugin_init()
  1226. {
  1227.     register_plugin(MOD_TITLE, MOD_VERSION, MOD_AUTHOR)
  1228.     set_pcvar_string(register_cvar("jctf_version", MOD_VERSION, FCVAR_SERVER|FCVAR_SPONLY), MOD_VERSION)
  1229.  
  1230.     register_dictionary("jctf.txt")
  1231.     register_dictionary("common.txt")
  1232.  
  1233.     new const SEPARATOR_TEMP[] = " - - - - - - - - - - - - - - - - -"
  1234.  
  1235.     server_print(SEPARATOR_TEMP)
  1236.     server_print("    %s - v%s", MOD_TITLE, MOD_VERSION)
  1237.     server_print("    Mod by %s", MOD_AUTHOR)
  1238.  
  1239. #if FEATURE_ORPHEU == false
  1240.     server_print("[!] Orpheu module usage is disabled! (FEATURE_ORPHEU = false)")
  1241. #endif
  1242.  
  1243. #if FEATURE_BUY == false
  1244.     server_print("[!] Custom buy feature is disabled! (FEATURE_BUY = false)")
  1245. #endif
  1246.  
  1247. #if FEATURE_C4 == false
  1248.     server_print("[!] C4 feature is disabled! (FEATURE_BUYC4 = false)")
  1249. #endif
  1250.  
  1251. #if FEATURE_ADRENALINE == false
  1252.     server_print("[!] Adrenaline feature is disabled! (FEATURE_ADRENALINE = false)")
  1253. #endif
  1254.  
  1255.     server_print(SEPARATOR_TEMP)
  1256.  
  1257.     // Forwards, hooks, events, etc
  1258.  
  1259.     unregister_forward(FM_Spawn, gHook_EntSpawn)
  1260.  
  1261.     register_forward(FM_GetGameDescription, "game_description")
  1262.  
  1263.     register_touch(FLAG_CLASSNAME, PLAYER, "flag_touch")
  1264.  
  1265.     register_think(FLAG_CLASSNAME, "flag_think")
  1266.     register_think(BASE_CLASSNAME, "base_think")
  1267.  
  1268.     register_logevent("event_restartGame", 2, "1&Restart_Round", "1&Game_Commencing")
  1269.     register_event("HLTV", "event_roundStart", "a", "1=0", "2=0")
  1270.  
  1271.     register_clcmd("fullupdate", "msg_block")
  1272.  
  1273.     register_event("TeamInfo", "player_joinTeam", "a")
  1274.  
  1275.     RegisterHam(Ham_Spawn, PLAYER, "player_spawn", 1)
  1276.     RegisterHam(Ham_Killed, PLAYER, "player_killed", 1)
  1277.     RegisterHam(Ham_TakeDamage, PLAYER, "player_damage")
  1278.  
  1279.     register_clcmd("say", "player_cmd_say")
  1280.     register_clcmd("say_team", "player_cmd_sayTeam")
  1281.  
  1282.     xMsgSync[0] = CreateHudSyncObj()
  1283.  
  1284. #if FEATURE_ADRENALINE == true
  1285.  
  1286.     register_menucmd(register_menuid(MENU_ADRENALINE), MENU_KEYS_ADRENALINE, "player_key_adrenaline")
  1287.  
  1288.     register_clcmd("adrenaline", "player_cmd_adrenaline")
  1289.  
  1290. #endif // FEATURE_ADRENALINE
  1291.  
  1292. #if FEATURE_BUY == true
  1293.  
  1294.     register_menucmd(register_menuid(MENU_BUY), MENU_KEYS_BUY, "player_key_buy")
  1295.  
  1296.     register_event("StatusIcon", "player_inBuyZone", "be", "2=buyzone")
  1297.  
  1298.     register_clcmd("buy", "player_cmd_buy_main")
  1299.     register_clcmd("buyammo1", "player_fillAmmo")
  1300.     register_clcmd("buyammo2", "player_fillAmmo")
  1301.     register_clcmd("primammo", "player_fillAmmo")
  1302.     register_clcmd("secammo", "player_fillAmmo")
  1303.     register_clcmd("client_buy_open", "player_cmd_buyVGUI")
  1304.  
  1305.     register_clcmd("autobuy", "player_cmd_autobuy")
  1306.     register_clcmd("cl_autobuy", "player_cmd_autobuy")
  1307.     register_clcmd("cl_setautobuy", "player_cmd_setAutobuy")
  1308.  
  1309.     register_clcmd("rebuy", "player_cmd_rebuy")
  1310.     register_clcmd("cl_rebuy", "player_cmd_rebuy")
  1311.     register_clcmd("cl_setrebuy", "player_cmd_setRebuy")
  1312.  
  1313.     register_clcmd("buyequip", "player_cmd_buy_equipament")
  1314.  
  1315. #endif // FEATURE_BUY
  1316.  
  1317.     for(new w = W_P228; w <= W_NVG; w++)
  1318.     {
  1319. #if FEATURE_BUY == true
  1320.         for(new i = 0; i < 2; i++)
  1321.         {
  1322.             if(strlen(g_szWeaponCommands[w][i]))
  1323.                 register_clcmd(g_szWeaponCommands[w][i], "player_cmd_buyWeapon")
  1324.         }
  1325. #endif // FEATURE_BUY
  1326.  
  1327.         if(w != W_SHIELD && w <= W_P90)
  1328.             RegisterHam(Ham_Weapon_PrimaryAttack, g_szWeaponEntity[w], "player_useWeapon", 1)
  1329.     }
  1330.  
  1331.     register_clcmd("ctf_moveflag", "admin_cmd_moveFlag", ADMIN_RCON, "<red/blue> - Moves team's flag base to your origin (for map management)")
  1332.     register_clcmd("ctf_save", "admin_cmd_saveFlags", ADMIN_RCON)
  1333.     register_clcmd("ctf_return", "admin_cmd_returnFlag", ADMIN_RETURN)
  1334.  
  1335.     register_clcmd("dropflag", "player_cmd_dropFlag")
  1336.  
  1337. #if FEATURE_C4 == true
  1338.  
  1339.     RegisterHam(Ham_Use, GRENADE, "c4_defuse", 1)
  1340.     register_logevent("c4_planted", 3, "2=Planted_The_Bomb")
  1341.     register_logevent("c4_defused", 3, "2=Defused_The_Bomb")
  1342.  
  1343.     register_touch(WEAPONBOX, PLAYER, "c4_pickup")
  1344.  
  1345. #endif // FEATURE_C4
  1346.  
  1347.     register_touch(ITEM_CLASSNAME, PLAYER, "item_touch")
  1348.  
  1349.     register_event("CurWeapon", "player_currentWeapon", "be", "1=1")
  1350.     register_event("SetFOV", "player_currentWeapon", "be", "1>1")
  1351.  
  1352.     RegisterHam(Ham_Spawn, WEAPONBOX, "weapon_spawn", 1)
  1353.  
  1354.     RegisterHam(Ham_Weapon_SecondaryAttack, g_szWeaponEntity[W_KNIFE], "player_useWeapon", 1) // not a typo
  1355.  
  1356. #if FEATURE_ADRENALINE == true
  1357.  
  1358.     RegisterHam(Ham_Weapon_SecondaryAttack, g_szWeaponEntity[W_USP], "player_useWeaponSec", 1)
  1359.     RegisterHam(Ham_Weapon_SecondaryAttack, g_szWeaponEntity[W_FAMAS], "player_useWeaponSec", 1)
  1360.     RegisterHam(Ham_Weapon_SecondaryAttack, g_szWeaponEntity[W_M4A1], "player_useWeaponSec", 1)
  1361.  
  1362. #endif // FEATURE_ADRENALINE
  1363.  
  1364.  
  1365. #if FEATURE_C4 == true
  1366.  
  1367.     gMsg_BarTime = get_user_msgid("BarTime")
  1368.     gMsg_DeathMsg = get_user_msgid("DeathMsg")
  1369.     gMsg_SendAudio = get_user_msgid("SendAudio")
  1370.  
  1371.     register_message(gMsg_BarTime, "c4_used")
  1372.     register_message(gMsg_SendAudio, "msg_sendAudio")
  1373.  
  1374. #endif // FEATURE_C4
  1375.  
  1376.     gMsg_HostagePos = get_user_msgid("HostagePos")
  1377.     gMsg_HostageK = get_user_msgid("HostageK")
  1378.     gMsg_RoundTime = get_user_msgid("RoundTime")
  1379.     gMsg_SayText = get_user_msgid("SayText")
  1380.     gMsg_ScoreInfo = get_user_msgid("ScoreInfo")
  1381.     gMsg_ScoreAttrib = get_user_msgid("ScoreAttrib")
  1382.     gMsg_ScreenFade = get_user_msgid("ScreenFade")
  1383.     gMsg_TextMsg = get_user_msgid("TextMsg")
  1384.     gMsg_TeamScore = get_user_msgid("TeamScore")
  1385.  
  1386.     register_message(gMsg_TextMsg, "msg_textMsg")
  1387.     register_message(get_user_msgid("BombDrop"), "msg_block")
  1388.     register_message(get_user_msgid("ClCorpse"), "msg_block")
  1389.     register_message(gMsg_HostageK, "msg_block")
  1390.     register_message(gMsg_HostagePos, "msg_block")
  1391.     register_message(gMsg_RoundTime, "msg_roundTime")
  1392.     register_message(gMsg_ScreenFade, "msg_screenFade")
  1393.     register_message(gMsg_ScoreAttrib, "msg_scoreAttrib")
  1394.     register_message(gMsg_TeamScore, "msg_teamScore")
  1395.     register_message(gMsg_SayText, "msg_sayText")
  1396.  
  1397.     // CVARS
  1398.  
  1399.     pCvar_ctf_flagcaptureslay = register_cvar("ctf_flagcaptureslay", "0")
  1400.     pCvar_ctf_flagheal = register_cvar("ctf_flagheal", "1")
  1401.     pCvar_ctf_flagreturn = register_cvar("ctf_flagreturn", "120")
  1402.     pCvar_ctf_respawntime = register_cvar("ctf_respawntime", "6")
  1403.     pCvar_ctf_protection = register_cvar("ctf_protection", "5")
  1404.     pCvar_ctf_dynamiclights = register_cvar("ctf_dynamiclights", "1")
  1405.     pCvar_ctf_glows = register_cvar("ctf_glows", "0")
  1406.     pCvar_ctf_weaponstay = register_cvar("ctf_weaponstay", "15")
  1407.     pCvar_ctf_spawnmoney = register_cvar("ctf_spawnmoney", "1000")
  1408.     pCvar_ctf_itempercent = register_cvar("ctf_itempercent", "25")
  1409.  
  1410. #if FEATURE_ORPHEU == true
  1411.  
  1412.     register_srvcmd("ctf_infiniteround", "server_cmd_infiniteround")
  1413.  
  1414.     pCvar_ctf_infiniteround = register_cvar("_ctf_infiniteround_memory", "1")
  1415.     pCvar_ctf_flagendround = register_cvar("ctf_flagendround", "0")
  1416.  
  1417. #endif // FEATURE_ORPHEU
  1418.  
  1419.  
  1420. #if FEATURE_BUY == true
  1421.  
  1422.     pCvar_ctf_nospam_flash = register_cvar("ctf_nospam_flash", "20")
  1423.     pCvar_ctf_nospam_he = register_cvar("ctf_nospam_he", "20")
  1424.     pCvar_ctf_nospam_smoke = register_cvar("ctf_nospam_smoke", "20")
  1425.     pCvar_ctf_spawn_prim = register_cvar("ctf_spawn_prim", "m4a1")
  1426.     pCvar_ctf_spawn_sec = register_cvar("ctf_spawn_sec", "usp")
  1427.     pCvar_ctf_spawn_knife = register_cvar("ctf_spawn_knife", "1")
  1428.  
  1429.     gMsg_BuyClose = get_user_msgid("BuyClose")
  1430.  
  1431. #endif // FEATURE_BUY
  1432.  
  1433.     pCvar_ctf_sound[EVENT_TAKEN] = register_cvar("ctf_sound_taken", "1")
  1434.     pCvar_ctf_sound[EVENT_DROPPED] = register_cvar("ctf_sound_dropped", "1")
  1435.     pCvar_ctf_sound[EVENT_RETURNED] = register_cvar("ctf_sound_returned", "1")
  1436.     pCvar_ctf_sound[EVENT_SCORE] = register_cvar("ctf_sound_score", "1")
  1437.  
  1438. #if FEATURE_C4 == true
  1439.  
  1440.     pCvar_mp_c4timer = get_cvar_pointer("mp_c4timer")
  1441.  
  1442. #endif // FEATURE_C4
  1443.  
  1444.     pCvar_mp_winlimit = get_cvar_pointer("mp_winlimit")
  1445.     pCvar_mp_startmoney = get_cvar_pointer("mp_startmoney")
  1446.     pCvar_mp_fadetoblack = get_cvar_pointer("mp_fadetoblack")
  1447.     pCvar_mp_forcecamera = get_cvar_pointer("mp_forcecamera")
  1448.     pCvar_mp_forcechasecam = get_cvar_pointer("mp_forcechasecam")
  1449.     pCvar_mp_autoteambalance = get_cvar_pointer("mp_autoteambalance")
  1450.  
  1451.     // Plugin's forwards
  1452.  
  1453.     g_iFW_flag = CreateMultiForward("jctf_flag", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL)
  1454.  
  1455.  
  1456.     // Variables
  1457.  
  1458.     new szGame[3]
  1459.  
  1460.     get_modname(szGame, charsmax(szGame))
  1461.  
  1462.     if(szGame[0] == 'c')
  1463.     {
  1464.         switch(szGame[1])
  1465.         {
  1466.             case 's': copy(g_szGame, charsmax(g_szGame), "CS 1.6 ") // leave the space at the end
  1467.             case 'z': copy(g_szGame, charsmax(g_szGame), "CS:CZ ")
  1468.         }
  1469.     }
  1470.  
  1471.     get_mapname(g_szMap, charsmax(g_szMap))
  1472.  
  1473.     g_iMaxPlayers = get_maxplayers()
  1474.  
  1475.  
  1476. #if FEATURE_C4 == true
  1477.     // fake bomb target
  1478.  
  1479.     new ent = entity_create(g_szRemoveEntities[2])
  1480.  
  1481.     if(ent)
  1482.     {
  1483.         entity_spawn(ent)
  1484.         entity_set_size(ent, Float:{-8192.0, -8192.0, -8192.0}, Float:{8192.0, 8192.0, 8192.0})
  1485.     }
  1486. #endif // FEATURE_C4
  1487.  
  1488. #if FEATURE_ORPHEU == true
  1489.     g_bLinux = bool:is_linux_server()
  1490.  
  1491.     state disabled
  1492.  
  1493.     game_enableForwards()
  1494. #endif // FEATURE_ORPHEU
  1495. }
  1496.  
  1497. #if FEATURE_ORPHEU == true
  1498.  
  1499. public game_onInstallGameRules()
  1500.     g_pGameRules = OrpheuGetReturn();
  1501.  
  1502. public game_enableForwards() <> {}
  1503. public game_enableForwards() <disabled>
  1504. {
  1505.     g_oMapConditions = OrpheuRegisterHook(OrpheuGetFunction("CheckMapConditions", "CHalfLifeMultiplay"), "game_blockConditions")
  1506.     g_oWinConditions = OrpheuRegisterHook(OrpheuGetFunction("CheckWinConditions", "CHalfLifeMultiplay"), "game_blockConditions")
  1507.  
  1508.     if(g_bLinux)
  1509.         g_oRoundTimeExpired = OrpheuRegisterHook(OrpheuGetFunction("HasRoundTimeExpired", "CHalfLifeMultiplay"), "game_blockConditions")
  1510.     else
  1511.         game_memoryReplace(MEMORY_ROUNDTIME, {0x90, 0x90, 0x90})
  1512.  
  1513.     state enabled
  1514. }
  1515.  
  1516. public game_disableForwards() <> {}
  1517. public game_disableForwards() <enabled>
  1518. {
  1519.     OrpheuUnregisterHook(g_oMapConditions)
  1520.     OrpheuUnregisterHook(g_oWinConditions)
  1521.  
  1522.     if(g_bLinux)
  1523.         OrpheuUnregisterHook(g_oRoundTimeExpired)
  1524.     else
  1525.         game_memoryReplace(MEMORY_ROUNDTIME, {0xF6, 0xC4, 0x41})
  1526.  
  1527.     state disabled
  1528. }
  1529.  
  1530. public OrpheuHookReturn:game_blockConditions() <>
  1531.     return OrpheuIgnored
  1532.  
  1533. public OrpheuHookReturn:game_blockConditions() <enabled>
  1534. {
  1535.     OrpheuSetReturn(false)
  1536.  
  1537.     return OrpheuSupercede
  1538. }
  1539.  
  1540. game_memoryReplace(szID[], const iBytes[], const iLen = sizeof iBytes)
  1541. {
  1542.     new iAddress
  1543.  
  1544.     OrpheuMemoryGet(szID, iAddress)
  1545.  
  1546.     for(new i; i < iLen; i++)
  1547.     {
  1548.         OrpheuMemorySetAtAddress(iAddress, "roundTimeCheck|dummy", 1, iBytes[i], iAddress)
  1549.  
  1550.         iAddress++
  1551.     }
  1552.  
  1553.     server_cmd("sv_restart 1")
  1554. }
  1555.  
  1556. public server_cmd_infiniteround()
  1557. {
  1558.     if(read_argc() == 2)
  1559.     {
  1560.         new szArg[2]
  1561.  
  1562.         read_argv(1, szArg, charsmax(szArg))
  1563.  
  1564.         new iSet = clamp(str_to_num(szArg), 0, 1)
  1565.  
  1566.         set_pcvar_num(pCvar_ctf_infiniteround, iSet)
  1567.  
  1568.         switch(iSet)
  1569.         {
  1570.             case 0: game_disableForwards()
  1571.             case 1: game_enableForwards()
  1572.         }
  1573.     }
  1574.     else
  1575.         server_print("^"ctf_infiniteround^" is ^"%d^"", get_pcvar_num(pCvar_ctf_infiniteround))
  1576. }
  1577.  
  1578. #endif // FEATURE_ORPHEU
  1579.  
  1580. public game_description()
  1581. {
  1582.     new szFormat[32]
  1583.  
  1584.     formatex(szFormat, charsmax(szFormat), "[PEGA BANDEIRA]", g_szGame, MOD_VERSION)
  1585.     forward_return(FMV_STRING, szFormat)
  1586.  
  1587.     return FMRES_SUPERCEDE
  1588. }
  1589.  
  1590. public plugin_cfg()
  1591. {
  1592.     new szFile[64]
  1593.  
  1594.     formatex(szFile, charsmax(szFile), FLAG_SAVELOCATION, g_szMap)
  1595.  
  1596.     new hFile = fopen(szFile, "rt")
  1597.  
  1598.     if(hFile)
  1599.     {
  1600.         new iFlagTeam = TEAM_RED
  1601.         new szData[24]
  1602.         new szOrigin[3][6]
  1603.  
  1604.         while(fgets(hFile, szData, charsmax(szData)))
  1605.         {
  1606.             if(iFlagTeam > TEAM_BLUE)
  1607.                 break
  1608.  
  1609.             trim(szData)
  1610.             parse(szData, szOrigin[x], charsmax(szOrigin[]), szOrigin[y], charsmax(szOrigin[]), szOrigin[z], charsmax(szOrigin[]))
  1611.  
  1612.             g_fFlagBase[iFlagTeam][x] = str_to_float(szOrigin[x])
  1613.             g_fFlagBase[iFlagTeam][y] = str_to_float(szOrigin[y])
  1614.             g_fFlagBase[iFlagTeam][z] = str_to_float(szOrigin[z])
  1615.  
  1616.             iFlagTeam++
  1617.         }
  1618.  
  1619.         fclose(hFile)
  1620.     }
  1621.  
  1622.     flag_spawn(TEAM_RED)
  1623.     flag_spawn(TEAM_BLUE)
  1624.  
  1625.     task_set(6.5, "plugin_postCfg")
  1626. }
  1627.  
  1628. public plugin_postCfg()
  1629. {
  1630.     set_cvar_num("mp_freezetime", 0)
  1631.     set_cvar_num("mp_limitteams", 0)
  1632.     set_cvar_num("mp_buytime", 99999999)
  1633.     server_cmd("sv_restart 1")
  1634. }
  1635.  
  1636. public plugin_natives()
  1637. {
  1638.     register_library("jctf")
  1639.  
  1640.     register_native("jctf_get_team", "native_get_team")
  1641.     register_native("jctf_get_flagcarrier", "native_get_flagcarrier")
  1642.     register_native("jctf_get_adrenaline", "native_get_adrenaline")
  1643.     register_native("jctf_add_adrenaline", "native_add_adrenaline")
  1644. }
  1645.  
  1646. public plugin_end()
  1647. {
  1648. #if FEATURE_ORPHEU == true
  1649.  
  1650.     game_disableForwards()
  1651.  
  1652. #endif // FEATURE_ORPHEU
  1653.  
  1654.     DestroyForward(g_iFW_flag)
  1655. }
  1656.  
  1657.  
  1658.  
  1659.  
  1660.  
  1661.  
  1662.  
  1663.  
  1664. public native_get_team(iPlugin, iParams)
  1665. {
  1666.     /* jctf_get_team(id) */
  1667.  
  1668.     return g_iTeam[get_param(1)]
  1669. }
  1670.  
  1671. public native_get_flagcarrier(iPlugin, iParams)
  1672. {
  1673.     /* jctf_get_flagcarrier(id) */
  1674.  
  1675.     new id = get_param(1)
  1676.  
  1677.     return g_iFlagHolder[get_opTeam(g_iTeam[id])] == id
  1678. }
  1679.  
  1680. public native_get_adrenaline(iPlugin, iParams)
  1681. {
  1682. #if FEATURE_ADRENALINE == true
  1683.  
  1684.     /* jctf_get_adrenaline(id) */
  1685.  
  1686.     return g_iAdrenaline[get_param(1)]
  1687.  
  1688. #else // FEATURE_ADRENALINE
  1689.  
  1690.     log_error(AMX_ERR_NATIVE, "jctf_get_adrenaline() does not work ! main jCTF plugin has FEATURE_ADRENALINE = false")
  1691.  
  1692.     return 0
  1693.  
  1694. #endif // FEATURE_ADRENALINE
  1695. }
  1696.  
  1697. public native_add_adrenaline(iPlugin, iParams)
  1698. {
  1699. #if FEATURE_ADRENALINE == true
  1700.  
  1701.     /* jctf_add_adrenaline(id, iAdd, szReason[]) */
  1702.  
  1703.     new id = get_param(1)
  1704.     new iAdd = get_param(2)
  1705.     new szReason[64]
  1706.  
  1707.     get_string(3, szReason, charsmax(szReason))
  1708.  
  1709.     if(strlen(szReason))
  1710.         player_award(id, 0, 0, iAdd, szReason)
  1711.  
  1712.     else
  1713.     {
  1714.         g_iAdrenaline[id] = clamp(g_iAdrenaline[id] + iAdd, 0, 100)
  1715.  
  1716.         player_hudAdrenaline(id)
  1717.     }
  1718.  
  1719.     return g_iAdrenaline[id]
  1720.  
  1721. #else // FEATURE_ADRENALINE
  1722.  
  1723.     log_error(AMX_ERR_NATIVE, "jctf_add_adrenaline() does not work ! main jCTF plugin has FEATURE_ADRENALINE = false")
  1724.  
  1725.     return 0
  1726.  
  1727. #endif // FEATURE_ADRENALINE
  1728. }
  1729.  
  1730.  
  1731.  
  1732.  
  1733.  
  1734.  
  1735.  
  1736.  
  1737.  
  1738.  
  1739.  
  1740. public flag_spawn(iFlagTeam)
  1741. {
  1742.     if(g_fFlagBase[iFlagTeam][x] == 0.0 && g_fFlagBase[iFlagTeam][y] == 0.0 && g_fFlagBase[iFlagTeam][z] == 0.0)
  1743.     {
  1744.         new iFindSpawn = find_ent_by_class(g_iMaxPlayers, iFlagTeam == TEAM_BLUE ? "info_player_start" : "info_player_deathmatch")
  1745.  
  1746.         if(iFindSpawn)
  1747.         {
  1748.             entity_get_vector(iFindSpawn, EV_VEC_origin, g_fFlagBase[iFlagTeam])
  1749.  
  1750.             server_print("[CTF] %s flag origin not defined, set on player spawn.", g_szTeamName[iFlagTeam])
  1751.             log_error(AMX_ERR_NOTFOUND, "[CTF] %s flag origin not defined, set on player spawn.", g_szTeamName[iFlagTeam])
  1752.         }
  1753.         else
  1754.         {
  1755.             server_print("[CTF] WARNING: player spawn for ^"%s^" team does not exist !", g_szTeamName[iFlagTeam])
  1756.             log_error(AMX_ERR_NOTFOUND, "[CTF] WARNING: player spawn for ^"%s^" team does not exist !", g_szTeamName[iFlagTeam])
  1757.             set_fail_state("Player spawn unexistent!")
  1758.  
  1759.             return PLUGIN_CONTINUE
  1760.         }
  1761.     }
  1762.     else
  1763.         server_print("[CTF] %s flag and base spawned at: %.1f %.1f %.1f", g_szTeamName[iFlagTeam], g_fFlagBase[iFlagTeam][x], g_fFlagBase[iFlagTeam][y], g_fFlagBase[iFlagTeam][z])
  1764.  
  1765.     new ent
  1766.     new Float:fGameTime = get_gametime()
  1767.  
  1768.     // the FLAG
  1769.  
  1770.     ent = entity_create(INFO_TARGET)
  1771.  
  1772.     if(!ent)
  1773.         return flag_spawn(iFlagTeam)
  1774.  
  1775.     entity_set_model(ent, FLAG_MODEL)
  1776.     entity_set_string(ent, EV_SZ_classname, FLAG_CLASSNAME)
  1777.     entity_set_int(ent, EV_INT_body, iFlagTeam)
  1778.     entity_set_int(ent, EV_INT_sequence, FLAG_ANI_STAND)
  1779.     entity_spawn(ent)
  1780.     entity_set_origin(ent, g_fFlagBase[iFlagTeam])
  1781.     entity_set_size(ent, FLAG_HULL_MIN, FLAG_HULL_MAX)
  1782.     entity_set_vector(ent, EV_VEC_velocity, FLAG_SPAWN_VELOCITY)
  1783.     entity_set_vector(ent, EV_VEC_angles, FLAG_SPAWN_ANGLES)
  1784.     entity_set_edict(ent, EV_ENT_aiment, 0)
  1785.     entity_set_int(ent, EV_INT_movetype, MOVETYPE_TOSS)
  1786.     entity_set_int(ent, EV_INT_solid, SOLID_TRIGGER)
  1787.     entity_set_float(ent, EV_FL_gravity, 2.0)
  1788.     entity_set_float(ent, EV_FL_nextthink, fGameTime + FLAG_THINK)
  1789.  
  1790.     g_iFlagEntity[iFlagTeam] = ent
  1791.     g_iFlagHolder[iFlagTeam] = FLAG_HOLD_BASE
  1792.  
  1793.     // flag BASE
  1794.  
  1795.     ent = entity_create(INFO_TARGET)
  1796.  
  1797.     if(!ent)
  1798.         return flag_spawn(iFlagTeam)
  1799.  
  1800.     entity_set_string(ent, EV_SZ_classname, BASE_CLASSNAME)
  1801.     entity_set_model(ent, FLAG_MODEL)
  1802.     entity_set_int(ent, EV_INT_body, 0)
  1803.     entity_set_int(ent, EV_INT_sequence, FLAG_ANI_BASE)
  1804.     entity_spawn(ent)
  1805.     entity_set_origin(ent, g_fFlagBase[iFlagTeam])
  1806.     entity_set_vector(ent, EV_VEC_velocity, FLAG_SPAWN_VELOCITY)
  1807.     entity_set_int(ent, EV_INT_movetype, MOVETYPE_TOSS)
  1808.  
  1809.     if(get_pcvar_num(pCvar_ctf_glows))
  1810.         entity_set_int(ent, EV_INT_renderfx, kRenderFxGlowShell)
  1811.  
  1812.     entity_set_float(ent, EV_FL_renderamt, 100.0)
  1813.     entity_set_float(ent, EV_FL_nextthink, fGameTime + BASE_THINK)
  1814.  
  1815.     if(iFlagTeam == TEAM_RED)
  1816.         entity_set_vector(ent, EV_VEC_rendercolor, Float:{150.0, 0.0, 0.0})
  1817.     else
  1818.         entity_set_vector(ent, EV_VEC_rendercolor, Float:{0.0, 0.0, 150.0})
  1819.  
  1820.     g_iBaseEntity[iFlagTeam] = ent
  1821.  
  1822.     return PLUGIN_CONTINUE
  1823. }
  1824.  
  1825. public flag_think(ent)
  1826. {
  1827.     if(!is_valid_ent(ent))
  1828.         return
  1829.  
  1830.     entity_set_float(ent, EV_FL_nextthink, get_gametime() + FLAG_THINK)
  1831.  
  1832.     static id
  1833.     static iStatus
  1834.     static iFlagTeam
  1835.     static iSkip[3]
  1836.     static Float:fOrigin[3]
  1837.     static Float:fPlayerOrigin[3]
  1838.  
  1839.     iFlagTeam = (ent == g_iFlagEntity[TEAM_BLUE] ? TEAM_BLUE : TEAM_RED)
  1840.  
  1841.     if(g_iFlagHolder[iFlagTeam] == FLAG_HOLD_BASE)
  1842.         fOrigin = g_fFlagBase[iFlagTeam]
  1843.     else
  1844.         entity_get_vector(ent, EV_VEC_origin, fOrigin)
  1845.  
  1846.     g_fFlagLocation[iFlagTeam] = fOrigin
  1847.  
  1848.     iStatus = 0
  1849.  
  1850.     if(++iSkip[iFlagTeam] >= FLAG_SKIPTHINK)
  1851.     {
  1852.         iSkip[iFlagTeam] = 0
  1853.  
  1854.         if(1 <= g_iFlagHolder[iFlagTeam] <= g_iMaxPlayers)
  1855.         {
  1856.             id = g_iFlagHolder[iFlagTeam]
  1857.  
  1858.             set_hudmessage(HUD_HELP)
  1859.             show_hudmessage(id, "%L", id, "HUD_YOUHAVEFLAG")
  1860.  
  1861.             iStatus = 1
  1862.         }
  1863.         else if(g_iFlagHolder[iFlagTeam] == FLAG_HOLD_DROPPED)
  1864.             iStatus = 2
  1865.  
  1866.         message_begin(MSG_BROADCAST, gMsg_HostagePos)
  1867.         write_byte(0)
  1868.         write_byte(iFlagTeam)
  1869.         engfunc(EngFunc_WriteCoord, fOrigin[x])
  1870.         engfunc(EngFunc_WriteCoord, fOrigin[y])
  1871.         engfunc(EngFunc_WriteCoord, fOrigin[z])
  1872.         message_end()
  1873.  
  1874.         message_begin(MSG_BROADCAST, gMsg_HostageK)
  1875.         write_byte(iFlagTeam)
  1876.         message_end()
  1877.  
  1878.         static iStuck[3]
  1879.  
  1880.         if(g_iFlagHolder[iFlagTeam] >= FLAG_HOLD_BASE && !(entity_get_int(ent, EV_INT_flags) & FL_ONGROUND))
  1881.         {
  1882.             if(++iStuck[iFlagTeam] > 4)
  1883.             {
  1884.                 flag_autoReturn(ent)
  1885.  
  1886.                 log_message("^"%s^" flag is outside world, auto-returned.", g_szTeamName[iFlagTeam])
  1887.  
  1888.                 return
  1889.             }
  1890.         }
  1891.         else
  1892.             iStuck[iFlagTeam] = 0
  1893.     }
  1894.  
  1895.     for(id = 1; id <= g_iMaxPlayers; id++)
  1896.     {
  1897.         if(g_iTeam[id] == TEAM_NONE || g_bBot[id])
  1898.             continue
  1899.  
  1900.         /* Check flag proximity for pickup */
  1901.         if(g_iFlagHolder[iFlagTeam] >= FLAG_HOLD_BASE)
  1902.         {
  1903.             entity_get_vector(id, EV_VEC_origin, fPlayerOrigin)
  1904.  
  1905.             if(get_distance_f(fOrigin, fPlayerOrigin) <= FLAG_PICKUPDISTANCE)
  1906.                 flag_touch(ent, id)
  1907.         }
  1908.  
  1909.         /* Send dynamic lights to players that have them enabled */
  1910.         if(g_iFlagHolder[iFlagTeam] != FLAG_HOLD_BASE && g_bLights[id])
  1911.         {
  1912.             message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)
  1913.             write_byte(TE_DLIGHT)
  1914.             engfunc(EngFunc_WriteCoord, fOrigin[x])
  1915.             engfunc(EngFunc_WriteCoord, fOrigin[y])
  1916.             engfunc(EngFunc_WriteCoord, fOrigin[z] + (g_iFlagHolder[iFlagTeam] == FLAG_HOLD_DROPPED ? 32 : -16))
  1917.             write_byte(FLAG_LIGHT_RANGE)
  1918.             write_byte(iFlagTeam == TEAM_RED ? 100 : 0)
  1919.             write_byte(0)
  1920.             write_byte(iFlagTeam == TEAM_BLUE ? 155 : 0)
  1921.             write_byte(FLAG_LIGHT_LIFE)
  1922.             write_byte(FLAG_LIGHT_DECAY)
  1923.             message_end()
  1924.         }
  1925.  
  1926.         /* If iFlagTeam's flag is stolen or dropped, constantly warn team players */
  1927.         if(iStatus && g_iTeam[id] == iFlagTeam)
  1928.         {
  1929.             set_hudmessage(HUD_HELP2)
  1930.             show_hudmessage(id, "%L", id, (iStatus == 1 ? "HUD_ENEMYHASFLAG" : "HUD_RETURNYOURFLAG"))
  1931.         }
  1932.     }
  1933. }
  1934.  
  1935. flag_sendHome(iFlagTeam)
  1936. {
  1937.     new ent = g_iFlagEntity[iFlagTeam]
  1938.  
  1939.     entity_set_edict(ent, EV_ENT_aiment, 0)
  1940.     entity_set_origin(ent, g_fFlagBase[iFlagTeam])
  1941.     entity_set_int(ent, EV_INT_sequence, FLAG_ANI_STAND)
  1942.     entity_set_int(ent, EV_INT_movetype, MOVETYPE_TOSS)
  1943.     entity_set_int(ent, EV_INT_solid, SOLID_TRIGGER)
  1944.     entity_set_vector(ent, EV_VEC_velocity, FLAG_SPAWN_VELOCITY)
  1945.     entity_set_vector(ent, EV_VEC_angles, FLAG_SPAWN_ANGLES)
  1946.  
  1947.     g_iFlagHolder[iFlagTeam] = FLAG_HOLD_BASE
  1948. }
  1949.  
  1950. flag_take(iFlagTeam, id)
  1951. {
  1952.     if(g_bProtected[id])
  1953.         player_removeProtection(id, "PROTECTION_TOUCHFLAG")
  1954.  
  1955.     new ent = g_iFlagEntity[iFlagTeam]
  1956.  
  1957.     entity_set_edict(ent, EV_ENT_aiment, id)
  1958.     entity_set_int(ent, EV_INT_movetype, MOVETYPE_FOLLOW)
  1959.     entity_set_int(ent, EV_INT_solid, SOLID_NOT)
  1960.  
  1961.     g_iFlagHolder[iFlagTeam] = id
  1962.  
  1963.     message_begin(MSG_BROADCAST, gMsg_ScoreAttrib)
  1964.     write_byte(id)
  1965.     write_byte(g_iTeam[id] == TEAM_BLUE ? 4 : 2)
  1966.     message_end()
  1967.  
  1968.     player_updateSpeed(id)
  1969. }
  1970.  
  1971. public flag_touch(ent, id)
  1972. {
  1973. #if FLAG_IGNORE_BOTS == true
  1974.  
  1975.     if(!g_bAlive[id] || g_bBot[id])
  1976.         return
  1977.  
  1978. #else // FLAG_IGNORE_BOTS
  1979.  
  1980.     if(!g_bAlive[id])
  1981.         return
  1982.  
  1983. #endif // FLAG_IGNORE_BOTS
  1984.  
  1985.     new iFlagTeam = (g_iFlagEntity[TEAM_BLUE] == ent ? TEAM_BLUE : TEAM_RED)
  1986.  
  1987.     if(1 <= g_iFlagHolder[iFlagTeam] <= g_iMaxPlayers) // if flag is carried we don't care
  1988.         return
  1989.  
  1990.     new Float:fGameTime = get_gametime()
  1991.  
  1992.     if(g_fLastDrop[id] > fGameTime)
  1993.         return
  1994.  
  1995.     new iTeam = g_iTeam[id]
  1996.  
  1997.     if(!(TEAM_RED <= g_iTeam[id] <= TEAM_BLUE))
  1998.         return
  1999.  
  2000.     new iFlagTeamOp = get_opTeam(iFlagTeam)
  2001.     new szName[32]
  2002.  
  2003.     get_user_name(id, szName, charsmax(szName))
  2004.  
  2005.     if(iTeam == iFlagTeam) // If the PLAYER is on the same team as the FLAG
  2006.     {
  2007.         if(g_iFlagHolder[iFlagTeam] == FLAG_HOLD_DROPPED) // if the team's flag is dropped, return it to base
  2008.         {
  2009.             flag_sendHome(iFlagTeam)
  2010.  
  2011.             task_remove(ent)
  2012.  
  2013.             player_award(id, REWARD_RETURN, "%L", id, "REWARD_RETURN")
  2014.  
  2015.             ExecuteForward(g_iFW_flag, g_iForwardReturn, FLAG_RETURNED, id, iFlagTeam, false)
  2016.  
  2017.             new iAssists = 0
  2018.  
  2019.             for(new i = 1; i <= g_iMaxPlayers; i++)
  2020.             {
  2021.                 if(i != id && g_bAssisted[i][iFlagTeam] && g_iTeam[i] == iFlagTeam)
  2022.                 {
  2023.                     player_award(i, REWARD_RETURN_ASSIST, "%L", i, "REWARD_RETURN_ASSIST")
  2024.  
  2025.                     ExecuteForward(g_iFW_flag, g_iForwardReturn, FLAG_RETURNED, i, iFlagTeam, true)
  2026.  
  2027.                     iAssists++
  2028.                 }
  2029.  
  2030.                 g_bAssisted[i][iFlagTeam] = false
  2031.             }
  2032.  
  2033.             if(1 <= g_iFlagHolder[iFlagTeamOp] <= g_iMaxPlayers)
  2034.                 g_bAssisted[id][iFlagTeamOp] = true
  2035.  
  2036.             if(iAssists)
  2037.             {
  2038.                 new szFormat[64]
  2039.  
  2040.                 format(szFormat, charsmax(szFormat), "", szName, iAssists)
  2041.  
  2042.                 game_announce(EVENT_RETURNED, iFlagTeam, szFormat)
  2043.             }
  2044.             else
  2045.                 game_announce(EVENT_RETURNED, iFlagTeam, szName)
  2046.  
  2047.             log_message("<%s>%s returned the ^"%s^" flag.", g_szTeamName[iTeam], szName, g_szTeamName[iFlagTeam])
  2048.  
  2049.             set_hudmessage(HUD_HELP)
  2050.             show_hudmessage(id, "%L", id, "HUD_RETURNEDFLAG")
  2051.  
  2052.             if(g_bProtected[id])
  2053.                 player_removeProtection(id, "PROTECTION_TOUCHFLAG")
  2054.         }
  2055.         else if(g_iFlagHolder[iFlagTeam] == FLAG_HOLD_BASE && g_iFlagHolder[iFlagTeamOp] == id) // if the PLAYER has the ENEMY FLAG and the FLAG is in the BASE make SCORE
  2056.         {
  2057.             message_begin(MSG_BROADCAST, gMsg_ScoreAttrib)
  2058.             write_byte(id)
  2059.             write_byte(0)
  2060.             message_end()
  2061.  
  2062.             player_award(id, REWARD_CAPTURE, "%L", id, "REWARD_CAPTURE")
  2063.  
  2064.             ExecuteForward(g_iFW_flag, g_iForwardReturn, FLAG_CAPTURED, id, iFlagTeamOp, false)
  2065.  
  2066.             new iAssists = 0
  2067.  
  2068.             for(new i = 1; i <= g_iMaxPlayers; i++)
  2069.             {
  2070.                 if(i != id && g_iTeam[i] > 0 && g_iTeam[i] == iTeam)
  2071.                 {
  2072.                     if(g_bAssisted[i][iFlagTeamOp])
  2073.                     {
  2074.                         player_award(i, REWARD_CAPTURE_ASSIST, "%L", i, "REWARD_CAPTURE_ASSIST")
  2075.  
  2076.                         ExecuteForward(g_iFW_flag, g_iForwardReturn, FLAG_CAPTURED, i, iFlagTeamOp, true)
  2077.  
  2078.                         iAssists++
  2079.                     }
  2080.                     else
  2081.                         player_award(i, REWARD_CAPTURE_TEAM, "%L", i, "REWARD_CAPTURE_TEAM")
  2082.                 }
  2083.  
  2084.                 g_bAssisted[i][iFlagTeamOp] = false
  2085.             }
  2086.  
  2087.             set_hudmessage(HUD_HELP)
  2088.             show_hudmessage(id, "%L", id, "HUD_CAPTUREDFLAG")
  2089.  
  2090.             if(iAssists)
  2091.             {
  2092.                 new szFormat[64]
  2093.  
  2094.                 format(szFormat, charsmax(szFormat), "", szName, iAssists)
  2095.  
  2096.                 game_announce(EVENT_SCORE, iFlagTeam, szFormat)
  2097.             }
  2098.             else
  2099.                 game_announce(EVENT_SCORE, iFlagTeam, szName)
  2100.  
  2101.             log_message("<%s>%s captured the ^"%s^" flag. (%d assists)", g_szTeamName[iTeam], szName, g_szTeamName[iFlagTeamOp], iAssists)
  2102.  
  2103.             emessage_begin(MSG_BROADCAST, gMsg_TeamScore)
  2104.             ewrite_string(g_szCSTeams[iFlagTeam])
  2105.             ewrite_short(++g_iScore[iFlagTeam])
  2106.             emessage_end()
  2107.  
  2108.             flag_sendHome(iFlagTeamOp)
  2109.  
  2110.             player_updateSpeed(id)
  2111.  
  2112.             g_fLastDrop[id] = fGameTime + 3.0
  2113.  
  2114.             if(g_bProtected[id])
  2115.                 player_removeProtection(id, "PROTECTION_TOUCHFLAG")
  2116.             else
  2117.                 player_updateRender(id)
  2118.  
  2119.             if(0 < get_pcvar_num(pCvar_mp_winlimit) <= g_iScore[iFlagTeam])
  2120.             {
  2121.                 emessage_begin(MSG_ALL, SVC_INTERMISSION) // hookable mapend
  2122.                 emessage_end()
  2123.  
  2124.                 return
  2125.             }
  2126.  
  2127. #if FEATURE_ORPHEU == true
  2128.  
  2129.             new iFlagRoundEnd = get_pcvar_num(pCvar_ctf_flagendround)
  2130.  
  2131.             if(iFlagRoundEnd)
  2132.             {
  2133.                 static OrpheuFunction:ofEndRoundMsg
  2134.                 static OrpheuFunction:ofUpdateTeamScores
  2135.                 static OrpheuFunction:ofCheckWinConditions
  2136.  
  2137.                 if(!ofEndRoundMsg)
  2138.                     ofEndRoundMsg = OrpheuGetFunction("EndRoundMessage")
  2139.  
  2140.                 if(!ofUpdateTeamScores)
  2141.                     ofUpdateTeamScores = OrpheuGetFunction("UpdateTeamScores", "CHalfLifeMultiplay")
  2142.  
  2143.                 if(!ofCheckWinConditions)
  2144.                     ofCheckWinConditions = OrpheuGetFunction("CheckWinConditions", "CHalfLifeMultiplay")
  2145.  
  2146.                 new iEvent
  2147.                 new iWinStatus
  2148.                 new szWinOffset[20]
  2149.                 new szWinMessage[16]
  2150.  
  2151.                 switch(iFlagTeam)
  2152.                 {
  2153.                     case TEAM_RED:
  2154.                     {
  2155.                         iEvent = 9
  2156.                         iWinStatus = 2
  2157.                         copy(szWinOffset, charsmax(szWinOffset), "m_iNumTerroristWins")
  2158.                         copy(szWinMessage, charsmax(szWinMessage), "#Terrorists_Win")
  2159.                     }
  2160.  
  2161.                     case TEAM_BLUE:
  2162.                     {
  2163.                         iEvent = 8
  2164.                         iWinStatus = 1
  2165.                         copy(szWinOffset, charsmax(szWinOffset), "m_iNumCTWins")
  2166.                         copy(szWinMessage, charsmax(szWinMessage), "#CTs_Win")
  2167.                     }
  2168.                 }
  2169.  
  2170.                 OrpheuCallSuper(ofUpdateTeamScores, g_pGameRules)
  2171.                 OrpheuCallSuper(ofEndRoundMsg, szWinMessage, iEvent)
  2172.  
  2173.                 OrpheuMemorySetAtAddress(g_pGameRules, "m_iRoundWinStatus", 1, iWinStatus)
  2174.                 OrpheuMemorySetAtAddress(g_pGameRules, "m_fTeamCount", 1, get_gametime() + 3.0)
  2175.                 OrpheuMemorySetAtAddress(g_pGameRules, "m_bRoundTerminating", 1, true)
  2176.                 OrpheuMemorySetAtAddress(g_pGameRules, szWinOffset, 1, g_iScore[iFlagTeam])
  2177.  
  2178.                 OrpheuCallSuper(ofCheckWinConditions, g_pGameRules)
  2179.             }
  2180.  
  2181. #else
  2182.             new iFlagRoundEnd = 1
  2183.  
  2184. #endif // FEATURE_ORPHEU
  2185.  
  2186.             if(iFlagRoundEnd && get_pcvar_num(pCvar_ctf_flagcaptureslay))
  2187.             {
  2188.                 for(new i = 1; i <= g_iMaxPlayers; i++)
  2189.                 {
  2190.                     if(g_iTeam[i] == iFlagTeamOp)
  2191.                     {
  2192.                         user_kill(i)
  2193.                         player_print(i, i, "%L", i, "DEATH_FLAGCAPTURED")
  2194.                     }
  2195.                 }
  2196.             }
  2197.         }
  2198.     }
  2199.     else
  2200.     {
  2201.         if(g_iFlagHolder[iFlagTeam] == FLAG_HOLD_BASE)
  2202.         {
  2203.             player_award(id, REWARD_STEAL, "%L", id, "REWARD_STEAL")
  2204.  
  2205.             ExecuteForward(g_iFW_flag, g_iForwardReturn, FLAG_STOLEN, id, iFlagTeam, false)
  2206.  
  2207.             log_message("<%s>%s stole the ^"%s^" flag.", g_szTeamName[iTeam], szName, g_szTeamName[iFlagTeam])
  2208.         }
  2209.         else
  2210.         {
  2211.             player_award(id, REWARD_PICKUP, "%L", id, "REWARD_PICKUP")
  2212.  
  2213.             ExecuteForward(g_iFW_flag, g_iForwardReturn, FLAG_PICKED, id, iFlagTeam, false)
  2214.  
  2215.             log_message("<%s>%s picked up the ^"%s^" flag.", g_szTeamName[iTeam], szName, g_szTeamName[iFlagTeam])
  2216.         }
  2217.  
  2218.         set_hudmessage(HUD_HELP)
  2219.         show_hudmessage(id, "%L", id, "HUD_YOUHAVEFLAG")
  2220.  
  2221.         flag_take(iFlagTeam, id)
  2222.  
  2223.         g_bAssisted[id][iFlagTeam] = true
  2224.  
  2225.         task_remove(ent)
  2226.  
  2227.         if(g_bProtected[id])
  2228.             player_removeProtection(id, "PROTECTION_TOUCHFLAG")
  2229.         else
  2230.             player_updateRender(id)
  2231.  
  2232.         game_announce(EVENT_TAKEN, iFlagTeam, szName)
  2233.     }
  2234. }
  2235.  
  2236. public flag_autoReturn(ent)
  2237. {
  2238.     task_remove(ent)
  2239.  
  2240.     new iFlagTeam = (g_iFlagEntity[TEAM_BLUE] == ent ? TEAM_BLUE : (g_iFlagEntity[TEAM_RED] == ent ? TEAM_RED : 0))
  2241.  
  2242.     if(!iFlagTeam)
  2243.         return
  2244.  
  2245.     flag_sendHome(iFlagTeam)
  2246.  
  2247.     ExecuteForward(g_iFW_flag, g_iForwardReturn, FLAG_AUTORETURN, 0, iFlagTeam, false)
  2248.  
  2249.     game_announce(EVENT_RETURNED, iFlagTeam, NULL)
  2250.  
  2251.     log_message("^"%s^" flag returned automatically", g_szTeamName[iFlagTeam])
  2252. }
  2253.  
  2254.  
  2255.  
  2256.  
  2257.  
  2258.  
  2259.  
  2260.  
  2261.  
  2262. public base_think(ent)
  2263. {
  2264.     if(!is_valid_ent(ent))
  2265.         return
  2266.  
  2267.     if(!get_pcvar_num(pCvar_ctf_flagheal))
  2268.     {
  2269.         entity_set_float(ent, EV_FL_nextthink, get_gametime() + 10.0) /* recheck each 10s seconds */
  2270.  
  2271.         return
  2272.     }
  2273.  
  2274.     entity_set_float(ent, EV_FL_nextthink, get_gametime() + BASE_THINK)
  2275.  
  2276.     new iFlagTeam = (g_iBaseEntity[TEAM_BLUE] == ent ? TEAM_BLUE : TEAM_RED)
  2277.  
  2278.     if(g_iFlagHolder[iFlagTeam] != FLAG_HOLD_BASE)
  2279.         return
  2280.  
  2281.     static id
  2282.     static iHealth
  2283.  
  2284.     id = -1
  2285.  
  2286.     while((id = find_ent_in_sphere(id, g_fFlagBase[iFlagTeam], BASE_HEAL_DISTANCE)) != 0)
  2287.     {
  2288.         if(1 <= id <= g_iMaxPlayers && g_bAlive[id] && g_iTeam[id] == iFlagTeam)
  2289.         {
  2290.             iHealth = get_user_health(id)
  2291.  
  2292.             if(iHealth < g_iMaxHealth[id])
  2293.             {
  2294.                 set_user_health(id, iHealth + 1)
  2295.  
  2296.                 player_healingEffect(id)
  2297.             }
  2298.         }
  2299.  
  2300.         if(id >= g_iMaxPlayers)
  2301.             break
  2302.     }
  2303. }
  2304.  
  2305.  
  2306.  
  2307.  
  2308.  
  2309.  
  2310.  
  2311.  
  2312.  
  2313.  
  2314.  
  2315. public client_putinserver(id)
  2316. {
  2317.     g_bBot[id] = (is_user_bot(id) ? true : false)
  2318.  
  2319.     g_iTeam[id] = TEAM_SPEC
  2320.     g_bFirstSpawn[id] = true
  2321.     g_bRestarted[id] = false
  2322.     g_bLights[id] = (g_bBot[id] ? false : (get_pcvar_num(pCvar_ctf_dynamiclights) ? true : false));
  2323.  
  2324.     task_set(3.0, "client_putinserverPost", id - TASK_PUTINSERVER)
  2325. }
  2326.  
  2327. public client_putinserverPost(id)
  2328. {
  2329.     id += TASK_PUTINSERVER
  2330.  
  2331.     player_print(id, id, "%L", id, "JOIN_INFO", "^x04", MOD_TITLE, "^x01", "^x03", MOD_AUTHOR, "^x01")
  2332.  
  2333.     client_print(id, print_console, "^n%s", SEPARATOR)
  2334.     client_print(id, print_console, "                %s v%s - %L", MOD_TITLE, MOD_VERSION, id, "QH_TITLE")
  2335.     client_print(id, print_console, "                   %L %s^n%s", id, "QH_MADEBY", MOD_AUTHOR, SEPARATOR)
  2336.     client_print(id, print_console, "    %L", id, "QH_LINE1")
  2337.     client_print(id, print_console, "    %L", id, "QH_LINE2")
  2338.     client_print(id, print_console, "    %L", id, "QH_LINE3")
  2339.     client_print(id, print_console, "^n    %L", id, "QH_HELP")
  2340.  
  2341. #if FEATURE_ADRENALINE == true
  2342.  
  2343.     client_print(id, print_console, "^n    %L", id, "QH_ADRENALINE")
  2344.  
  2345. #endif // FEATURE_ADRENALINE
  2346.  
  2347. #if FEATURE_ORPHEU == false || FEATURE_BUY == false || FEATURE_C4 == false || FEATURE_ADRENALINE == false
  2348.  
  2349.     player_print(id, id, "%L", id, "JOIN_NOFEATURES")
  2350.  
  2351. #endif // FEATURE_ORPHEU || FEATURE_BUY || FEATURE_C4 || FEATURE_ADRENALINE
  2352. }
  2353.  
  2354. public client_disconnected(id)
  2355. {
  2356.     player_dropFlag(id)
  2357.     task_remove(id)
  2358.  
  2359.     g_iTeam[id] = TEAM_NONE
  2360.     g_iAdrenaline[id] = 0
  2361.     g_iAdrenalineUse[id] = 0
  2362.  
  2363.     g_bAlive[id] = false
  2364.     g_bLights[id] = false
  2365.     g_bFreeLook[id] = false
  2366.     g_bAssisted[id][TEAM_RED] = false
  2367.     g_bAssisted[id][TEAM_BLUE] = false
  2368. }
  2369.  
  2370. public player_joinTeam()
  2371. {
  2372.     new id = read_data(1)
  2373.  
  2374.     if(g_bAlive[id])
  2375.         return
  2376.  
  2377.     new szTeam[2]
  2378.  
  2379.     read_data(2, szTeam, charsmax(szTeam))
  2380.  
  2381.     switch(szTeam[0])
  2382.     {
  2383.         case 'T':
  2384.         {
  2385.             if(g_iTeam[id] == TEAM_RED && g_bFirstSpawn[id])
  2386.             {
  2387.                 new iRespawn = get_pcvar_num(pCvar_ctf_respawntime)
  2388.  
  2389.                 if(iRespawn > 0)
  2390.                     player_respawn(id - TASK_RESPAWN, iRespawn + 1)
  2391.  
  2392.                 task_remove(id - TASK_TEAMBALANCE)
  2393.                 task_set(1.0, "player_checkTeam", id - TASK_TEAMBALANCE)
  2394.             }
  2395.  
  2396.             g_iTeam[id] = TEAM_RED
  2397.         }
  2398.  
  2399.         case 'C':
  2400.         {
  2401.             if(g_iTeam[id] == TEAM_BLUE && g_bFirstSpawn[id])
  2402.             {
  2403.                 new iRespawn = get_pcvar_num(pCvar_ctf_respawntime)
  2404.  
  2405.                 if(iRespawn > 0)
  2406.                     player_respawn(id - TASK_RESPAWN, iRespawn + 1)
  2407.  
  2408.                 task_remove(id - TASK_TEAMBALANCE)
  2409.                 task_set(1.0, "player_checkTeam", id - TASK_TEAMBALANCE)
  2410.             }
  2411.  
  2412.             g_iTeam[id] = TEAM_BLUE
  2413.         }
  2414.  
  2415.         case 'U':
  2416.         {
  2417.             g_iTeam[id] = TEAM_NONE
  2418.             g_bFirstSpawn[id] = true
  2419.         }
  2420.  
  2421.         default:
  2422.         {
  2423.             player_screenFade(id, {0,0,0,0}, 0.0, 0.0, FADE_OUT, false)
  2424.             player_allowChangeTeam(id)
  2425.  
  2426.             g_iTeam[id] = TEAM_SPEC
  2427.             g_bFirstSpawn[id] = true
  2428.         }
  2429.     }
  2430. }
  2431.  
  2432. public player_spawn(id)
  2433. {
  2434.     if(!is_user_alive(id) || (!g_bRestarted[id] && g_bAlive[id]))
  2435.         return
  2436.  
  2437.     /* make sure we have team right */
  2438.  
  2439.     switch(cs_get_user_team(id))
  2440.     {
  2441.         case CS_TEAM_T: g_iTeam[id] = TEAM_RED
  2442.         case CS_TEAM_CT: g_iTeam[id] = TEAM_BLUE
  2443.         default: return
  2444.     }
  2445.  
  2446.     g_bAlive[id] = true
  2447.     g_bDefuse[id] = false
  2448.     g_bBuyZone[id] = true
  2449.     g_bFreeLook[id] = false
  2450.     g_fLastBuy[id] = Float:{0.0, 0.0, 0.0, 0.0}
  2451.  
  2452.     task_remove(id - TASK_PROTECTION)
  2453.     task_remove(id - TASK_EQUIPAMENT)
  2454.     task_remove(id - TASK_DAMAGEPROTECTION)
  2455.     task_remove(id - TASK_TEAMBALANCE)
  2456.     task_remove(id - TASK_ADRENALINE)
  2457.     task_remove(id - TASK_DEFUSE)
  2458.  
  2459. #if FEATURE_BUY == true
  2460.  
  2461.     task_set(0.1, "player_spawnEquipament", id - TASK_EQUIPAMENT)
  2462.  
  2463. #endif // FEATURE_BUY
  2464.  
  2465.     task_set(0.2, "player_checkVitals", id - TASK_CHECKHP)
  2466.  
  2467. #if FEATURE_ADRENALINE == true
  2468.  
  2469.     player_hudAdrenaline(id)
  2470.  
  2471. #endif // FEATURE_ADRENALINE
  2472.  
  2473.     new iProtection = get_pcvar_num(pCvar_ctf_protection)
  2474.  
  2475.     if(iProtection > 0)
  2476.         player_protection(id - TASK_PROTECTION, iProtection)
  2477.  
  2478.     message_begin(MSG_BROADCAST, gMsg_ScoreAttrib)
  2479.     write_byte(id)
  2480.     write_byte(0)
  2481.     message_end()
  2482.  
  2483.     if(g_bFirstSpawn[id] || g_bRestarted[id])
  2484.     {
  2485.         g_bRestarted[id] = false
  2486.         g_bFirstSpawn[id] = false
  2487.  
  2488.         cs_set_user_money(id, get_pcvar_num(pCvar_mp_startmoney))
  2489.     }
  2490.     else if(g_bSuicide[id])
  2491.     {
  2492.         g_bSuicide[id] = false
  2493.  
  2494.         player_print(id, id, "%L", id, "SPAWN_NOMONEY")
  2495.     }
  2496.     else
  2497.         cs_set_user_money(id, clamp((cs_get_user_money(id) + get_pcvar_num(pCvar_ctf_spawnmoney)), get_pcvar_num(pCvar_mp_startmoney), 16000))
  2498. }
  2499.  
  2500. public player_checkVitals(id)
  2501. {
  2502.     id += TASK_CHECKHP
  2503.  
  2504.     if(!g_bAlive[id])
  2505.         return
  2506.  
  2507.     /* in case player is VIP or whatever special class that sets armor */
  2508.     new CsArmorType:iArmorType
  2509.     new iArmor = cs_get_user_armor(id, iArmorType)
  2510.  
  2511.     g_iMaxArmor[id] = (iArmor > 0 ? iArmor : 100)
  2512.     g_iMaxHealth[id] = get_user_health(id)
  2513. }
  2514.  
  2515. #if FEATURE_BUY == true
  2516.  
  2517. public player_spawnEquipament(id)
  2518. {
  2519.     id += TASK_EQUIPAMENT
  2520.  
  2521.     if(!g_bAlive[id])
  2522.         return
  2523.  
  2524.     strip_user_weapons(id)
  2525.  
  2526.     if(get_pcvar_num(pCvar_ctf_spawn_knife))
  2527.         give_item(id, g_szWeaponEntity[W_KNIFE])
  2528.  
  2529.     new szWeapon[3][24]
  2530.  
  2531.     get_pcvar_string(pCvar_ctf_spawn_prim, szWeapon[1], charsmax(szWeapon[]))
  2532.     get_pcvar_string(pCvar_ctf_spawn_sec, szWeapon[2], charsmax(szWeapon[]))
  2533.  
  2534.     for(new iWeapon, i = 2; i >= 1; i--)
  2535.     {
  2536.         iWeapon = 0
  2537.  
  2538.         if(strlen(szWeapon[i]))
  2539.         {
  2540.             for(new w = 1; w < sizeof g_szWeaponCommands; w++)
  2541.             {
  2542.                 if(g_iWeaponSlot[w] == i && equali(szWeapon[i], g_szWeaponCommands[w][0]))
  2543.                 {
  2544.                     iWeapon = w
  2545.                     break
  2546.                 }
  2547.             }
  2548.  
  2549.             if(iWeapon)
  2550.             {
  2551.                 give_item(id, g_szWeaponEntity[iWeapon])
  2552.                 cs_set_user_bpammo(id, iWeapon, g_iBPAmmo[iWeapon])
  2553.             }
  2554.             else
  2555.                 log_error(AMX_ERR_NOTFOUND, "Invalid %s weapon: ^"%s^", please fix ctf_spawn_%s cvar", (i == 1 ? "primary" : "secondary"), szWeapon[i], (i == 1 ? "prim" : "sec"))
  2556.         }
  2557.     }
  2558. }
  2559.  
  2560. #endif // FEATURE_BUY
  2561.  
  2562. public player_protection(id, iStart)
  2563. {
  2564.     id += TASK_PROTECTION
  2565.  
  2566.     if(!(TEAM_RED <= g_iTeam[id] <= TEAM_BLUE))
  2567.         return
  2568.  
  2569.     static iCount[33]
  2570.  
  2571.     if(iStart)
  2572.     {
  2573.         iCount[id] = iStart + 1
  2574.  
  2575.         g_bProtected[id] = true
  2576.  
  2577.         player_updateRender(id)
  2578.     }
  2579.  
  2580.     if(--iCount[id] > 0)
  2581.     {
  2582.         set_hudmessage(HUD_RESPAWN)
  2583.         ShowSyncHudMsg(id, xMsgSync[0], "^n• Proteção: %d segundos", id, iCount[id])
  2584.  
  2585.         task_set(1.0, "player_protection", id - TASK_PROTECTION)
  2586.     }
  2587.     else
  2588.         player_removeProtection(id, "^n^nSpawn proteção expirado.")
  2589. }
  2590.  
  2591. public player_removeProtection(id, szLang[])
  2592. {
  2593.     if(!(TEAM_RED <= g_iTeam[id] <= TEAM_BLUE))
  2594.         return
  2595.  
  2596.     g_bProtected[id] = false
  2597.  
  2598.     task_remove(id - TASK_PROTECTION)
  2599.     task_remove(id - TASK_DAMAGEPROTECTION)
  2600.  
  2601.     set_hudmessage(HUD_PROTECTION)
  2602.     show_hudmessage(id, "%L", id, szLang)
  2603.  
  2604.     player_updateRender(id)
  2605. }
  2606.  
  2607. public player_currentWeapon(id)
  2608. {
  2609.     if(!g_bAlive[id])
  2610.         return
  2611.  
  2612.     static bool:bZoom[33]
  2613.  
  2614.     new iZoom = read_data(1)
  2615.  
  2616.     if(1 < iZoom <= 90) /* setFOV event */
  2617.         bZoom[id] = bool:(iZoom <= 40)
  2618.  
  2619.     else /* CurWeapon event */
  2620.     {
  2621.         if(!bZoom[id]) /* if not zooming, get weapon speed */
  2622.             g_fWeaponSpeed[id] = g_fWeaponRunSpeed[read_data(2)]
  2623.  
  2624.         else /* if zooming, set zoom speed */
  2625.             g_fWeaponSpeed[id] = g_fWeaponRunSpeed[0]
  2626.  
  2627.         player_updateSpeed(id)
  2628.     }
  2629. }
  2630.  
  2631. public client_PostThink(id)
  2632. {
  2633.     if(!g_bAlive[id])
  2634.         return
  2635.  
  2636.     static iOffset
  2637.     static iShield[33]
  2638.  
  2639.     iOffset = get_pdata_int(id, m_iUserPrefs)
  2640.  
  2641.     if(iOffset & (1<<24)) /* Shield available */
  2642.     {
  2643.         if(iOffset & (1<<16)) /* Uses shield */
  2644.         {
  2645.             if(iShield[id] < 2) /* Trigger only once */
  2646.             {
  2647.                 iShield[id] = 2
  2648.  
  2649.                 g_fWeaponSpeed[id] = 180.0
  2650.  
  2651.                 player_updateSpeed(id)
  2652.             }
  2653.         }
  2654.         else if(iShield[id] == 2) /* Doesn't use the shield anymore */
  2655.         {
  2656.             iShield[id] = 1
  2657.  
  2658.             g_fWeaponSpeed[id] = 250.0
  2659.  
  2660.             player_updateSpeed(id)
  2661.         }
  2662.     }
  2663.     else if(iShield[id]) /* Shield not available anymore */
  2664.         iShield[id] = 0
  2665. }
  2666.  
  2667. public player_useWeapon(ent)
  2668. {
  2669.     if(!is_valid_ent(ent))
  2670.         return
  2671.  
  2672.     static id
  2673.  
  2674.     id = entity_get_edict(ent, EV_ENT_owner)
  2675.  
  2676.     if(1 <= id <= g_iMaxPlayers && g_bAlive[id])
  2677.     {
  2678.         if(g_bProtected[id])
  2679.             player_removeProtection(id, "PROTECTION_WEAPONUSE")
  2680.  
  2681. #if FEATURE_ADRENALINE == true
  2682.         else if(g_iAdrenalineUse[id] == ADRENALINE_BERSERK)
  2683.         {
  2684.             set_pdata_float(ent, m_flNextPrimaryAttack, get_pdata_float(ent, m_flNextPrimaryAttack, 4) * BERSERKER_SPEED1)
  2685.             set_pdata_float(ent, m_flNextSecondaryAttack, get_pdata_float(ent, m_flNextSecondaryAttack, 4) * BERSERKER_SPEED2)
  2686.         }
  2687. #endif // FEATURE_ADRENALINE
  2688.     }
  2689. }
  2690.  
  2691. #if FEATURE_ADRENALINE == true
  2692.  
  2693. public player_useWeaponSec(ent)
  2694. {
  2695.     if(!is_valid_ent(ent))
  2696.         return
  2697.  
  2698.     static id
  2699.  
  2700.     id = entity_get_edict(ent, EV_ENT_owner)
  2701.  
  2702.     if(1 <= id <= g_iMaxPlayers && g_bAlive[id] && g_iAdrenalineUse[id] == ADRENALINE_BERSERK)
  2703.     {
  2704.         set_pdata_float(ent, m_flNextPrimaryAttack, get_pdata_float(ent, m_flNextPrimaryAttack, 4) * BERSERKER_SPEED1)
  2705.         set_pdata_float(ent, m_flNextSecondaryAttack, get_pdata_float(ent, m_flNextSecondaryAttack, 4) * BERSERKER_SPEED2)
  2706.     }
  2707. }
  2708.  
  2709. #endif // FEATURE_ADRENALINE
  2710.  
  2711.  
  2712. public player_damage(id, iWeapon, iAttacker, Float:fDamage, iType)
  2713. {
  2714.     if(g_bProtected[id])
  2715.     {
  2716.         player_updateRender(id, fDamage)
  2717.  
  2718.         task_remove(id - TASK_DAMAGEPROTECTION)
  2719.         task_set(0.1, "player_damageProtection", id - TASK_DAMAGEPROTECTION)
  2720.  
  2721.         entity_set_vector(id, EV_VEC_punchangle, FLAG_SPAWN_ANGLES)
  2722.  
  2723.         return HAM_SUPERCEDE
  2724.     }
  2725.  
  2726. #if FEATURE_ADRENALINE == true
  2727.  
  2728.     else if(1 <= iAttacker <= g_iMaxPlayers && g_iAdrenalineUse[iAttacker] == ADRENALINE_BERSERK && g_iTeam[iAttacker] != g_iTeam[id])
  2729.     {
  2730.         SetHamParamFloat(4, fDamage * BERSERKER_DAMAGE)
  2731.  
  2732.         new iOrigin[3]
  2733.  
  2734.         get_user_origin(id, iOrigin)
  2735.  
  2736.         message_begin(MSG_PVS, SVC_TEMPENTITY, iOrigin)
  2737.         write_byte(TE_BLOODSPRITE)
  2738.         write_coord(iOrigin[x] + random_num(-15, 15))
  2739.         write_coord(iOrigin[y] + random_num(-15, 15))
  2740.         write_coord(iOrigin[z] + random_num(-15, 15))
  2741.         write_short(gSpr_blood2)
  2742.         write_short(gSpr_blood1)
  2743.         write_byte(248)
  2744.         write_byte(18)
  2745.         message_end()
  2746.  
  2747.         return HAM_OVERRIDE
  2748.     }
  2749.  
  2750. #endif // FEATURE_ADRENALINE
  2751.  
  2752.     return HAM_IGNORED
  2753. }
  2754.  
  2755. public player_damageProtection(id)
  2756. {
  2757.     id += TASK_DAMAGEPROTECTION
  2758.  
  2759.     if(g_bAlive[id])
  2760.         player_updateRender(id)
  2761. }
  2762.  
  2763. public player_killed(id, killer)
  2764. {
  2765.     g_bAlive[id] = false
  2766.     g_bBuyZone[id] = false
  2767.  
  2768.     task_remove(id - TASK_RESPAWN)
  2769.     task_remove(id - TASK_PROTECTION)
  2770.     task_remove(id - TASK_EQUIPAMENT)
  2771.     task_remove(id - TASK_DAMAGEPROTECTION)
  2772.     task_remove(id - TASK_TEAMBALANCE)
  2773.     task_remove(id - TASK_ADRENALINE)
  2774.     task_remove(id - TASK_DEFUSE)
  2775.  
  2776.     new szHint[10]
  2777.  
  2778. #if FEATURE_C4 == true && FEATURE_ADRENALINE == true
  2779.  
  2780.     formatex(szHint, charsmax(szHint), "HINT_%d", random_num(1, 12))
  2781.  
  2782. #else
  2783.  
  2784.     new iHint
  2785.  
  2786.     while((iHint = random_num(1, 12)))
  2787.     {
  2788. #if FEATURE_ADRENALINE == false
  2789.         if(iHint == 1 || iHint == 7 || iHint == 9)
  2790.             continue
  2791. #endif // FEATURE_ADRENALINE
  2792.  
  2793.  
  2794. #if FEATURE_C4 == false
  2795.         if(iHint == 4 || iHint == 8 || iHint == 10)
  2796.             continue
  2797. #endif // FEATURE_C4
  2798.  
  2799.         break
  2800.     }
  2801.  
  2802.     formatex(szHint, charsmax(szHint), "HINT_%d", iHint)
  2803.  
  2804. #endif // FEATURE_C4 || FEATURE_ADRENALINE
  2805.  
  2806.     //set_hudmessage(HUD_HINT)
  2807.     //show_hudmessage(id, "%L: %L", id, "HINT", id, szHint)
  2808.     client_print(id, print_console, "%s%L: %L", CONSOLE_PREFIX, id, "HINT", id, szHint)
  2809.  
  2810. #if FEATURE_C4 == true
  2811.  
  2812.     new iWeapon = entity_get_edict(id, EV_ENT_dmg_inflictor)
  2813.     new szWeapon[10]
  2814.     new bool:bC4 = false
  2815.  
  2816.     if(iWeapon > g_iMaxPlayers && is_valid_ent(iWeapon))
  2817.     {
  2818.         entity_get_string(iWeapon, EV_SZ_classname, szWeapon, charsmax(szWeapon))
  2819.  
  2820.         if(equal(szWeapon, GRENADE) && get_pdata_int(iWeapon, 96) & (1<<8))
  2821.         {
  2822.             message_begin(MSG_ALL, gMsg_DeathMsg)
  2823.             write_byte(killer)
  2824.             write_byte(id)
  2825.             write_byte(0)
  2826.             write_string("c4")
  2827.             message_end()
  2828.  
  2829.             bC4 = true
  2830.         }
  2831.     }
  2832.  
  2833. #endif // FEATURE_C4
  2834.  
  2835.     if(id == killer || !(1 <= killer <= g_iMaxPlayers))
  2836.     {
  2837.         g_bSuicide[id] = true
  2838.  
  2839.         player_award(id, PENALTY_SUICIDE, "%L", id, "PENALTY_SUICIDE")
  2840.  
  2841. #if FEATURE_C4 == true
  2842.  
  2843.         if(bC4)
  2844.             player_setScore(id, -1, 1)
  2845.  
  2846. #endif // FEATURE_C4
  2847.  
  2848.     }
  2849.     else if(1 <= killer <= g_iMaxPlayers)
  2850.     {
  2851.         if(g_iTeam[id] == g_iTeam[killer])
  2852.         {
  2853.  
  2854. #if FEATURE_C4 == true
  2855.  
  2856.             if(bC4)
  2857.             {
  2858.                 player_setScore(killer, -1, 0)
  2859.                 cs_set_user_money(killer, clamp(cs_get_user_money(killer) - 3300, 0, 16000), 1)
  2860.             }
  2861.  
  2862. #endif // FEATURE_C4
  2863.  
  2864.             player_award(killer, PENALTY_TEAMKILL, "%L", killer, "PENALTY_TEAMKILL")
  2865.         }
  2866.         else
  2867.         {
  2868.  
  2869. #if FEATURE_C4 == true
  2870.  
  2871.             if(bC4)
  2872.             {
  2873.                 player_setScore(killer, -1, 0)
  2874.                 player_setScore(id, 0, 1)
  2875.  
  2876.                 cs_set_user_money(killer, clamp(cs_get_user_money(killer) + 300, 0, 16000), 1)
  2877.             }
  2878.  
  2879. #endif // FEATURE_C4
  2880.  
  2881.             if(id == g_iFlagHolder[g_iTeam[killer]])
  2882.             {
  2883.                 g_bAssisted[killer][g_iTeam[killer]] = true
  2884.  
  2885.                 player_award(killer, REWARD_KILLCARRIER, "%L", killer, "REWARD_KILLCARRIER")
  2886.  
  2887.                 message_begin(MSG_BROADCAST, gMsg_ScoreAttrib)
  2888.                 write_byte(id)
  2889.                 write_byte(0)
  2890.                 message_end()
  2891.             }
  2892.             else
  2893.             {
  2894.                 player_spawnItem(id)
  2895.                 player_award(killer, REWARD_KILL, "%L", killer, "REWARD_KILL")
  2896.             }
  2897.         }
  2898.     }
  2899.  
  2900. #if FEATURE_ADRENALINE == true
  2901.  
  2902.     if(g_iAdrenalineUse[id])
  2903.     {
  2904.  
  2905.         switch(g_iAdrenalineUse[id])
  2906.         {
  2907.             case ADRENALINE_SPEED:
  2908.             {
  2909.                 message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  2910.                 write_byte(TE_KILLBEAM)
  2911.                 write_short(id)
  2912.                 message_end()
  2913.             }
  2914.         }
  2915.  
  2916.         g_iAdrenaline[id] = 0
  2917.         g_iAdrenalineUse[id] = 0
  2918.  
  2919.         player_updateRender(id)
  2920.         player_hudAdrenaline(id)
  2921.     }
  2922.  
  2923. #endif // FEATURE_ADRENALINE
  2924.  
  2925.     new iRespawn = get_pcvar_num(pCvar_ctf_respawntime)
  2926.  
  2927.     if(iRespawn > 0)
  2928.         player_respawn(id - TASK_RESPAWN, iRespawn)
  2929.  
  2930.     player_dropFlag(id)
  2931.     player_allowChangeTeam(id)
  2932.  
  2933.     task_set(1.0, "player_checkTeam", id - TASK_TEAMBALANCE)
  2934. }
  2935.  
  2936. public player_checkTeam(id)
  2937. {
  2938.     id += TASK_TEAMBALANCE
  2939.  
  2940.     if(!(TEAM_RED <= g_iTeam[id] <= TEAM_BLUE) || g_bAlive[id] || !get_pcvar_num(pCvar_mp_autoteambalance))
  2941.         return
  2942.  
  2943.     new iPlayers[3]
  2944.     new iTeam = g_iTeam[id]
  2945.     new iOpTeam = get_opTeam(iTeam)
  2946.  
  2947.     for(new i = 1; i <= g_iMaxPlayers; i++)
  2948.     {
  2949.         if(TEAM_RED <= g_iTeam[i] <= TEAM_BLUE)
  2950.             iPlayers[g_iTeam[i]]++
  2951.     }
  2952.  
  2953.     if((iPlayers[iTeam] > 1 && !iPlayers[iOpTeam]) || iPlayers[iTeam] > (iPlayers[iOpTeam] + 1))
  2954.     {
  2955.         player_allowChangeTeam(id)
  2956.  
  2957.         engclient_cmd(id, "jointeam", (iOpTeam == TEAM_BLUE ? "2" : "1"))
  2958.  
  2959.         set_task(2.0, "player_forceJoinClass", id)
  2960.  
  2961.         player_print(id, id, "%L", id, "DEATH_TRANSFER", "^x04", id, g_szMLTeamName[iOpTeam], "^x01")
  2962.     }
  2963. }
  2964.  
  2965. public player_forceJoinClass(id)
  2966. {
  2967.     engclient_cmd(id, "joinclass", "5")
  2968. }
  2969.  
  2970. public player_respawn(id, iStart)
  2971. {
  2972.     id += TASK_RESPAWN
  2973.  
  2974.     if(!(TEAM_RED <= g_iTeam[id] <= TEAM_BLUE) || g_bAlive[id])
  2975.         return
  2976.  
  2977.     static iCount[33]
  2978.  
  2979.     if(iStart)
  2980.         iCount[id] = iStart + 1
  2981.  
  2982.     set_hudmessage(HUD_RESPAWN)
  2983.  
  2984.     if(--iCount[id] > 0)
  2985.     {
  2986.         ShowSyncHudMsg(id, xMsgSync[0], "• Respawn: %d Segundos", iCount[id])
  2987.         //client_print(id, print_console, "%L", id, "RESPAWNING_IN", iCount[id])
  2988.  
  2989.         task_set(1.0, "player_respawn", id - TASK_RESPAWN)
  2990.     }
  2991.     else
  2992.     {
  2993.         ShowSyncHudMsg(id, xMsgSync[0],  "• Boa Sorte...")
  2994.         //client_print(id, print_console, "%L", id, "RESPAWNING")
  2995.  
  2996.         entity_set_int(id, EV_INT_deadflag, DEAD_RESPAWNABLE)
  2997.         entity_set_int(id, EV_INT_iuser1, 0)
  2998.         entity_think(id)
  2999.         entity_spawn(id)
  3000.         set_user_health(id, 100)
  3001.     }
  3002. }
  3003.  
  3004. #if FEATURE_ADRENALINE == true
  3005.  
  3006. public player_cmd_buySpawn(id)
  3007. {
  3008.     if(g_bAlive[id] || !(TEAM_RED <= g_iTeam[id] <= TEAM_BLUE))
  3009.         player_print(id, id, "%L", id, "INSTANTSPAWN_NOTEAM")
  3010.  
  3011.     else if(g_iAdrenaline[id] < INSTANTSPAWN_COST)
  3012.         player_print(id, id, "%L", id, "INSTANTSPAWN_NOADRENALINE", INSTANTSPAWN_COST)
  3013.  
  3014.     else
  3015.     {
  3016.         g_iAdrenaline[id] -= INSTANTSPAWN_COST
  3017.  
  3018.         player_print(id, id, "%L", id, "INSTANTSPAWN_BOUGHT", INSTANTSPAWN_COST)
  3019.  
  3020.         task_remove(id)
  3021.         player_respawn(id - TASK_RESPAWN, -1)
  3022.     }
  3023.  
  3024.     return PLUGIN_HANDLED
  3025. }
  3026.  
  3027. #endif // FEATURE_ADRENALINE
  3028.  
  3029. public player_cmd_dropFlag(id)
  3030. {
  3031.     if(!g_bAlive[id] || id != g_iFlagHolder[get_opTeam(g_iTeam[id])])
  3032.         player_print(id, id, "%L", id, "DROPFLAG_NOFLAG")
  3033.  
  3034.     else
  3035.     {
  3036.         new iOpTeam = get_opTeam(g_iTeam[id])
  3037.  
  3038.         player_dropFlag(id)
  3039.         player_award(id, PENALTY_DROP, "%L", id, "PENALTY_MANUALDROP")
  3040.  
  3041.         ExecuteForward(g_iFW_flag, g_iForwardReturn, FLAG_MANUALDROP, id, iOpTeam, false)
  3042.  
  3043.         g_bAssisted[id][iOpTeam] = false
  3044.     }
  3045.  
  3046.     return PLUGIN_HANDLED
  3047. }
  3048.  
  3049. public player_dropFlag(id)
  3050. {
  3051.     new iOpTeam = get_opTeam(g_iTeam[id])
  3052.  
  3053.     if(id != g_iFlagHolder[iOpTeam])
  3054.         return
  3055.  
  3056.     new ent = g_iFlagEntity[iOpTeam]
  3057.  
  3058.     if(!is_valid_ent(ent))
  3059.         return
  3060.  
  3061.     g_fLastDrop[id] = get_gametime() + 2.0
  3062.     g_iFlagHolder[iOpTeam] = FLAG_HOLD_DROPPED
  3063.  
  3064.     entity_set_edict(ent, EV_ENT_aiment, -1)
  3065.     entity_set_int(ent, EV_INT_movetype, MOVETYPE_TOSS)
  3066.     entity_set_int(ent, EV_INT_sequence, FLAG_ANI_DROPPED)
  3067.     entity_set_int(ent, EV_INT_solid, SOLID_TRIGGER)
  3068.     entity_set_origin(ent, g_fFlagLocation[iOpTeam])
  3069.  
  3070.     new Float:fReturn = get_pcvar_float(pCvar_ctf_flagreturn)
  3071.  
  3072.     if(fReturn > 0)
  3073.         task_set(fReturn, "flag_autoReturn", ent)
  3074.  
  3075.     if(g_bAlive[id])
  3076.     {
  3077.         new Float:fVelocity[3]
  3078.  
  3079.         velocity_by_aim(id, 200, fVelocity)
  3080.  
  3081.         fVelocity[z] = 0.0
  3082.  
  3083.         entity_set_vector(ent, EV_VEC_velocity, fVelocity)
  3084.  
  3085.         player_updateSpeed(id)
  3086.         player_updateRender(id)
  3087.  
  3088.         message_begin(MSG_BROADCAST, gMsg_ScoreAttrib)
  3089.         write_byte(id)
  3090.         write_byte(0)
  3091.         message_end()
  3092.     }
  3093.     else
  3094.         entity_set_vector(ent, EV_VEC_velocity, FLAG_DROP_VELOCITY)
  3095.  
  3096.     new szName[32]
  3097.  
  3098.     get_user_name(id, szName, charsmax(szName))
  3099.  
  3100.     game_announce(EVENT_DROPPED, iOpTeam, szName)
  3101.  
  3102.     ExecuteForward(g_iFW_flag, g_iForwardReturn, FLAG_DROPPED, id, iOpTeam, false)
  3103.  
  3104.     g_fFlagDropped[iOpTeam] = get_gametime()
  3105.  
  3106.     log_message("<%s>%s dropped the ^"%s^" flag.", g_szTeamName[g_iTeam[id]], szName, g_szTeamName[iOpTeam])
  3107. }
  3108.  
  3109. public player_cmd_say(id)
  3110. {
  3111.     static Float:fLastUsage[33]
  3112.  
  3113.     new Float:fGameTime = get_gametime()
  3114.  
  3115.     if((fLastUsage[id] + 0.5) > fGameTime)
  3116.         return PLUGIN_HANDLED
  3117.  
  3118.     fLastUsage[id] = fGameTime
  3119.  
  3120.     new szMsg[128]
  3121.  
  3122.     read_args(szMsg, charsmax(szMsg))
  3123.     remove_quotes(szMsg)
  3124.     trim(szMsg)
  3125.  
  3126.     if(equal(szMsg, NULL))
  3127.         return PLUGIN_HANDLED
  3128.  
  3129.     if(equal(szMsg[0], "@"))
  3130.         return PLUGIN_CONTINUE
  3131.  
  3132.     new szFormat[192]
  3133.     new szName[32]
  3134.  
  3135.     get_user_name(id, szName, charsmax(szName))
  3136.  
  3137.     switch(g_iTeam[id])
  3138.     {
  3139.         //case TEAM_RED, TEAM_BLUE: formatex(szFormat, charsmax(szFormat), "^x01%s^x03%s ^x01:  %s", (g_bAlive[id] ? NULL : "^x01*DEAD* "), szName, szMsg)
  3140.         //case TEAM_NONE, TEAM_SPEC: formatex(szFormat, charsmax(szFormat), "^x01*SPEC* ^x03%s ^x01:  %s", szName, szMsg)
  3141.     }
  3142.  
  3143.     for(new i = 1; i <= g_iMaxPlayers; i++)
  3144.     {
  3145.         if(i == id || g_iTeam[i] == TEAM_NONE || g_bAlive[i] == g_bAlive[id] || g_bBot[id])
  3146.             continue
  3147.  
  3148.         message_begin(MSG_ONE, gMsg_SayText, _, i)
  3149.         write_byte(id)
  3150.         write_string(szFormat)
  3151.         message_end()
  3152.     }
  3153.  
  3154. #if FEATURE_BUY == true
  3155.  
  3156.     if(equali(szMsg, "/buy"))
  3157.     {
  3158.         player_menu_buy(id, 0)
  3159.  
  3160.         return CHAT_SHOW_COMMANDS ? PLUGIN_CONTINUE : PLUGIN_HANDLED
  3161.     }
  3162.  
  3163. #endif // FEATURE_BUY
  3164.  
  3165. #if FEATURE_ADRENALINE == true
  3166.  
  3167.     if(equali(szMsg, "/spawn"))
  3168.     {
  3169.         player_cmd_buySpawn(id)
  3170.  
  3171.         return CHAT_SHOW_COMMANDS ? PLUGIN_CONTINUE : PLUGIN_HANDLED
  3172.     }
  3173.  
  3174.     if(equali(szMsg, "/adrenaline"))
  3175.     {
  3176.         player_cmd_adrenaline(id)
  3177.  
  3178.         return CHAT_SHOW_COMMANDS ? PLUGIN_CONTINUE : PLUGIN_HANDLED
  3179.     }
  3180.  
  3181. #endif // FEATURE_ADRENALINE
  3182.  
  3183.     if(equali(szMsg, "/help"))
  3184.     {
  3185.         player_cmd_help(id)
  3186.  
  3187.         return CHAT_SHOW_COMMANDS ? PLUGIN_CONTINUE : PLUGIN_HANDLED
  3188.     }
  3189.  
  3190.     if(equali(szMsg, "/dropflag"))
  3191.     {
  3192.         player_cmd_dropFlag(id)
  3193.  
  3194.         return CHAT_SHOW_COMMANDS ? PLUGIN_CONTINUE : PLUGIN_HANDLED
  3195.     }
  3196.  
  3197.     if(equali(szMsg, "/lights", 7))
  3198.     {
  3199.         player_cmd_setLights(id, szMsg[8])
  3200.  
  3201.         return CHAT_SHOW_COMMANDS ? PLUGIN_CONTINUE : PLUGIN_HANDLED
  3202.     }
  3203.  
  3204.     if(equali(szMsg, "/sounds", 7))
  3205.     {
  3206.         player_cmd_setSounds(id, szMsg[8])
  3207.  
  3208.         return CHAT_SHOW_COMMANDS ? PLUGIN_CONTINUE : PLUGIN_HANDLED
  3209.     }
  3210.  
  3211.     return PLUGIN_CONTINUE
  3212. }
  3213.  
  3214. public player_cmd_sayTeam(id)
  3215. {
  3216.     static Float:fLastUsage[33]
  3217.  
  3218.     new Float:fGameTime = get_gametime()
  3219.  
  3220.     if((fLastUsage[id] + 0.5) > fGameTime)
  3221.         return PLUGIN_HANDLED
  3222.  
  3223.     fLastUsage[id] = fGameTime
  3224.  
  3225.     new szMsg[128]
  3226.  
  3227.     read_args(szMsg, charsmax(szMsg))
  3228.     remove_quotes(szMsg)
  3229.     trim(szMsg)
  3230.  
  3231.     if(equal(szMsg, NULL))
  3232.         return PLUGIN_HANDLED
  3233.  
  3234.     if(equal(szMsg[0], "@"))
  3235.         return PLUGIN_CONTINUE
  3236.  
  3237.     new szFormat[192]
  3238.     new szName[32]
  3239.  
  3240.     get_user_name(id, szName, charsmax(szName))
  3241.  
  3242.     switch(g_iTeam[id])
  3243.     {
  3244.         //case TEAM_RED, TEAM_BLUE: formatex(szFormat, charsmax(szFormat), "^x01%s(%L) ^x03%s ^x01:  %s", (g_bAlive[id] ? NULL : "*DEAD* "), LANG_PLAYER, g_szMLFlagTeam[g_iTeam[id]], szName, szMsg)
  3245.         //case TEAM_NONE, TEAM_SPEC: formatex(szFormat, charsmax(szFormat), "^x01*SPEC*(%L) ^x03%s ^x01:  %s", LANG_PLAYER, g_szMLTeamName[TEAM_SPEC], szName, szMsg)
  3246.     }
  3247.  
  3248.     for(new i = 1; i <= g_iMaxPlayers; i++)
  3249.     {
  3250.         if(i == id || g_iTeam[i] == TEAM_NONE || g_iTeam[i] != g_iTeam[id] || g_bAlive[i] == g_bAlive[id] || g_bBot[id])
  3251.             continue
  3252.  
  3253.         message_begin(MSG_ONE, gMsg_SayText, _, i)
  3254.         write_byte(id)
  3255.         write_string(szFormat)
  3256.         message_end()
  3257.     }
  3258.  
  3259. #if FEATURE_BUY == true
  3260.  
  3261.     if(equali(szMsg, "/buy"))
  3262.     {
  3263.         player_menu_buy(id, 0)
  3264.  
  3265.         return CHAT_SHOW_COMMANDS ? PLUGIN_CONTINUE : PLUGIN_HANDLED
  3266.     }
  3267.  
  3268. #endif // FEATURE_BUY
  3269.  
  3270. #if FEATURE_ADRENALINE == true
  3271.  
  3272.     if(equali(szMsg, "/spawn"))
  3273.     {
  3274.         player_cmd_buySpawn(id)
  3275.  
  3276.         return CHAT_SHOW_COMMANDS ? PLUGIN_CONTINUE : PLUGIN_HANDLED
  3277.     }
  3278.  
  3279.     if(equali(szMsg, "/adrenaline"))
  3280.     {
  3281.         player_cmd_adrenaline(id)
  3282.  
  3283.         return CHAT_SHOW_COMMANDS ? PLUGIN_CONTINUE : PLUGIN_HANDLED
  3284.     }
  3285.  
  3286. #endif // FEATURE_ADRENALINE
  3287.  
  3288.     if(equali(szMsg, "/dropflag"))
  3289.     {
  3290.         player_cmd_dropFlag(id)
  3291.  
  3292.         return CHAT_SHOW_COMMANDS ? PLUGIN_CONTINUE : PLUGIN_HANDLED
  3293.     }
  3294.  
  3295.     if(equali(szMsg, "/help"))
  3296.     {
  3297.         player_cmd_help(id)
  3298.  
  3299.         return CHAT_SHOW_COMMANDS ? PLUGIN_CONTINUE : PLUGIN_HANDLED
  3300.     }
  3301.  
  3302.     return PLUGIN_CONTINUE
  3303. }
  3304.  
  3305. public player_cmd_help(id)
  3306. {
  3307.     client_cmd(id, "hideconsole;toggleconsole")
  3308.  
  3309.     client_print(id, print_console, "^n^n^n^n%s", SEPARATOR)
  3310.     client_print(id, print_console, "                %s v%s - %L^n              Mod by %s", MOD_TITLE, MOD_VERSION, id, "HELP_TITLE", MOD_AUTHOR)
  3311.     client_print(id, print_console, SEPARATOR)
  3312.     client_print(id, print_console, "    1. %L^n    2. %L^n    3. %L^n    4. %L", id, "HELP_1", id, "HELP_2", id, "HELP_3", id, "HELP_4")
  3313.     client_print(id, print_console, "^n    --- 1: %L ---^n", id, "HELP_1")
  3314.     client_print(id, print_console, "%L", id, "HELP_1_LINE1")
  3315.     client_print(id, print_console, "%L", id, "HELP_1_LINE2")
  3316.     client_print(id, print_console, "%L", id, "HELP_1_LINE3")
  3317.     client_print(id, print_console, "%L", id, "HELP_1_LINE4")
  3318.     client_print(id, print_console, "^n    --- 2: %L ---", id, "HELP_2")
  3319.     client_print(id, print_console, "%L", id, "HELP_2_NOTE")
  3320.     client_print(id, print_console, "%L", id, "HELP_2_LINE1")
  3321.     client_print(id, print_console, "%L", id, "HELP_2_LINE2")
  3322.  
  3323. #if FEATURE_ADRENALINE == true
  3324.     client_print(id, print_console, "%L", id, "HELP_2_LINE3", INSTANTSPAWN_COST)
  3325. #endif // FEATURE_ADRENALINE
  3326.  
  3327.     client_print(id, print_console, "%L", id, "HELP_2_LINE4")
  3328.  
  3329. #if FEATURE_ADRENALINE == true
  3330.     client_print(id, print_console, "%L", id, "HELP_2_LINE5")
  3331. #endif // FEATURE_ADRENALINE
  3332.  
  3333.     client_print(id, print_console, "^n    --- 3: %L ---", id, "HELP_3")
  3334.  
  3335. #if FEATURE_ORPHEU == false
  3336.     client_print(id, print_console, " * %L", id, "HELP_3_INFROUND", id, "OFF")
  3337.     client_print(id, print_console, " * %L", id, "HELP_3_ROUNDEND", id, "OFF")
  3338. #else
  3339.     client_print(id, print_console, " * %L", id, "HELP_3_INFROUND", id, get_pcvar_num(pCvar_ctf_infiniteround) ? "ON" : "OFF")
  3340.     client_print(id, print_console, " * %L", id, "HELP_3_ROUNDEND", id, get_pcvar_num(pCvar_ctf_flagendround) ? "ON" : "OFF")
  3341. #endif
  3342.  
  3343.     client_print(id, print_console, " * %L", id, "HELP_3_CAPTURESLAY", id, get_pcvar_num(pCvar_ctf_flagcaptureslay) ? "ON" : "OFF")
  3344.  
  3345. #if FEATURE_BUY == true
  3346.     client_print(id, print_console, " * %L", id, "HELP_3_BUY", id, "ON")
  3347. #else
  3348.     client_print(id, print_console, " * %L", id, "HELP_3_BUY", id, "OFF")
  3349. #endif
  3350.  
  3351. #if FEATURE_C4 == true
  3352.     client_print(id, print_console, " * %L", id, "HELP_3_C4", id, "ON")
  3353. #else
  3354.     client_print(id, print_console, " * %L", id, "HELP_3_C4", id, "OFF")
  3355. #endif
  3356.  
  3357. #if FEATURE_ADRENALINE == true
  3358.     client_print(id, print_console, " * %L", id, "HELP_3_ADRENALINE", id, "ON")
  3359. #else
  3360.     client_print(id, print_console, " * %L", id, "HELP_3_ADRENALINE", id, "OFF")
  3361. #endif
  3362.  
  3363.     client_print(id, print_console, " * %L", id, "HELP_3_FLAGHEAL", id, get_pcvar_num(pCvar_ctf_flagheal) ? "ON" : "OFF")
  3364.     client_print(id, print_console, " * %L", id, "HELP_3_RESPAWN", get_pcvar_num(pCvar_ctf_respawntime))
  3365.     client_print(id, print_console, " * %L", id, "HELP_3_PROTECTION", get_pcvar_num(pCvar_ctf_protection))
  3366.     client_print(id, print_console, " * %L", id, "HELP_3_FLAGRETURN", get_pcvar_num(pCvar_ctf_flagreturn))
  3367.     client_print(id, print_console, " * %L", id, "HELP_3_WEAPONSTAY", get_pcvar_num(pCvar_ctf_weaponstay))
  3368.     client_print(id, print_console, " * %L", id, "HELP_3_ITEMDROP", get_pcvar_num(pCvar_ctf_itempercent))
  3369.  
  3370.     client_print(id, print_console, "^n    --- 4: %L ---", id, "HELP_4")
  3371.     client_print(id, print_console, "   %L: http://forums.alliedmods.net/showthread.php?t=132115", id, "HELP_4_LINE1")
  3372.     client_print(id, print_console, "   %L: http://thehunters.ro/jctf", id, "HELP_4_LINE2")
  3373.     client_print(id, print_console, SEPARATOR)
  3374.  
  3375.     return PLUGIN_HANDLED
  3376. }
  3377.  
  3378. public player_cmd_setLights(id, const szMsg[])
  3379. {
  3380.     switch(szMsg[1])
  3381.     {
  3382.         case 'n':
  3383.         {
  3384.             g_bLights[id] = true
  3385.             player_print(id, id, "%L", id, "LIGHTS_ON", "^x04", "^x01")
  3386.         }
  3387.  
  3388.         case 'f':
  3389.         {
  3390.             g_bLights[id] = false
  3391.             player_print(id, id, "%L", id, "LIGHTS_OFF", "^x04", "^x01")
  3392.         }
  3393.  
  3394.         default: player_print(id, id, "%L", id, "LIGHTS_INVALID", "^x04", "^x01", "^x04")
  3395.     }
  3396.  
  3397.     return PLUGIN_HANDLED
  3398. }
  3399.  
  3400. public player_cmd_setSounds(id, const szMsg[])
  3401. {
  3402.     if(equali(szMsg, "test"))
  3403.     {
  3404.         player_print(id, id, "%L", id, "SOUNDS_TEST", "^x04Bandeira vermelha roubada^x01")
  3405.         client_cmd(id, "mp3 play ^"sound/csrevo/ctf/red_roubada.mp3^"")
  3406.  
  3407.         return PLUGIN_HANDLED
  3408.     }
  3409.  
  3410.     new iVol = (strlen(szMsg) ? str_to_num(szMsg) : -1)
  3411.  
  3412.     if(0 <= iVol <= 10)
  3413.     {
  3414.         client_cmd(id, "mp3volume %.2f", iVol == 0 ? 0.0 : iVol * 0.1)
  3415.         player_print(id, id, "%L", id, "SOUNDS_SET", "^x04", iVol)
  3416.     }
  3417.     else
  3418.         player_print(id, id, "%L", id, "SOUNDS_INVALID", "^x04 0^x01", "^x04 10^x01", "^x04 test")
  3419.  
  3420.     return PLUGIN_HANDLED
  3421. }
  3422.  
  3423.  
  3424.  
  3425.  
  3426.  
  3427.  
  3428.  
  3429.  
  3430.  
  3431.  
  3432.  
  3433. #if FEATURE_ADRENALINE == true
  3434.  
  3435. public player_cmd_adrenaline(id)
  3436. {
  3437.     player_hudAdrenaline(id)
  3438.  
  3439.     if(!(TEAM_RED <= g_iTeam[id] <= TEAM_BLUE) || !g_bAlive[id])
  3440.         return player_print(id, id, "%L", id, "ADR_ALIVE")
  3441.  
  3442.     if(g_iAdrenalineUse[id])
  3443.         return player_print(id, id, "%L", id, "ADR_USING")
  3444.  
  3445.     if(g_iAdrenaline[id] < 100)
  3446.         return player_print(id, id, "%L", id, "ADR_MORE", 100)
  3447.  
  3448.     new szFormat[256]
  3449.  
  3450.     formatex(szFormat, charsmax(szFormat), "\r%L:^n^n\w1. \y%L \d(%L)^n\w2. \y%L \d(%L)^n\w3. \y%L \d(%L)^n\w4. \y%L \d(%L)^n^n\d\w0. %L",
  3451.         id, "ADR_MENU_TITLE",
  3452.         id, "ADR_SPEED", id, "ADR_SPEED_DESC",
  3453.         id, "ADR_BERSERK", id, "ADR_BERSERK_DESC",
  3454.         id, "ADR_REGENERATE", id, "ADR_REGENERATE_DESC",
  3455.         id, "ADR_INVISIBILITY", id, "ADR_INVISIBILITY_DESC",
  3456.         id, "EXIT"
  3457.     )
  3458.  
  3459.     show_menu(id, MENU_KEYS_ADRENALINE, szFormat, -1, MENU_ADRENALINE)
  3460.  
  3461.     return PLUGIN_HANDLED
  3462. }
  3463.  
  3464. public player_key_adrenaline(id, iKey)
  3465. {
  3466.     if(!(TEAM_RED <= g_iTeam[id] <= TEAM_BLUE) || !g_bAlive[id])
  3467.         return player_print(id, id, "%L", id, "ADR_ALIVE")
  3468.  
  3469.     if(g_iAdrenalineUse[id])
  3470.         return player_print(id, id, "%L", id, "ADR_USING")
  3471.  
  3472.     if(g_iAdrenaline[id] < 100)
  3473.         return player_print(id, id, "%L", id, "ADR_USING", 100)
  3474.  
  3475.     iKey += 1
  3476.  
  3477.     if(1 <= iKey <= 4)
  3478.         player_useAdrenaline(id, iKey)
  3479.  
  3480.     return PLUGIN_HANDLED
  3481. }
  3482.  
  3483. public player_useAdrenaline(id, iUse)
  3484. {
  3485.     if(!(1 <= iUse <= 4))
  3486.         return PLUGIN_HANDLED
  3487.  
  3488.     if(!(TEAM_RED <= g_iTeam[id] <= TEAM_BLUE) || !g_bAlive[id])
  3489.         return player_print(id, id, "%L", id, "ADR_ALIVE")
  3490.  
  3491.     if(g_iAdrenalineUse[id])
  3492.         return player_print(id, id, "%L", id, "ADR_USING")
  3493.  
  3494.     if(g_iAdrenaline[id] < 100)
  3495.         return player_print(id, id, "%L", id, "ADR_USING", 100)
  3496.  
  3497.     if(g_bProtected[id])
  3498.         player_removeProtection(id, "PROTECTION_ADRENALINE")
  3499.  
  3500.     g_iAdrenalineUse[id] = iUse
  3501.  
  3502.     task_set(0.25, "player_adrenalineDrain", id - TASK_ADRENALINE)
  3503.  
  3504.     if(iUse == ADRENALINE_SPEED)
  3505.     {
  3506.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  3507.         write_byte(TE_BEAMFOLLOW)
  3508.         write_short(id)
  3509.         write_short(gSpr_trail)
  3510.         write_byte(8) // life in 0.1's
  3511.         write_byte(6) // line width in 0.1's
  3512.         write_byte(255)
  3513.         write_byte(255)
  3514.         write_byte(0)
  3515.         write_byte(255) // brightness
  3516.         message_end()
  3517.  
  3518.         player_updateSpeed(id)
  3519.     }
  3520.  
  3521.     player_updateRender(id)
  3522.  
  3523.     new iOrigin[3]
  3524.  
  3525.     get_user_origin(id, iOrigin)
  3526.  
  3527.     message_begin(MSG_PVS, SVC_TEMPENTITY, iOrigin)
  3528.     write_byte(TE_IMPLOSION)
  3529.     write_coord(iOrigin[x])
  3530.     write_coord(iOrigin[y])
  3531.     write_coord(iOrigin[z])
  3532.     write_byte(128) // radius
  3533.     write_byte(32) // count
  3534.     write_byte(4) // life in 0.1's
  3535.     message_end()
  3536.  
  3537.     emit_sound(id, CHAN_ITEM, SND_ADRENALINE, VOL_NORM, ATTN_NORM, 0, 255)
  3538.  
  3539.     return PLUGIN_HANDLED
  3540. }
  3541.  
  3542. public player_adrenalineDrain(id)
  3543. {
  3544.     id += TASK_ADRENALINE
  3545.  
  3546.     if(!g_bAlive[id] || !g_iAdrenalineUse[id] || !(TEAM_RED <= g_iTeam[id] <= TEAM_BLUE))
  3547.     {
  3548.         g_iAdrenaline[id] = 0
  3549.         return
  3550.     }
  3551.  
  3552.     if(g_iAdrenaline[id] > 0)
  3553.     {
  3554.         new iDrain = (player_hasFlag(id) ? 2 : 1)
  3555.  
  3556.         g_iAdrenaline[id] = clamp(g_iAdrenaline[id] - (g_iAdrenalineUse[id] == ADRENALINE_REGENERATE ? iDrain : iDrain * 2), 0, 100)
  3557.  
  3558.         switch(g_iAdrenalineUse[id])
  3559.         {
  3560.             case ADRENALINE_REGENERATE:
  3561.             {
  3562.                 new iHealth = get_user_health(id)
  3563.  
  3564.                 if(iHealth < (g_iMaxHealth[id] + REGENERATE_EXTRAHP))
  3565.                     set_user_health(id, iHealth + 1)
  3566.  
  3567.                 else
  3568.                 {
  3569.                     new CsArmorType:ArmorType
  3570.                     new iArmor = cs_get_user_armor(id, ArmorType)
  3571.  
  3572.                     if(iArmor < g_iMaxArmor[id])
  3573.                         cs_set_user_armor(id, iArmor + 1, ArmorType)
  3574.                 }
  3575.  
  3576.                 player_healingEffect(id)
  3577.             }
  3578.         }
  3579.  
  3580.         task_set(0.25, "player_adrenalineDrain", id - TASK_ADRENALINE)
  3581.     }
  3582.     else
  3583.     {
  3584.         new iUsed = g_iAdrenalineUse[id]
  3585.  
  3586.         g_iAdrenaline[id] = 0
  3587.         g_iAdrenalineUse[id] = 0 /* to allow player_updateSpeed() to work correctly */
  3588.  
  3589.         switch(iUsed)
  3590.         {
  3591.             case ADRENALINE_SPEED:
  3592.             {
  3593.                 player_updateSpeed(id)
  3594.  
  3595.                 message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  3596.                 write_byte(TE_KILLBEAM)
  3597.                 write_short(id)
  3598.                 message_end()
  3599.             }
  3600.  
  3601.             case ADRENALINE_BERSERK, ADRENALINE_INVISIBILITY: player_updateRender(id)
  3602.         }
  3603.     }
  3604.  
  3605.     player_hudAdrenaline(id)
  3606. }
  3607.  
  3608. #endif // FEATURE_ADRENALINE
  3609.  
  3610.  
  3611.  
  3612.  
  3613.  
  3614.  
  3615.  
  3616.  
  3617.  
  3618.  
  3619.  
  3620.  
  3621. public admin_cmd_moveFlag(id, level, cid)
  3622. {
  3623.     if(!cmd_access(id, level, cid, 2))
  3624.         return PLUGIN_HANDLED
  3625.  
  3626.     new szTeam[2]
  3627.  
  3628.     read_argv(1, szTeam, charsmax(szTeam))
  3629.  
  3630.     new iTeam = str_to_num(szTeam)
  3631.  
  3632.     if(!(TEAM_RED <= iTeam <= TEAM_BLUE))
  3633.     {
  3634.         switch(szTeam[0])
  3635.         {
  3636.             case 'r', 'R': iTeam = 1
  3637.             case 'b', 'B': iTeam = 2
  3638.         }
  3639.     }
  3640.  
  3641.     if(!(TEAM_RED <= iTeam <= TEAM_BLUE))
  3642.         return PLUGIN_HANDLED
  3643.  
  3644.     entity_get_vector(id, EV_VEC_origin, g_fFlagBase[iTeam])
  3645.  
  3646.     entity_set_origin(g_iBaseEntity[iTeam], g_fFlagBase[iTeam])
  3647.     entity_set_vector(g_iBaseEntity[iTeam], EV_VEC_velocity, FLAG_SPAWN_VELOCITY)
  3648.  
  3649.     if(g_iFlagHolder[iTeam] == FLAG_HOLD_BASE)
  3650.     {
  3651.         entity_set_origin(g_iFlagEntity[iTeam], g_fFlagBase[iTeam])
  3652.         entity_set_vector(g_iFlagEntity[iTeam], EV_VEC_velocity, FLAG_SPAWN_VELOCITY)
  3653.     }
  3654.  
  3655.     new szName[32]
  3656.     new szSteam[48]
  3657.  
  3658.     get_user_name(id, szName, charsmax(szName))
  3659.     get_user_authid(id, szSteam, charsmax(szSteam))
  3660.  
  3661.     log_amx("Admin %s<%s><%s> moved %s flag to %.2f %.2f %.2f", szName, szSteam, g_szTeamName[g_iTeam[id]], g_szTeamName[iTeam], g_fFlagBase[iTeam][0], g_fFlagBase[iTeam][1], g_fFlagBase[iTeam][2])
  3662.  
  3663.     show_activity_key("ADMIN_MOVEBASE_1", "ADMIN_MOVEBASE_2", szName, LANG_PLAYER, g_szMLFlagTeam[iTeam])
  3664.  
  3665.     client_print(id, print_console, "%s%L", CONSOLE_PREFIX, id, "ADMIN_MOVEBASE_MOVED", id, g_szMLFlagTeam[iTeam])
  3666.  
  3667.     return PLUGIN_HANDLED
  3668. }
  3669.  
  3670. public admin_cmd_saveFlags(id, level, cid)
  3671. {
  3672.     if(!cmd_access(id, level, cid, 1))
  3673.         return PLUGIN_HANDLED
  3674.  
  3675.     new iOrigin[3][3]
  3676.     new szFile[96]
  3677.     new szBuffer[1024]
  3678.  
  3679.     FVecIVec(g_fFlagBase[TEAM_RED], iOrigin[TEAM_RED])
  3680.     FVecIVec(g_fFlagBase[TEAM_BLUE], iOrigin[TEAM_BLUE])
  3681.  
  3682.     formatex(szBuffer, charsmax(szBuffer), "%d %d %d^n%d %d %d", iOrigin[TEAM_RED][x], iOrigin[TEAM_RED][y], iOrigin[TEAM_RED][z], iOrigin[TEAM_BLUE][x], iOrigin[TEAM_BLUE][y], iOrigin[TEAM_BLUE][z])
  3683.     formatex(szFile, charsmax(szFile), FLAG_SAVELOCATION, g_szMap)
  3684.  
  3685.     if(file_exists(szFile))
  3686.         delete_file(szFile)
  3687.  
  3688.     write_file(szFile, szBuffer)
  3689.  
  3690.     new szName[32]
  3691.     new szSteam[48]
  3692.  
  3693.     get_user_name(id, szName, charsmax(szName))
  3694.     get_user_authid(id, szSteam, charsmax(szSteam))
  3695.  
  3696.     log_amx("Admin %s<%s><%s> saved flag positions.", szName, szSteam, g_szTeamName[g_iTeam[id]])
  3697.  
  3698.     client_print(id, print_console, "%s%L %s", CONSOLE_PREFIX, id, "ADMIN_MOVEBASE_SAVED", szFile)
  3699.  
  3700.     return PLUGIN_HANDLED
  3701. }
  3702.  
  3703. public admin_cmd_returnFlag(id, level, cid)
  3704. {
  3705.     if(!cmd_access(id, level, cid, 2))
  3706.         return PLUGIN_HANDLED
  3707.  
  3708.     new szTeam[2]
  3709.  
  3710.     read_argv(1, szTeam, charsmax(szTeam))
  3711.  
  3712.     new iTeam = str_to_num(szTeam)
  3713.  
  3714.     if(!(TEAM_RED <= iTeam <= TEAM_BLUE))
  3715.     {
  3716.         switch(szTeam[0])
  3717.         {
  3718.             case 'r', 'R': iTeam = 1
  3719.             case 'b', 'B': iTeam = 2
  3720.         }
  3721.     }
  3722.  
  3723.     if(!(TEAM_RED <= iTeam <= TEAM_BLUE))
  3724.         return PLUGIN_HANDLED
  3725.  
  3726.     if(g_iFlagHolder[iTeam] == FLAG_HOLD_DROPPED)
  3727.     {
  3728.         if(g_fFlagDropped[iTeam] < (get_gametime() - ADMIN_RETURNWAIT))
  3729.         {
  3730.             new szName[32]
  3731.             new szSteam[48]
  3732.  
  3733.             new Float:fFlagOrigin[3]
  3734.  
  3735.             entity_get_vector(g_iFlagEntity[iTeam], EV_VEC_origin, fFlagOrigin)
  3736.  
  3737.             flag_sendHome(iTeam)
  3738.  
  3739.             ExecuteForward(g_iFW_flag, g_iForwardReturn, FLAG_ADMINRETURN, id, iTeam, false)
  3740.  
  3741.             game_announce(EVENT_RETURNED, iTeam, NULL)
  3742.  
  3743.             get_user_name(id, szName, charsmax(szName))
  3744.             get_user_authid(id, szSteam, charsmax(szSteam))
  3745.  
  3746.             log_message("^"%s^" flag returned by admin %s<%s><%s>", g_szTeamName[iTeam], szName, szSteam, g_szTeamName[g_iTeam[id]])
  3747.             log_amx("Admin %s<%s><%s> returned %s flag from %.2f %.2f %.2f", szName, szSteam, g_szTeamName[g_iTeam[id]], g_szTeamName[iTeam], fFlagOrigin[0], fFlagOrigin[1], fFlagOrigin[2])
  3748.  
  3749.             show_activity_key("ADMIN_RETURN_1", "ADMIN_RETURN_2", szName, LANG_PLAYER, g_szMLFlagTeam[iTeam])
  3750.  
  3751.             client_print(id, print_console, "%s%L", CONSOLE_PREFIX, id, "ADMIN_RETURN_DONE", id, g_szMLFlagTeam[iTeam])
  3752.         }
  3753.         else
  3754.             client_print(id, print_console, "%s%L", CONSOLE_PREFIX, id, "ADMIN_RETURN_WAIT", id, g_szMLFlagTeam[iTeam], ADMIN_RETURNWAIT)
  3755.     }
  3756.     else
  3757.         client_print(id, print_console, "%s%L", CONSOLE_PREFIX, id, "ADMIN_RETURN_NOTDROPPED", id, g_szMLFlagTeam[iTeam])
  3758.  
  3759.     return PLUGIN_HANDLED
  3760. }
  3761.  
  3762.  
  3763.  
  3764.  
  3765.  
  3766.  
  3767.  
  3768.  
  3769.  
  3770.  
  3771.  
  3772.  
  3773. #if FEATURE_BUY == true
  3774.  
  3775. public player_inBuyZone(id)
  3776. {
  3777.     if(!g_bAlive[id])
  3778.         return
  3779.  
  3780.     g_bBuyZone[id] = (read_data(1) ? true : false)
  3781.  
  3782.     if(!g_bBuyZone[id])
  3783.         set_pdata_int(id, 205, 0) // no "close menu upon exit buyzone" thing
  3784. }
  3785.  
  3786. public player_cmd_setAutobuy(id)
  3787. {
  3788.     new iIndex
  3789.     new szWeapon[24]
  3790.     new szArgs[1024]
  3791.  
  3792.     read_args(szArgs, charsmax(szArgs))
  3793.     remove_quotes(szArgs)
  3794.     trim(szArgs)
  3795.  
  3796.     while(contain(szArgs, WHITESPACE) != -1)
  3797.     {
  3798.         argbreak(szArgs, szWeapon, charsmax(szWeapon), szArgs, charsmax(szArgs))
  3799.  
  3800.         for(new bool:bFound, w = W_P228; w <= W_NVG; w++)
  3801.         {
  3802.             if(!bFound)
  3803.             {
  3804.                 for(new i = 0; i < 2; i++)
  3805.                 {
  3806.                     if(!bFound && equali(g_szWeaponCommands[w][i], szWeapon))
  3807.                     {
  3808.                         bFound = true
  3809.  
  3810.                         g_iAutobuy[id][iIndex++] = w
  3811.                     }
  3812.                 }
  3813.             }
  3814.         }
  3815.     }
  3816.  
  3817.     player_cmd_autobuy(id)
  3818.  
  3819.     return PLUGIN_HANDLED
  3820. }
  3821.  
  3822. public player_cmd_autobuy(id)
  3823. {
  3824.     if(!g_bAlive[id])
  3825.         return PLUGIN_HANDLED
  3826.  
  3827.     if(!g_bBuyZone[id])
  3828.     {
  3829.         client_print(id, print_center, "%L", id, "BUY_NOTINZONE")
  3830.         return PLUGIN_HANDLED
  3831.     }
  3832.  
  3833.     new iMoney = cs_get_user_money(id)
  3834.  
  3835.     for(new bool:bBought[6], iWeapon, i = 0; i < sizeof g_iAutobuy[]; i++)
  3836.     {
  3837.         if(!g_iAutobuy[id][i])
  3838.             return PLUGIN_HANDLED
  3839.  
  3840.         iWeapon = g_iAutobuy[id][i]
  3841.  
  3842.         if(bBought[g_iWeaponSlot[iWeapon]])
  3843.             continue
  3844.  
  3845. #if FEATURE_ADRENALINE == true
  3846.  
  3847.         if((g_iWeaponPrice[iWeapon] > 0 && g_iWeaponPrice[iWeapon] > iMoney) || (g_iWeaponAdrenaline[iWeapon] > 0 && g_iWeaponAdrenaline[iWeapon] > g_iAdrenaline[id]))
  3848.             continue
  3849.  
  3850. #else // FEATURE_ADRENALINE
  3851.  
  3852.         if(g_iWeaponPrice[iWeapon] > 0 && g_iWeaponPrice[iWeapon] > iMoney)
  3853.             continue
  3854.  
  3855. #endif // FEATURE_ADRENALINE
  3856.  
  3857.         player_buyWeapon(id, iWeapon)
  3858.         bBought[g_iWeaponSlot[iWeapon]] = true
  3859.     }
  3860.  
  3861.     return PLUGIN_HANDLED
  3862. }
  3863.  
  3864. public player_cmd_setRebuy(id)
  3865. {
  3866.     new iIndex
  3867.     new szType[18]
  3868.     new szArgs[256]
  3869.  
  3870.     read_args(szArgs, charsmax(szArgs))
  3871.     replace_all(szArgs, charsmax(szArgs), "^"", NULL)
  3872.     trim(szArgs)
  3873.  
  3874.     while(contain(szArgs, WHITESPACE) != -1)
  3875.     {
  3876.         split(szArgs, szType, charsmax(szType), szArgs, charsmax(szArgs), WHITESPACE)
  3877.  
  3878.         for(new i = 1; i < sizeof g_szRebuyCommands; i++)
  3879.         {
  3880.             if(equali(szType, g_szRebuyCommands[i]))
  3881.                 g_iRebuy[id][++iIndex] = i
  3882.         }
  3883.     }
  3884.  
  3885.     player_cmd_rebuy(id)
  3886.  
  3887.     return PLUGIN_HANDLED
  3888. }
  3889.  
  3890. public player_cmd_rebuy(id)
  3891. {
  3892.     if(!g_bAlive[id])
  3893.         return PLUGIN_HANDLED
  3894.  
  3895.     if(!g_bBuyZone[id])
  3896.     {
  3897.         client_print(id, print_center, "%L", id, "BUY_NOTINZONE")
  3898.         return PLUGIN_HANDLED
  3899.     }
  3900.  
  3901.     new iBought
  3902.  
  3903.     for(new iType, iBuy, i = 1; i < sizeof g_iRebuy[]; i++)
  3904.     {
  3905.         iType = g_iRebuy[id][i]
  3906.  
  3907.         if(!iType)
  3908.             continue
  3909.  
  3910.         iBuy = g_iRebuyWeapons[id][iType]
  3911.  
  3912.         if(!iBuy)
  3913.             continue
  3914.  
  3915.         switch(iType)
  3916.         {
  3917.             case primary, secondary: player_buyWeapon(id, iBuy)
  3918.  
  3919.             case armor: player_buyWeapon(id, (iBuy == 2 ? W_VESTHELM : W_VEST))
  3920.  
  3921.             case he: player_buyWeapon(id, W_HEGRENADE)
  3922.  
  3923.             case flash:
  3924.             {
  3925.                 player_buyWeapon(id, W_FLASHBANG)
  3926.  
  3927.                 if(iBuy == 2)
  3928.                     player_buyWeapon(id, W_FLASHBANG)
  3929.             }
  3930.  
  3931.             case smoke: player_buyWeapon(id, W_SMOKEGRENADE)
  3932.  
  3933.             case nvg: player_buyWeapon(id, W_NVG)
  3934.         }
  3935.  
  3936.         iBought++
  3937.  
  3938.         if(iType == flash && iBuy == 2)
  3939.             iBought++
  3940.     }
  3941.  
  3942.     if(iBought)
  3943.         client_print(id, print_center, "%L", id, "BUY_REBOUGHT", iBought)
  3944.  
  3945.     return PLUGIN_HANDLED
  3946. }
  3947.  
  3948. public player_addRebuy(id, iWeapon)
  3949. {
  3950.     if(!g_bAlive[id])
  3951.         return
  3952.  
  3953.     switch(g_iWeaponSlot[iWeapon])
  3954.     {
  3955.         case 1: g_iRebuyWeapons[id][primary] = iWeapon
  3956.         case 2: g_iRebuyWeapons[id][secondary] = iWeapon
  3957.  
  3958.         default:
  3959.         {
  3960.             switch(iWeapon)
  3961.             {
  3962.                 case W_VEST: g_iRebuyWeapons[id][armor] = (g_iRebuyWeapons[id][armor] == 2 ? 2 : 1)
  3963.                 case W_VESTHELM: g_iRebuyWeapons[id][armor] = 2
  3964.                 case W_FLASHBANG: g_iRebuyWeapons[id][flash] = clamp(g_iRebuyWeapons[id][flash] + 1, 0, 2)
  3965.                 case W_HEGRENADE: g_iRebuyWeapons[id][he] = 1
  3966.                 case W_SMOKEGRENADE: g_iRebuyWeapons[id][smoke] = 1
  3967.                 case W_NVG: g_iRebuyWeapons[id][nvg] = 1
  3968.             }
  3969.         }
  3970.     }
  3971. }
  3972.  
  3973. public player_cmd_buy_main(id)
  3974.     return player_menu_buy(id, 0)
  3975.  
  3976. public player_cmd_buy_equipament(id)
  3977.     return player_menu_buy(id, 8)
  3978.  
  3979. public player_cmd_buyVGUI(id)
  3980. {
  3981.     message_begin(MSG_ONE, gMsg_BuyClose, _, id)
  3982.     message_end()
  3983.  
  3984.     return player_menu_buy(id, 0)
  3985. }
  3986.  
  3987. public player_menu_buy(id, iMenu)
  3988. {
  3989.     if(!g_bAlive[id])
  3990.         return PLUGIN_HANDLED
  3991.  
  3992.     if(!g_bBuyZone[id])
  3993.     {
  3994.         client_print(id, print_center, "%L", id, "BUY_NOTINZONE")
  3995.         return PLUGIN_HANDLED
  3996.     }
  3997.  
  3998.     static szMenu[1024]
  3999.  
  4000.     new iMoney = cs_get_user_money(id)
  4001.  
  4002.     switch(iMenu)
  4003.     {
  4004.         case 1:
  4005.         {
  4006.             formatex(szMenu, charsmax(szMenu),
  4007.                 "\y%L: %L^n^n\d1. \%sGlock 18\R$%d^n\d2. \%sUSP\R$%d^n\d3. \%sP228\R$%d^n\d4. \%sDesert Eagle\R$%d^n\d5. \%sFiveseven\R$%d^n\d6. \%sDual Elites\R$%d^n^n\d0. \w%L",
  4008.                 id, "BUYMENU_TITLE", id, "BUYMENU_PISTOLS",
  4009.                 (iMoney >= g_iWeaponPrice[W_GLOCK18] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_GLOCK18],
  4010.                 (iMoney >= g_iWeaponPrice[W_USP] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_USP],
  4011.                 (iMoney >= g_iWeaponPrice[W_P228] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_P228],
  4012.                 (iMoney >= g_iWeaponPrice[W_DEAGLE] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_DEAGLE],
  4013.                 (iMoney >= g_iWeaponPrice[W_FIVESEVEN] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_FIVESEVEN],
  4014.                 (iMoney >= g_iWeaponPrice[W_ELITE] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_ELITE],
  4015.                 id, "EXIT"
  4016.             )
  4017.         }
  4018.  
  4019.         case 2:
  4020.         {
  4021.             formatex(szMenu, charsmax(szMenu),
  4022.                 "\y%L: %L^n^n\d1. \%sM3 Super90\R$%d^n\d2. \%sXM1014\R$%d^n^n\d0. \w%L",
  4023.                 id, "BUYMENU_TITLE", id, "BUYMENU_SHOTGUNS",
  4024.                 (iMoney >= g_iWeaponPrice[W_M3] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_M3],
  4025.                 (iMoney >= g_iWeaponPrice[W_XM1014] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_XM1014],
  4026.                 id, "EXIT"
  4027.             )
  4028.         }
  4029.  
  4030.         case 3:
  4031.         {
  4032.             formatex(szMenu, charsmax(szMenu),
  4033.                 "\y%L: %L^n^n\d1. \%sTMP\R$%d^n\d2. \%sMac-10\R$%d^n\d3. \%sMP5 Navy\R$%d^n\d4. \%sUMP-45\R$%d^n\d5. \%sP90\R$%d^n^n\d0. \w%L",
  4034.                 id, "BUYMENU_TITLE", id, "BUYMENU_SMGS",
  4035.                 (iMoney >= g_iWeaponPrice[W_TMP] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_TMP],
  4036.                 (iMoney >= g_iWeaponPrice[W_MAC10] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_MAC10],
  4037.                 (iMoney >= g_iWeaponPrice[W_MP5NAVY] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_MP5NAVY],
  4038.                 (iMoney >= g_iWeaponPrice[W_UMP45] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_UMP45],
  4039.                 (iMoney >= g_iWeaponPrice[W_P90] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_P90],
  4040.                 id, "EXIT"
  4041.             )
  4042.         }
  4043.  
  4044.         case 4:
  4045.         {
  4046.             formatex(szMenu, charsmax(szMenu),
  4047.                 "\y%L: %L^n^n\d1. \%sGalil\R$%d^n\d2. \%sFamas\R$%d^n\d3. \%sAK-47\R$%d^n\d4. \%sM4A1\R$%d^n\d5. \%sAUG\R$%d^n\d6. \%sSG552\R$%d^n^n\d0. \w%L",
  4048.                 id, "BUYMENU_TITLE", id, "BUYMENU_RIFLES",
  4049.                 (iMoney >= g_iWeaponPrice[W_GALIL] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_GALIL],
  4050.                 (iMoney >= g_iWeaponPrice[W_FAMAS] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_FAMAS],
  4051.                 (iMoney >= g_iWeaponPrice[W_AK47] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_AK47],
  4052.                 (iMoney >= g_iWeaponPrice[W_M4A1] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_M4A1],
  4053.                 (iMoney >= g_iWeaponPrice[W_AUG] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_AUG],
  4054.                 (iMoney >= g_iWeaponPrice[W_SG552] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_SG552],
  4055.                 id, "EXIT"
  4056.             )
  4057.         }
  4058.  
  4059.         case 5:
  4060.         {
  4061.  
  4062. #if FEATURE_ADRENALINE == true
  4063.  
  4064. #if FEATURE_C4 == true
  4065.  
  4066.             formatex(szMenu, charsmax(szMenu),
  4067.                 "\y%L: %L^n^n\d1. \%sM249 \w(\%s%d %L\w)\R\%s$%d^n\d3. \%sSG550 \w(\%s%d %L\w)\R\%s$%d^n\d3. \%sG3SG1 \w(\%s%d %L\w)\R\%s$%d^n\d4. \%sScout \w(\%s%d %L\w)\R\%s$%d^n\d5. \%sAWP \w(\%s%d %L\w)\R\%s$%d^n\d6. \%s%L \w(\%s%d %L\w)\R\%s$%d^n\d7. \%s%L \w(\%s%d %L\w)\R\%s$%d^n^n\d0. \w%L",
  4068.                 id, "BUYMENU_TITLE", id, "BUYMENU_SPECIAL",
  4069.                 (iMoney >= g_iWeaponPrice[W_M249] && g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_M249] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), (g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_M249] ? BUY_ITEM_AVAILABLE2 : BUY_ITEM_DISABLED), g_iWeaponAdrenaline[W_M249], id, "ADRENALINE", (iMoney >= g_iWeaponPrice[W_M249] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_M249],
  4070.                 (iMoney >= g_iWeaponPrice[W_SG550] && g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_SG550] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), (g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_SG550] ? BUY_ITEM_AVAILABLE2 : BUY_ITEM_DISABLED), g_iWeaponAdrenaline[W_SG550], id, "ADRENALINE", (iMoney >= g_iWeaponPrice[W_SG550] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_SG550],
  4071.                 (iMoney >= g_iWeaponPrice[W_G3SG1] && g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_G3SG1] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), (g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_G3SG1] ? BUY_ITEM_AVAILABLE2 : BUY_ITEM_DISABLED), g_iWeaponAdrenaline[W_G3SG1], id, "ADRENALINE", (iMoney >= g_iWeaponPrice[W_G3SG1] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_G3SG1],
  4072.                 (iMoney >= g_iWeaponPrice[W_SCOUT] && g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_SCOUT] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), (g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_SCOUT] ? BUY_ITEM_AVAILABLE2 : BUY_ITEM_DISABLED), g_iWeaponAdrenaline[W_SCOUT], id, "ADRENALINE", (iMoney >= g_iWeaponPrice[W_SCOUT] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_SCOUT],
  4073.                 (iMoney >= g_iWeaponPrice[W_AWP] && g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_AWP] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), (g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_AWP] ? BUY_ITEM_AVAILABLE2 : BUY_ITEM_DISABLED), g_iWeaponAdrenaline[W_AWP], id, "ADRENALINE", (iMoney >= g_iWeaponPrice[W_AWP] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_AWP],
  4074.                 (iMoney >= g_iWeaponPrice[W_SHIELD] && g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_SHIELD] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), id, "BUYMENU_ITEM_SHIELD", (g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_SHIELD] ? BUY_ITEM_AVAILABLE2 : BUY_ITEM_DISABLED), g_iWeaponAdrenaline[W_SHIELD], id, "ADRENALINE", (iMoney >= g_iWeaponPrice[W_SHIELD] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_SHIELD],
  4075.                 (iMoney >= g_iWeaponPrice[W_C4] && g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_C4] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), id, "BUYMENU_ITEM_C4", (g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_C4] ? BUY_ITEM_AVAILABLE2 : BUY_ITEM_DISABLED), g_iWeaponAdrenaline[W_C4], id, "ADRENALINE", (iMoney >= g_iWeaponPrice[W_C4] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_C4],
  4076.                 id, "EXIT"
  4077.             )
  4078.  
  4079. #else // FEATURE_C4
  4080.  
  4081.             formatex(szMenu, charsmax(szMenu),
  4082.                 "\y%L: %L^n^n\d1. \%sM249 \w(\%s%d %L\w)\R\%s$%d^n\d3. \%sSG550 \w(\%s%d %L\w)\R\%s$%d^n\d3. \%sG3SG1 \w(\%s%d %L\w)\R\%s$%d^n\d4. \%sScout \w(\%s%d %L\w)\R\%s$%d^n\d5. \%sAWP \w(\%s%d %L\w)\R\%s$%d^n\d6. \%s%L \w(\%s%d %L\w)\R\%s$%d^n^n\d0. \w%L",
  4083.                 id, "BUYMENU_TITLE", id, "BUYMENU_SPECIAL",
  4084.                 (iMoney >= g_iWeaponPrice[W_M249] && g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_M249] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), (g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_M249] ? BUY_ITEM_AVAILABLE2 : BUY_ITEM_DISABLED), g_iWeaponAdrenaline[W_M249], id, "ADRENALINE", (iMoney >= g_iWeaponPrice[W_M249] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_M249],
  4085.                 (iMoney >= g_iWeaponPrice[W_SG550] && g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_SG550] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), (g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_SG550] ? BUY_ITEM_AVAILABLE2 : BUY_ITEM_DISABLED), g_iWeaponAdrenaline[W_SG550], id, "ADRENALINE", (iMoney >= g_iWeaponPrice[W_SG550] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_SG550],
  4086.                 (iMoney >= g_iWeaponPrice[W_G3SG1] && g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_G3SG1] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), (g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_G3SG1] ? BUY_ITEM_AVAILABLE2 : BUY_ITEM_DISABLED), g_iWeaponAdrenaline[W_G3SG1], id, "ADRENALINE", (iMoney >= g_iWeaponPrice[W_G3SG1] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_G3SG1],
  4087.                 (iMoney >= g_iWeaponPrice[W_SCOUT] && g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_SCOUT] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), (g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_SCOUT] ? BUY_ITEM_AVAILABLE2 : BUY_ITEM_DISABLED), g_iWeaponAdrenaline[W_SCOUT], id, "ADRENALINE", (iMoney >= g_iWeaponPrice[W_SCOUT] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_SCOUT],
  4088.                 (iMoney >= g_iWeaponPrice[W_AWP] && g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_AWP] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), (g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_AWP] ? BUY_ITEM_AVAILABLE2 : BUY_ITEM_DISABLED), g_iWeaponAdrenaline[W_AWP], id, "ADRENALINE", (iMoney >= g_iWeaponPrice[W_AWP] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_AWP],
  4089.                 (iMoney >= g_iWeaponPrice[W_SHIELD] && g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_SHIELD] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), id, "BUYMENU_ITEM_SHIELD", (g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_SHIELD] ? BUY_ITEM_AVAILABLE2 : BUY_ITEM_DISABLED), g_iWeaponAdrenaline[W_SHIELD], id, "ADRENALINE", (iMoney >= g_iWeaponPrice[W_SHIELD] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_SHIELD],
  4090.                 id, "EXIT"
  4091.             )
  4092.  
  4093. #endif // FEATURE_C4
  4094.  
  4095. #else // FEATURE_ADRENALINE
  4096.  
  4097. #if FEATURE_C4 == true
  4098.  
  4099.             formatex(szMenu, charsmax(szMenu),
  4100.                 "\y%L: %L^n^n\d1. \%sM249\R\%s$%d^n\d3. \%sSG550\R\%s$%d^n\d3. \%sG3SG1\R\%s$%d^n\d4. \%sScout\R\%s$%d^n\d5. \%sAWP\R\%s$%d^n\d6. \%s%L\R\%s$%d^n\d7. \%s%L\R\%s$%d^n^n\d0. \w%L",
  4101.                 id, "BUYMENU_TITLE", id, "BUYMENU_SPECIAL",
  4102.                 (iMoney >= g_iWeaponPrice[W_M249] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED),(iMoney >= g_iWeaponPrice[W_M249] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_M249],
  4103.                 (iMoney >= g_iWeaponPrice[W_SG550] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), (iMoney >= g_iWeaponPrice[W_SG550] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_SG550],
  4104.                 (iMoney >= g_iWeaponPrice[W_G3SG1] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), (iMoney >= g_iWeaponPrice[W_G3SG1] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_G3SG1],
  4105.                 (iMoney >= g_iWeaponPrice[W_SCOUT] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), (iMoney >= g_iWeaponPrice[W_SCOUT] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_SCOUT],
  4106.                 (iMoney >= g_iWeaponPrice[W_AWP] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), (iMoney >= g_iWeaponPrice[W_AWP] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_AWP],
  4107.                 (iMoney >= g_iWeaponPrice[W_SHIELD] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), id, "BUYMENU_ITEM_SHIELD", (iMoney >= g_iWeaponPrice[W_SHIELD] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_SHIELD],
  4108.                 (iMoney >= g_iWeaponPrice[W_C4] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), id, "BUYMENU_ITEM_C4", (iMoney >= g_iWeaponPrice[W_C4] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_C4],
  4109.                 id, "EXIT"
  4110.             )
  4111.  
  4112. #else // FEATURE_C4
  4113.  
  4114.             formatex(szMenu, charsmax(szMenu),
  4115.                 "\y%L: %L^n^n\d1. \%sM249\R\%s$%d^n\d3. \%sSG550\R\%s$%d^n\d3. \%sG3SG1\R\%s$%d^n\d4. \%sScout\R\%s$%d^n\d5. \%sAWP\R\%s$%d^n\d6. \%s%L\R\%s$%d^n^n\d0. \w%L",
  4116.                 id, "BUYMENU_TITLE", id, "BUYMENU_SPECIAL",
  4117.                 (iMoney >= g_iWeaponPrice[W_M249] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED),(iMoney >= g_iWeaponPrice[W_M249] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_M249],
  4118.                 (iMoney >= g_iWeaponPrice[W_SG550] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), (iMoney >= g_iWeaponPrice[W_SG550] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_SG550],
  4119.                 (iMoney >= g_iWeaponPrice[W_G3SG1] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), (iMoney >= g_iWeaponPrice[W_G3SG1] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_G3SG1],
  4120.                 (iMoney >= g_iWeaponPrice[W_SCOUT] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), (iMoney >= g_iWeaponPrice[W_SCOUT] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_SCOUT],
  4121.                 (iMoney >= g_iWeaponPrice[W_AWP] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), (iMoney >= g_iWeaponPrice[W_AWP] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_AWP],
  4122.                 (iMoney >= g_iWeaponPrice[W_SHIELD] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), id, "BUYMENU_ITEM_SHIELD", (iMoney >= g_iWeaponPrice[W_SHIELD] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), g_iWeaponPrice[W_SHIELD],
  4123.                 id, "EXIT"
  4124.             )
  4125.  
  4126. #endif // FEATURE_C4
  4127.  
  4128.  
  4129. #endif // FEATURE_ADRENALINE
  4130.  
  4131.         }
  4132.  
  4133.         case 8:
  4134.         {
  4135.             formatex(szMenu, charsmax(szMenu),
  4136.                 "\y%L: %L^n^n\d1. \%s%L\R$%d^n\d2. \%s%L\R$%d^n^n\d3. \%s%L\R$%d^n\d4. \%s%L\R$%d^n\d5. \%s%L\R$%d^n^n\d7. \%s%L\R$%d^n^n\d0. \w%L",
  4137.                 id, "BUYMENU_TITLE", id, "BUYMENU_EQUIPAMENT",
  4138.                 (iMoney >= g_iWeaponPrice[W_VEST] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), id, "BUYMENU_ITEM_VEST", g_iWeaponPrice[W_VEST],
  4139.                 (iMoney >= g_iWeaponPrice[W_VESTHELM] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), id, "BUYMENU_ITEM_VESTHELM", g_iWeaponPrice[W_VESTHELM],
  4140.                 (iMoney >= g_iWeaponPrice[W_FLASHBANG] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), id, "BUYMENU_ITEM_FLASHBANG", g_iWeaponPrice[W_FLASHBANG],
  4141.                 (iMoney >= g_iWeaponPrice[W_HEGRENADE] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), id, "BUYMENU_ITEM_HE", g_iWeaponPrice[W_HEGRENADE],
  4142.                 (iMoney >= g_iWeaponPrice[W_SMOKEGRENADE] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), id, "BUYMENU_ITEM_SMOKE", g_iWeaponPrice[W_SMOKEGRENADE],
  4143.                 (iMoney >= g_iWeaponPrice[W_NVG] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), id, "BUYMENU_ITEM_NVG", g_iWeaponPrice[W_NVG],
  4144.                 id, "EXIT"
  4145.             )
  4146.         }
  4147.  
  4148.         default:
  4149.         {
  4150.  
  4151. #if FEATURE_ADRENALINE == true
  4152.  
  4153.             formatex(szMenu, charsmax(szMenu),
  4154.                 "\y%L^n^n\d1. \%s%L^n\d2. \%s%L^n\d3. \%s%L^n\d4. \%s%L^n\d5. \%s%L^n^n\d6. \w%L\R$0^n^n\d8. \%s%L^n^n\d0. \w%L",
  4155.                 id, "BUYMENU_TITLE",
  4156.                 (iMoney >= g_iWeaponPrice[W_GLOCK18] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), id, "BUYMENU_PISTOLS",
  4157.                 (iMoney >= g_iWeaponPrice[W_M3] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), id, "BUYMENU_SHOTGUNS",
  4158.                 (iMoney >= g_iWeaponPrice[W_TMP] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), id, "BUYMENU_SMGS",
  4159.                 (iMoney >= g_iWeaponPrice[W_GALIL] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), id, "BUYMENU_RIFLES",
  4160.                 (iMoney >= g_iWeaponPrice[W_M249] && g_iAdrenaline[id] >= g_iWeaponAdrenaline[W_M249] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), id, "BUYMENU_SPECIAL",
  4161.                 id, "BUYMENU_AMMO",
  4162.                 (iMoney >= g_iWeaponPrice[W_FLASHBANG] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), id, "BUYMENU_EQUIPAMENT",
  4163.                 id, "EXIT"
  4164.             )
  4165.  
  4166. #else // FEATURE_ADRENALINE
  4167.  
  4168.             formatex(szMenu, charsmax(szMenu),
  4169.                 "\y%L^n^n\d1. \%s%L^n\d2. \%s%L^n\d3. \%s%L^n\d4. \%s%L^n\d5. \%s%L^n^n\d6. \w%L\R$0^n^n\d8. \%s%L^n^n\d0. \w%L",
  4170.                 id, "BUYMENU_TITLE",
  4171.                 (iMoney >= g_iWeaponPrice[W_GLOCK18] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), id, "BUYMENU_PISTOLS",
  4172.                 (iMoney >= g_iWeaponPrice[W_M3] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), id, "BUYMENU_SHOTGUNS",
  4173.                 (iMoney >= g_iWeaponPrice[W_TMP] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), id, "BUYMENU_SMGS",
  4174.                 (iMoney >= g_iWeaponPrice[W_GALIL] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), id, "BUYMENU_RIFLES",
  4175.                 (iMoney >= g_iWeaponPrice[W_M249] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), id, "BUYMENU_SPECIAL",
  4176.                 id, "BUYMENU_AMMO",
  4177.                 (iMoney >= g_iWeaponPrice[W_FLASHBANG] ? BUY_ITEM_AVAILABLE : BUY_ITEM_DISABLED), id, "BUYMENU_EQUIPAMENT",
  4178.                 id, "EXIT"
  4179.             )
  4180.  
  4181. #endif // FEATURE_ADRENALINE
  4182.  
  4183.         }
  4184.     }
  4185.  
  4186.     g_iMenu[id] = iMenu
  4187.  
  4188.     show_menu(id, MENU_KEYS_BUY, szMenu, -1, MENU_BUY)
  4189.  
  4190.     return PLUGIN_HANDLED
  4191. }
  4192.  
  4193. public player_key_buy(id, iKey)
  4194. {
  4195.     iKey += 1
  4196.  
  4197.     if(!g_bAlive[id] || iKey == 10)
  4198.         return PLUGIN_HANDLED
  4199.  
  4200.     if(!g_bBuyZone[id])
  4201.     {
  4202.         client_print(id, print_center, "%L", id, "BUY_NOTINZONE")
  4203.         return PLUGIN_HANDLED
  4204.     }
  4205.  
  4206.     switch(g_iMenu[id])
  4207.     {
  4208.         case 1:
  4209.         {
  4210.             switch(iKey)
  4211.             {
  4212.                 case 1: player_buyWeapon(id, W_GLOCK18)
  4213.                 case 2: player_buyWeapon(id, W_USP)
  4214.                 case 3: player_buyWeapon(id, W_P228)
  4215.                 case 4: player_buyWeapon(id, W_DEAGLE)
  4216.                 case 5: player_buyWeapon(id, W_FIVESEVEN)
  4217.                 case 6: player_buyWeapon(id, W_ELITE)
  4218.             }
  4219.         }
  4220.  
  4221.         case 2:
  4222.         {
  4223.             switch(iKey)
  4224.             {
  4225.                 case 1: player_buyWeapon(id, W_M3)
  4226.                 case 2: player_buyWeapon(id, W_XM1014)
  4227.             }
  4228.         }
  4229.  
  4230.         case 3:
  4231.         {
  4232.             switch(iKey)
  4233.             {
  4234.                 case 1: player_buyWeapon(id, W_TMP)
  4235.                 case 2: player_buyWeapon(id, W_MAC10)
  4236.                 case 3: player_buyWeapon(id, W_MP5NAVY)
  4237.                 case 4: player_buyWeapon(id, W_UMP45)
  4238.                 case 5: player_buyWeapon(id, W_P90)
  4239.             }
  4240.         }
  4241.  
  4242.         case 4:
  4243.         {
  4244.             switch(iKey)
  4245.             {
  4246.                 case 1: player_buyWeapon(id, W_GALIL)
  4247.                 case 2: player_buyWeapon(id, W_FAMAS)
  4248.                 case 3: player_buyWeapon(id, W_AK47)
  4249.                 case 4: player_buyWeapon(id, W_M4A1)
  4250.                 case 5: player_buyWeapon(id, W_AUG)
  4251.                 case 6: player_buyWeapon(id, W_SG552)
  4252.             }
  4253.         }
  4254.  
  4255.         case 5:
  4256.         {
  4257.             switch(iKey)
  4258.             {
  4259.                 case 1: player_buyWeapon(id, W_M249)
  4260.                 case 2: player_buyWeapon(id, W_SG550)
  4261.                 case 3: player_buyWeapon(id, W_G3SG1)
  4262.                 case 4: player_buyWeapon(id, W_SCOUT)
  4263.                 case 5: player_buyWeapon(id, W_AWP)
  4264.                 case 6: player_buyWeapon(id, W_SHIELD)
  4265.                 case 7: player_buyWeapon(id, W_C4)
  4266.             }
  4267.         }
  4268.  
  4269.         case 8:
  4270.         {
  4271.             switch(iKey)
  4272.             {
  4273.                 case 1: player_buyWeapon(id, W_VEST)
  4274.                 case 2: player_buyWeapon(id, W_VESTHELM)
  4275.                 case 3: player_buyWeapon(id, W_FLASHBANG)
  4276.                 case 4: player_buyWeapon(id, W_HEGRENADE)
  4277.                 case 5: player_buyWeapon(id, W_SMOKEGRENADE)
  4278.                 case 7: player_buyWeapon(id, W_NVG)
  4279.             }
  4280.         }
  4281.  
  4282.         default:
  4283.         {
  4284.             switch(iKey)
  4285.             {
  4286.                 case 1,2,3,4,5,8: player_menu_buy(id, iKey)
  4287.                 case 6,7: player_fillAmmo(id)
  4288.             }
  4289.         }
  4290.     }
  4291.  
  4292.     return PLUGIN_HANDLED
  4293. }
  4294.  
  4295. public player_cmd_buyWeapon(id)
  4296. {
  4297.     if(!g_bBuyZone[id])
  4298.     {
  4299.         client_print(id, print_center, "%L", id, "BUY_NOTINZONE")
  4300.         return PLUGIN_HANDLED
  4301.     }
  4302.  
  4303.     new szCmd[12]
  4304.  
  4305.     read_argv(0, szCmd, charsmax(szCmd))
  4306.  
  4307.     for(new w = W_P228; w <= W_NVG; w++)
  4308.     {
  4309.         for(new i = 0; i < 2; i++)
  4310.         {
  4311.             if(equali(g_szWeaponCommands[w][i], szCmd))
  4312.             {
  4313.                 player_buyWeapon(id, w)
  4314.                 return PLUGIN_HANDLED
  4315.             }
  4316.         }
  4317.     }
  4318.  
  4319.     return PLUGIN_HANDLED
  4320. }
  4321.  
  4322. public player_buyWeapon(id, iWeapon)
  4323. {
  4324.     if(!g_bAlive[id])
  4325.         return
  4326.  
  4327.     new CsArmorType:ArmorType
  4328.     new iArmor = cs_get_user_armor(id, ArmorType)
  4329.  
  4330.     new iMoney = cs_get_user_money(id)
  4331.  
  4332.     /* apply discount if you already have a kevlar and buying a kevlar+helmet */
  4333.     new iCost = g_iWeaponPrice[iWeapon] - (ArmorType == CS_ARMOR_KEVLAR && iWeapon == W_VESTHELM ? 650 : 0)
  4334.  
  4335. #if FEATURE_ADRENALINE == true
  4336.  
  4337.     new iCostAdrenaline = g_iWeaponAdrenaline[iWeapon]
  4338.  
  4339. #endif // FEATURE_ADRENALINE
  4340.  
  4341.     if(iCost > iMoney)
  4342.     {
  4343.         client_print(id, print_center, "%L", id, "BUY_NEEDMONEY", iCost)
  4344.         return
  4345.     }
  4346.  
  4347. #if FEATURE_ADRENALINE == true
  4348.  
  4349.     else if(!(iCostAdrenaline <= g_iAdrenaline[id]))
  4350.     {
  4351.         client_print(id, print_center, "%L", id, "BUY_NEEDADRENALINE", iCostAdrenaline)
  4352.         return
  4353.     }
  4354.  
  4355. #endif // FEATURE_ADRENALINE
  4356.  
  4357.     switch(iWeapon)
  4358.     {
  4359.  
  4360. #if FEATURE_C4 == true
  4361.  
  4362.         case W_C4:
  4363.         {
  4364.             if(user_has_weapon(id, W_C4))
  4365.             {
  4366.                 client_print(id, print_center, "%L", id, "BUY_HAVE_C4")
  4367.                 return
  4368.             }
  4369.  
  4370.             player_giveC4(id)
  4371.         }
  4372.  
  4373. #endif // FEATURE_C4
  4374.  
  4375.         case W_NVG:
  4376.         {
  4377.             if(cs_get_user_nvg(id))
  4378.             {
  4379.                 client_print(id, print_center, "%L", id, "BUY_HAVE_NVG")
  4380.                 return
  4381.             }
  4382.  
  4383.             cs_set_user_nvg(id, 1)
  4384.         }
  4385.  
  4386.         case W_VEST:
  4387.         {
  4388.             if(iArmor >= 100)
  4389.             {
  4390.                 client_print(id, print_center, "%L", id, "BUY_HAVE_KEVLAR")
  4391.                 return
  4392.             }
  4393.         }
  4394.  
  4395.         case W_VESTHELM:
  4396.         {
  4397.             if(iArmor >= 100 && ArmorType == CS_ARMOR_VESTHELM)
  4398.             {
  4399.                 client_print(id, print_center, "%L", id, "BUY_HAVE_KEVLARHELM")
  4400.                 return
  4401.             }
  4402.         }
  4403.  
  4404.         case W_FLASHBANG:
  4405.         {
  4406.             new iGrenades = cs_get_user_bpammo(id, W_FLASHBANG)
  4407.  
  4408.             if(iGrenades >= 2)
  4409.             {
  4410.                 client_print(id, print_center, "%L", id, "BUY_NOMORE_FLASH")
  4411.                 return
  4412.             }
  4413.  
  4414.             new iCvar = get_pcvar_num(pCvar_ctf_nospam_flash)
  4415.             new Float:fGameTime = get_gametime()
  4416.  
  4417.             if(g_fLastBuy[id][iGrenades] > fGameTime)
  4418.             {
  4419.                 client_print(id, print_center, "%L", id, "BUY_DELAY_FLASH", iCvar)
  4420.                 return
  4421.             }
  4422.  
  4423.             g_fLastBuy[id][iGrenades] = fGameTime + iCvar
  4424.  
  4425.             if(iGrenades == 1)
  4426.                 g_fLastBuy[id][0] = g_fLastBuy[id][iGrenades]
  4427.         }
  4428.  
  4429.         case W_HEGRENADE:
  4430.         {
  4431.             if(cs_get_user_bpammo(id, W_HEGRENADE) >= 1)
  4432.             {
  4433.                 client_print(id, print_center, "%L", id, "BUY_NOMORE_HE")
  4434.                 return
  4435.             }
  4436.  
  4437.             new iCvar = get_pcvar_num(pCvar_ctf_nospam_he)
  4438.             new Float:fGameTime = get_gametime()
  4439.  
  4440.             if(g_fLastBuy[id][2] > fGameTime)
  4441.             {
  4442.                 client_print(id, print_center, "%L", id, "BUY_DELAY_HE", iCvar)
  4443.                 return
  4444.             }
  4445.  
  4446.             g_fLastBuy[id][2] = fGameTime + iCvar
  4447.         }
  4448.  
  4449.         case W_SMOKEGRENADE:
  4450.         {
  4451.             if(cs_get_user_bpammo(id, W_SMOKEGRENADE) >= 1)
  4452.             {
  4453.                 client_print(id, print_center, "%L", id, "BUY_NOMORE_SMOKE")
  4454.                 return
  4455.             }
  4456.  
  4457.             new iCvar = get_pcvar_num(pCvar_ctf_nospam_smoke)
  4458.             new Float:fGameTime = get_gametime()
  4459.  
  4460.             if(g_fLastBuy[id][3] > fGameTime)
  4461.             {
  4462.                 client_print(id, print_center, "%L", id, "BUY_DELAY_SMOKE", iCvar)
  4463.                 return
  4464.             }
  4465.  
  4466.             g_fLastBuy[id][3] = fGameTime + iCvar
  4467.         }
  4468.     }
  4469.  
  4470.     if(1 <= g_iWeaponSlot[iWeapon] <= 2)
  4471.     {
  4472.         new iWeapons
  4473.         new iWeaponList[32]
  4474.  
  4475.         get_user_weapons(id, iWeaponList, iWeapons)
  4476.  
  4477.         if(cs_get_user_shield(id))
  4478.             iWeaponList[iWeapons++] = W_SHIELD
  4479.  
  4480.         for(new w, i = 0; i < iWeapons; i++)
  4481.         {
  4482.             w = iWeaponList[i]
  4483.  
  4484.             if(1 <= g_iWeaponSlot[w] <= 2)
  4485.             {
  4486.                 if(w == iWeapon)
  4487.                 {
  4488.                     client_print(id, print_center, "%L", id, "BUY_HAVE_WEAPON")
  4489.                     return
  4490.                 }
  4491.  
  4492.                 if(iWeapon == W_SHIELD && w == W_ELITE)
  4493.                     engclient_cmd(id, "drop", g_szWeaponEntity[W_ELITE]) // drop the dual elites too if buying a shield
  4494.  
  4495.                 if(iWeapon == W_ELITE && w == W_SHIELD)
  4496.                     engclient_cmd(id, "drop", g_szWeaponEntity[W_SHIELD]) // drop the too shield if buying dual elites
  4497.  
  4498.                 if(g_iWeaponSlot[w] == g_iWeaponSlot[iWeapon])
  4499.                 {
  4500.                     if(g_iWeaponSlot[w] == 2 && iWeaponList[iWeapons-1] == W_SHIELD)
  4501.                     {
  4502.                         engclient_cmd(id, "drop", g_szWeaponEntity[W_SHIELD]) // drop the shield
  4503.  
  4504.                         new ent = find_ent_by_owner(g_iMaxPlayers, g_szWeaponEntity[W_SHIELD], id)
  4505.  
  4506.                         if(ent)
  4507.                         {
  4508.                             entity_set_int(ent, EV_INT_flags, FL_KILLME) // kill the shield
  4509.                             call_think(ent)
  4510.                         }
  4511.  
  4512.                         engclient_cmd(id, "drop", g_szWeaponEntity[w]) // drop the secondary
  4513.  
  4514.                         give_item(id, g_szWeaponEntity[W_SHIELD]) // give back the shield
  4515.                     }
  4516.                     else
  4517.                         engclient_cmd(id, "drop", g_szWeaponEntity[w]) // drop weapon if it's of the same slot
  4518.                 }
  4519.             }
  4520.         }
  4521.     }
  4522.  
  4523.     if(iWeapon != W_NVG && iWeapon != W_C4)
  4524.         give_item(id, g_szWeaponEntity[iWeapon])
  4525.  
  4526.     player_addRebuy(id, iWeapon)
  4527.  
  4528.     if(g_iWeaponPrice[iWeapon])
  4529.         cs_set_user_money(id, iMoney - iCost, 1)
  4530.  
  4531. #if FEATURE_ADRENALINE == true
  4532.  
  4533.     if(iCostAdrenaline)
  4534.     {
  4535.         g_iAdrenaline[id] -= iCostAdrenaline
  4536.         player_hudAdrenaline(id)
  4537.     }
  4538.  
  4539. #endif // FEATURE_ADRENALINE
  4540.  
  4541.     if(g_iBPAmmo[iWeapon])
  4542.         cs_set_user_bpammo(id, iWeapon, g_iBPAmmo[iWeapon])
  4543. }
  4544.  
  4545. public player_fillAmmo(id)
  4546. {
  4547.     if(!g_bAlive[id])
  4548.         return PLUGIN_HANDLED
  4549.  
  4550.     if(!g_bBuyZone[id])
  4551.     {
  4552.         client_print(id, print_center, "%L", id, "BUY_NOTINZONE")
  4553.         return PLUGIN_HANDLED
  4554.     }
  4555.  
  4556.     if(player_getAmmo(id))
  4557.     {
  4558.         emit_sound(id, CHAN_ITEM, SND_GETAMMO, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  4559.         client_print(id, print_center, "%L", id, "BUY_FULLAMMO")
  4560.     }
  4561.  
  4562.     return PLUGIN_HANDLED
  4563. }
  4564.  
  4565. #endif // FEATURE_BUY
  4566.  
  4567.  
  4568.  
  4569.  
  4570.  
  4571.  
  4572.  
  4573.  
  4574.  
  4575.  
  4576.  
  4577. #if FEATURE_C4 == true
  4578.  
  4579. public c4_used(msgid, dest, id)
  4580. {
  4581.     if(g_iTeam[id])
  4582.         player_updateSpeed(id)
  4583.  
  4584.     if(get_msg_arg_int(1) == 0)
  4585.         g_bDefuse[id] = false
  4586.  
  4587.     return PLUGIN_HANDLED
  4588. }
  4589.  
  4590. public c4_planted()
  4591. {
  4592.     new szLogUser[80], szName[32]
  4593.  
  4594.     read_logargv(0, szLogUser, charsmax(szLogUser))
  4595.     parse_loguser(szLogUser, szName, charsmax(szName))
  4596.  
  4597.     new id = get_user_index(szName)
  4598.     new ent = g_iMaxPlayers
  4599.     new Float:fAngles[3]
  4600.     new szFormat[40]
  4601.  
  4602.     entity_get_vector(id, EV_VEC_angles, fAngles)
  4603.  
  4604.     fAngles[pitch] = 0.0
  4605.     fAngles[yaw] += 90.0
  4606.     fAngles[roll] = 0.0
  4607.  
  4608.     new iC4Timer = get_pcvar_num(pCvar_mp_c4timer)
  4609.  
  4610.     client_print(id, print_center, "%L", id, "C4_ARMED", iC4Timer)
  4611.  
  4612.     formatex(szFormat, charsmax(szFormat), "%L", LANG_PLAYER, "C4_ARMED_RADIO", iC4Timer)
  4613.  
  4614.     for(new i = 1; i <= g_iMaxPlayers; i++)
  4615.     {
  4616.         if(g_iTeam[i] == g_iTeam[id] && !g_bBot[id])
  4617.         {
  4618.             /* fully fake hookable radio message and event */
  4619.  
  4620.             emessage_begin(MSG_ONE, gMsg_TextMsg, _, i)
  4621.             ewrite_byte(3)
  4622.             ewrite_string("#Game_radio")
  4623.             ewrite_string(szName)
  4624.             ewrite_string(szFormat)
  4625.             emessage_end()
  4626.  
  4627.             emessage_begin(MSG_ONE, gMsg_SendAudio, _, i)
  4628.             ewrite_byte(id)
  4629.             ewrite_string("%!MRAD_BLOW")
  4630.             ewrite_short(100)
  4631.             emessage_end()
  4632.         }
  4633.     }
  4634.  
  4635.     while((ent = find_ent_by_owner(ent, GRENADE, id)))
  4636.     {
  4637.         if(get_pdata_int(ent, 96) & (1<<8))
  4638.         {
  4639.             entity_set_int(ent, EV_INT_solid, SOLID_NOT)
  4640.             entity_set_int(ent, EV_INT_movetype, MOVETYPE_TOSS)
  4641.             entity_set_float(ent, EV_FL_gravity, 1.0)
  4642.             entity_set_vector(ent, EV_VEC_angles, fAngles)
  4643.  
  4644.             return
  4645.         }
  4646.     }
  4647. }
  4648.  
  4649. public c4_defuse(ent, id, activator, iType, Float:fValue)
  4650. {
  4651.     if(g_bAlive[id] && get_pdata_int(ent, 96) & (1<<8))
  4652.     {
  4653.         new iOwner = entity_get_edict(ent, EV_ENT_owner)
  4654.  
  4655.         if(id != iOwner && 1 <= iOwner <= g_iMaxPlayers && g_iTeam[id] == g_iTeam[iOwner])
  4656.         {
  4657.             client_print(id, print_center, "%L", id, "C4_NODEFUSE")
  4658.             client_cmd(id, "-use")
  4659.  
  4660.             return HAM_SUPERCEDE
  4661.         }
  4662.  
  4663.         if(g_iTeam[id] == TEAM_RED)
  4664.         {
  4665.             set_pdata_int(id, 114, TEAM_BLUE, 5)
  4666.  
  4667.             ExecuteHam(Ham_Use, ent, id, activator, iType, fValue)
  4668.  
  4669.             set_pdata_int(id, 114, TEAM_RED, 5)
  4670.         }
  4671.  
  4672.         if(!g_bDefuse[id])
  4673.         {
  4674.             client_print(id, print_center, "%L", id, "C4_DEFUSING", C4_DEFUSETIME)
  4675.  
  4676.             message_begin(MSG_ONE_UNRELIABLE, gMsg_BarTime, _, id)
  4677.             write_short(C4_DEFUSETIME)
  4678.             message_end()
  4679.  
  4680.             set_pdata_float(ent, 99, get_gametime() + C4_DEFUSETIME, 5)
  4681.  
  4682.             g_bDefuse[id] = true
  4683.         }
  4684.     }
  4685.  
  4686.     return HAM_IGNORED
  4687. }
  4688.  
  4689. public c4_defused()
  4690. {
  4691.     new szLogUser[80], szName[32]
  4692.  
  4693.     read_logargv(0, szLogUser, charsmax(szLogUser))
  4694.     parse_loguser(szLogUser, szName, charsmax(szName))
  4695.  
  4696.     new id = get_user_index(szName)
  4697.  
  4698.     if(!g_bAlive[id])
  4699.         return
  4700.  
  4701.     g_bDefuse[id] = false
  4702.  
  4703.     player_giveC4(id)
  4704.     client_print(id, print_center, "%L", id, "C4_DEFUSED")
  4705. }
  4706.  
  4707. public c4_pickup(ent, id)
  4708. {
  4709.     if(g_bAlive[id] && is_valid_ent(ent) && (entity_get_int(ent, EV_INT_flags) & FL_ONGROUND))
  4710.     {
  4711.         static szModel[32]
  4712.  
  4713.         entity_get_string(ent, EV_SZ_model, szModel, charsmax(szModel))
  4714.  
  4715.         if(equal(szModel, "models/w_backpack.mdl"))
  4716.         {
  4717.             if(user_has_weapon(id, W_C4))
  4718.                 return PLUGIN_HANDLED
  4719.  
  4720.             player_giveC4(id)
  4721.  
  4722.             weapon_remove(ent)
  4723.  
  4724.             return PLUGIN_HANDLED
  4725.         }
  4726.     }
  4727.  
  4728.     return PLUGIN_CONTINUE
  4729. }
  4730.  
  4731. #endif // FEATURE_C4 == true
  4732.  
  4733.  
  4734.  
  4735.  
  4736.  
  4737.  
  4738.  
  4739.  
  4740.  
  4741.  
  4742.  
  4743.  
  4744. public weapon_spawn(ent)
  4745. {
  4746.     if(!is_valid_ent(ent))
  4747.         return
  4748.  
  4749.     new Float:fWeaponStay = get_pcvar_float(pCvar_ctf_weaponstay)
  4750.  
  4751.     if(fWeaponStay > 0)
  4752.     {
  4753.         task_remove(ent)
  4754.         task_set(fWeaponStay, "weapon_startFade", ent)
  4755.     }
  4756. }
  4757.  
  4758. public weapon_startFade(ent)
  4759. {
  4760.     if(!is_valid_ent(ent))
  4761.         return
  4762.  
  4763.     new szClass[32]
  4764.  
  4765.     entity_get_string(ent, EV_SZ_classname, szClass, charsmax(szClass))
  4766.  
  4767.     if(!equal(szClass, WEAPONBOX) && !equal(szClass, ITEM_CLASSNAME))
  4768.         return
  4769.  
  4770.     entity_set_int(ent, EV_INT_movetype, MOVETYPE_FLY)
  4771.     entity_set_int(ent, EV_INT_rendermode, kRenderTransAlpha)
  4772.  
  4773.     if(get_pcvar_num(pCvar_ctf_glows))
  4774.         entity_set_int(ent, EV_INT_renderfx, kRenderFxGlowShell)
  4775.  
  4776.     entity_set_float(ent, EV_FL_renderamt, 255.0)
  4777.     entity_set_vector(ent, EV_VEC_rendercolor, Float:{255.0, 255.0, 0.0})
  4778.     entity_set_vector(ent, EV_VEC_velocity, Float:{0.0, 0.0, 20.0})
  4779.  
  4780.     weapon_fadeOut(ent, 255.0)
  4781. }
  4782.  
  4783. public weapon_fadeOut(ent, Float:fStart)
  4784. {
  4785.     if(!is_valid_ent(ent))
  4786.     {
  4787.         task_remove(ent)
  4788.         return
  4789.     }
  4790.  
  4791.     static Float:fFadeAmount[4096]
  4792.  
  4793.     if(fStart)
  4794.     {
  4795.         task_remove(ent)
  4796.         fFadeAmount[ent] = fStart
  4797.     }
  4798.  
  4799.     fFadeAmount[ent] -= 25.5
  4800.  
  4801.     if(fFadeAmount[ent] > 0.0)
  4802.     {
  4803.         entity_set_float(ent, EV_FL_renderamt, fFadeAmount[ent])
  4804.  
  4805.         task_set(0.1, "weapon_fadeOut", ent)
  4806.     }
  4807.     else
  4808.     {
  4809.         new szClass[32]
  4810.  
  4811.         entity_get_string(ent, EV_SZ_classname, szClass, charsmax(szClass))
  4812.  
  4813.         if(equal(szClass, WEAPONBOX))
  4814.             weapon_remove(ent)
  4815.         else
  4816.             entity_remove(ent)
  4817.     }
  4818. }
  4819.  
  4820.  
  4821.  
  4822.  
  4823.  
  4824.  
  4825.  
  4826.  
  4827. public item_touch(ent, id)
  4828. {
  4829.     if(g_bAlive[id] && is_valid_ent(ent) && entity_get_int(ent, EV_INT_flags) & FL_ONGROUND)
  4830.     {
  4831.         new iType = entity_get_int(ent, EV_INT_iuser2)
  4832.  
  4833.         switch(iType)
  4834.         {
  4835.             case ITEM_AMMO:
  4836.             {
  4837.                 if(!player_getAmmo(id))
  4838.                     return PLUGIN_HANDLED
  4839.  
  4840.                 client_print(id, print_center, "%L", id, "PICKED_AMMO")
  4841.  
  4842.                 emit_sound(id, CHAN_ITEM, SND_GETAMMO, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  4843.             }
  4844.  
  4845.             case ITEM_MEDKIT:
  4846.             {
  4847.                 new iHealth = get_user_health(id)
  4848.  
  4849.                 if(iHealth >= g_iMaxHealth[id])
  4850.                     return PLUGIN_HANDLED
  4851.  
  4852.                 set_user_health(id, clamp(iHealth + ITEM_MEDKIT_GIVE, 0, 100))
  4853.  
  4854.                 client_print(id, print_center, "%L", id, "PICKED_HEALTH", ITEM_MEDKIT_GIVE)
  4855.  
  4856.                 emit_sound(id, CHAN_ITEM, SND_GETMEDKIT, VOL_NORM, ATTN_NORM, 0, 110)
  4857.             }
  4858.  
  4859. #if FEATURE_ADRENALINE == true
  4860.  
  4861.             case ITEM_ADRENALINE:
  4862.             {
  4863.                 if(g_iAdrenaline[id] >= 100)
  4864.                     return PLUGIN_HANDLED
  4865.  
  4866.                 g_iAdrenaline[id] = clamp(g_iAdrenaline[id] + ITEM_ADRENALINE_GIVE, 0, 100)
  4867.  
  4868.                 player_hudAdrenaline(id)
  4869.  
  4870.                 client_print(id, print_center, "%L", id, "PICKED_ADRENALINE", ITEM_ADRENALINE_GIVE)
  4871.  
  4872.                 emit_sound(id, CHAN_ITEM, SND_GETADRENALINE, VOL_NORM, ATTN_NORM, 0, 140)
  4873.             }
  4874.  
  4875. #endif // FEATURE_ADRENALINE == true
  4876.         }
  4877.  
  4878.         task_remove(ent)
  4879.         entity_remove(ent)
  4880.     }
  4881.  
  4882.     return PLUGIN_CONTINUE
  4883. }
  4884.  
  4885.  
  4886.  
  4887.  
  4888.  
  4889.  
  4890.  
  4891.  
  4892.  
  4893.  
  4894.  
  4895.  
  4896.  
  4897.  
  4898.  
  4899.  
  4900.  
  4901. public event_restartGame()
  4902.     g_bRestarting = true
  4903.  
  4904. public event_roundStart()
  4905. {
  4906.     new ent = -1
  4907.  
  4908.     while((ent = find_ent_by_class(ent, WEAPONBOX)) > 0)
  4909.     {
  4910.         task_remove(ent)
  4911.         weapon_remove(ent)
  4912.     }
  4913.  
  4914.     ent = -1
  4915.  
  4916.     while((ent = find_ent_by_class(ent, ITEM_CLASSNAME)) > 0)
  4917.     {
  4918.         task_remove(ent)
  4919.         entity_remove(ent)
  4920.     }
  4921.  
  4922.     for(new id = 1; id < g_iMaxPlayers; id++)
  4923.     {
  4924.         if(!g_bAlive[id])
  4925.             continue
  4926.  
  4927.         g_bDefuse[id] = false
  4928.         g_bFreeLook[id] = false
  4929.         g_fLastBuy[id] = Float:{0.0, 0.0, 0.0, 0.0}
  4930.  
  4931.         task_remove(id - TASK_EQUIPAMENT)
  4932.         task_remove(id - TASK_TEAMBALANCE)
  4933.         task_remove(id - TASK_DEFUSE)
  4934.  
  4935.         if(g_bRestarting)
  4936.         {
  4937.             task_remove(id)
  4938.             task_remove(id - TASK_ADRENALINE)
  4939.  
  4940.             g_bRestarted[id] = true
  4941.             g_iAdrenaline[id] = 0
  4942.             g_iAdrenalineUse[id] = 0
  4943.         }
  4944.  
  4945.         player_updateSpeed(id)
  4946.     }
  4947.  
  4948.     for(new iFlagTeam = TEAM_RED; iFlagTeam <= TEAM_BLUE; iFlagTeam++)
  4949.     {
  4950.         flag_sendHome(iFlagTeam)
  4951.  
  4952.         task_remove(g_iFlagEntity[iFlagTeam])
  4953.  
  4954.         log_message("%s, %s flag returned back to base.", (g_bRestarting ? "Game restarted" : "New round started"), g_szTeamName[iFlagTeam])
  4955.     }
  4956.  
  4957.     if(g_bRestarting)
  4958.     {
  4959.         g_iScore = {0,0,0}
  4960.         g_bRestarting = false
  4961.     }
  4962. }
  4963.  
  4964.  
  4965.  
  4966.  
  4967.  
  4968.  
  4969.  
  4970.  
  4971.  
  4972.  
  4973.  
  4974.  
  4975.  
  4976.  
  4977.  
  4978.  
  4979.  
  4980. public msg_block()
  4981.     return PLUGIN_HANDLED
  4982.  
  4983. #if FEATURE_C4 == true
  4984.  
  4985. public msg_sendAudio()
  4986. {
  4987.     new szAudio[14]
  4988.  
  4989.     get_msg_arg_string(2, szAudio, charsmax(szAudio))
  4990.  
  4991.     return equal(szAudio, "%!MRAD_BOMB", 11) ? PLUGIN_HANDLED : PLUGIN_CONTINUE
  4992. }
  4993.  
  4994. #endif // FEATURE_C4 == true
  4995.  
  4996. public msg_screenFade(msgid, dest, id)
  4997.     return (g_bProtected[id] && g_bAlive[id] && get_msg_arg_int(4) == 255 && get_msg_arg_int(5) == 255 && get_msg_arg_int(6) == 255 && get_msg_arg_int(7) > 199 ? PLUGIN_HANDLED : PLUGIN_CONTINUE)
  4998.  
  4999. public msg_scoreAttrib()
  5000.     return (get_msg_arg_int(2) & (1<<1) ? PLUGIN_HANDLED : PLUGIN_CONTINUE)
  5001.  
  5002. public msg_teamScore()
  5003. {
  5004.     new szTeam[2]
  5005.  
  5006.     get_msg_arg_string(1, szTeam, 1)
  5007.  
  5008.     switch(szTeam[0])
  5009.     {
  5010.         case 'T': set_msg_arg_int(2, ARG_SHORT, g_iScore[TEAM_RED])
  5011.         case 'C': set_msg_arg_int(2, ARG_SHORT, g_iScore[TEAM_BLUE])
  5012.     }
  5013. }
  5014.  
  5015. public msg_roundTime()
  5016.     set_msg_arg_int(1, ARG_SHORT, get_timeleft())
  5017.  
  5018. public msg_sayText(msgid, dest, id)
  5019. {
  5020.     new szString[32]
  5021.  
  5022.     get_msg_arg_string(2, szString, charsmax(szString))
  5023.  
  5024.     new iTeam = (szString[14] == 'T' ? TEAM_RED : (szString[14] == 'C' ? TEAM_BLUE : TEAM_SPEC))
  5025.     //new bool:bDead = (szString[16] == 'D' || szString[17] == 'D')
  5026.  
  5027.     if(TEAM_RED <= iTeam <= TEAM_BLUE && equali(szString, "#Cstrike_Chat_", 14))
  5028.     {
  5029.         //formatex(szString, charsmax(szString), "^x01%s(%L)^x03 %%s1^x01 :  %%s2", (bDead ? "*DEAD* " : NULL), id, g_szMLFlagTeam[iTeam])
  5030.         set_msg_arg_string(2, szString)
  5031.     }
  5032. }
  5033.  
  5034. public msg_textMsg(msgid, dest, id)
  5035. {
  5036.     static szMsg[48]
  5037.  
  5038.     get_msg_arg_string(2, szMsg, charsmax(szMsg))
  5039.  
  5040.     if(equal(szMsg, "#Spec_Mode", 10) && !get_pcvar_num(pCvar_mp_fadetoblack) && (get_pcvar_num(pCvar_mp_forcecamera) || get_pcvar_num(pCvar_mp_forcechasecam)))
  5041.     {
  5042.         if(TEAM_RED <= g_iTeam[id] <= TEAM_BLUE && szMsg[10] == '3')
  5043.         {
  5044.             if(!g_bFreeLook[id])
  5045.             {
  5046.                 player_screenFade(id, {0,0,0,255}, 0.25, 9999.0, FADE_IN, true)
  5047.                 g_bFreeLook[id] = true
  5048.             }
  5049.  
  5050.             formatex(szMsg, charsmax(szMsg), "%L", id, "DEATH_NOFREELOOK")
  5051.  
  5052.             set_msg_arg_string(2, szMsg)
  5053.         }
  5054.         else if(g_bFreeLook[id])
  5055.         {
  5056.             player_screenFade(id, {0,0,0,255}, 0.25, 0.0, FADE_OUT, true)
  5057.             g_bFreeLook[id] = false
  5058.         }
  5059.     }
  5060.     else if(equal(szMsg, "#Terrorists_Win") || equal(szMsg, "#CTs_Win"))
  5061.     {
  5062.         static szString[32]
  5063.  
  5064.         formatex(szString, charsmax(szString), "%L", LANG_PLAYER, "STARTING_NEWROUND")
  5065.  
  5066.         set_msg_arg_string(2, szString)
  5067.     }
  5068.     else if(equal(szMsg, "#Only_1", 7))
  5069.     {
  5070.         formatex(szMsg, charsmax(szMsg), "%L", id, "DEATH_ONLY1CHANGE")
  5071.  
  5072.         set_msg_arg_string(2, szMsg)
  5073.     }
  5074.  
  5075. #if FEATURE_C4 == true
  5076.  
  5077.     else if(equal(szMsg, "#Defusing", 9) || equal(szMsg, "#Got_bomb", 9) || equal(szMsg, "#Game_bomb", 10) || equal(szMsg, "#Bomb", 5) || equal(szMsg, "#Target", 7))
  5078.         return PLUGIN_HANDLED
  5079.  
  5080. #endif // FEATURE_C4 == true
  5081.  
  5082.     return PLUGIN_CONTINUE
  5083. }
  5084.  
  5085.  
  5086.  
  5087.  
  5088.  
  5089.  
  5090.  
  5091.  
  5092.  
  5093.  
  5094.  
  5095.  
  5096.  
  5097.  
  5098.  
  5099. player_award(id, iMoney, iFrags, iAdrenaline, szText[], any:...)
  5100. {
  5101. #if FEATURE_ADRENALINE == false
  5102.  
  5103.     iAdrenaline = 0
  5104.  
  5105. #endif // FEATURE_ADRENALINE
  5106.  
  5107.     if(!g_iTeam[id] || (!iMoney && !iFrags && !iAdrenaline))
  5108.         return
  5109.  
  5110.     new szMsg[48]
  5111.     new szMoney[24]
  5112.     new szFrags[48]
  5113.     new szFormat[192]
  5114.     new szAdrenaline[48]
  5115.  
  5116.     if(iMoney != 0)
  5117.     {
  5118.         cs_set_user_money(id, clamp(cs_get_user_money(id) + iMoney, 0, 16000), 1)
  5119.  
  5120.         formatex(szMoney, charsmax(szMoney), "%s%d$", iMoney > 0 ? "+" : NULL, iMoney)
  5121.     }
  5122.  
  5123.     if(iFrags != 0)
  5124.     {
  5125.         player_setScore(id, iFrags, 0)
  5126.  
  5127.         formatex(szFrags, charsmax(szFrags), "%s%d %L", iFrags > 0 ? "+" : NULL, iFrags, id, (iFrags > 1 ? "FRAGS" : "FRAG"))
  5128.     }
  5129.  
  5130. #if FEATURE_ADRENALINE == true
  5131.  
  5132.     if(iAdrenaline != 0)
  5133.     {
  5134.         g_iAdrenaline[id] = clamp(g_iAdrenaline[id] + iAdrenaline, 0, 100)
  5135.  
  5136.         player_hudAdrenaline(id)
  5137.  
  5138.         formatex(szAdrenaline, charsmax(szAdrenaline), "%s%d %L", iAdrenaline > 0 ? "+" : NULL, iAdrenaline, id, "ADRENALINE")
  5139.     }
  5140.  
  5141. #endif // FEATURE_ADRENALINE == true
  5142.  
  5143.     vformat(szMsg, charsmax(szMsg), szText, 6)
  5144.     formatex(szFormat, charsmax(szFormat), "%s%s%s%s%s %s", szMoney, (szMoney[0] && (szFrags[0] || szAdrenaline[0]) ? ", " : NULL), szFrags, (szFrags[0] && szAdrenaline[0] ? ", " : NULL), szAdrenaline, szMsg)
  5145.  
  5146.     client_print(id, print_console, "%s%L: %s", CONSOLE_PREFIX, id, "REWARD", szFormat)
  5147.     client_print(id, print_center, szFormat)
  5148. }
  5149.  
  5150. #if FEATURE_ADRENALINE == true
  5151.  
  5152. player_hudAdrenaline(id)
  5153. {
  5154.     set_hudmessage(HUD_ADRENALINE)
  5155.  
  5156.     if(g_iAdrenalineUse[id])
  5157.         show_hudmessage(id, "%L", id, "HUD_ADRENALINECOMBO", id, g_szAdrenalineUseML[g_iAdrenalineUse[id]], g_iAdrenaline[id], 100)
  5158.  
  5159.     else if(g_iAdrenaline[id] >= 100)
  5160.         show_hudmessage(id, "%L", id, "HUD_ADRENALINEFULL")
  5161.  
  5162.     else
  5163.         show_hudmessage(id, "%L", id, "HUD_ADRENALINE", g_iAdrenaline[id], 100)
  5164. }
  5165.  
  5166. #endif // FEATURE_ADRENALINE == true
  5167.  
  5168. player_print(id, iSender, szMsg[], any:...)
  5169. {
  5170.     if(g_bBot[id] || (id && !g_iTeam[id]))
  5171.         return PLUGIN_HANDLED
  5172.  
  5173.     new szFormat[192]
  5174.  
  5175.     vformat(szFormat, charsmax(szFormat), szMsg, 4)
  5176.     format(szFormat, charsmax(szFormat), "%s%s", CHAT_PREFIX, szFormat)
  5177.  
  5178.     if(id)
  5179.         message_begin(MSG_ONE, gMsg_SayText, _, id)
  5180.     else
  5181.         message_begin(MSG_ALL, gMsg_SayText)
  5182.  
  5183.     write_byte(iSender)
  5184.     write_string(szFormat)
  5185.     message_end()
  5186.  
  5187.     return PLUGIN_HANDLED
  5188. }
  5189.  
  5190. bool:player_getAmmo(id)
  5191. {
  5192.     if(!g_bAlive[id])
  5193.         return false
  5194.  
  5195.     new iWeapons
  5196.     new iWeaponList[32]
  5197.     new bool:bGotAmmo = false
  5198.  
  5199.     get_user_weapons(id, iWeaponList, iWeapons)
  5200.  
  5201.     for(new iAmmo, iClip, ent, w, i = 0; i < iWeapons; i++)
  5202.     {
  5203.         w = iWeaponList[i]
  5204.  
  5205.         if(g_iBPAmmo[w])
  5206.         {
  5207.             ent = find_ent_by_owner(g_iMaxPlayers, g_szWeaponEntity[w], id)
  5208.  
  5209.             iAmmo = cs_get_user_bpammo(id, w)
  5210.             iClip = (ent ? cs_get_weapon_ammo(ent) : 0)
  5211.  
  5212.             if((iAmmo + iClip) < (g_iBPAmmo[w] + g_iClip[w]))
  5213.             {
  5214.                 cs_set_user_bpammo(id, w, g_iBPAmmo[w] + (g_iClip[w] - iClip))
  5215.                 bGotAmmo = true
  5216.             }
  5217.         }
  5218.     }
  5219.  
  5220.     return bGotAmmo
  5221. }
  5222.  
  5223. player_setScore(id, iAddFrags, iAddDeaths)
  5224. {
  5225.     new iFrags = get_user_frags(id)
  5226.     new iDeaths = cs_get_user_deaths(id)
  5227.  
  5228.     if(iAddFrags != 0)
  5229.     {
  5230.         iFrags += iAddFrags
  5231.  
  5232.         set_user_frags(id, iFrags)
  5233.     }
  5234.  
  5235.     if(iAddDeaths != 0)
  5236.     {
  5237.         iDeaths += iAddDeaths
  5238.  
  5239.         cs_set_user_deaths(id, iDeaths)
  5240.     }
  5241.  
  5242.     message_begin(MSG_BROADCAST, gMsg_ScoreInfo)
  5243.     write_byte(id)
  5244.     write_short(iFrags)
  5245.     write_short(iDeaths)
  5246.     write_short(0)
  5247.     write_short(g_iTeam[id])
  5248.     message_end()
  5249. }
  5250.  
  5251. player_spawnItem(id)
  5252. {
  5253. #if FEATURE_ADRENALINE == true
  5254.     if(!ITEM_DROP_AMMO && !ITEM_DROP_MEDKIT && !ITEM_DROP_ADRENALINE)
  5255.         return
  5256. #else
  5257.     if(!ITEM_DROP_AMMO && !ITEM_DROP_MEDKIT)
  5258.         return
  5259. #endif
  5260.  
  5261.     if(random_num(1, 100) > get_pcvar_float(pCvar_ctf_itempercent))
  5262.         return
  5263.  
  5264.     new ent = entity_create(INFO_TARGET)
  5265.  
  5266.     if(!ent)
  5267.         return
  5268.  
  5269.     new iType
  5270.     new Float:fOrigin[3]
  5271.     new Float:fAngles[3]
  5272.     new Float:fVelocity[3]
  5273.  
  5274.     entity_get_vector(id, EV_VEC_origin, fOrigin)
  5275.  
  5276.     fVelocity[x] = random_float(-100.0, 100.0)
  5277.     fVelocity[y] = random_float(-100.0, 100.0)
  5278.     fVelocity[z] = 50.0
  5279.  
  5280.     fAngles[yaw] = random_float(0.0, 360.0)
  5281.  
  5282. #if FEATURE_ADRENALINE == true
  5283.     while((iType = random(3)))
  5284. #else
  5285.     while((iType = random(2)))
  5286. #endif
  5287.     {
  5288.         switch(iType)
  5289.         {
  5290.             case ITEM_AMMO:
  5291.             {
  5292.                 if(ITEM_DROP_AMMO)
  5293.                 {
  5294.                     entity_set_model(ent, ITEM_MODEL_AMMO)
  5295.                     break
  5296.                 }
  5297.             }
  5298.  
  5299.             case ITEM_MEDKIT:
  5300.             {
  5301.                 if(ITEM_DROP_MEDKIT)
  5302.                 {
  5303.                     entity_set_model(ent, ITEM_MODEL_MEDKIT)
  5304.                     break
  5305.                 }
  5306.             }
  5307.  
  5308. #if FEATURE_ADRENALINE == true
  5309.             case ITEM_ADRENALINE:
  5310.             {
  5311.                 if(ITEM_DROP_ADRENALINE)
  5312.                 {
  5313.                     entity_set_model(ent, ITEM_MODEL_ADRENALINE)
  5314.                     entity_set_int(ent, EV_INT_skin, 2)
  5315.                     break
  5316.                 }
  5317.             }
  5318. #endif // FEATURE_ADRENALINE == true
  5319.         }
  5320.     }
  5321.  
  5322.     entity_set_string(ent, EV_SZ_classname, ITEM_CLASSNAME)
  5323.     entity_spawn(ent)
  5324.     entity_set_size(ent, ITEM_HULL_MIN, ITEM_HULL_MAX)
  5325.     entity_set_origin(ent, fOrigin)
  5326.     entity_set_vector(ent, EV_VEC_angles, fAngles)
  5327.     entity_set_vector(ent, EV_VEC_velocity, fVelocity)
  5328.     entity_set_int(ent, EV_INT_movetype, MOVETYPE_TOSS)
  5329.     entity_set_int(ent, EV_INT_solid, SOLID_TRIGGER)
  5330.     entity_set_int(ent, EV_INT_iuser2, iType)
  5331.  
  5332.     task_remove(ent)
  5333.     task_set(get_pcvar_float(pCvar_ctf_weaponstay), "weapon_startFade", ent)
  5334. }
  5335.  
  5336. #if FEATURE_C4 == true
  5337.  
  5338. player_giveC4(id)
  5339. {
  5340.     give_item(id, g_szWeaponEntity[W_C4])
  5341.  
  5342.     cs_set_user_plant(id, 1, 1)
  5343. }
  5344.  
  5345. #endif // FEATURE_C4
  5346.  
  5347. player_healingEffect(id)
  5348. {
  5349.     new iOrigin[3]
  5350.  
  5351.     get_user_origin(id, iOrigin)
  5352.  
  5353.     message_begin(MSG_PVS, SVC_TEMPENTITY, iOrigin)
  5354.     write_byte(TE_PROJECTILE)
  5355.     write_coord(iOrigin[x] + random_num(-10, 10))
  5356.     write_coord(iOrigin[y] + random_num(-10, 10))
  5357.     write_coord(iOrigin[z] + random_num(0, 30))
  5358.     write_coord(0)
  5359.     write_coord(0)
  5360.     write_coord(15)
  5361.     write_short(gSpr_regeneration)
  5362.     write_byte(1)
  5363.     write_byte(id)
  5364.     message_end()
  5365. }
  5366.  
  5367. player_updateRender(id, Float:fDamage = 0.0)
  5368. {
  5369.     new bool:bGlows = (get_pcvar_num(pCvar_ctf_glows) == 1)
  5370.     new iTeam = g_iTeam[id]
  5371.     new iMode = kRenderNormal
  5372.     new iEffect = kRenderFxNone
  5373.     new iAmount = 0
  5374.     new iColor[3] = {0,0,0}
  5375.  
  5376.     if(g_bProtected[id])
  5377.     {
  5378.         if(bGlows)
  5379.             iEffect = kRenderFxGlowShell
  5380.  
  5381.         iAmount = 200
  5382.  
  5383.         iColor[0] = (iTeam == TEAM_RED ? 155 : 0)
  5384.         iColor[1] = (fDamage > 0.0 ? 100 - clamp(floatround(fDamage), 0, 100) : 0)
  5385.         iColor[2] = (iTeam == TEAM_BLUE ? 155 : 0)
  5386.     }
  5387.  
  5388. #if FEATURE_ADRENALINE == true
  5389.     switch(g_iAdrenalineUse[id])
  5390.     {
  5391.         case ADRENALINE_BERSERK:
  5392.         {
  5393.             if(bGlows)
  5394.                 iEffect = kRenderFxGlowShell
  5395.  
  5396.             iAmount = 160
  5397.             iColor = {55, 0, 55}
  5398.         }
  5399.  
  5400.         case ADRENALINE_INVISIBILITY:
  5401.         {
  5402.             iMode = kRenderTransAlpha
  5403.  
  5404.             if(bGlows)
  5405.                 iEffect = kRenderFxGlowShell
  5406.  
  5407.             iAmount = 10
  5408.             iColor = {15, 15, 15}
  5409.         }
  5410.     }
  5411. #endif // FEATURE_ADRENALINE == true
  5412.  
  5413.     if(player_hasFlag(id))
  5414.     {
  5415.         if(iMode != kRenderTransAlpha)
  5416.             iMode = kRenderNormal
  5417.  
  5418.         if(bGlows)
  5419.             iEffect = kRenderFxGlowShell
  5420.  
  5421.         iColor[0] = (iTeam == TEAM_RED ? (iColor[0] > 0 ? 200 : 155) : 0)
  5422.         iColor[1] = (iAmount == 160 ? 55 : 0)
  5423.         iColor[2] = (iTeam == TEAM_BLUE ? (iColor[2] > 0 ? 200 : 155) : 0)
  5424.  
  5425.         iAmount = (iAmount == 160 ? 50 : (iAmount == 10 ? 20 : 30))
  5426.     }
  5427.  
  5428.     set_user_rendering(id, iEffect, iColor[0], iColor[1], iColor[2], iMode, iAmount)
  5429. }
  5430.  
  5431. player_updateSpeed(id)
  5432. {
  5433.     new Float:fSpeed = 1.0
  5434.  
  5435.     if(player_hasFlag(id))
  5436.         fSpeed *= SPEED_FLAG
  5437.  
  5438. #if FEATURE_ADRENALINE == true
  5439.  
  5440.     if(g_iAdrenalineUse[id] == ADRENALINE_SPEED)
  5441.         fSpeed *= SPEED_ADRENALINE
  5442.  
  5443. #endif // FEATURE_ADRENALINE
  5444.  
  5445.     set_user_maxspeed(id, g_fWeaponSpeed[id] * fSpeed)
  5446. }
  5447.  
  5448. player_screenFade(id, iColor[4] = {0,0,0,0}, Float:fEffect = 0.0, Float:fHold = 0.0, iFlags = FADE_OUT, bool:bReliable = false)
  5449. {
  5450.     if(id && !g_iTeam[id])
  5451.         return
  5452.  
  5453.     static iType
  5454.  
  5455.     if(1 <= id <= g_iMaxPlayers)
  5456.         iType = (bReliable ? MSG_ONE : MSG_ONE_UNRELIABLE)
  5457.     else
  5458.         iType = (bReliable ? MSG_ALL : MSG_BROADCAST)
  5459.  
  5460.     message_begin(iType, gMsg_ScreenFade, _, id)
  5461.     write_short(clamp(floatround(fEffect * (1<<12)), 0, 0xFFFF))
  5462.     write_short(clamp(floatround(fHold * (1<<12)), 0, 0xFFFF))
  5463.     write_short(iFlags)
  5464.     write_byte(iColor[0])
  5465.     write_byte(iColor[1])
  5466.     write_byte(iColor[2])
  5467.     write_byte(iColor[3])
  5468.     message_end()
  5469. }
  5470.  
  5471. game_announce(iEvent, iFlagTeam, szName[])
  5472. {
  5473.     new iColor = iFlagTeam
  5474.     new szText[64]
  5475.  
  5476.     switch(iEvent)
  5477.     {
  5478.         case EVENT_TAKEN:
  5479.         {
  5480.             iColor = get_opTeam(iFlagTeam)
  5481.             formatex(szText, charsmax(szText), "%L", LANG_PLAYER, "ANNOUNCE_FLAGTAKEN", szName, LANG_PLAYER, g_szMLFlagTeam[iFlagTeam])
  5482.         }
  5483.  
  5484.         case EVENT_DROPPED: formatex(szText, charsmax(szText), "%L", LANG_PLAYER, "ANNOUNCE_FLAGDROPPED", szName, LANG_PLAYER, g_szMLFlagTeam[iFlagTeam])
  5485.  
  5486.         case EVENT_RETURNED:
  5487.         {
  5488.             if(strlen(szName) != 0)
  5489.                 formatex(szText, charsmax(szText), "%L", LANG_PLAYER, "ANNOUNCE_FLAGRETURNED", szName, LANG_PLAYER, g_szMLFlagTeam[iFlagTeam])
  5490.             else
  5491.                 formatex(szText, charsmax(szText), "%L", LANG_PLAYER, "ANNOUNCE_FLAGAUTORETURNED", LANG_PLAYER, g_szMLFlagTeam[iFlagTeam])
  5492.         }
  5493.  
  5494.         case EVENT_SCORE: formatex(szText, charsmax(szText), "%L", LANG_PLAYER, "ANNOUNCE_FLAGCAPTURED", szName, LANG_PLAYER, g_szMLFlagTeam[get_opTeam(iFlagTeam)])
  5495.     }
  5496.  
  5497.     set_hudmessage(iColor == TEAM_RED ? 255 : 0, 0, iColor == TEAM_BLUE ? 255 : 0, HUD_ANNOUNCE)
  5498.     show_hudmessage(0, szText)
  5499.  
  5500.     client_print(0, print_console, "%s%L: %s", CONSOLE_PREFIX, LANG_PLAYER, "ANNOUNCEMENT", szText)
  5501.  
  5502.     if(get_pcvar_num(pCvar_ctf_sound[iEvent]))
  5503.         client_cmd(0, "mp3 play ^"sound/csrevo/ctf/%s.mp3^"", g_szSounds[iEvent][iFlagTeam])
  5504. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement