Advertisement
DecaK

Untitled

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