HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #define PLUGIN "Modern Warfare 2"
  2. #define VERSION "1.3.6b"
  3. #define AUTHOR "D.Moder"
  4.  
  5. #include <amxmodx>
  6. #include <amxmisc>
  7. #include <engine>
  8. #include <fakemeta>
  9. #include <hamsandwich>
  10. #if defined _orpheu_memory_included
  11. #endinput
  12. #endif
  13. #define _orpheu_memory_included
  14.  
  15.  
  16. #if defined _orpheu_const_included
  17. #endinput
  18. #endif
  19. #define _orpheu_const_included
  20.  
  21. #if AMXX_VERSION_NUM >= 175
  22. #pragma reqlib orpheu
  23. #if !defined AMXMODX_NOAUTOLOAD
  24. #pragma loadlib orpheu
  25. #endif
  26. #else
  27. #pragma library orpheu
  28. #endif
  29.  
  30. const OrpheuFunction:OrpheuInvalidFunction = OrpheuFunction:0
  31.  
  32. enum OrpheuHookReturn
  33. {
  34. OrpheuIgnored,
  35. OrpheuOverride,
  36. OrpheuSupercede
  37. }
  38.  
  39. enum OrpheuHookPhase
  40. {
  41. OrpheuHookPre,
  42. OrpheuHookPost
  43. }
  44.  
  45. enum OrpheuStructType
  46. {
  47. OrpheuStructMovevars,
  48. OrpheuStructUsercmd,
  49. OrpheuStructMonsterEvent,
  50. OrpheuStructDLL_FUNCTIONS,
  51. OrpheuStructPlayerMove,
  52. OrpheuStructEngineFuncs,
  53. OrpheuStructTraceResult,
  54. OrpheuStructPhysent,
  55. OrpheuStructPmplane,
  56. OrpheuStructPmtrace,
  57. OrpheuStructWeaponData,
  58. OrpheuStructAmmoInfo,
  59. OrpheuStructItemInfo,
  60. OrpheuStructTask,
  61. OrpheuStructSchedule,
  62. OrpheuStructKeyValueData
  63. }
  64.  
  65.  
  66. native OrpheuMemoryReplace(const memoryDataName[],count,any:...)
  67. native OrpheuMemoryReplaceAtAddress(address,const memoryDataNameName[],count,any:...)
  68. native OrpheuMemoryGet(const memoryDataName[],any:...)
  69. native OrpheuMemoryGetAtAddress(address,const memoryDataName[],any:...)
  70. native OrpheuMemorySet(const memoryDataName[],count,any:...)
  71. native OrpheuMemorySetAtAddress(address,const memoryDataName[],count,any:...)
  72.  
  73.  
  74. const OrpheuFunction:OrpheuInvalidFunction = OrpheuFunction:0
  75.  
  76. enum OrpheuHookReturn
  77. {
  78. OrpheuIgnored,
  79. OrpheuOverride,
  80. OrpheuSupercede
  81. }
  82.  
  83. enum OrpheuHookPhase
  84. {
  85. OrpheuHookPre,
  86. OrpheuHookPost
  87. }
  88.  
  89. enum OrpheuStructType
  90. {
  91. OrpheuStructMovevars,
  92. OrpheuStructUsercmd,
  93. OrpheuStructMonsterEvent,
  94. OrpheuStructDLL_FUNCTIONS,
  95. OrpheuStructPlayerMove,
  96. OrpheuStructEngineFuncs,
  97. OrpheuStructTraceResult,
  98. OrpheuStructPhysent,
  99. OrpheuStructPmplane,
  100. OrpheuStructPmtrace,
  101. OrpheuStructWeaponData,
  102. OrpheuStructAmmoInfo,
  103. OrpheuStructItemInfo,
  104. OrpheuStructTask,
  105. OrpheuStructSchedule,
  106. OrpheuStructKeyValueData
  107. }
  108.  
  109.  
  110.  
  111. const OrpheuFunction:OrpheuInvalidFunction = OrpheuFunction:0
  112.  
  113. enum OrpheuHookReturn
  114. {
  115. OrpheuIgnored,
  116. OrpheuOverride,
  117. OrpheuSupercede
  118. }
  119.  
  120. enum OrpheuHookPhase
  121. {
  122. OrpheuHookPre,
  123. OrpheuHookPost
  124. }
  125.  
  126. enum OrpheuStructType
  127. {
  128. OrpheuStructMovevars,
  129. OrpheuStructUsercmd,
  130. OrpheuStructMonsterEvent,
  131. OrpheuStructDLL_FUNCTIONS,
  132. OrpheuStructPlayerMove,
  133. OrpheuStructEngineFuncs,
  134. OrpheuStructTraceResult,
  135. OrpheuStructPhysent,
  136. OrpheuStructPmplane,
  137. OrpheuStructPmtrace,
  138. OrpheuStructWeaponData,
  139. OrpheuStructAmmoInfo,
  140. OrpheuStructItemInfo,
  141. OrpheuStructTask,
  142. OrpheuStructSchedule,
  143. OrpheuStructKeyValueData
  144. }
  145.  
  146.  
  147.  
  148. native OrpheuFunction:OrpheuGetFunction(const libFunctionName[],const className[]="")
  149. native OrpheuHook:OrpheuRegisterHook(OrpheuFunction:function,const hookFunctionName[],OrpheuHookPhase:phase = OrpheuHookPre)
  150. native OrpheuUnregisterHook(OrpheuHook:hook)
  151. native OrpheuCall(OrpheuFunction:function,any:...)
  152. native OrpheuCallSuper(OrpheuFunction:function,any:...)
  153. native any:OrpheuGetReturn(any:...)
  154. native OrpheuSetReturn(any:...)
  155. native OrpheuSetParam(num,any:...)
  156. native OrpheuStruct:OrpheuCreateStruct(OrpheuStructType:structType)
  157. native OrpheuGetParamStructMember(num,const memberName[],any:...)
  158. native OrpheuSetParamStructMember(num,const memberName[],any:...)
  159. native OrpheuStruct:OrpheuGetStructFromParam(num)
  160. native OrpheuStruct:OrpheuCloneStructFromParam(num)
  161. native OrpheuSetStructMember(OrpheuStruct:struct,const memberName[],any:...)
  162. native OrpheuGetStructMember(OrpheuStruct:struct,const memberName[],any:...)
  163. native OrpheuStruct:OrpheuGetEngineFunctionsStruct()
  164. native OrpheuStruct:OrpheuGetDLLFunctionsStruct()
  165. native OrpheuFunction:OrpheuGetFunctionFromClass(const entityClassName[],const libFunctionName[],const libClassName[])
  166. native OrpheuFunction:OrpheuGetFunctionFromEntity(id,const libFunctionName[],const libClassName[])
  167. native OrpheuFunction:OrpheuGetFunctionFromObject(object,const libFunctionName[],const libClassName[])
  168. native OrpheuFunction:OrpheuGetFunctionFromMonster(id, const libFunctionName[], const libClassName[])
  169.  
  170.  
  171. const OrpheuFunction:OrpheuInvalidFunction = OrpheuFunction:0
  172.  
  173. enum OrpheuHookReturn
  174. {
  175. OrpheuIgnored,
  176. OrpheuOverride,
  177. OrpheuSupercede
  178. }
  179.  
  180. enum OrpheuHookPhase
  181. {
  182. OrpheuHookPre,
  183. OrpheuHookPost
  184. }
  185.  
  186. enum OrpheuStructType
  187. {
  188. OrpheuStructMovevars,
  189. OrpheuStructUsercmd,
  190. OrpheuStructMonsterEvent,
  191. OrpheuStructDLL_FUNCTIONS,
  192. OrpheuStructPlayerMove,
  193. OrpheuStructEngineFuncs,
  194. OrpheuStructTraceResult,
  195. OrpheuStructPhysent,
  196. OrpheuStructPmplane,
  197. OrpheuStructPmtrace,
  198. OrpheuStructWeaponData,
  199. OrpheuStructAmmoInfo,
  200. OrpheuStructItemInfo,
  201. OrpheuStructTask,
  202. OrpheuStructSchedule,
  203. OrpheuStructKeyValueData
  204. }
  205.  
  206.  
  207. native OrpheuGetBytesAtAddress(address,bytes[],count)
  208. native OrpheuGetFunctionAddress(OrpheuFunction:function)
  209. native OrpheuStruct:OrpheuGetStructFromAddress(OrpheuStructType:structType,address)
  210. native OrpheuFunction:OrpheuCreateFunction(address,const libFunctionName[],const classname[]="")
  211. native OrpheuGetFunctionOffset(OrpheuFunction:function)
  212. native OrpheuGetLibraryAddress(const libraryName[])
  213. native OrpheuGetNextCallAtAddress(address,number)
  214.  
  215.  
  216.  
  217. /**
  218.  * Retrieves an engine function handler by having its name as a member of the struct that hold
  219.  * engine functions and the name that you give it in the file where you define the function
  220.  * The name must be the same as the one in the file where the function is defined
  221.  *
  222.  * @param memberName The name of the member of the struct that holds the address of the function
  223.  * Example: pfnPrecacheModel
  224.  * The struct representation can be seen in hlsdk at multiplayer/engine/eiface.h with the name "enginefuncs_s"
  225.  *
  226.  * @param libFunctionName The name of the function as it is in the file where the function is defined
  227.  *
  228.  * @return A handler to the function
  229.  */
  230. stock OrpheuFunction:OrpheuGetEngineFunction(const memberName[],const libFunctionName[])
  231. {
  232. static OrpheuStruct:engineFunctions
  233.  
  234. if(!engineFunctions)
  235. {
  236. engineFunctions = OrpheuGetEngineFunctionsStruct()
  237. }
  238.  
  239. return OrpheuCreateFunction( OrpheuGetStructMember(engineFunctions,memberName),libFunctionName )
  240. }
  241.  
  242. /**
  243.  * Retrieves a dll function handler by having its name as a member of the struct that hold
  244.  * dll functions and the name that you give it in the file where you define the function
  245.  * The name must be the same as the one in the file where the function is defined
  246.  *
  247.  * @param memberName The name of the member of the struct that holds the address of the function
  248.  * Example: pfnGameInit
  249.  * The struct representation can be seen in hlsdk at multiplayer/engine/eiface.h with the name "DLL_FUNCTIONS"
  250.  *
  251.  * @param libFunctionName The name of the function as it is in the file where the function is defined
  252.  *
  253.  * @return A handler to the function
  254.  */
  255. stock OrpheuFunction:OrpheuGetDLLFunction(const memberName[],const libFunctionName[])
  256. {
  257. static OrpheuStruct:OrpheuDLLFunctions
  258.  
  259. if(!OrpheuDLLFunctions)
  260. {
  261. OrpheuDLLFunctions = OrpheuGetDLLFunctionsStruct()
  262. }
  263.  
  264. return OrpheuCreateFunction( OrpheuGetStructMember(OrpheuDLLFunctions,memberName),libFunctionName )
  265. }
  266.  
  267. stock OrpheuHook:OrpheuRegisterHookFromClass(const entityClassName[],const libFunctionName[],const libClassName[],const hookFunctionName[],OrpheuHookPhase:phase = OrpheuHookPre)
  268. {
  269. return OrpheuRegisterHook(OrpheuGetFunctionFromClass(entityClassName,libFunctionName,libClassName),hookFunctionName,phase)
  270. }
  271.  
  272. stock OrpheuHook:OrpheuRegisterHookFromEntity(id,const libFunctionName[],const libClassName[],const hookFunctionName[],OrpheuHookPhase:phase = OrpheuHookPre)
  273. {
  274. return OrpheuRegisterHook(OrpheuGetFunctionFromEntity(id,libFunctionName,libClassName),hookFunctionName,phase)
  275. }
  276.  
  277. stock OrpheuHook:OrpheuRegisterHookFromObject(object,const libFunctionName[],const libClassName[],const hookFunctionName[],OrpheuHookPhase:phase = OrpheuHookPre)
  278. {
  279. return OrpheuRegisterHook(OrpheuGetFunctionFromObject(object,libFunctionName,libClassName),hookFunctionName,phase)
  280. }
  281.  
  282. // *** CHOOSE YOUR VAULT MODULE HERE ***
  283.  
  284. //#include <sqlx> // Save data using sqlx (comment to disable)
  285. #include <nvault> // Save data using nVault (comment to disable)
  286.  
  287.  
  288. /***************************************************************\
  289. - Customizatios -
  290. \***************************************************************/
  291. #define DO_RESPAWN // comment to disable
  292. #define RESPAWN_DELAY 3.0 // automatic respawn in x sec.
  293. #define MAXKS 64 // maximum killstreak rewards a player can hold
  294. #define AUTOJOIN // comment to disable (credits to VEN)
  295. #define ADMIN_ACCESS_FLAG ADMIN_RCON // admin access flas
  296. #define XACCURATE // doubles accuracy (comment to disable)
  297.  
  298. //#define TEST_MODE // this should only be On for testing (comment to disable)
  299.  
  300. // available weapons (DEagle is given as secondary for all classes)
  301. new const PLAYER_CLASSES[] = { CSW_M4A1, CSW_P90, CSW_AK47, CSW_SCOUT, CSW_M249, CSW_M3 }
  302.  
  303. /******************** modify at your own risk! *****************\
  304. - -
  305. - or if you touch 'em... did you know how sharp this sword is? -
  306. - -
  307. - o==[]::::::::::::::::> -
  308. - -
  309. \***************************************************************/
  310. #define USUR 0.40 // User Screen(hud) Update Rate in sec. (0.20 and above no lags)
  311. #define CLASSMAX 6 // no change
  312. #define TIME_LIMIT 10.0 // map time limit
  313. #define SCORE_LIMIT 7500 // score limit
  314. #define RESTART_DELAY 16.0 // seconds after round end until new round start
  315. #define MAX_KS_SET 3 // maximum killstreak rewards per player
  316. #define GODMODE_DELAY 2.0 // on respawn you get x sec godmode
  317. #define HP_LIMIT 100.0 // health max
  318. #define HUD_POS_X 0.02 // my hud x (percentage. 0.5 = in center)
  319. #define HUD_POS_Y 0.9 // my hud y (percentage)
  320. #define LIGHT_SPEED 440.0 // speed when having lightwight on
  321. #define DEF_SPEED 240.0 // default speed
  322. #define REMOVE_DROPPED 15.0 // remove guns after x sec. (comment to disable)
  323. #define DAMAGE_MULTI 1.5 // damage multiplier (when having StoppingPower or DangerClose on)
  324. #define LASTSTAND_DUR 10.0 // the amount of time you live in Last Stand perk
  325. #define MARTYRDOM_D 2.5 // seconds to explosion
  326. #define MARTYRDOM_DS 3 // how many deaths no kills, to get a martyrdom
  327. #define DMGTIME_XTRA 0.35 // add a little more time to grenade explosion time
  328. #define GL_SAFTY_RANGE 250.0 // grenade launcher safty range (how long has to travel in order to explode!) (GL_POWER[3])
  329. #define GL_MAX 2 // max nubetubes player can carry
  330. #define CLASS_CHANGE_D 3.5 // seconds takes to change class (one man army)
  331. #define ATTN_LOUD 0.25 // grenade sound range
  332. #define HIDE_NORMAL (1<<1)|(1<<4)|(1<<5) // Flashlight, Timer, Money
  333.  
  334. // this is my baby. mmmuuah
  335. #define USERPERKS(%1,%2) (perks[%1][player_class[%1]][%2])
  336. #define USEREQUIP(%1) (equipment[%1][player_class[%1]])
  337. #define USERKSR(%1) (player_killstreak_queue[%1][player_killstreak_index[%1]])
  338. #define USERRANK(%1) (RANK_LABLE[player_rank[%1] - 1])
  339. #define SAMETEAM(%1,%2) (get_user_team(%1) == get_user_team(%2))
  340. #define eng_get_user_health(%1) floatround(GET_health(%1))
  341. #define ADD_LANGUAGE(%1) formatex(tempLable,charsmax(tempLable),"%L",LANG_PLAYER,%1)
  342. #define NAME_FORMAT " %i [%s] %L: %s" // rank - ranklable - enemy/friend - Name
  343. #define HUD_FORMAT "%L:[%s] %L: %i [%s] " // Class: - Rank: rank - ranklable
  344. #define PITCH_RANDOM(%1) random_num(100-%1,100+%1) // random pitch for emit_sound
  345. #define VALIDTEAM(%1) (%1 == TEAM_T || %1 == TEAM_CT)
  346. #define emit_sound_amb(%1,%2,%3,%4,%5) engfunc(EngFunc_EmitAmbientSound, 0, %1, %2, %3, %4, 0, %5)
  347. #define IS_SEC(%1) (%1 == CSW_DEAGLE || %1 == CSW_GLOCK18)
  348. #define RESET_MODEL(%1) set_user_info(%1, "model", g_playermodel[%1])
  349.  
  350. // user ent values set/get
  351. #define GET_NADE_TYPE(%1) entity_get_int(%1, EV_INT_flTimeStepSound)
  352. #define SET_NADE_TYPE(%1,%2) entity_set_int(%1, EV_INT_flTimeStepSound, %2)
  353. #define GET_ATTACHED(%1) entity_get_edict(%1, EV_ENT_euser1)
  354. #define SET_ATTACHED(%1,%2) entity_set_edict(%1, EV_ENT_euser1, %2)
  355. #define GET_STUCK(%1) entity_get_int(%1, EV_INT_iuser1)
  356. #define SET_STUCK(%1,%2) entity_set_int(%1, EV_INT_iuser1, %2)
  357. #define GET_TRIGGERED(%1) entity_get_int(%1, EV_INT_iuser2)
  358. #define SET_TRIGGERED(%1,%2) entity_set_int(%1, EV_INT_iuser2, %2)
  359. #define GET_COUNTS_KS(%1) entity_get_int(%1, EV_INT_iuser4)
  360. #define SET_COUNTS_KS(%1,%2) entity_set_int(%1, EV_INT_iuser4, %2)
  361. #define GET_CP_CONTAINS(%1) entity_get_int(%1, EV_INT_iuser1)
  362. #define SET_CP_CONTAINS(%1,%2) entity_set_int(%1, EV_INT_iuser1, %2)
  363. #define GET_SENTRY_ACTIVE(%1) entity_get_int(%1, EV_INT_iuser2)
  364. #define SET_SENTRY_ACTIVE(%1,%2) entity_set_int(%1, EV_INT_iuser2, %2)
  365. #define GET_SENTRY_TARGET(%1) entity_get_int(%1, EV_INT_iuser3)
  366. #define SET_SENTRY_TARGET(%1,%2) entity_set_int(%1, EV_INT_iuser3, %2)
  367. #define SET_SENTRY_TILT_TURRET(%1,%2) set_pev(%1, pev_controller_1, %2) // has to be pev_
  368.  
  369. // easier switching
  370. #define SET_origin(%1,%2) entity_set_origin(%1, %2) // bugfix
  371. #define GET_owner(%1) entity_get_edict(%1, EV_ENT_owner)
  372. #define SET_owner(%1,%2) entity_set_edict(%1, EV_ENT_owner, %2)
  373. #define GET_classname(%1,%2) entity_get_string(%1, EV_SZ_classname, %2, charsmax(%2))
  374. #define SET_classname(%1,%2) entity_set_string(%1, EV_SZ_classname, %2)
  375. #define SET_viewmodel(%1,%2) entity_set_string(%1, EV_SZ_viewmodel, %2)
  376. #define GET_dmgtime(%1) entity_get_float(%1, EV_FL_dmgtime)
  377. #define SET_dmgtime(%1,%2) entity_set_float(%1, EV_FL_dmgtime, %2)
  378. #define SET_nextthink(%1,%2) entity_set_float(%1, EV_FL_nextthink, %2)
  379. #define GET_health(%1) entity_get_float(%1, EV_FL_health)
  380. #define SET_health(%1,%2) entity_set_float(%1, EV_FL_health, %2)
  381. #define GET_takedamage(%1) entity_get_float(%1, EV_FL_takedamage)
  382. #define SET_takedamage(%1,%2) entity_set_float(%1, EV_FL_takedamage, %2)
  383. #define SET_armorvalue(%1,%2) entity_set_float(%1, EV_FL_armorvalue, %2)
  384. #define SET_frame(%1,%2) entity_set_float(%1, EV_FL_frame, %2)
  385. #define SET_framerate(%1,%2) entity_set_float(%1, EV_FL_framerate, %2)
  386. #define SET_maxspeed(%1,%2) entity_set_float(%1, EV_FL_maxspeed, %2)
  387. #define SET_gravity(%1,%2) entity_set_float(%1, EV_FL_gravity, %2)
  388. #define GET_flFallVelocity(%1) entity_get_float(%1, EV_FL_flFallVelocity)
  389. #define GET_velocity(%1,%2) entity_get_vector(%1, EV_VEC_velocity, %2)
  390. #define SET_velocity(%1,%2) entity_set_vector(%1, EV_VEC_velocity, %2)
  391. #define GET_absmax(%1,%2) entity_get_vector(%1, EV_VEC_absmax, %2)
  392. #define GET_angles(%1,%2) entity_get_vector(%1, EV_VEC_angles, %2)
  393. #define SET_angles(%1,%2) entity_set_vector(%1, EV_VEC_angles, %2)
  394. #define GET_mins(%1,%2) entity_get_vector(%1, EV_VEC_mins, %2)
  395. #define GET_v_angle(%1,%2) entity_get_vector(%1, EV_VEC_v_angle, %2)
  396. #define SET_punchangle(%1,%2) entity_set_vector(%1, EV_VEC_punchangle, %2)
  397. #define GET_origin(%1,%2) entity_get_vector(%1, EV_VEC_origin, %2)
  398. #define SET_body(%1,%2) entity_set_int(%1, EV_INT_body, %2)
  399. #define SET_sequence(%1,%2) entity_set_int(%1, EV_INT_sequence, %2)
  400. #define GET_button(%1) entity_get_int(%1, EV_INT_button)
  401. #define SET_button(%1,%2) entity_set_int(%1, EV_INT_button, %2)
  402. #define GET_flags(%1) entity_get_int(%1, EV_INT_flags)
  403. #define SET_flags(%1,%2) entity_set_int(%1, EV_INT_flags, %2)
  404. #define GET_spawnflags(%1) entity_get_int(%1, EV_INT_spawnflags)
  405. #define SET_spawnflags(%1,%2) entity_set_int(%1, EV_INT_spawnflags, %2)
  406. #define GET_effects(%1) entity_get_int(%1, EV_INT_effects)
  407. #define SET_effects(%1,%2) entity_set_int(%1, EV_INT_effects, %2)
  408. #define SET_colormap(%1,%2) entity_set_int(%1, EV_INT_colormap, %2)
  409. #define SET_watertype(%1,%2) entity_set_int(%1, EV_INT_watertype, %2)
  410. #define SET_movetype(%1,%2) entity_set_int(%1, EV_INT_movetype, %2)
  411. #define GET_solid(%1) entity_get_int(%1, EV_INT_solid)
  412. #define SET_solid(%1,%2) entity_set_int(%1, EV_INT_solid, %2)
  413. #define SET_flTimeStepSound(%1,%2) entity_set_int(%1, EV_INT_flTimeStepSound, %2)
  414. #define GET_frags(%1) floatround(entity_get_float(%1, EV_FL_frags))
  415. #define SET_frags(%1,%2) entity_set_float(%1, EV_FL_frags, float(%2))
  416.  
  417. // MW2 rankings
  418. #define RANKING_DIFFICULTY po_difficulty * 100.0
  419. #define LEVEL_REQ_XP(%1) floatround(floatpower(float(%1) * RANKING_DIFFICULTY, 1.4054467)) // the fomula
  420. #define MAXRANK 70 // last rank MW2 default (no change)
  421.  
  422. // uav
  423. #define UAV_DUR 30.0 // how long uav stays on in seconds
  424.  
  425. // predator missile
  426. #define PREDATOR_SPEED 700 // predator missile speed normal
  427. #define ATTN_PREDATOR 0.1 // explosion sound range (used in emit_sound)
  428.  
  429. // care packare
  430. #define CP_RESUPPLY -5 // resupply
  431. #define CP_TAKE_SPEED floatround(USUR * 100.0) // taking speed for owner
  432. #define CP_STEAL_SPEED floatround(USUR * 25.0) // taking speed for others
  433.  
  434. // sentries (credits to The_Thing)
  435. #define SENTRY_HEALTH 200 // Health
  436. #define SENTRY_LIFE 90.0 // Seconds
  437. #define SENTRY_RANGE 1300.0 // Range
  438. #define SENTRY_RETARGET 1.0 // change target delay
  439. #define SENTRY_DAMAGE 28.0 // sentry bullet damage
  440.  
  441. // precision
  442. #define P_MAXBOMBS 10 // amount of bombs dropped from precision air strike
  443. #define P_BOMBSPACE 80 // space between each bomb
  444.  
  445. // stealth
  446. #define MAXBOMBS 5 // amount of bombs dropped from stealth bomber
  447. #define BOMBSPACE 150 // space between each bomb
  448. #define PLANE_Z 200 // plane height from ground
  449.  
  450. // EMP
  451. #define EMP_HIDE_FLAGS (1<<0)|(1<<1)|(1<<3)|(1<<4)|(1<<5) // hide in order: CAL + FLASH + RHA + TIMER + MONEY
  452. #define EMP_DUR 60.0 // how long emp stays on in seconds
  453.  
  454. // class menu options
  455. #define CREATE_YES -1
  456. #define CREATE_NO -2
  457.  
  458. // CS Teams
  459. #define TEAM_UNASSIGNED 0
  460. #define TEAM_T 1
  461. #define TEAM_CT 2
  462. #define TEAM_SPECTATOR 3
  463.  
  464. // CS zoom (cstrike.h)
  465. #define CS_FIRST_ZOOM 0x28
  466. #define CS_SECOND_AWP_ZOOM 0xA
  467. #define CS_SECOND_NONAWP_ZOOM 0xF
  468. #define CS_AUGSG552_ZOOM 0x37
  469. #define CS_NO_ZOOM 0x5A
  470.  
  471. // for Last Stand perk
  472. #define LS_WID 0
  473. #define LS_KILLER 1
  474.  
  475. // Radius Damage Ratios (gl_radius_damage)
  476. #define RDR_PREDATOR 2.50 // predator missile
  477. #define RDR_STEALTH 2.00 // stealth bomber
  478. #define RDR_PRECISION 1.50 // precision airstrike
  479.  
  480. // grenade types
  481. #define GT_FRAG 1111
  482. #define GT_SEMTEX 2222
  483. #define GT_FLASH 3333
  484. #define GT_SMOKE 4444
  485.  
  486. // low health indicator stats
  487. enum { HI_HIDE, HI_SHOW, HI_FLASH }
  488.  
  489. // Task offsets
  490. enum (+= 100)
  491. {
  492. TASK_MAINLOOP = 2000,
  493. TASK_GIVESTUFF,
  494. TASK_RESPAWN,
  495. TASK_GODMODE_OFF,
  496. TASK_PHURT,
  497. TASK_PBETTER,
  498. TASK_MELEE,
  499. TASK_MELEE_Q,
  500. TASK_ANNOUNCE,
  501. TASK_DEATH,
  502. TASK_CLAYMORE_EXPLODE,
  503. TASK_TACTICAL_INSERTION,
  504. TASK_MESSAGE_BONUS,
  505. TASK_SEMTEX_STICK,
  506. TASK_CLASS_CHANGE,
  507. TASK_ONTARGET,
  508. TASK_TARGET_RESET,
  509. TASK_SENTRY_ACTIVATE,
  510. TASK_SENTRY_DEACTIVATE,
  511. TASK_SENTRY_REMOVE,
  512. TASK_PRED_FLY,
  513. TASK_CAREPACKAGE,
  514. TASK_UN_EMP,
  515. TASK_PRECISIONAIRSTRIKE,
  516. TASK_STEALTHBOMBER,
  517. TASK_TACTICAL_NUKE
  518. }
  519.  
  520. // perk types
  521. enum { BLUE_PERK, RED_PERK, GREEN_PERK }
  522.  
  523. // perks
  524. enum {
  525. // Blue perks
  526. PERK_MARATHON,
  527. PERK_SLEIGHT_OF_HAND,
  528. PERK_SCAVENGER,
  529. PERK_BLING, // unavailable
  530. PERK_ONE_MAN_ARMY,
  531. // red perks
  532. PERK_STOPPING_POWER,
  533. PERK_LIGHTWEIGHT,
  534. PERK_HARDLINE,
  535. PERK_COLD_BLOODED,
  536. PERK_DANGER_CLOSE,
  537. // green perks
  538. PERK_COMMANDO,
  539. PERK_STEADY_AIM,
  540. PERK_SCRAMBLER,
  541. PERK_NINJA,
  542. PERK_SITREP, // unavailable
  543. PERK_LAST_STAND
  544. }
  545.  
  546. // equipments
  547. enum
  548. {
  549. UE_FRAG,
  550. UE_SEMTEX,
  551. UE_THROWING_KNIFE,
  552. UE_TACTICAL_INSERTION,
  553. UE_CLAYMORE,
  554. UE_C4
  555. }
  556.  
  557. // *** THIS IS NOT IN ORIGINAL ORDER ***
  558. // I'm still working on them
  559. // killstreak rewards
  560. enum
  561. {
  562. KSR_UAV,
  563. KSR_CARE_PACKAGE,
  564. KSR_PREDATOR_MISSILE,
  565. KSR_SENTRY_GUN,
  566. KSR_PRECISION_AIRSTRIKE,
  567. KSR_STEALTH_BOMBER,
  568. KSR_EMP,
  569. KSR_TACTICAL_NUKE,
  570. KSR_TOTAL
  571. }
  572.  
  573. // required kills for reward
  574. new const KILLS_REQUIRED[] =
  575. {
  576. 3, // uav
  577. 4, // care
  578. 5, // pred
  579. 6, // sentry
  580. 7, // prec
  581. 9, // stealth
  582. 15,// emp
  583. 25 // nuke
  584. }
  585.  
  586. // care package reward chances
  587. new const CP_CHANCE[] =
  588. {
  589. // 55 // Resupply!
  590. 18, // uav
  591. 0, // - (invalid)
  592. 7, // pred
  593. 6, // sentry
  594. 9, // prec
  595. 3, // stealth
  596. 2, // emp
  597. 0 // - (invalid)
  598. }
  599.  
  600. // killstreak reward lables
  601. new const KILLSTREAK_LABLE[][] =
  602. {
  603. "UAV",
  604. "Care Package",
  605. "Predator Missile",
  606. "Sentry Gun",
  607. "Precision Airstrike",
  608. "Stealth Bomber",
  609. "EMP",
  610. "Tactical Nuke"
  611. }
  612.  
  613. // killstreaks use extra XP
  614. new const KS_USE_POINT[] =
  615. {
  616. 150, // uav
  617. 100, // care
  618. 100, // pred
  619. 100, // sentry
  620. 150, // prec
  621. 200, // stealth
  622. 400, // emp
  623. 150 // nuke
  624. }
  625.  
  626. // killstreak sound types
  627. // used in KSE_SOUNDS
  628. enum
  629. {
  630. KSST_ACHIEVE1,
  631. KSST_ACHIEVE2,
  632. KSST_ENEMY,
  633. KSST_FRIENDLY
  634. }
  635.  
  636. // bonus messages
  637. enum
  638. {
  639. BM_PAYBACK,
  640. BM_BUZZKILL,
  641. BM_BULLS_EYE,
  642. BM_STUCK,
  643. BM_RESCUER,
  644. BM_HIJACKER,
  645. BM_FIRST_BLOOD,
  646. BM_COMEBACK,
  647. BM_DOUBLE_KILL,
  648. BM_TRIPLE_KILL,
  649. BM_MULTI_KILL,
  650. BM_LONGSHOT,
  651. BM_SHARE_PACKAGE,
  652. BM_ONE_SHOT_KILL,
  653. BM_HEADSHOT,
  654. BM_AFTER_LIFE,
  655. BM_ASSISTED_SUICIDE,
  656. BM_EXECUTION,
  657. BM_AVENGER
  658. }
  659.  
  660. // bonus messages points
  661. new const MESSAGE_POINTS[] =
  662. {
  663. 50,
  664. 100,
  665. 50,
  666. 50,
  667. 50,
  668. 100,
  669. 100,
  670. 100,
  671. 50,
  672. 75,
  673. 100,
  674. 50,
  675. 100,
  676. 50,
  677. 50,
  678. 25,
  679. 350,
  680. 100,
  681. 50
  682. }
  683.  
  684. // bonus messages lables
  685. new const MESSAGE_LABLE[][] =
  686. {
  687. "Fenomenalis!",
  688. "Tokeletes K.O!",
  689. "Elpusztithatatlan!",
  690. "Gyilkologep!",
  691. "Az arena kiralya!",
  692. "HS Oszto!",
  693. "Ver Furdo!",
  694. "Elkepeszto!",
  695. "Double Kill!",
  696. "Triple Kill!",
  697. "Multi Kill!",
  698. "Mazlista!",
  699. "Share Package!",
  700. "Egy loves egy oles",
  701. ".:!!FEJLOVES!!:.",
  702. "Akar mint Hitler!",
  703. "Bergyilkos!",
  704. "Kivegzo!",
  705. "Bosszuallo!"
  706. }
  707.  
  708. // player ranking lables (MW2!)
  709. new const RANK_LABLE[MAXRANK][]=
  710. {
  711. "Civil",
  712. "Katona",
  713. "Kozlegeny",
  714. "Kozlegeny I",
  715. "Kozlegeny II",
  716. "Kozlegeny III",
  717. "Elsorendu Kozlegeny",
  718. "Elsorendu Kozlegeny I",
  719. "Elsorendu Kozlegeny II",
  720. "Specialista",
  721. "Specialista I",
  722. "Specialista II",
  723. "Ormester",
  724. "Ormester I",
  725. "Ormester II",
  726. "Tizedes",
  727. "Szazados",
  728. "Ezredes",
  729. "Elsorendu Ezredes",
  730. "Elsorendu Ezredes I",
  731. "Elsorendu Ezredes II",
  732. "Veteran",
  733. "Veteran I",
  734. "Veteran II",
  735. "Fegyver Mester",
  736. "Fegyver Mester I",
  737. "Fegyver Mester II",
  738. "Tuz Szeresz",
  739. "Specialis Ornagy",
  740. "Specialis Ornagy I",
  741. "Specialis Ornagy II",
  742. "Kepzett Veteran",
  743. "Kepzett Veteran I",
  744. "Kepzett Hadnagy",
  745. "Kepzett Hadnagy I",
  746. "Kepzett Hadnagy II",
  747. "Specialis Ezredes",
  748. "Specialis Ezredes I",
  749. "Specialis Ezredes II",
  750. "Kapitany",
  751. "Kapitany I",
  752. "Kapitany II",
  753. "Specialis Kapitany",
  754. "Specialis Kapitany I",
  755. "Specialis Kapitany II",
  756. "Bergyilkos",
  757. "Bergyilkos I",
  758. "Bergyilkos II",
  759. "HS Oszto",
  760. "HS Oszto I",
  761. "HS Oszto II",
  762. "Colonel II",
  763. "Colonel III",
  764. "Fel Isten",
  765. "Orult",
  766. "Orult I",
  767. "Orult Mesterfokon",
  768. "Eszmeletlen",
  769. "Eszmeletlen I",
  770. "Eszmeletlen II",
  771. "Legendas",
  772. "Legendas I",
  773. "Legendas II",
  774. "Generalis",
  775. "Generalis I",
  776. "Generalis II",
  777. "Rambooo",
  778. "SWAT SHIELD",
  779. "Isten",
  780. "Szuper Kommandos (MesterFokon)"
  781. }
  782.  
  783. // pdata offsets
  784. const EXTRAOFFSET = 5
  785. const EXTRAOFFSET_WEAPONS = 4
  786. const OFFSET_MAPZONE = 235
  787. const OFFSET_ZOOMTYPE = 363
  788. const OFFSET_CSDEATHS = 444
  789. const OFFSET_HE_AMMO = 388
  790. const m_rgpPlayerItems_Slot0 = 367
  791. const m_pNext = 42
  792. const m_iId = 43
  793. const m_pActiveItem = 373
  794. const m_pPlayer = 41
  795. const m_fInReload = 54
  796. const m_flNextAttack = 83
  797. const m_flNextPrimaryAttack = 46
  798. const m_flNextSecondaryAttack = 47
  799. const m_iShotsFired = 64
  800.  
  801. const IC_FLASHLIGHT = 100
  802.  
  803. // stuff for Display_Fade
  804. const UNIT_SECOND = (1<<12)
  805. const FFADE_IN = 0x0000
  806. const FFADE_OUT = 0x0001
  807. const FFADE_MODULATE = 0x0002
  808. const FFADE_STAYOUT = 0x0004
  809.  
  810. // catch shot event (credits to VEN)
  811. new g_fwid, g_guns_eventids_bitsum
  812. new const g_guns_events[][] = {
  813. "events/awp.sc",
  814. "events/g3sg1.sc",
  815. "events/ak47.sc",
  816. "events/scout.sc",
  817. "events/m249.sc",
  818. "events/m4a1.sc",
  819. "events/sg552.sc",
  820. "events/aug.sc",
  821. "events/sg550.sc",
  822. "events/m3.sc",
  823. "events/xm1014.sc",
  824. "events/usp.sc",
  825. "events/mac10.sc",
  826. "events/ump45.sc",
  827. "events/fiveseven.sc",
  828. "events/p90.sc",
  829. "events/deagle.sc",
  830. "events/p228.sc",
  831. "events/glock18.sc",
  832. "events/mp5n.sc",
  833. "events/tmp.sc",
  834. "events/elite_left.sc",
  835. "events/elite_right.sc",
  836. "events/galil.sc",
  837. "events/famas.sc"
  838. }
  839.  
  840. // all wavs and mdls used.
  841. new const
  842. ROCKET_MDL[] = "models/grenade.mdl",
  843. MEDKIT_MDL[] = "models/w_battery.mdl",
  844. MARTYRDOM_MDL[] = "models/w_hegrenade.mdl",
  845. CLAYMORE_MODEL[] = "models/v_tripmine.mdl",
  846. CLAYMORE_TRIGGER_MODEL[] = "models/bag.mdl",
  847. C4_MODEL[] = "models/w_c4.mdl",
  848. TI_MODEL[] = "models/w_flare.mdl",
  849. PACKAGE_HELI_MODEL[] = "models/stealth.mdl", // c.p.
  850. PACKAGE_PACK_MODEL[] = "models/w_gaussammo.mdl", // c.p.
  851. PICKUP_SOUND[] = "items/gunpickup2.wav",
  852. NADEDROP_SOUND[] = "weapons/he_bounce-1.wav",
  853. DRY_SOUND[] = "weapons/dryfire1.wav",
  854. SWITCH_SOUND[] = "buttons/lightswitch2.wav",
  855. STEALTH_FLYBY_SOUND[] = "ambience/jetflyby1.wav", // c.p.
  856. NUKE_HIT_SOUND[] = "weapons/mortarhit.wav", // nuke
  857. SMOKE_SOUND[] = "weapons/sg_explode.wav",
  858.  
  859. TKNIFE_MODEL[] = "models/codmw2/w_throwingknife.mdl",
  860. KNIFE_DEP_SOUND[] = "codmw2/knife_deploy1.wav",
  861. KNIFE_HIT_SOUND[][] = { "codmw2/knife_hit1.wav", "codmw2/knife_hit2.wav" },
  862. KNIFE_WAL_SOUND[] = "codmw2/knife_hitwall1.wav",
  863. KNIFE_SLA_SOUND[] = "codmw2/knife_slash1.wav",
  864. KNIFE_STA_SOUND[] = "codmw2/knife_stab.wav",
  865. MENU1_SOUND[] = "codmw2/menu1.wav",
  866. ANNOUNCE_SOUND[] = "codmw2/announcer.wav",
  867. BONUS_SOUND[] = "codmw2/bonus.wav",
  868. FLASH_BEEP[] = "codmw2/fbeep.wav",
  869. GL_SOUND[] = "codmw2/gl_thro.wav",
  870. R_REL_SOUND[] = "codmw2/gl_relo.wav",
  871. EXPLDE_SOUND[] = "codmw2/gl_expl.wav",
  872. EXPLDE2_SOUND[][] = { "codmw2/gr_expl_1.wav", "codmw2/gr_expl_2.wav", "codmw2/gr_expl_3.wav" },
  873. MEDKIT_SOUND[] = "codmw2/mk_pickup.wav",
  874. SND_BETTER[] = "codmw2/pl_better.wav",
  875. BULLETX_SOUND[][] = { "codmw2/hitmark_0.wav", "codmw2/hitmark_1.wav", "codmw2/hitmark_2.wav", "codmw2/hitmark_3.wav" },
  876. SND_WARN[][] = { "codmw2/pl_hurt_1.wav", "codmw2/pl_hurt_2.wav", "codmw2/pl_hurt_3.wav" },
  877. CLAYMORE_SOUND[] = "codmw2/claymore.wav",
  878. CLAYMORE_T_SOUND[] = "codmw2/claymore_t.wav",
  879. THROW_SOUND[] = "codmw2/throw.wav",
  880. C4_STUCK_SOUND[] = "codmw2/c4_stuck.wav",
  881. C4_TRIGGER_SOUND[] = "codmw2/c4_trigger.wav",
  882. SEMTEX_SOUND[] = "codmw2/semtex.wav",
  883. TKNIFE_SOUND[] = "codmw2/tknife.wav",
  884. TI_SOUND[] = "codmw2/ti.wav",
  885. FLASH_SOUND[] = "codmw2/flashbang.wav",
  886. BADNEWS_SOUND[] = "codmw2/badnews.wav",
  887. HEADSHOT_SOUND[] = "codmw2/headshot.wav",
  888. WIND_SOUND[] = "codmw2/wind.wav",
  889. OMA_SOUND[] = "codmw2/oma_change.wav",
  890. TDM_SOUND[] = "codmw2/TDM.wav",
  891. MEND_SOUND[][] = { "codmw2/mission_success1.wav", "codmw2/mission_success2.wav", "codmw2/mission_fail1.wav", "codmw2/mission_fail2.wav" },
  892.  
  893. ROUND_START_SOUND[] = "codmw2/mp3/roundstart.mp3", // mp3
  894. ROUND_NUKE_SOUND[] = "codmw2/mp3/defeat_nuke.mp3",
  895. ROUND_LOSE_SOUND[] = "codmw2/mp3/roundlose.mp3",
  896. ROUND_WIN_SOUND[] = "codmw2/mp3/roundwin.mp3",
  897. LEVELUP_MP3[] = "codmw2/mp3/levelup2.mp3",
  898.  
  899. // sentry gun
  900. SENRYBASE_MODEL[] = "models/sentry.mdl",
  901. SENRY_MODEL[] = "models/codmw2/sentry1.mdl",
  902. SENTRY_BLT[] = "models/rshell.mdl",
  903. SENTRY_SHOOT[] = "codmw2/ks/sentry_shoot.wav",
  904. SENTRY_SPOT[] = "fvox/buzz.wav",
  905. SENTRY_READY[] = "buttons/button9.wav",
  906. SENTRY_BREAK[] = "buttons/spark6.wav",
  907.  
  908. // predator missile
  909. PR_EXPL_SOUND[][] = { "codmw2/ks/pr_explo_1.wav", "codmw2/ks/pr_explo_2.wav", "codmw2/ks/pr_explo_3.wav" },
  910. PR_FLY[] = "codmw2/ks/pr_fly.wav",
  911. PR_FLY_START[] = "codmw2/ks/pr_start.wav",
  912. PR_FLY_STOP[] = "codmw2/ks/pr_fly_stop.wav",
  913.  
  914. // tactical nuke
  915. NUKE_ALARM_SOUND[] = "codmw2/ks/nuke_alarm.wav",
  916.  
  917. // killstreak sounds + announces
  918. KSE_SOUNDS[][][] =
  919. {
  920. { "codmw2/ks_earn/uav_achieve1.wav", "codmw2/ks_earn/uav_achieve2.wav", "codmw2/ks_earn/uav_enemy.wav", "codmw2/ks_earn/uav_friendly.wav" }, // UAV
  921. { "codmw2/ks_earn/cp_achieve1.wav", "codmw2/ks_earn/cp_achieve2.wav", "codmw2/ks_earn/cp_enemy.wav", "codmw2/ks_earn/cp_friendly.wav" }, // CARE PACKAGE
  922. { "codmw2/ks_earn/pred_achieve1.wav", "codmw2/ks_earn/pred_achieve2.wav", "codmw2/ks_earn/pred_enemy.wav", "codmw2/ks_earn/pred_friendly.wav" }, // PREDATOR MISSILE
  923. { "codmw2/ks_earn/sentry_achieve1.wav", "codmw2/ks_earn/sentry_achieve2.wav", "codmw2/ks_earn/sentry_enemy.wav", "codmw2/ks_earn/sentry_friendly.wav" }, // SENTRY GUN
  924. { "codmw2/ks_earn/prec_achieve1.wav", "codmw2/ks_earn/stealth_achieve2.wav", "codmw2/ks_earn/prec_enemy.wav", "codmw2/ks_earn/stealth_friendly.wav" }, // PRECISION AIRSTRIKE
  925. { "codmw2/ks_earn/stealth_achieve1.wav", "codmw2/ks_earn/stealth_achieve2.wav", "codmw2/ks_earn/stealth_enemy.wav", "codmw2/ks_earn/stealth_friendly.wav" }, // STEALTH BOMBER
  926. { "codmw2/ks_earn/emp_achieve1.wav", "codmw2/ks_earn/emp_achieve2.wav", "codmw2/ks_earn/emp_enemy.wav", "codmw2/ks_earn/emp_friendly.wav" }, // EMP
  927. { "codmw2/ks_earn/nuke_achieve1.wav", "codmw2/ks_earn/nuke_achieve2.wav", "codmw2/ks_earn/nuke_enemy.wav", "codmw2/ks_earn/nuke_friendly.wav" } // TACTICAL NUKE
  928. }
  929.  
  930. // optional MW2 models
  931. new const V_AK47_MODEL[] = "models/codmw2/v_ak47.mdl" // AK47
  932. new const V_DEAGLE_MODEL[] = "models/codmw2/v_deagle.mdl" // DEAGLE
  933. new const V_M3_MODEL[] = "models/codmw2/v_m3.mdl" // SPAS-12
  934. new const V_M4A1_MODEL[] = "models/codmw2/v_m4a1.mdl" // M4A1
  935. new const V_M249_MODEL[] = "models/codmw2/v_m249.mdl" // M249
  936. new const V_SCOUT_MODEL[] = "models/codmw2/v_scout.mdl" // INTERVENTION
  937. new const V_P90_MODEL[] = "models/codmw2/v_p90.mdl" // P90
  938. new const V_KNIFE_MODEL[] = "models/codmw2/v_knife.mdl" // KNIFE
  939. new const V_GLOCK18_MODEL[] = "models/codmw2/v_glock18.mdl" // KNIFE
  940.  
  941. new const INTERVENTION_FIRE[] = "weapons/intervention_fire.wav" // intervention sound!!!
  942.  
  943. // all weapon names (without weapon_)
  944. new const WEAPONNAMES[][] = { "", "p228", "", "scout", "hegrenade", "xm1014", "c4", "mac10", "aug",
  945. "smokegrenade", "elite", "fiveseven", "ump45", "sg550", "galil", "famas",
  946. "usp", "glock18", "awp", "mp5navy", "m249", "m3", "m4a1", "tmp", "g3sg1",
  947. "flashbang", "deagle", "sg552", "ak47", "knife", "p90", "", ""}
  948.  
  949.  
  950. // Max BP ammo for weapons
  951. new const MAXBPAMMO[] = { -1, 52, -1, 90, 1, 32, 1, 100, 90, 1, 120, 100, 100, 90, 90, 90, 100, 120,
  952. 30, 120, 200, 32, 90, 120, 90, 2, 35, 90, 90, -1, 100 }
  953. // Max bullets in each pack
  954. new const AMMOPACK[] = { -1, 13, -1, 30, -1, 8, -1, 12, 30, -1, 30, 50, 12, 30, 30, 30, 12, 30,
  955. 10, 30, 30, 8, 30, 30, 30, -1, 7, 30, 30, -1, 50 }
  956. // ammo types (sorted by weapon index!)
  957. new const AMMOTYPE[][] = { "", "357sig", "", "762nato", "", "buckshot", "", "45acp", "556nato", "",
  958. "9mm", "57mm", "45acp", "556nato", "556nato", "556nato", "45acp", "9mm",
  959. "338magnum", "9mm", "556natobox", "buckshot", "556nato", "9mm", "762nato",
  960. "", "50ae", "556nato", "762nato", "", "57mm" }
  961.  
  962. new const WEAPONSLOT[] = {
  963. -1, 2, -1, 1, 4, 1, 5, 1, 1, 4, 2, 2, 1, 1, 1, 1, 2, 2, 1, 1, 1, 1, 1, 1, 1, 4, 2, 1, 1, 3, 1
  964. }
  965.  
  966. // objectives to remove
  967. new const g_objective_ents[][] = { "func_bomb_target", "info_bomb_target", "hostage_entity",
  968. "monster_scientist", "func_hostage_rescue", "info_hostage_rescue", "info_vip_start",
  969. "func_vip_safetyzone", "func_escapezone"
  970. }
  971.  
  972. // unreloadables
  973. const NOCLIP_WPN_BS = ((1<<2)|(1<<CSW_HEGRENADE)|(1<<CSW_SMOKEGRENADE)|(1<<CSW_FLASHBANG)|(1<<CSW_KNIFE)|(1<<CSW_C4))
  974. const SHOTGUNS_BS = ((1<<CSW_M3)|(1<<CSW_XM1014))
  975.  
  976. // lables for perks
  977. new const PERKS_LABLE[][] = {
  978. "[Bosszu Allo]",
  979. "[Formatum]",
  980. "[Mentos]",
  981. "[Szamuraj]",
  982. "[Extra Ero]",
  983.  
  984. "[Golyo allo]",
  985. "[Szuper Sebesseg]",
  986. "[Kemeny Vonalu]",
  987. "[Hidegveru]",
  988. "[Szuper Gyilkos]",
  989.  
  990. "[Kommandos]",
  991. "[No Recoil]",
  992. "[Harcos]",
  993. "[Ninja]",
  994. "[Helyzetjelento]",
  995. "[Modernizator]"
  996. }
  997.  
  998. // lables for equipments
  999. new const EQUIPMENTS_LABLE[][] = {
  1000. "[Titok]",
  1001. "[Hiper Granat]",
  1002. "[Dobo Kes]",
  1003. "[Taktikai Kozzetetel]",
  1004. "[Lezeres]",
  1005. "[C4 Mester]"
  1006. }
  1007.  
  1008. // load / save
  1009. #if defined _sqlx_included
  1010. new Handle:g_SqlTuple
  1011. new g_Error[512]
  1012. #endif
  1013. #if defined _nvault_included
  1014. new g_vault
  1015. #endif
  1016.  
  1017. // add language
  1018. new tempLable[128]
  1019.  
  1020. // class names
  1021. new const glnade_classname[] = "cod_glnade", medkit_classname[] = "cod_medkit", martyrdom_classname[] = "cod_martyrdom"
  1022. new const claymore_classname[] = "cod_claymore", claymore_trigger_classname[] = "cod_claymoret", c4_classname[] = "cod_c4", tknife_classname[] = "cod_tknife", ti_classname[] = "cod_ti"
  1023. new const sentrybase_classname[] = "sentrybase", sentry_classname[] = "sentry", sentryblt_classname[] = "sentrybullet"
  1024. new const pred_classname[] = "predator_missile", bomb_classname[] = "stealth_bomb", stealth_classname[] = "cod_stealth", package_classname[] = "care_package", pbomb_classname[] = "precision_bomb"
  1025.  
  1026. // grenade launcher settings
  1027. new const Float:GL_POWER[] = { 2.0, 1500.0, 110.0, 250.0 } // (delay,speed,damage,range)
  1028.  
  1029. // func_breakable materials
  1030. // 0 = Glass, 1 = Wood, 2 = Metal, 3 = Flesh, 4 = Cinder Block
  1031. // 5 = Ceiling Tile, 6 = Computer, 7 = Unbreakable Glass, 8 = Rocks
  1032. new const material_Computer[] = "6"
  1033.  
  1034. // Orpheu stuff
  1035. #define set_mp_pdata(%1,%2) ( OrpheuMemorySetAtAddress( g_pGameRules, %1, 1, %2 ) )
  1036. #define get_mp_pdata(%1) ( OrpheuMemoryGetAtAddress( g_pGameRules, %1 ) )
  1037. enum /* Win Status */
  1038. {
  1039. WinStatus_Ct = 1,
  1040. WinStatus_Terrorist,
  1041. WinStatus_RoundDraw
  1042. };
  1043. new g_pGameRules
  1044.  
  1045. // global vars
  1046. new imp_falldamage
  1047. new bool:g_newround, Float:g_round_started_time, team_score[4], bool:score_freeze, winner
  1048. new g_maxplayers, g_maxentities
  1049. new spr_explosion, spr_trail, spr_white, spr_smoke, spr_money
  1050. new g_MsgSyncHUD, g_MsgSyncAX
  1051. new g_fwSpawn, g_fwPrecacheSound
  1052. new g_msgStatusIcon, g_msgScreenFade, g_msgDeathMsg, g_msgHostagePos, g_msgHostageK, g_msgBarTime2, g_msgHideWeapon, g_msgScreenShake, g_msgDamage, g_msgScoreInfo
  1053. new g_flasher, Float:flash_explosion_time // flash grenade things
  1054. new g_pluginenabled, toggle_used // MW2 enabled
  1055.  
  1056. new po_enable, po_skin, Float:po_difficulty, po_start_hp, po_medkit_hp, po_random_spawn, po_desert_fx
  1057. new sqlx_host[64], sqlx_user[32], sqlx_pass[32], sqlx_db[32]
  1058.  
  1059. // **************
  1060. // * Arrays *
  1061. // **************
  1062.  
  1063. // gameplay things
  1064. new Float:melee_time[33], bool:g_isFalling[33], hasgl[33], g_playermodel[33][32], g_playername[33][32],
  1065. bool:low_hp_warning[33], bool:had_knife[33], g_szAuthID[33][35], g_currentweapon[33],
  1066. Float:last_glnade[33], bool:glsets[33][3], player_used_bind[33], user_last_target[33],
  1067. Float:combo_time[33], player_combos[33] = 0, first_spawn[33], Float:aim_target[33],
  1068. g_assists[33], g_kills[33], g_deaths[33]
  1069.  
  1070. // XP things
  1071. new player_points[33], player_rank[33], temp_xp[33], first_killer, bool:is_selfkill[33]
  1072. new bool:got_bullseye[33], last_attacker[33], damage_count[33], damage_prcnt_from[33][33]
  1073. new bool:to_payback[33][33], bool:is_bullet_kill[33], bool:is_comeback[33], Float:last_kill[33]
  1074. new player_message_queue[33][16], player_message_index[33] // bonus message queue
  1075.  
  1076. // player class-perks, ks-sets
  1077. new player_class[33], is_creating[33], user_next_class[33], bool:is_changing[33]
  1078. new perks[33][CLASSMAX][3], in_last_stand[33][2], martyrdoms[32], death_inrow[33], bool:using_martyrdom[33]
  1079. new bool:user_killstreak_set[33][KSR_TOTAL], bool:user_ks_temp[33][KSR_TOTAL], bool:is_user_ks_set[33]
  1080.  
  1081. // Equipments stuff
  1082. new equipment[33][CLASSMAX]
  1083. new player_c4[33][2] // stores ent#
  1084. new player_claymore[33][2] // stores ent# (only 2 of them per person)
  1085. new player_ti[33] // stores ent# (only 1)
  1086. new bool:has_c4[33], bool:has_claymore[33], bool:has_ti[33], bool:has_tknife[33]
  1087.  
  1088. // killstreak stuff
  1089. new kills_no_deaths[33], player_killstreak_queue[33][MAXKS], player_killstreak_index[33]
  1090. new bool:killstreak_counts_ks[33][MAXKS]
  1091. new bool:hasUAV[4], Float:uavEndTime[4], has_sentry[33], bool:ignore_ks_add[33], user_ctrl_pred[33], user_pred_speed[33], user_stealth[33], user_precision[33]
  1092. new bool:is_EMPd[4], id_nuker, team_nuker, nuke_countdown, bool:is_nuke_time
  1093. new Float:cpd_time[33], cpd_taking_package[33], cpd_progress[33]
  1094.  
  1095. // random spawns from ZP 4.3 (credits to MeRcyLeZZ)
  1096. const MAX_CSDM_SPAWNS = 128
  1097. new g_spawnCount, g_spawnCount2 // available spawn points counter
  1098. new Float:g_spawns[MAX_CSDM_SPAWNS][3], Float:g_spawns2[MAX_CSDM_SPAWNS][3] // spawn points data
  1099.  
  1100. /*---------------------*\
  1101. - Plugin initialization -
  1102. \*---------------------*/
  1103. public plugin_init()
  1104. {
  1105. // plugin enable?
  1106. if (!g_pluginenabled) return
  1107.  
  1108. // language file
  1109. register_dictionary("cod_mw2.txt")
  1110.  
  1111. // events
  1112. register_event ("DeathMsg", "event_DeathMsg", "a", "1>0" ) // death event
  1113. register_event ("Damage", "event_Damage", "b", "2!0", "3=0", "4!0" ) // damage event
  1114. register_event ("HLTV", "event_HLTV", "a", "1=0", "2=0" ) // round start
  1115. register_event ("CurWeapon", "event_CurWeapon", "be", "1=1" ) // check weapon
  1116. register_event ("ResetHUD", "event_ResetHUD", "b" ) // random spawn
  1117.  
  1118. // fakemeta forwards
  1119. register_forward(FM_GetGameDescription, "fw_GetGameDescription")
  1120. #if defined XACCURATE
  1121. register_forward(FM_StartFrame, "fw_StartFrame")
  1122. #endif
  1123. // register_forward(FM_Touch, "fw_Touch")
  1124. register_forward(FM_CmdStart, "fw_CmdStart")
  1125. register_forward(FM_SetModel, "fw_SetModel")
  1126. register_forward(FM_EmitSound, "fw_EmitSound")
  1127. register_forward(FM_FindEntityInSphere, "fw_FindEntityInSphere", 0)
  1128. if (po_skin) register_forward(FM_SetClientKeyValue, "fw_SetClientKeyValue")
  1129. unregister_forward(FM_Spawn, g_fwSpawn)
  1130. unregister_forward(FM_PrecacheSound, g_fwPrecacheSound)
  1131.  
  1132. // catch shot event (credits to VEN)
  1133. unregister_forward(FM_PrecacheEvent, g_fwid, 1)
  1134. register_forward(FM_PlaybackEvent, "fw_PlaybackEvent")
  1135.  
  1136. // ham forwards
  1137. RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  1138. RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawn_Post", 1)
  1139. RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
  1140. RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
  1141. RegisterHam(Ham_Player_PreThink, "player", "fw_Player_PreThink")
  1142. RegisterHam(Ham_Player_PostThink, "player", "fw_Player_PostThink")
  1143. RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_scout", "fw_ScoutSecondaryAttack_Post", 1)
  1144. RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_m4a1", "fw_M4A1SecondaryAttack", 1)
  1145. RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_glock18", "CGLOCK18_PrimaryAttack_Post", true)
  1146.  
  1147. // self note: fw_Touch / fw_Player_PreThink / fw_Player_PostThink
  1148.  
  1149. new sWeapon[32]
  1150. for(new i=1; i<=CSW_P90; i++)
  1151. if(!(NOCLIP_WPN_BS&(1<<i)) && !(SHOTGUNS_BS&(1<<i)) && get_weaponname(i, sWeapon, charsmax(sWeapon)))
  1152. RegisterHam(Ham_Weapon_Reload, sWeapon, "Weapon_Reload", 1)
  1153.  
  1154. // console commands
  1155. register_clcmd("say", "cmd_say")
  1156. register_clcmd("glfire", "cmd_glfire")
  1157. register_clcmd("radio2", "cmd_glfire")
  1158. register_clcmd("radio3", "cmd_c4det")
  1159. register_clcmd("flashsmoke", "cmd_flashsmoke")
  1160. register_clcmd("codclass", "cmd_cchoose_menu")
  1161. register_clcmd("codkillstreak", "cmd_codkillstreak")
  1162. register_clcmd("chooseteam", "cmd_gamemenu")
  1163.  
  1164. // messages
  1165. g_msgStatusIcon = get_user_msgid("StatusIcon")
  1166. g_msgScreenFade = get_user_msgid("ScreenFade")
  1167. g_msgDeathMsg = get_user_msgid("DeathMsg")
  1168. g_msgBarTime2 = get_user_msgid("BarTime2")
  1169. g_msgHideWeapon = get_user_msgid("HideWeapon")
  1170. g_msgScreenShake= get_user_msgid("ScreenShake")
  1171. g_msgHostagePos = get_user_msgid("HostagePos")
  1172. g_msgHostageK = get_user_msgid("HostageK")
  1173. g_msgDamage = get_user_msgid("Damage")
  1174. g_msgScoreInfo = get_user_msgid("ScoreInfo")
  1175. register_message(g_msgStatusIcon, "msgStatusIcon")
  1176. register_message(g_msgScreenFade, "msgScreenFade")
  1177. register_message(g_msgHideWeapon, "msgHideWeapon")
  1178. #if defined AUTOJOIN
  1179. register_message(get_user_msgid("ShowMenu"), "msgShowMenu")
  1180. register_message(get_user_msgid("VGUIMenu"), "msgVGUIMenu")
  1181. #endif
  1182.  
  1183. // no dead bodies!
  1184. set_msg_block(get_user_msgid("ClCorpse"), BLOCK_SET)
  1185.  
  1186. // no radio sounds
  1187. set_msg_block(get_user_msgid("SendAudio"), BLOCK_SET)
  1188.  
  1189. // some global vars
  1190. g_maxplayers = get_maxplayers()
  1191. g_maxentities = global_get(glb_maxEntities)
  1192. g_MsgSyncHUD = CreateHudSyncObj()
  1193. g_MsgSyncAX = CreateHudSyncObj()
  1194.  
  1195. // load / save
  1196. #if defined _sqlx_included
  1197. set_task(1.0, "MySql_Init")
  1198. #endif
  1199. #if defined _nvault_included
  1200. g_vault = nvault_open(AUTHOR)
  1201. if (g_vault == INVALID_HANDLE) set_fail_state("Error opening nVault")
  1202. #endif
  1203.  
  1204. // mp cvar pointers
  1205. imp_falldamage = get_cvar_num("mp_falldamage") // just value
  1206.  
  1207. // cvar settings
  1208. set_cvar_num("sv_cheats", 1)
  1209. set_cvar_num("mp_playerid", 2)
  1210. set_cvar_num("mp_flashlight", 1)
  1211. // set_cvar_float("mp_buytime", 0.0)
  1212. // set_cvar_num("sv_skycolor_r", 0)
  1213. // set_cvar_num("sv_skycolor_g", 0)
  1214. // set_cvar_num("sv_skycolor_b", 0)
  1215.  
  1216. // announcements
  1217. Task_Announce()
  1218.  
  1219. // spawn spots
  1220. load_spawns()
  1221.  
  1222. #if !defined XACCURATE
  1223. set_task(0.1, "fw_StartFrame", _, _, _, "b")
  1224. #endif
  1225.  
  1226. // uav loop
  1227. set_task(2.0, "radar_scan", _, _, _, "b")
  1228.  
  1229. // sentry think
  1230. #if defined XACCURATE
  1231. set_task(0.1, "sentry_think", _, _, _, "b")
  1232. #endif
  1233.  
  1234. score_freeze = false
  1235. }
  1236.  
  1237. public plugin_end()
  1238. {
  1239. if (!g_pluginenabled) return
  1240.  
  1241. #if defined _sqlx_included
  1242. SQL_FreeHandle(g_SqlTuple)
  1243. #endif
  1244.  
  1245. #if defined _nvault_included
  1246. nvault_close(g_vault)
  1247. #endif
  1248. }
  1249.  
  1250.  
  1251.  
  1252. /*-------------------
  1253. | Plugin precache |
  1254.   -------------------*/
  1255. public plugin_precache()
  1256. {
  1257. // whos done all the work here?
  1258. register_plugin(PLUGIN, VERSION, AUTHOR)
  1259.  
  1260. // load the config file
  1261. load_cod_mw2_ini()
  1262.  
  1263. // To switch plugin on/off
  1264. register_concmd("cod_toggle", "cmd_toggle", _, "<1/0> - Enable/Disable Modern Warfare 2", 0)
  1265.  
  1266. if (toggle_used)
  1267. toggle_used = 0
  1268. else
  1269. g_pluginenabled = 1
  1270.  
  1271. if (!po_enable || !g_pluginenabled) return
  1272.  
  1273. // Orpheu
  1274. OrpheuRegisterHook(OrpheuGetFunction("InstallGameRules"), "OnInstallGameRules", OrpheuHookPost);
  1275.  
  1276. // precache files
  1277. new d
  1278. // avoid loading unneeded stuff (credits to MeRcyLeZZ)
  1279. g_fwSpawn = register_forward(FM_Spawn, "fw_Spawn")
  1280. g_fwPrecacheSound = register_forward(FM_PrecacheSound, "fw_PrecacheSound")
  1281.  
  1282. // catch shot event (credits to VEN)
  1283. g_fwid = register_forward(FM_PrecacheEvent, "fw_PrecacheEvent", 1)
  1284.  
  1285. // recache models, sounds, sprites
  1286. spr_explosion = precache_model("sprites/fexplo1.spr")
  1287. spr_trail = precache_model("sprites/smoke.spr")
  1288. spr_white = precache_model("sprites/white.spr")
  1289. spr_smoke = precache_model("sprites/black_smoke4.spr")
  1290. spr_money = precache_model("sprites/blood.spr")
  1291. precache_model(ROCKET_MDL)
  1292. precache_model(MEDKIT_MDL)
  1293. precache_model(MARTYRDOM_MDL)
  1294. precache_model(PACKAGE_HELI_MODEL)
  1295. precache_model(PACKAGE_PACK_MODEL)
  1296. precache_model(CLAYMORE_TRIGGER_MODEL)
  1297. precache_model(CLAYMORE_MODEL)
  1298. precache_model(C4_MODEL)
  1299. precache_model(TI_MODEL)
  1300. precache_model(TKNIFE_MODEL)
  1301. precache_model(SENRYBASE_MODEL)
  1302. precache_model(SENRY_MODEL)
  1303. precache_model(SENTRY_BLT)
  1304. precache_model("models/computergibs.mdl") // "6"
  1305.  
  1306. // optional mw2 models/sounds
  1307. if (po_skin)
  1308. {
  1309. for (d = 1; d <= 3; d++){
  1310. new temp[64]
  1311. formatex(temp, charsmax(temp), "models/player/rangers%i/rangers%i.mdl", d, d)
  1312. precache_model(temp)
  1313. formatex(temp, charsmax(temp), "models/player/spetsnaz%i/spetsnaz%i.mdl", d, d)
  1314. precache_model(temp)
  1315. }
  1316. precache_model(V_AK47_MODEL)
  1317. precache_model(V_DEAGLE_MODEL)
  1318. precache_model(V_M3_MODEL)
  1319. precache_model(V_M4A1_MODEL)
  1320. precache_model(V_M249_MODEL)
  1321. precache_model(V_SCOUT_MODEL)
  1322. precache_model(V_P90_MODEL)
  1323. precache_model(V_KNIFE_MODEL)
  1324. precache_model(V_GLOCK18_MODEL)
  1325. precache_sound("weapons/intervention_bolt1.wav")
  1326. precache_sound("weapons/intervention_bolt2.wav")
  1327. precache_sound("weapons/intervention_endbolt1.wav")
  1328. precache_sound("weapons/intervention_endbolt2.wav")
  1329. precache_sound("weapons/intervention_magin.wav")
  1330. precache_sound("weapons/intervention_magout.wav")
  1331. precache_sound("weapons/m249_boxin.wav")
  1332. precache_sound("weapons/m249_boxout.wav")
  1333. precache_sound("weapons/m249_chain.wav")
  1334. precache_sound("weapons/m249_coverdown.wav")
  1335. precache_sound("weapons/m249_coverup.wav")
  1336. precache_sound("weapons/rpd_boltpull.wav")
  1337. precache_sound("weapons/M4A1_Carbine/Clipin.wav")
  1338. precache_sound("weapons/M4A1_Carbine/Clipout.wav")
  1339. precache_sound("weapons/M4A1_Carbine/cloth.wav")
  1340. precache_sound("weapons/M4A1_Carbine/Forearm.wav")
  1341. precache_sound("weapons/p90_cock.wav")
  1342. precache_sound("weapons/p90_magin.wav")
  1343. precache_sound("weapons/p90_magout.wav")
  1344. precache_sound("weapons/p90_unlock.wav")
  1345. precache_sound("weapons/Glock/Glock_clipin.wav")
  1346. precache_sound("weapons/Glock/Glock_clipout.wav")
  1347. precache_sound("weapons/Glock/Glock_sliderelease.wav")
  1348. precache_sound("weapons/Glock/Glock_slipslap.wav")
  1349. precache_sound(INTERVENTION_FIRE)
  1350. }
  1351. precache_sound(SND_BETTER)
  1352. precache_sound(KNIFE_DEP_SOUND)
  1353. precache_sound(KNIFE_HIT_SOUND[0])
  1354. precache_sound(KNIFE_HIT_SOUND[1])
  1355. precache_sound(KNIFE_WAL_SOUND)
  1356. precache_sound(KNIFE_SLA_SOUND)
  1357. precache_sound(KNIFE_STA_SOUND)
  1358. precache_sound(ANNOUNCE_SOUND)
  1359. precache_sound(BONUS_SOUND)
  1360. precache_sound(FLASH_BEEP)
  1361. precache_sound(GL_SOUND)
  1362. precache_sound(R_REL_SOUND)
  1363. precache_sound(MEDKIT_SOUND)
  1364. precache_sound(MENU1_SOUND)
  1365. precache_sound(EXPLDE_SOUND)
  1366. precache_sound(PICKUP_SOUND)
  1367. precache_sound(DRY_SOUND)
  1368. precache_sound(SWITCH_SOUND)
  1369. precache_sound(NADEDROP_SOUND)
  1370. for (d = 0; d < 3; d++){
  1371. precache_sound(SND_WARN[d])
  1372. precache_sound(EXPLDE2_SOUND[d])
  1373. precache_sound(PR_EXPL_SOUND[d])
  1374. }
  1375. for (d = 0; d < 4; d++){
  1376. precache_sound(BULLETX_SOUND[d])
  1377. precache_sound(MEND_SOUND[d])
  1378. }
  1379. precache_sound(TDM_SOUND)
  1380. precache_sound(CLAYMORE_SOUND)
  1381. precache_sound(CLAYMORE_T_SOUND)
  1382. precache_sound(TI_SOUND)
  1383. precache_sound(THROW_SOUND)
  1384. precache_sound(C4_STUCK_SOUND)
  1385. precache_sound(C4_TRIGGER_SOUND)
  1386. precache_sound(SEMTEX_SOUND)
  1387. precache_sound(TKNIFE_SOUND)
  1388. precache_sound(FLASH_SOUND)
  1389. precache_sound(BADNEWS_SOUND)
  1390. precache_sound(WIND_SOUND)
  1391. precache_sound(ROUND_START_SOUND)
  1392. precache_sound(ROUND_NUKE_SOUND)
  1393. precache_sound(ROUND_LOSE_SOUND)
  1394. precache_sound(ROUND_WIN_SOUND)
  1395. precache_sound(HEADSHOT_SOUND)
  1396. precache_sound(OMA_SOUND)
  1397. precache_sound(SMOKE_SOUND)
  1398. precache_sound(LEVELUP_MP3)
  1399. precache_sound(SENTRY_SHOOT)
  1400. precache_sound(SENTRY_READY)
  1401. precache_sound(SENTRY_BREAK)
  1402. precache_sound(SENTRY_SPOT)
  1403. precache_sound(PR_FLY)
  1404. precache_sound(PR_FLY_STOP)
  1405. precache_sound(PR_FLY_START)
  1406. precache_sound(STEALTH_FLYBY_SOUND)
  1407. precache_sound(NUKE_ALARM_SOUND)
  1408. precache_sound(NUKE_HIT_SOUND)
  1409. precache_sound("debris/bustmetal1.wav") // "6"
  1410. precache_sound("debris/bustmetal2.wav") // "6"
  1411. precache_sound("debris/metal1.wav") // "6"
  1412. precache_sound("debris/metal3.wav") // "6"
  1413.  
  1414. // killstreak earn sounds
  1415. for (d = 0; d <= charsmax(KSE_SOUNDS); d++)
  1416. for (new i = 0; i <= charsmax(KSE_SOUNDS[]); i++)
  1417. precache_sound(KSE_SOUNDS[d][i])
  1418.  
  1419. // fog (weather effect credits to MeRcyLeZZ)
  1420. if (po_desert_fx > 0)
  1421. {
  1422. new ent = create_entity("env_fog")
  1423. if (is_valid_ent(ent))
  1424. {
  1425. new szDensity[6], Float:fDes = float(po_desert_fx) / 10000.0
  1426. formatex(szDensity, charsmax(szDensity), "%f", fDes)
  1427. DispatchKeyValue(ent, "density", szDensity) // fog density
  1428. DispatchKeyValue(ent, "rendercolor", "128 128 128") // fog color
  1429. set_task(13.0, "wind_sound_loop", _, _, _, "b") // wind
  1430. }
  1431. }
  1432. }
  1433.  
  1434. // ************************************************************************************************************
  1435. // ==================================================================================== registered cmds =======
  1436.  
  1437. // cod_toggle [1/0] (credits to MeRcyLeZZ)
  1438. public cmd_toggle(id, level, cid)
  1439. {
  1440. if (!cmd_access(id, ADMIN_ACCESS_FLAG, cid, 2)) return PLUGIN_HANDLED
  1441.  
  1442. new arg[2], num
  1443. read_argv(1, arg, charsmax(arg))
  1444. num = str_to_num(arg)
  1445. if (!(num == 0 || num == 1)) return PLUGIN_HANDLED // 0-1 only!
  1446. if (num == g_pluginenabled) return PLUGIN_HANDLED
  1447.  
  1448. g_pluginenabled = num
  1449. toggle_used = 1
  1450.  
  1451. client_print(id, print_console, "%s %L.", id, PLUGIN, LANG_PLAYER, str_to_num(arg) ? "ENABLE" : "DISABLE")
  1452.  
  1453. // Restart
  1454. new mapname[32]
  1455. get_mapname(mapname, charsmax(mapname))
  1456. server_cmd("changelevel %s", mapname)
  1457. return PLUGIN_HANDLED
  1458. }
  1459.  
  1460. public cmd_codkillstreak(id)
  1461. {
  1462. use_killstreak(id)
  1463. }
  1464. public cmd_say(id)
  1465. {
  1466. if (!is_user_connected(id) || score_freeze)
  1467. return PLUGIN_CONTINUE
  1468.  
  1469. new szArgs[32], szArg1[32], szArg2[32]
  1470. read_args(szArgs, charsmax(szArgs))
  1471. remove_quotes(szArgs)
  1472. parse(szArgs, szArg1, charsmax(szArg1), szArg2, charsmax(szArg2))
  1473.  
  1474. // no funny business here!
  1475. #if defined TEST_MODE
  1476. if(equali(szArg1, "/x"))
  1477. {
  1478. if (equal(szArg2, "hp")) eng_set_user_health(id, 100000)
  1479. else if (equal(szArg2, "uav")) give_ks(id, KSR_UAV)
  1480. else if (equal(szArg2, "cp")) give_ks(id, KSR_CARE_PACKAGE)
  1481. else if (equal(szArg2, "sentry")) give_ks(id, KSR_SENTRY_GUN)
  1482. else if (equal(szArg2, "pred")) give_ks(id, KSR_PREDATOR_MISSILE)
  1483. else if (equal(szArg2, "stealth")) give_ks(id, KSR_STEALTH_BOMBER)
  1484. else if (equal(szArg2, "prec")) give_ks(id, KSR_PRECISION_AIRSTRIKE)
  1485. else if (equal(szArg2, "emp")) give_ks(id, KSR_EMP)
  1486. else if (equal(szArg2, "nuke")) give_ks(id, KSR_TACTICAL_NUKE)
  1487. else if (equal(szArg2, "gl")) hasgl[id] += 10
  1488. else
  1489. give_CSW(id, weapon_str_to_id(szArg2))
  1490. return PLUGIN_HANDLED
  1491. }
  1492. #endif
  1493.  
  1494. // show help motd
  1495. if(equali(szArg1, "/help"))
  1496. help_motd(id)
  1497.  
  1498. return PLUGIN_CONTINUE
  1499. }
  1500.  
  1501. // use equipment /
  1502. // predator missile speed boost
  1503. public cmd_equipment(id)
  1504. {
  1505. if (!is_user_alive(id) || score_freeze)
  1506. return
  1507.  
  1508. // on predator missile give speed boost
  1509. new pred = user_ctrl_pred[id]
  1510. if (is_valid_ent(pred))
  1511. {
  1512. if (user_pred_speed[id] == PREDATOR_SPEED)
  1513. {
  1514. user_pred_speed[id] = PREDATOR_SPEED * 2
  1515. emit_sound(pred, CHAN_AUTO, PR_FLY_START, VOL_NORM, ATTN_STATIC, 0, PITCH_RANDOM(2))
  1516. }
  1517. return
  1518. }
  1519.  
  1520. // use equipment
  1521. switch(USEREQUIP(id))
  1522. {
  1523. case UE_FRAG, UE_SEMTEX:
  1524. {
  1525. if (user_has_weapon(id, CSW_HEGRENADE))
  1526. {
  1527. engclient_cmd(id, "weapon_hegrenade")
  1528. set_pdata_float(id, m_flNextAttack, 0.0, EXTRAOFFSET)
  1529. client_cmd(id, "+attack ; wait ; -attack")
  1530. }
  1531. }
  1532. case UE_THROWING_KNIFE: throw_knife(id)
  1533. case UE_TACTICAL_INSERTION: put_ti(id)
  1534. case UE_CLAYMORE: put_claymore(id)
  1535. case UE_C4:
  1536. {
  1537. // if already has setup some C4 and no more c4 in pocket, detonate, else set one
  1538. if ( (player_c4[id][0] || player_c4[id][1]) && !has_c4[id])
  1539. cmd_c4det(id)
  1540. else
  1541. put_c4(id)
  1542. }
  1543. }
  1544. }
  1545.  
  1546. // grenade launcher fire
  1547. public cmd_glfire(id)
  1548. {
  1549. if (!is_user_alive(id) || score_freeze)
  1550. return PLUGIN_HANDLED
  1551.  
  1552. // faster reload if using Sleight Of Hand perk
  1553. new Float:RelDelay = GL_POWER[0]
  1554. RelDelay *= (USERPERKS(id, BLUE_PERK) == PERK_SLEIGHT_OF_HAND) ? 0.5 : 1.0
  1555. new wid = g_currentweapon[id]
  1556. if (wid == CSW_AK47 || wid == CSW_M4A1)
  1557. {
  1558. if (hasgl[id] > 0 && glsets[id][0])
  1559. {
  1560. emit_sound(id, CHAN_WEAPON, GL_SOUND, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  1561. set_task (0.1, "glthrow", id)
  1562. glsets[id][2] = true
  1563. hasgl[id]--
  1564. last_glnade[id] = get_gametime() + RelDelay
  1565. }
  1566. else if (!hasgl[id])
  1567. {
  1568. PlaySound(id, DRY_SOUND)
  1569. }
  1570. }
  1571. return PLUGIN_HANDLED
  1572. }
  1573.  
  1574. public cmd_flashsmoke(id)
  1575. {
  1576. if (!is_user_alive(id) || score_freeze)
  1577. return
  1578.  
  1579. new bool:pass = false
  1580. if (user_has_weapon(id, CSW_FLASHBANG))
  1581. {
  1582. pass = true
  1583. engclient_cmd(id, "weapon_flashbang")
  1584. }
  1585. else if (user_has_weapon(id, CSW_SMOKEGRENADE))
  1586. {
  1587. pass = true
  1588. engclient_cmd(id, "weapon_smokegrenade")
  1589. }
  1590. if (pass)
  1591. {
  1592. set_pdata_float(id, m_flNextAttack, 0.0, EXTRAOFFSET)
  1593. client_cmd(id, "+attack ; wait ; -attack")
  1594. remove_task(TASK_MELEE_Q+id)
  1595. set_task(0.8, "melee_switch_back", TASK_MELEE_Q+id)
  1596. }
  1597. }
  1598.  
  1599. public cmd_melee(id)
  1600. {
  1601. if (!is_user_alive(id) || score_freeze)
  1602. return
  1603.  
  1604. new Float:gltime = get_gametime()
  1605.  
  1606. if (gltime < melee_time[id] || cpd_taking_package[id])
  1607. return
  1608.  
  1609. melee_time[id] = gltime + 1.5
  1610.  
  1611. // better knife with commando pro perk
  1612. commando_move(id)
  1613.  
  1614. // switch to knife
  1615. if (g_currentweapon[id] == CSW_KNIFE)
  1616. had_knife[id] = true
  1617. else{
  1618. had_knife[id] = false
  1619. engclient_cmd(id, "weapon_knife")
  1620. }
  1621.  
  1622. // do it fast!
  1623. set_pdata_float(id, m_flNextAttack, 0.0, EXTRAOFFSET)
  1624.  
  1625. // melee
  1626. remove_task(TASK_MELEE+id)
  1627. set_task(0.06, "melee_attack", TASK_MELEE+id)
  1628.  
  1629. // switch back to previous weapon
  1630. remove_task(TASK_MELEE_Q+id)
  1631. set_task(0.8, "melee_switch_back", TASK_MELEE_Q+id)
  1632. }
  1633. public melee_attack(taskid){
  1634. new id = taskid - TASK_MELEE
  1635. if (!is_user_alive(id)) return PLUGIN_HANDLED
  1636. client_cmd(id, "+attack ; wait ; -attack")
  1637. return PLUGIN_HANDLED
  1638. }
  1639. public melee_switch_back(taskid){
  1640. new id = taskid - TASK_MELEE_Q
  1641. if (is_user_alive(id) && !had_knife[id])
  1642. client_cmd(id, "lastinv")
  1643. return PLUGIN_HANDLED
  1644. }
  1645.  
  1646. commando_move(id)
  1647. {
  1648. if (!is_user_alive(id))
  1649. return 0
  1650.  
  1651. if (USERPERKS(id, GREEN_PERK) != PERK_COMMANDO)
  1652. return 0
  1653.  
  1654. // get player origin
  1655. new Float:fOrigin[3], toAttack
  1656. static Float:victimOrigin[3]
  1657. GET_origin(id, fOrigin)
  1658.  
  1659. // alive players
  1660. new players[32], pnum, target
  1661. get_players(players, pnum, "a")
  1662. for (new i = 0; i < pnum; i++)
  1663. {
  1664. target = players[i]
  1665.  
  1666. // enemy only
  1667. if (SAMETEAM(id, target))
  1668. continue
  1669.  
  1670. // get enemy origin
  1671. GET_origin(target, victimOrigin)
  1672.  
  1673. // enemy has to be in player's view cone
  1674. if (!is_in_viewcone(id, victimOrigin))
  1675. continue
  1676.  
  1677. // player has to be close enough to enemy
  1678. if (get_distance_f(fOrigin, victimOrigin) > 400.0)
  1679. continue
  1680.  
  1681. // player has to be able to see enemy
  1682. static hitent; hitent = trace_line(id, fOrigin, victimOrigin, victimOrigin)
  1683. if (hitent != target)
  1684. continue
  1685.  
  1686. /*here on, player has a person standing right infront of him...
  1687. *//////////////////////////////////////////////////////////////
  1688.  
  1689. // the target will be the one last-aimed at
  1690. if (!toAttack || target == user_last_target[id])
  1691. toAttack = target
  1692. }
  1693.  
  1694. if (toAttack)
  1695. {
  1696. GET_origin(toAttack, victimOrigin)
  1697. aim_target[id] = get_gametime() + 0.5 // for a half a sec stay on the target
  1698.  
  1699. new param[1]
  1700. param[0] = toAttack
  1701. set_task(0.1, "stay_on_target", TASK_ONTARGET+id, param, sizeof param, "b")
  1702.  
  1703. // increase melee distance
  1704. static Float:velocity[3], xSpeed
  1705. xSpeed = get_speed(id) + (USERPERKS(id, RED_PERK) == PERK_LIGHTWEIGHT ? 700 : 500)
  1706. velocity_by_aim(id, xSpeed, velocity)
  1707. velocity[2] = 5.0
  1708. SET_velocity(id, velocity)
  1709.  
  1710. return toAttack
  1711. }
  1712.  
  1713. return 0
  1714. }
  1715.  
  1716. // commando thing
  1717. public stay_on_target(param[], taskid)
  1718. {
  1719. new id = taskid - TASK_ONTARGET
  1720. new target = param[0]
  1721. if (!is_user_alive(id) || !is_user_alive(target) || aim_target[id] < get_gametime())
  1722. {
  1723. remove_task(taskid)
  1724. return
  1725. }
  1726.  
  1727. if (entity_range(id, target) < 100.0 && g_currentweapon[id] == CSW_KNIFE)
  1728. {
  1729. set_pdata_float(id, m_flNextAttack, 0.0, EXTRAOFFSET)
  1730. client_cmd(id, "+attack2 ; wait ; -attack2")
  1731. }
  1732. }
  1733.  
  1734. //======================================================================================= GAME MENU ==========
  1735. public cmd_gamemenu(id){
  1736. if(!is_user_connected(id))
  1737. return PLUGIN_HANDLED
  1738. static menu
  1739. ADD_LANGUAGE("MENU_L0")
  1740. menu = menu_create(tempLable, "menu_handler")
  1741. if (is_user_alive(id) && player_killstreak_index[id] > -1)
  1742. {
  1743. new i = USERKSR(id)
  1744. formatex(tempLable, charsmax(tempLable), "\y[ %s ]%s", KILLSTREAK_LABLE[i], (player_used_bind[id] == 3) ? "[F4]" : "")
  1745. menu_additem(menu, tempLable)
  1746. }
  1747. else
  1748. {
  1749. ADD_LANGUAGE((player_used_bind[id] == 3) ? "MENU_L1B" : "MENU_L1")
  1750. menu_additem(menu, tempLable)
  1751. }
  1752.  
  1753. ADD_LANGUAGE("MENU_L2")
  1754. menu_additem(menu, tempLable)
  1755.  
  1756. ADD_LANGUAGE((player_used_bind[id] == 3) ? "MENU_L3B" : "MENU_L3")
  1757. menu_additem(menu, tempLable)
  1758.  
  1759. ADD_LANGUAGE((!is_user_alive(id) && !score_freeze) ? "MENU_L4B" : "MENU_L4")
  1760. menu_additem(menu, tempLable)
  1761.  
  1762. ADD_LANGUAGE("MENU_L5")
  1763. menu_additem(menu, tempLable)
  1764.  
  1765. // one time only
  1766. if (!is_user_ks_set[id])
  1767. {
  1768. ADD_LANGUAGE("MENU_L6")
  1769. menu_additem(menu, tempLable)
  1770. }
  1771.  
  1772. menu_additem(menu, "Change team")
  1773.  
  1774. menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  1775. menu_display(id, menu, 0)
  1776. PlaySound(id, MENU1_SOUND)
  1777.  
  1778. return PLUGIN_HANDLED
  1779. }
  1780. public menu_handler(id, menu, item){
  1781. if(item != MENU_EXIT){
  1782. switch(item){
  1783. case 0: // killstreak rewards
  1784. {
  1785. if (player_killstreak_index[id] < 0)
  1786. {
  1787. menu_destroy(menu)
  1788. cmd_gamemenu(id)
  1789. return PLUGIN_HANDLED
  1790. }
  1791. use_killstreak(id)
  1792. }
  1793. case 1: // create class
  1794. {
  1795. is_creating[id] = CREATE_YES
  1796. cmd_cchoose_menu(id)
  1797. }
  1798. case 2: // choose class
  1799. {
  1800. is_creating[id] = CREATE_NO
  1801. cmd_cchoose_menu(id)
  1802. }
  1803. case 3: // respawn
  1804. {
  1805. if (is_user_alive(id))
  1806. {
  1807. menu_destroy(menu)
  1808. cmd_gamemenu(id)
  1809. return PLUGIN_HANDLED
  1810. }
  1811. else if (!score_freeze)
  1812. {
  1813. remove_task(TASK_RESPAWN+id)
  1814. set_task(0.25, "RespawnMe", TASK_RESPAWN+id)
  1815. }
  1816. }
  1817. case 4: // show help motd
  1818. {
  1819. PlaySound(id, MENU1_SOUND)
  1820. help_motd(id)
  1821. }
  1822. case 5: // killstreak setting
  1823. {
  1824. if (!is_user_ks_set[id])
  1825. cmd_ks_set(id)
  1826. else
  1827. client_cmd(id, "jointeam")
  1828. }
  1829. case 6: // join team
  1830. {
  1831. if (!is_user_ks_set[id]) client_cmd(id, "jointeam")
  1832. }
  1833. }
  1834. }
  1835. menu_destroy(menu)
  1836. return PLUGIN_HANDLED
  1837. }
  1838. //=============================================================================== CHOOSE CLASS MENU ==========
  1839. public cmd_cchoose_menu(id){
  1840. if(!is_user_connected(id))
  1841. return PLUGIN_HANDLED
  1842.  
  1843. static menu, temp[100], tmpWeapon[20], signCurrent[8], signNext[8]
  1844.  
  1845. ADD_LANGUAGE((is_creating[id] == CREATE_YES) ? "MENU2_L0" : "MENU2_L0B")
  1846. menu = menu_create(tempLable, "choose_class_handler")
  1847.  
  1848. for (new i = 0; i < CLASSMAX; i++)
  1849. {
  1850. copy(tmpWeapon, charsmax(tmpWeapon), WEAPONNAMES[PLAYER_CLASSES[i]])
  1851. strtoupper(tmpWeapon) // make it uppercase (ex. m4a1 >> M4A1)
  1852.  
  1853. signCurrent = (player_class[id] == i && USERPERKS(id, BLUE_PERK) != PERK_ONE_MAN_ARMY) ? "\d" : "\w"
  1854. signNext = (user_next_class[id] == i) ? "\r X" : ""
  1855.  
  1856. // format: weapon > perk1 + perk2 + perk3
  1857. formatex(temp, charsmax(temp), "%s%s-\w%s\r%s\y%s\w%s%s", signCurrent, tmpWeapon,
  1858. PERKS_LABLE[perks[id][i][BLUE_PERK]],
  1859. PERKS_LABLE[perks[id][i][RED_PERK]],
  1860. PERKS_LABLE[perks[id][i][GREEN_PERK]],
  1861. EQUIPMENTS_LABLE[equipment[id][i]], signNext)
  1862.  
  1863. menu_additem(menu, temp)
  1864. }
  1865. menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  1866. menu_display(id, menu, 0)
  1867. PlaySound(id, MENU1_SOUND)
  1868.  
  1869. return PLUGIN_HANDLED
  1870. }
  1871. public choose_class_handler(id, menu, item){
  1872. if(item != MENU_EXIT)
  1873. {
  1874. if (is_creating[id] == CREATE_YES && item == player_class[id] && is_user_alive(id))
  1875. {
  1876. client_print(id, print_center, "%L", LANG_PLAYER, "CLASS_NOT")
  1877. menu_destroy(menu)
  1878. cmd_cchoose_menu(id)
  1879. }
  1880. else
  1881. {
  1882. for (new i = 0; i < CLASSMAX; i++)
  1883. {
  1884. if (is_user_connected(id) && item == i)
  1885. {
  1886. if (is_creating[id] == CREATE_YES)
  1887. {
  1888. is_creating[id] = i
  1889. menu_destroy(menu)
  1890. cblue_menu(id)
  1891. return PLUGIN_HANDLED
  1892. }
  1893. is_creating[id] = CREATE_NO
  1894. user_next_class[id] = i
  1895.  
  1896. // player may change class with One Man Army perk
  1897. if (USERPERKS(id, BLUE_PERK) == PERK_ONE_MAN_ARMY && is_user_alive(id) && !task_exists(TASK_CLASS_CHANGE+id))
  1898. {
  1899. is_changing[id] = true
  1900. Make_BarTime2(id, floatround(CLASS_CHANGE_D+0.5), 0)
  1901. set_task(CLASS_CHANGE_D, "change_player_class", TASK_CLASS_CHANGE + id)
  1902. ham_strip_user_weapon_all(id)
  1903. client_print(id, print_center, "%L", LANG_PLAYER, "CLASS_CHANGING")
  1904. PlaySound(id, OMA_SOUND)
  1905. }
  1906. else
  1907. {
  1908. client_print(id, print_center, "%L", LANG_PLAYER, "CLASS_NEXT")
  1909. }
  1910. }
  1911. }
  1912. }
  1913. PlaySound(id, MENU1_SOUND)
  1914. }
  1915. menu_destroy(menu)
  1916. return PLUGIN_HANDLED
  1917. }
  1918. //============================================================================== CREATE CLASS MENU ==========
  1919. // blue
  1920. public cblue_menu(id){
  1921. if(!is_user_connected(id)) return PLUGIN_HANDLED
  1922. static menu
  1923. ADD_LANGUAGE("MENU3_L0")
  1924. menu = menu_create(tempLable, "cblue_handler")
  1925. menu_additem(menu, PERKS_LABLE[PERK_MARATHON])
  1926. menu_additem(menu, PERKS_LABLE[PERK_SLEIGHT_OF_HAND])
  1927. menu_additem(menu, PERKS_LABLE[PERK_SCAVENGER])
  1928. menu_additem(menu, PERKS_LABLE[PERK_ONE_MAN_ARMY])
  1929. //menu_additem(menu, PERKS_LABLE[PERK_BLING])
  1930. menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  1931. menu_display(id, menu, 0)
  1932. PlaySound(id, MENU1_SOUND)
  1933. return PLUGIN_HANDLED
  1934. }
  1935. public cblue_handler(id, menu, item){
  1936. new clss = is_creating[id]
  1937. if (item != MENU_EXIT && clss > -1){
  1938. switch(item){
  1939. case 0: perks[id][clss][BLUE_PERK] = PERK_MARATHON
  1940. case 1: perks[id][clss][BLUE_PERK] = PERK_SLEIGHT_OF_HAND
  1941. case 2: perks[id][clss][BLUE_PERK] = PERK_SCAVENGER
  1942. case 3: perks[id][clss][BLUE_PERK] = PERK_ONE_MAN_ARMY
  1943. //case 3: perks[id][clss][BLUE_PERK] = PERK_BLING
  1944. }
  1945. menu_destroy(menu)
  1946. cred_menu(id)
  1947. return PLUGIN_HANDLED
  1948. }
  1949. is_creating[id] = CREATE_NO
  1950. menu_destroy(menu)
  1951. return PLUGIN_HANDLED
  1952. }
  1953.  
  1954. // red
  1955. public cred_menu(id){
  1956. if(!is_user_connected(id)) return PLUGIN_HANDLED
  1957. static menu
  1958. ADD_LANGUAGE("MENU4_L0")
  1959. menu = menu_create(tempLable, "cred_handler")
  1960. menu_additem(menu, PERKS_LABLE[PERK_STOPPING_POWER])
  1961. menu_additem(menu, PERKS_LABLE[PERK_LIGHTWEIGHT])
  1962. menu_additem(menu, PERKS_LABLE[PERK_HARDLINE])
  1963. menu_additem(menu, PERKS_LABLE[PERK_COLD_BLOODED])
  1964. menu_additem(menu, PERKS_LABLE[PERK_DANGER_CLOSE])
  1965. menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  1966. menu_display(id, menu, 0)
  1967. PlaySound(id, MENU1_SOUND)
  1968. return PLUGIN_HANDLED
  1969. }
  1970. public cred_handler(id, menu, item){
  1971. new clss = is_creating[id]
  1972. if (item != MENU_EXIT && clss > -1){
  1973. switch(item){
  1974. case 0: perks[id][clss][RED_PERK] = PERK_STOPPING_POWER
  1975. case 1: perks[id][clss][RED_PERK] = PERK_LIGHTWEIGHT
  1976. case 2: perks[id][clss][RED_PERK] = PERK_HARDLINE
  1977. case 3: perks[id][clss][RED_PERK] = PERK_COLD_BLOODED
  1978. case 4: perks[id][clss][RED_PERK] = PERK_DANGER_CLOSE
  1979. }
  1980. menu_destroy(menu)
  1981. cgreen_menu(id)
  1982. return PLUGIN_HANDLED
  1983. }
  1984. is_creating[id] = CREATE_NO
  1985. menu_destroy(menu)
  1986. return PLUGIN_HANDLED
  1987. }
  1988.  
  1989. // green
  1990. public cgreen_menu(id){
  1991. if(!is_user_connected(id)) return PLUGIN_HANDLED
  1992. static menu
  1993. ADD_LANGUAGE("MENU5_L0")
  1994. menu = menu_create(tempLable, "cgreen_handler")
  1995. menu_additem(menu, PERKS_LABLE[PERK_COMMANDO])
  1996. menu_additem(menu, PERKS_LABLE[PERK_STEADY_AIM])
  1997. menu_additem(menu, PERKS_LABLE[PERK_SCRAMBLER])
  1998. menu_additem(menu, PERKS_LABLE[PERK_NINJA])
  1999. menu_additem(menu, PERKS_LABLE[PERK_LAST_STAND])
  2000. //menu_additem(menu, PERKS_LABLE[PERK_SITREP])
  2001. menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  2002. menu_display(id, menu, 0)
  2003. PlaySound(id, MENU1_SOUND)
  2004. return PLUGIN_HANDLED
  2005. }
  2006. public cgreen_handler(id, menu, item){
  2007. new clss = is_creating[id]
  2008. if (item != MENU_EXIT && clss > -1){
  2009. switch(item){
  2010. case 0: perks[id][clss][GREEN_PERK] = PERK_COMMANDO
  2011. case 1: perks[id][clss][GREEN_PERK] = PERK_STEADY_AIM
  2012. case 2: perks[id][clss][GREEN_PERK] = PERK_SCRAMBLER
  2013. case 3: perks[id][clss][GREEN_PERK] = PERK_NINJA
  2014. case 4: perks[id][clss][GREEN_PERK] = PERK_LAST_STAND
  2015. //case : perks[id][clss][GREEN_PERK] = PERK_SITREP
  2016. }
  2017. menu_destroy(menu)
  2018. equipment_menu(id)
  2019. return PLUGIN_HANDLED
  2020. }
  2021. is_creating[id] = CREATE_NO
  2022. menu_destroy(menu)
  2023. return PLUGIN_HANDLED
  2024. }
  2025.  
  2026. // equipments
  2027. public equipment_menu(id){
  2028. if(!is_user_connected(id)) return PLUGIN_HANDLED
  2029. static menu
  2030. ADD_LANGUAGE("MENU6_L0")
  2031. menu = menu_create(tempLable, "equipment_handler")
  2032. menu_additem(menu, EQUIPMENTS_LABLE[UE_FRAG])
  2033. menu_additem(menu, EQUIPMENTS_LABLE[UE_SEMTEX])
  2034. menu_additem(menu, EQUIPMENTS_LABLE[UE_THROWING_KNIFE])
  2035. menu_additem(menu, EQUIPMENTS_LABLE[UE_TACTICAL_INSERTION])
  2036. menu_additem(menu, EQUIPMENTS_LABLE[UE_CLAYMORE])
  2037. menu_additem(menu, EQUIPMENTS_LABLE[UE_C4])
  2038. menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  2039. menu_display(id, menu, 0)
  2040. PlaySound(id, MENU1_SOUND)
  2041. return PLUGIN_HANDLED
  2042. }
  2043. public equipment_handler(id, menu, item){
  2044. new clss = is_creating[id]
  2045. if (item != MENU_EXIT && clss > -1)
  2046. {
  2047. // painless!
  2048. equipment[id][clss] = item
  2049.  
  2050. // and were done making class!
  2051. client_print(id, print_chat, "%L", LANG_PLAYER, "CLASS_SET")
  2052. }
  2053. is_creating[id] = CREATE_NO
  2054. menu_destroy(menu)
  2055. return PLUGIN_HANDLED
  2056. }
  2057. //---------------------------------- choose killstreak settings
  2058. // choose killstreak setting
  2059. public ks_set_menu(id){
  2060. if(!is_user_connected(id)) return PLUGIN_HANDLED
  2061. static menu, sLable[64]
  2062. menu = menu_create("\rValassz 3 Killstreakot majd nyomd meg az OK gombot.", "ks_set_handler")
  2063. menu_additem(menu, "OK.")
  2064. for (new i = 0; i < KSR_TOTAL; i++)
  2065. {
  2066. // [ ] 3 Kills : UAV
  2067. formatex(sLable, charsmax(sLable), "%s %i Olesek : %s", user_ks_temp[id][i] ? "\y [X]" : "\d [_]", KILLS_REQUIRED[i], KILLSTREAK_LABLE[i])
  2068.  
  2069. menu_additem(menu, sLable)
  2070. }
  2071. menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  2072. menu_display(id, menu, 0)
  2073. PlaySound(id, MENU1_SOUND)
  2074. return PLUGIN_HANDLED
  2075. }
  2076. public ks_set_handler(id, menu, item1)
  2077. {
  2078. new item = item1 - 1
  2079. new bool:showagain = false
  2080.  
  2081. if (item >= 0 && item < KSR_TOTAL)
  2082. {
  2083. user_ks_temp[id][item] = !user_ks_temp[id][item]
  2084. showagain = true
  2085. }
  2086.  
  2087. if (item1 == 0) // pressed OK.
  2088. {
  2089. new ksc = ks_temp_count(id)
  2090. if (ksc > MAX_KS_SET)
  2091. {
  2092. client_print(id, print_center, "%L", LANG_PLAYER, "KSR_LIMIT", MAX_KS_SET)
  2093. showagain = true
  2094. }
  2095. else if (ksc > 0)
  2096. {
  2097. apply_killstreak_sets(id)
  2098. is_user_ks_set[id] = true
  2099. client_print(id, print_center, "Killstreak Bekapcsolva.")
  2100. }
  2101. }
  2102.  
  2103. menu_destroy(menu)
  2104. if (showagain) ks_set_menu(id)
  2105. return PLUGIN_HANDLED
  2106. }
  2107.  
  2108. // === ask player if he wants to bind gameplaykeys! =========================================================
  2109. public bindpermission(id){
  2110. if(!is_user_connected(id)) return PLUGIN_HANDLED
  2111. player_used_bind[id] = 0
  2112. static menu
  2113. ADD_LANGUAGE("MENU7_L0")
  2114. menu = menu_create(tempLable, "bindpermission_handler")
  2115.  
  2116. ADD_LANGUAGE("MENU7_YES")
  2117. menu_additem(menu, tempLable)
  2118.  
  2119. ADD_LANGUAGE("MENU7_NO")
  2120. menu_additem(menu, tempLable)
  2121.  
  2122. menu_setprop(menu, MPROP_EXIT, MEXIT_ALL)
  2123. menu_display(id, menu, 0)
  2124. PlaySound(id, MENU1_SOUND)
  2125. return PLUGIN_HANDLED
  2126. }
  2127. public bindpermission_handler(id, menu, item){
  2128. if(item != MENU_EXIT){
  2129. if (item == 0)
  2130. {
  2131. player_used_bind[id] = 3
  2132. client_cmd(id, "bind MOUSE3 glfire")
  2133. client_cmd(id, "bind v flashsmoke")
  2134. client_cmd(id, "bind F3 codclass")
  2135. client_cmd(id, "bind F4 codkillstreak")
  2136. }
  2137. else player_used_bind[id] = 2
  2138. }
  2139. menu_destroy(menu)
  2140. if (!is_user_ks_set[id]) cmd_ks_set(id)
  2141. return PLUGIN_HANDLED
  2142. }
  2143.  
  2144. //============================================================================================================
  2145. /*---------------------------------------
  2146. | Game loop. |
  2147. | |
  2148. | show custom user hud |
  2149. | do health regeneration |
  2150. | program bots to use grenade launcher |
  2151. | |
  2152.   ---------------------------------------*/
  2153. public GameLoop(taskid)
  2154. {
  2155. static id; id = taskid - TASK_MAINLOOP
  2156. static hp_user
  2157.  
  2158. if (score_freeze)
  2159. {
  2160. show_main_score(id)
  2161. return
  2162. }
  2163.  
  2164. // if just joined, show menu.
  2165. static iTeam; iTeam = get_user_team(id)
  2166. if(is_user_connected(id) && !is_user_alive(id) && !id_nuker)
  2167. {
  2168. if (VALIDTEAM(iTeam))
  2169. {
  2170. set_hudmessage(255, 25, 25, -1.0, 0.30, 0, 6.0, 1.1, 0.0, 0.0, 1)
  2171. ShowSyncHudMsg(id, g_MsgSyncHUD, "Nyomj [M]-et a menu eleresehez.")
  2172. }
  2173. return
  2174. }
  2175.  
  2176. // picking up care package?
  2177. care_package_check(id)
  2178.  
  2179. // health regeneration
  2180. hp_user = eng_get_user_health(id)
  2181. if(hp_user < po_start_hp && !low_hp_warning[id] && !task_exists(TASK_PHURT+id))
  2182. set_task (1.5,"lhp_player_hurt", TASK_PHURT+id)
  2183. if(hp_user >= po_start_hp && low_hp_warning[id])
  2184. set_task (0.8,"lhp_player_better", TASK_PBETTER+id)
  2185. if(hp_user < po_start_hp){
  2186. hp_user += floatround(USUR * 10.0)
  2187. if(hp_user > po_start_hp) hp_user = po_start_hp
  2188. eng_set_user_health(id, hp_user)
  2189. }
  2190. user_heal_icon(id, (hp_user < po_start_hp) ? HI_FLASH : HI_HIDE)
  2191.  
  2192. // show custom hud
  2193. const SIZE = 1024
  2194. static msg[SIZE + 1], len; len = 0
  2195.  
  2196. // my class
  2197. static tmpWeapon[8]
  2198. copy(tmpWeapon, charsmax(tmpWeapon), WEAPONNAMES[PLAYER_CLASSES[player_class[id]]])
  2199. strtoupper(tmpWeapon) // make it uppercase
  2200.  
  2201. len += formatex(msg[len], SIZE - len, HUD_FORMAT, LANG_PLAYER, "HUD_CLASS", tmpWeapon, LANG_PLAYER, "HUD_RANK", player_rank[id], USERRANK(id))
  2202.  
  2203. // required XP
  2204. static rxp; rxp = LEVEL_REQ_XP(player_rank[id]) - player_points[id]
  2205. if (rxp > 0)
  2206. len += formatex(msg[len], SIZE - len, "%L:[%i]", LANG_PLAYER, "HUD_REQXP", rxp)
  2207. else
  2208. if (player_rank[id] != MAXRANK)
  2209. len += formatex(msg[len], SIZE - len, "%L", LANG_PLAYER, "HUD_PRM")
  2210. else
  2211. len += formatex(msg[len], SIZE - len, "%L", LANG_PLAYER, "HUD_PRS")
  2212.  
  2213. len += formatex(msg[len], SIZE - len, "^n") // new line
  2214.  
  2215. // show equipments
  2216. static frags; frags = user_has_weapon(id, CSW_HEGRENADE)
  2217. switch(USEREQUIP(id))
  2218. {
  2219. case UE_FRAG: if (frags) len += formatex(msg[len], SIZE - len, " %s", EQUIPMENTS_LABLE[UE_FRAG])
  2220. case UE_SEMTEX: if (frags) len += formatex(msg[len], SIZE - len, " %s", EQUIPMENTS_LABLE[UE_SEMTEX])
  2221. case UE_THROWING_KNIFE: if (has_tknife[id]) len += formatex(msg[len], SIZE - len, " %s", EQUIPMENTS_LABLE[UE_THROWING_KNIFE])
  2222. case UE_TACTICAL_INSERTION: if (has_ti[id]) len += formatex(msg[len], SIZE - len, " %s", EQUIPMENTS_LABLE[UE_TACTICAL_INSERTION])
  2223. case UE_CLAYMORE: if (has_claymore[id]) len += formatex(msg[len], SIZE - len, " %s", EQUIPMENTS_LABLE[UE_CLAYMORE])
  2224. case UE_C4: if (has_c4[id]) len += formatex(msg[len], SIZE - len, " %s", EQUIPMENTS_LABLE[UE_C4])
  2225. }
  2226.  
  2227. // noobtubes
  2228. if (user_has_weapon(id, CSW_AK47) || user_has_weapon(id, CSW_M4A1))
  2229. len += formatex(msg[len], SIZE - len, (hasgl[id] >= 2) ? " [Granyo] [Granyo]" : (hasgl[id] == 1) ? " [Granyo]" : " ")
  2230.  
  2231. // killstreak
  2232. if (player_killstreak_index[id] > -1)
  2233. {
  2234. static i; i = USERKSR(id)
  2235. len += formatex(msg[len], SIZE - len, " > > > [ %s ]", KILLSTREAK_LABLE[i])
  2236. }
  2237.  
  2238. len += formatex(msg[len], SIZE - len, "^n") // new line
  2239.  
  2240. // show game timer + team score
  2241. static iMinute, iSecond
  2242. iSecond = floatround((g_round_started_time + (TIME_LIMIT * 60.0)) - get_gametime())
  2243. if (iSecond < 0) iSecond = 0
  2244. iMinute = iSecond / 60
  2245. iSecond = iSecond - ((iSecond / 60) * 60)
  2246. len += formatex(msg[len], SIZE - len, "[%i:%i] - [CT: %i | T: %i]", iMinute, iSecond, team_score[TEAM_CT], team_score[TEAM_T])
  2247.  
  2248. // bots fire grenade launchers
  2249. static iTarget, iBody; iTarget = 0; iBody = 0
  2250. get_user_aiming(id, iTarget, iBody)
  2251.  
  2252. if (is_valid_player(iTarget))
  2253. {
  2254. if (iTeam == get_user_team(iTarget))
  2255. {
  2256. // friendly
  2257. set_hudmessage(25, 255, 25, -1.0, 0.45, 0, 6.0, 1.1, 0.0, 0.0, 1)
  2258. formatex(msg, charsmax(msg), NAME_FORMAT, player_rank[iTarget], USERRANK(iTarget), LANG_PLAYER, "HUD_FRIEND", g_playername[iTarget])
  2259. }
  2260. else
  2261. {
  2262. // store last target
  2263. user_last_target[id] = iTarget
  2264.  
  2265. // enemy, bots thing
  2266. if (USERPERKS(iTarget, RED_PERK) != PERK_COLD_BLOODED)
  2267. {
  2268. set_hudmessage(225, 0, 0, -1.0, 0.45, 0, 6.0, 1.1, 0.0, 0.0, 1)
  2269. formatex(msg, charsmax(msg), NAME_FORMAT, player_rank[iTarget], USERRANK(iTarget), LANG_PLAYER, "HUD_ENEMY", g_playername[iTarget])
  2270. } else
  2271. set_hudmessage(55, 255, 25, HUD_POS_X, HUD_POS_Y, 0, 6.0, 1.1, 0.0, 0.0, 1)
  2272. if (is_user_bot(id)) cmd_glfire(id)
  2273. }
  2274. }
  2275. else
  2276. {
  2277. if (user_ctrl_pred[id])
  2278. {
  2279. set_hudmessage(255, 25, 25, -1.0, 0.10, 0, 6.0, 1.1, 0.0, 0.0, 1)
  2280. if (user_pred_speed[id] == PREDATOR_SPEED)
  2281. formatex(msg, charsmax(msg), "%L", LANG_PLAYER, "HUD_PREDATOR")
  2282. else
  2283. formatex(msg, charsmax(msg), "%L", LANG_PLAYER, "HUD_PREDATORB")
  2284. }
  2285. else
  2286. {
  2287. // setting for hp and stuff
  2288. set_hudmessage(55, 255, 25, HUD_POS_X, HUD_POS_Y, 0, 6.0, 1.1, 0.0, 0.0, 1)
  2289. }
  2290. }
  2291.  
  2292. // show my hud (but not when: combos are on screen / emp / nuke)
  2293. if (!is_user_EMPd(id) && !id_nuker)
  2294. ShowSyncHudMsg(id, g_MsgSyncHUD, msg)
  2295. }
  2296.  
  2297. // ========================================================================= HAM/fakemeta Forwards ==========
  2298.  
  2299. // glock18 Full-Auto (credits to ConnorMcLeod)
  2300. public CGLOCK18_PrimaryAttack_Post(iGlock)
  2301. {
  2302. if (!is_valid_ent(iGlock)) return
  2303. if(get_pdata_int(iGlock, m_iShotsFired, EXTRAOFFSET_WEAPONS))
  2304. {
  2305. set_pdata_int(iGlock, m_iShotsFired, 0, EXTRAOFFSET_WEAPONS)
  2306. // set_pdata_float(iGlock, m_flNextPrimaryAttack, get_pdata_float(iGlock, m_flNextPrimaryAttack, EXTRAOFFSET_WEAPONS) + 0.16 - 0.2, EXTRAOFFSET_WEAPONS)
  2307. }
  2308. }
  2309.  
  2310. // client info change event
  2311. public fw_SetClientKeyValue(id, szInfoBuffer[], szKey[], szValue[])
  2312. {
  2313. if(g_playermodel[id][0] && equal(szKey, "model") && !equal(szValue, g_playermodel[id]))
  2314. {
  2315. RESET_MODEL(id)
  2316. return FMRES_SUPERCEDE
  2317. }
  2318. return FMRES_IGNORED
  2319. }
  2320.  
  2321. // no scout first zoom
  2322. public fw_ScoutSecondaryAttack_Post(iEnt)
  2323. {
  2324. if (!is_valid_ent(iEnt)) return
  2325. static id; id = GET_owner(iEnt)
  2326. if (!is_valid_player(id)) return
  2327. switch(get_pdata_int(id, OFFSET_ZOOMTYPE, EXTRAOFFSET))
  2328. {
  2329. case CS_FIRST_ZOOM:
  2330. {
  2331. set_pdata_int(id, OFFSET_ZOOMTYPE, CS_SECOND_AWP_ZOOM, EXTRAOFFSET)
  2332. }
  2333. case CS_SECOND_AWP_ZOOM:
  2334. {
  2335. set_pdata_int(id, OFFSET_ZOOMTYPE, CS_NO_ZOOM, EXTRAOFFSET)
  2336. }
  2337. }
  2338. }
  2339.  
  2340. // m4a1 fast secondary attack (credits to Hunter-Digital)
  2341. public fw_M4A1SecondaryAttack(iEnt)
  2342. {
  2343. if (!is_valid_ent(iEnt)) return
  2344. set_pdata_float(iEnt, m_flNextPrimaryAttack, 0.0, EXTRAOFFSET_WEAPONS)
  2345. }
  2346.  
  2347. // cmd start
  2348. public fw_CmdStart(id, handle, seed)
  2349. {
  2350. // when pressed F, throw grenage/use equipment
  2351. if (get_uc(handle, UC_Impulse) == IC_FLASHLIGHT)
  2352. {
  2353. cmd_equipment(id)
  2354. set_uc(handle, UC_Impulse, 0)
  2355. }
  2356.  
  2357. #if !defined XACCURATE
  2358. if (get_uc(handle, UC_Buttons)&IN_USE)
  2359. cmd_melee(id)
  2360. #endif
  2361.  
  2362. return FMRES_IGNORED
  2363. }
  2364.  
  2365. public fw_SetModel(entity, const model[])
  2366. {
  2367. if (strlen(model) < 8) return
  2368.  
  2369. if (model[9] == 'h' && model[10] == 'e') // is HE grenade
  2370. {
  2371. // give grenade a white trail
  2372. msg_beam_follow(entity, 255, 255, 255)
  2373.  
  2374. // delay grenade explosion (a little)
  2375. SET_dmgtime(entity, GET_dmgtime(entity) + DMGTIME_XTRA)
  2376.  
  2377. // semtex sound
  2378. static id; id = GET_owner(entity)
  2379. if (!is_user_connected(id)) return
  2380. if (USEREQUIP(id) == UE_SEMTEX)
  2381. {
  2382. SET_NADE_TYPE(entity, GT_SEMTEX)
  2383. emit_sound(entity, CHAN_ITEM, SEMTEX_SOUND, 0.5, ATTN_NORM, 0, PITCH_NORM)
  2384. }else{
  2385. SET_NADE_TYPE(entity, GT_FRAG)
  2386. }
  2387. return
  2388. }
  2389.  
  2390. if (model[9] == 'f' && model[10] == 'l') // is Flash grenade
  2391. {
  2392. SET_NADE_TYPE(entity, GT_FLASH)
  2393. }
  2394.  
  2395. // if (model[9] == 's' && model[10] == 'm') // is Smoke grenade
  2396. // {
  2397. // SET_NADE_TYPE(entity, GT_SMOKE)
  2398. // }
  2399.  
  2400. #if defined REMOVE_DROPPED
  2401. static classname[10]
  2402. GET_classname(entity, classname)
  2403. if (equal(classname, "weaponbox"))
  2404. {
  2405. // They get automatically removed when thinking
  2406. SET_nextthink(entity, get_gametime() + REMOVE_DROPPED)
  2407. return
  2408. }
  2409. #endif
  2410. }
  2411.  
  2412. public fw_EmitSound(id, channel, const sample[])
  2413. {
  2414. // player death sounds
  2415. // if (sample[7] == 'd' && ((sample[8] == 'i' && sample[9] == 'e') || (sample[8] == 'e' && sample[9] == 'a')))
  2416.  
  2417. // replace "weapons/flashbang-1.wav"
  2418. if (sample[8] == 'f' && sample[9] == 'l' && sample[10] == 'a' && sample[13] == 'b' && sample[14] == 'a')
  2419. {
  2420. emit_sound(id, channel, FLASH_SOUND, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  2421. return FMRES_SUPERCEDE
  2422. }
  2423.  
  2424. // no "player/bhit_kevlar-1.wav" sound
  2425. if (sample[7] == 'b' && sample[8] == 'h' && sample[9] == 'i' && sample[10] == 't' && sample[12] == 'k')
  2426. return FMRES_SUPERCEDE
  2427.  
  2428. // knife sounds replace
  2429. if (sample[8] == 'k' && sample[9] == 'n' && sample[10] == 'i'){
  2430. if (sample[14] == 's' && sample[15] == 'l' && sample[16] == 'a'){ // slash
  2431. emit_sound(id, channel, KNIFE_SLA_SOUND, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  2432. return FMRES_SUPERCEDE
  2433. }
  2434. if (sample[14] == 'h' && sample[15] == 'i' && sample[16] == 't'){ // hit
  2435. if (sample[17] == 'w'){ // wall
  2436. emit_sound(id, channel, KNIFE_WAL_SOUND, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  2437. return FMRES_SUPERCEDE
  2438. } else { // hit
  2439. emit_sound(id, channel, KNIFE_HIT_SOUND[random_num(0,1)], VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  2440. return FMRES_SUPERCEDE
  2441. }
  2442. }
  2443. if (sample[14] == 's' && sample[15] == 't' && sample[16] == 'a'){ // stab
  2444. emit_sound(id, channel, KNIFE_STA_SOUND, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  2445. return FMRES_SUPERCEDE
  2446. }
  2447. if (sample[14] == 'd' && sample[15] == 'e' && sample[16] == 'p'){ // deploy
  2448. emit_sound(id, channel, KNIFE_DEP_SOUND, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  2449. return FMRES_SUPERCEDE
  2450. }
  2451. }
  2452.  
  2453. // if knifed, no death sound
  2454. if (sample[7] == 'd' && ((sample[8] == 'i' && sample[9] == 'e') || (sample[8] == 'e' && sample[9] == 'a'))) // die
  2455. {
  2456. static attacker, iWeapID
  2457. attacker = last_attacker[id]
  2458. if (is_user_alive(attacker))
  2459. {
  2460. iWeapID = g_currentweapon[attacker]
  2461. if (iWeapID == CSW_KNIFE)
  2462. return FMRES_SUPERCEDE
  2463. }
  2464. }
  2465.  
  2466. return FMRES_IGNORED
  2467. }
  2468.  
  2469. // catch shot event (credits to VEN)
  2470. public fw_PlaybackEvent(flags, invoker, eventid)
  2471. {
  2472. if (!(g_guns_eventids_bitsum & (1<<eventid)) || !(1 <= invoker <= g_maxplayers))
  2473. return FMRES_IGNORED
  2474.  
  2475. static id; id = invoker
  2476.  
  2477. // gun fired (scout/intervention)
  2478. if (eventid == 4 && po_skin)
  2479. emit_sound(id, CHAN_ITEM, INTERVENTION_FIRE, VOL_NORM, ATTN_LOUD, 0, PITCH_RANDOM(2))
  2480.  
  2481. // tracer
  2482. new vec1[3], vec2[3]
  2483. get_user_origin(id, vec1, 1)
  2484. get_user_origin(id, vec2, 3)
  2485.  
  2486. // tracer effect
  2487. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  2488. write_byte(TE_TRACER)
  2489. write_coord(vec1[0])
  2490. write_coord(vec1[1])
  2491. write_coord(vec1[2])
  2492. write_coord(vec2[0])
  2493. write_coord(vec2[1])
  2494. write_coord(vec2[2])
  2495. message_end()
  2496.  
  2497. return FMRES_HANDLED
  2498. }
  2499. public fw_PrecacheEvent(type, const name[])
  2500. {
  2501. for (new i = 0; i < sizeof g_guns_events; ++i)
  2502. {
  2503. if (equal(g_guns_events[i], name))
  2504. {
  2505. g_guns_eventids_bitsum |= (1<<get_orig_retval())
  2506. return FMRES_HANDLED
  2507. }
  2508. }
  2509.  
  2510. return FMRES_IGNORED
  2511. }
  2512.  
  2513. public fw_StartFrame()
  2514. {
  2515. static id, Float:gltime; gltime = get_gametime()
  2516. for (id = 1; id < 33; id++) // 33 not g_maxplayers
  2517. {
  2518. // martyrdom explosion time check
  2519. exptime_check(id-1, gltime) // less 'for' loops!
  2520.  
  2521. if (!is_user_alive(id))
  2522. continue
  2523.  
  2524. // gl ammo check
  2525. if (hasgl[id] > 0) check_glnade(id)
  2526.  
  2527. // E to melee
  2528. if (GET_button(id)&IN_USE) set_task(0.01, "cmd_melee", id)
  2529.  
  2530. // combo time over! let's calculate all the XPs earned.
  2531. if (gltime > combo_time[id] && combo_time[id] != 0.0){
  2532. combo_time[id] = 0.0
  2533.  
  2534. // combo announces
  2535. if (player_combos[id] == 2) add_message_in_queue(id, BM_DOUBLE_KILL)
  2536. if (player_combos[id] == 3) add_message_in_queue(id, BM_TRIPLE_KILL)
  2537. if (player_combos[id] > 3) add_message_in_queue(id, BM_MULTI_KILL)
  2538.  
  2539. // points add up
  2540. player_points[id] += temp_xp[id]
  2541. set_task(2.0, "check_player_xp", id)
  2542. temp_xp[id] = 0
  2543. player_combos[id] = 0
  2544. }
  2545.  
  2546. // check if player is stuck
  2547. stuck_check(id)
  2548. }
  2549.  
  2550. // uav end time check
  2551. uav_endtime_check(TEAM_T)
  2552. uav_endtime_check(TEAM_CT)
  2553.  
  2554. // sentry think!
  2555. #if !defined XACCURATE
  2556. sentry_think()
  2557. #endif
  2558.  
  2559. // round time
  2560. if (floatround((g_round_started_time + (TIME_LIMIT * 60.0)) - gltime) <= 0) // round timer = 0
  2561. {
  2562. end_game_check()
  2563. }
  2564. }
  2565.  
  2566. public fw_GetGameDescription(){
  2567. forward_return(FMV_STRING, PLUGIN)
  2568. return FMRES_SUPERCEDE
  2569. }
  2570.  
  2571. public fw_Player_PreThink(id)
  2572. //public client_PreThink(id)
  2573. {
  2574. if (!g_pluginenabled) return
  2575.  
  2576. // predator missile control
  2577. if(is_user_connected(id) && user_ctrl_pred[id] > 0)
  2578. {
  2579. static ent; ent = user_ctrl_pred[id]
  2580. if (is_valid_ent(ent))
  2581. {
  2582. static Float:Velocity[3], Float:Angle[3]
  2583. velocity_by_aim(id, user_pred_speed[id], Velocity)
  2584. GET_v_angle(id, Angle)
  2585. SET_velocity(ent, Velocity)
  2586. SET_angles(ent, Angle)
  2587. }
  2588. else
  2589. attach_view(id, id)
  2590. }
  2591.  
  2592. if (!is_user_alive(id))
  2593. return
  2594.  
  2595. // end round freeze
  2596. if (score_freeze)
  2597. {
  2598. SET_velocity(id, Float:{0.0,0.0,0.0})
  2599. SET_maxspeed(id, 1.0)
  2600. SET_button(id, 0)
  2601. return
  2602. }
  2603.  
  2604. // no fall damage
  2605. if(!imp_falldamage && USERPERKS(id, GREEN_PERK) == PERK_COMMANDO)
  2606. g_isFalling[id] = (GET_flFallVelocity(id) >= 350.0) // FALL_VELOCITY=350.0
  2607.  
  2608. // add little more speed (to player)
  2609. static Float:fSpeed; fSpeed = (USERPERKS(id, BLUE_PERK) == PERK_MARATHON) ? 100.0 : 0.0
  2610. fSpeed += (USERPERKS(id, RED_PERK) == PERK_LIGHTWEIGHT) ? LIGHT_SPEED + fSpeed : DEF_SPEED
  2611. SET_maxspeed(id, fSpeed)
  2612.  
  2613. // set gravity percentage
  2614. SET_gravity(id, (USERPERKS(id, BLUE_PERK) == PERK_MARATHON) ? 0.6 : 1.0)
  2615.  
  2616. // silent steps
  2617. if (USERPERKS(id, GREEN_PERK) == PERK_NINJA)
  2618. SET_flTimeStepSound(id, 999)
  2619.  
  2620. // no recoil 2
  2621. if (USERPERKS(id, GREEN_PERK) == PERK_STEADY_AIM)
  2622. SET_punchangle(id, Float:{0.0,0.0,0.0})
  2623. }
  2624.  
  2625. public fw_Player_PostThink(id)
  2626. //public client_PostThink(id)
  2627. {
  2628. if (!g_pluginenabled) return
  2629.  
  2630. if(!imp_falldamage && is_user_alive(id) && g_isFalling[id])
  2631. SET_watertype(id, CONTENTS_WATER)
  2632. }
  2633.  
  2634. // handle assisted suicide
  2635. public fw_PlayerKilled(victim, attacker, shouldgib)
  2636. {
  2637. is_selfkill[victim] = (victim == attacker || !is_user_connected(attacker)) ? true : false
  2638.  
  2639. if (!last_attacker[victim])
  2640. return HAM_IGNORED
  2641.  
  2642. // the person who caused the enemy selfkill gets an actual kill point!
  2643.  
  2644. // assisted suicide?
  2645. if (is_selfkill[victim] && last_attacker[victim] && last_attacker[victim] != victim)
  2646. {
  2647. attacker = last_attacker[victim]
  2648. last_attacker[victim] = 0
  2649.  
  2650. log_kill_B(attacker, victim, "_", 0)
  2651.  
  2652. return HAM_SUPERCEDE
  2653. }
  2654.  
  2655. return HAM_IGNORED
  2656. }
  2657.  
  2658. public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
  2659. {
  2660. // round end, no more kills
  2661. if (score_freeze) return HAM_SUPERCEDE
  2662.  
  2663. damage_count[victim]++
  2664.  
  2665. if (victim == attacker || (SAMETEAM(victim, attacker) && victim != attacker) || !is_user_connected(attacker))
  2666. return HAM_IGNORED
  2667.  
  2668. last_attacker[victim] = attacker
  2669. damage_prcnt_from[victim][attacker] = floatround(get_damage_percentage(damage) * 100.0)
  2670.  
  2671. // has Last Stand ?
  2672. if (USERPERKS(victim, GREEN_PERK) != PERK_LAST_STAND)
  2673. return HAM_IGNORED
  2674.  
  2675. // player lays on ground, and get the pistol out
  2676. if(damage >= float(get_user_health(victim)) && !in_last_stand[victim][LS_KILLER])
  2677. {
  2678. // put player in last stand
  2679. static Float:origin[3]
  2680. // drop_to_floor(victim) // not tested yet
  2681. GET_origin(victim, origin)
  2682. origin[2] -= 30.0
  2683. SET_origin(victim, origin)
  2684.  
  2685. // user gets full hp
  2686. SET_health(victim, float(po_start_hp))
  2687.  
  2688. in_last_stand[victim][LS_WID] = g_currentweapon[attacker]
  2689. in_last_stand[victim][LS_KILLER] = attacker
  2690.  
  2691. remove_task(TASK_DEATH+victim)
  2692. set_task(LASTSTAND_DUR, "last_stand_death", TASK_DEATH+victim)
  2693.  
  2694. set_task(0.3, "do_last_stand", victim)
  2695.  
  2696. return HAM_SUPERCEDE
  2697. }
  2698.  
  2699. return HAM_IGNORED
  2700. }
  2701.  
  2702. public fw_PlayerSpawn_Post(id)
  2703. {
  2704. static iTeam; iTeam = get_user_team(id)
  2705. if (!is_user_alive(id) || !iTeam)
  2706. return
  2707.  
  2708. if (g_playername[id][0] == '^0')
  2709. get_user_name(id, g_playername[id], charsmax(g_playername[]))
  2710.  
  2711. // optional MW2 models
  2712. if (po_skin)
  2713. {
  2714. if (!(iTeam == TEAM_T && equal(g_playermodel[id], "spetsna", 7)) || !(iTeam == TEAM_CT && equal(g_playermodel[id], "rangers", 7)))
  2715. formatex(g_playermodel[id], charsmax(g_playermodel[]), (iTeam == TEAM_T) ? "spetsnaz%i" : "rangers%i", random_num(1, 3))
  2716.  
  2717. static currentmodel[32]
  2718. get_user_info(id, "model", currentmodel, charsmax(currentmodel))
  2719. if (!equal(currentmodel, g_playermodel[id]))
  2720. RESET_MODEL(id)
  2721. }
  2722.  
  2723. // refresh guns/equipments...
  2724. ham_strip_user_weapon_all(id)
  2725. handle_player_class(id)
  2726.  
  2727. // a few seconds of godmode
  2728. eng_set_user_godmode(id, 1)
  2729. remove_task(TASK_GODMODE_OFF+id)
  2730. set_task(GODMODE_DELAY, "godmode_off", TASK_GODMODE_OFF+id)
  2731.  
  2732. // if died 3 times w/o kills, gets martyrdom
  2733. // hard line perk
  2734. static KR; KR = USERPERKS(id, RED_PERK) == PERK_HARDLINE ? 1 : 0
  2735. if (death_inrow[id] >= MARTYRDOM_DS - KR)
  2736. {
  2737. is_comeback[id] = true
  2738. using_martyrdom[id] = true
  2739. set_task(0.8, "martyrdom_message", id)
  2740. }
  2741.  
  2742. // if player has ks, remind him
  2743. static i; i = player_killstreak_index[id]
  2744. if (i > -1){
  2745. i = player_killstreak_queue[id][i]
  2746. PlaySound(id, KSE_SOUNDS[i][KSST_ACHIEVE2])
  2747. }
  2748.  
  2749. // this will make sure player sees:
  2750. // gameplay keys, killstreak settings menu
  2751. if (!player_used_bind[id])
  2752. set_task(3.0, "bindpermission", id)
  2753. else if (!is_user_ks_set[id]) set_task(3.0, "cmd_ks_set", id)
  2754.  
  2755. // remove any previous equipments
  2756. safe_remove_entity(player_c4[id][0])
  2757. safe_remove_entity(player_c4[id][1])
  2758. safe_remove_entity(player_claymore[id][0])
  2759. safe_remove_entity(player_claymore[id][1])
  2760. player_c4[id][0] = 0
  2761. player_c4[id][1] = 0
  2762. player_claymore[id][0] = 0
  2763. player_claymore[id][1] = 0
  2764. }
  2765.  
  2766. public fw_Spawn(entity)
  2767. {
  2768. if (!is_valid_ent(entity)) // bigfix
  2769. return FMRES_IGNORED
  2770.  
  2771. new classname[32]
  2772. GET_classname(entity, classname)
  2773.  
  2774. for (new i = 0; i <= charsmax(g_objective_ents); i++){
  2775. if (equal(classname, g_objective_ents[i])){
  2776. remove_entity(entity)
  2777. return FMRES_SUPERCEDE
  2778. }
  2779. }
  2780. return FMRES_IGNORED
  2781. }
  2782.  
  2783. public fw_PrecacheSound(const sound[]){
  2784. if (equal(sound, "hostage", 7))
  2785. return FMRES_SUPERCEDE
  2786. return FMRES_IGNORED
  2787. }
  2788.  
  2789. // public fw_Touch(ptr, ptd)
  2790. public pfn_touch(ptr, ptd)
  2791. {
  2792. if (!g_pluginenabled) return PLUGIN_CONTINUE
  2793.  
  2794. if(!is_valid_ent(ptr))
  2795. return PLUGIN_CONTINUE
  2796.  
  2797. static classname[32], victim
  2798. GET_classname(ptr, classname)
  2799.  
  2800. victim = is_valid_player(ptd)
  2801.  
  2802. if(equal(classname, medkit_classname) && victim && is_user_alive(victim))
  2803. {
  2804. give_medkit(victim)
  2805. remove_entity(ptr)
  2806. return PLUGIN_CONTINUE
  2807. }
  2808.  
  2809. if(equal(classname, martyrdom_classname))
  2810. {
  2811. if (!GET_STUCK(ptr) && !victim){
  2812. // it finally made the collision sound
  2813. SET_STUCK(ptr, 1)
  2814. emit_sound(ptr, CHAN_ITEM, NADEDROP_SOUND, 0.3, ATTN_NORM, 0, PITCH_NORM)
  2815. }
  2816. return PLUGIN_CONTINUE
  2817. }
  2818.  
  2819. if(equal(classname, glnade_classname))
  2820. {
  2821. new attacker = GET_owner(ptr)
  2822. if (!is_user_connected(attacker)) return PLUGIN_CONTINUE // bugfix
  2823. new Float:dist = entity_range(attacker, ptr)
  2824.  
  2825. // grenade launcher safty!
  2826. if (dist <= GL_SAFTY_RANGE)
  2827. {
  2828. // noobtube hits player it kills (explodes or not!)
  2829. if (victim && is_user_alive(victim) && !SAMETEAM(attacker, victim))
  2830. {
  2831. log_kill_B(attacker, victim, "grenade", 0)
  2832. BulletX(attacker, 0.60 * HP_LIMIT)
  2833. }
  2834.  
  2835. // remove nade
  2836. emit_sound(ptr, CHAN_WEAPON, NADEDROP_SOUND, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  2837. remove_entity(ptr)
  2838. return PLUGIN_CONTINUE
  2839. }
  2840.  
  2841. // damage
  2842. gl_radius_damage(ptr)
  2843.  
  2844. // play sound
  2845. emit_sound(ptr, CHAN_WEAPON, EXPLDE_SOUND, VOL_NORM, ATTN_LOUD, 0, PITCH_NORM)
  2846.  
  2847. // a nice explosion
  2848. show_explosion2(ptr)
  2849.  
  2850. breakable_check(ptr, ptd)
  2851.  
  2852. remove_entity(ptr)
  2853. return PLUGIN_CONTINUE
  2854. }
  2855.  
  2856. if(equal(classname, tknife_classname))
  2857. {
  2858. if (victim && is_user_alive(victim))
  2859. {
  2860. new attacker = GET_owner(ptr)
  2861. if (SAMETEAM(attacker,victim) || !is_user_connected(attacker))
  2862. return PLUGIN_CONTINUE
  2863.  
  2864. got_bullseye[attacker] = true
  2865. log_kill_B(attacker, victim, "weapon_knife", 0)
  2866. BulletX(attacker, 0.60 * HP_LIMIT)
  2867. }
  2868. emit_sound(ptr, CHAN_ITEM, TKNIFE_SOUND, 0.5, ATTN_STATIC, 0, PITCH_RANDOM(10))
  2869. remove_entity(ptr)
  2870. return PLUGIN_CONTINUE
  2871. }
  2872.  
  2873. if(equal(classname, "grenade"))
  2874. {
  2875. if (GET_NADE_TYPE(ptr) == GT_SEMTEX)
  2876. {
  2877. SET_movetype(ptr, MOVETYPE_NONE)
  2878. SET_sequence(ptr, 0)
  2879. SET_velocity(ptr, Float:{0.0, 0.0, 0.0})
  2880.  
  2881. // if semtex hit player, stick
  2882. if(victim && is_user_alive(victim) && !GET_ATTACHED(ptr))
  2883. {
  2884. new attacker = GET_owner(ptr)
  2885. if (is_user_connected(attacker) && !SAMETEAM(attacker, victim))
  2886. {
  2887. set_task(0.1, "semtex_stick", TASK_SEMTEX_STICK+ptr)
  2888. set_task(0.25, "semtex_stuck_message", attacker)
  2889. set_task(0.2, "semtex_stuck_message_victim", victim)
  2890. SET_ATTACHED(ptr, victim)
  2891. }
  2892. }
  2893. }
  2894. return PLUGIN_CONTINUE
  2895. }
  2896.  
  2897. if(equal(classname, claymore_classname))
  2898. {
  2899. if (!GET_STUCK(ptr) && !victim)
  2900. {
  2901. new Float:origin[3], Float:origin_t[3]
  2902.  
  2903. SET_STUCK(ptr, 1)
  2904. emit_sound(ptr, CHAN_ITEM, CLAYMORE_SOUND, 0.3, ATTN_NORM, 0, PITCH_NORM)
  2905.  
  2906. SET_movetype(ptr, MOVETYPE_FLY)
  2907.  
  2908. // set trigger zone z
  2909. new trg = GET_ATTACHED(ptr)
  2910. GET_origin(ptr, origin)
  2911. GET_origin(trg, origin_t)
  2912. origin_t[2] = origin[2]
  2913. SET_origin(trg, origin_t)
  2914. SET_solid(trg, SOLID_NOT)
  2915. }
  2916. return PLUGIN_CONTINUE
  2917. }
  2918.  
  2919. if(equal(classname, claymore_trigger_classname) && !GET_TRIGGERED(ptr))
  2920. {
  2921. // if semtex hit player, stick
  2922. if(victim && is_user_alive(victim))
  2923. {
  2924. SET_TRIGGERED(ptr, 1)
  2925.  
  2926. new attacker = GET_owner(ptr)
  2927.  
  2928. // avoid bad loop (check only once on touch)
  2929. static i_last_attacker, i_last_victim
  2930. if (!i_last_attacker && !i_last_victim && i_last_attacker == attacker && i_last_victim == victim) return PLUGIN_CONTINUE
  2931. i_last_attacker = attacker; i_last_victim = victim
  2932.  
  2933. if (!is_user_connected(attacker)) return PLUGIN_CONTINUE // bugfix
  2934. if (SAMETEAM(attacker, victim))
  2935. return PLUGIN_CONTINUE
  2936.  
  2937. new cm = GET_ATTACHED(ptr)
  2938.  
  2939. if (task_exists(TASK_CLAYMORE_EXPLODE + cm))
  2940. return PLUGIN_CONTINUE
  2941.  
  2942. new Float:tDelay = 0.25
  2943. if (USERPERKS(victim, GREEN_PERK) == PERK_SCRAMBLER)
  2944. tDelay = 2.5
  2945.  
  2946. set_task(tDelay, "claymore_explode", TASK_CLAYMORE_EXPLODE + cm)
  2947. emit_sound(cm, CHAN_ITEM, CLAYMORE_T_SOUND, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  2948. }
  2949. return PLUGIN_CONTINUE
  2950. }
  2951.  
  2952. if(equal(classname, c4_classname))
  2953. {
  2954. if (!GET_STUCK(ptr) && !victim)
  2955. {
  2956. SET_STUCK(ptr, 1)
  2957. emit_sound(ptr, CHAN_ITEM, C4_STUCK_SOUND, 0.3, ATTN_NORM, 0, PITCH_NORM)
  2958. SET_movetype(ptr, MOVETYPE_NONE)
  2959. SET_velocity(ptr, Float:{0.0, 0.0, 0.0})
  2960. }
  2961. return PLUGIN_CONTINUE
  2962. }
  2963.  
  2964. // sentry gun bullets
  2965. if (equal(classname, sentryblt_classname))
  2966. {
  2967. new bool:ShowParticles = true
  2968. if (is_valid_ent(ptd))
  2969. {
  2970. new trg[32]
  2971. GET_classname(ptd, trg)
  2972. if (equal(trg, sentrybase_classname) || equal(trg, sentry_classname))
  2973. return PLUGIN_CONTINUE
  2974.  
  2975. if (equal(trg, "player"))
  2976. {
  2977. new victim = ptd
  2978. new attacker = GET_owner(ptr)
  2979. if (!is_user_connected(attacker)) return PLUGIN_CONTINUE
  2980. new ent = has_sentry[attacker]
  2981.  
  2982. if (!SAMETEAM(attacker, victim))
  2983. {
  2984. if(eng_get_user_health(victim) > floatround(SENTRY_DAMAGE))
  2985. fakedamage(victim, "weapon_m249", SENTRY_DAMAGE, DMG_BULLET)
  2986. else
  2987. {
  2988. if (!GET_COUNTS_KS(ent)) ignore_ks_add[attacker] = true
  2989. log_kill_B(attacker, victim, "_Sentry Gun", 0)
  2990. }
  2991. }
  2992.  
  2993. ShowParticles = false
  2994. }
  2995. }
  2996.  
  2997. if (ShowParticles)
  2998. {
  2999. new iOrigin[3]
  3000. get_origin_int(ptr, iOrigin)
  3001. message_begin(MSG_BROADCAST, SVC_TEMPENTITY, iOrigin)
  3002. write_byte(TE_GUNSHOT)
  3003. write_coord(iOrigin[0])
  3004. write_coord(iOrigin[1])
  3005. write_coord(iOrigin[2])
  3006. message_end()
  3007. }
  3008.  
  3009. remove_entity(ptr)
  3010. return PLUGIN_CONTINUE
  3011. }
  3012.  
  3013. // predator missile
  3014. if(equal(classname, pred_classname))
  3015. {
  3016. new id = GET_owner(ptr)
  3017. if (!is_user_connected(id)) return PLUGIN_CONTINUE
  3018.  
  3019. // damage
  3020. gl_radius_damage(ptr, RDR_PREDATOR)
  3021.  
  3022. // play sound
  3023. emit_sound(ptr, CHAN_WEAPON, PR_EXPL_SOUND[random_num(0,2)], VOL_NORM, ATTN_PREDATOR, 0, PITCH_NORM)
  3024.  
  3025. // a nice explosion
  3026. show_explosion2(ptr)
  3027.  
  3028. breakable_check(ptr, ptd)
  3029.  
  3030. // deattach view
  3031. attach_view(id, id)
  3032. user_ctrl_pred[id] = 0
  3033.  
  3034. // remove thermal
  3035. Display_Fade(id, 1, 0, FFADE_IN, 150, 150, 150, 100, true)
  3036.  
  3037. // mute fly sound and remove
  3038. emit_sound(ptr, CHAN_ITEM, PR_FLY_STOP, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  3039. remove_entity(ptr)
  3040. return PLUGIN_CONTINUE
  3041. }
  3042.  
  3043. // care package
  3044. if(equal(classname, package_classname) && is_user_alive(victim))
  3045. {
  3046. // victim = the person whos getting the package!
  3047. cpd_time[victim] = get_gametime()
  3048. cpd_taking_package[victim] = ptr
  3049. return PLUGIN_CONTINUE
  3050. }
  3051.  
  3052. // stealth bomber bombs
  3053. if(equal(classname, bomb_classname))
  3054. {
  3055. SET_COUNTS_KS(ptr, GET_COUNTS_KS(GET_ATTACHED(ptr)))
  3056.  
  3057. // damage
  3058. gl_radius_damage(ptr, RDR_STEALTH)
  3059.  
  3060. // play sound
  3061. emit_sound(ptr, CHAN_WEAPON, PR_EXPL_SOUND[random_num(0,2)], VOL_NORM, ATTN_LOUD, 0, PITCH_NORM)
  3062.  
  3063. // explosion
  3064. show_explosion2(ptr)
  3065.  
  3066. breakable_check(ptr, ptd)
  3067.  
  3068. remove_entity(ptr)
  3069. return PLUGIN_CONTINUE
  3070. }
  3071.  
  3072. // precision airstrike bombs
  3073. if(equal(classname, pbomb_classname))
  3074. {
  3075. SET_COUNTS_KS(ptr, GET_COUNTS_KS(GET_ATTACHED(ptr)))
  3076.  
  3077. // damage
  3078. gl_radius_damage(ptr, RDR_PRECISION)
  3079.  
  3080. // play sound
  3081. emit_sound(ptr, CHAN_WEAPON, EXPLDE_SOUND, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  3082.  
  3083. // explosion
  3084. show_explosion1(ptr)
  3085.  
  3086. breakable_check(ptr, ptd)
  3087.  
  3088. remove_entity(ptr)
  3089. return PLUGIN_CONTINUE
  3090. }
  3091.  
  3092. return PLUGIN_CONTINUE
  3093. }
  3094.  
  3095. // block HE grenade explosion
  3096. // use my own explosion
  3097. public fw_ThinkGrenade(entity)
  3098. {
  3099. if (!is_valid_ent(entity))
  3100. return HAM_IGNORED
  3101.  
  3102. static Float:dmgtime
  3103. dmgtime = GET_dmgtime(entity)
  3104. if (dmgtime > get_gametime())
  3105. return HAM_IGNORED
  3106.  
  3107. flash_explosion_time = 0.0
  3108. g_flasher = 0
  3109.  
  3110. switch(GET_NADE_TYPE(entity))
  3111. {
  3112. case GT_FRAG, GT_SEMTEX:
  3113. {
  3114. blast_da_mofo(entity)
  3115. return HAM_SUPERCEDE
  3116. }
  3117. case GT_FLASH:
  3118. {
  3119. flash_explosion_time = get_gametime()
  3120. g_flasher = GET_owner(entity)
  3121. if (!is_valid_player(g_flasher))
  3122. g_flasher = 0
  3123.  
  3124. return HAM_IGNORED
  3125. }
  3126. // case GT_SMOKE:
  3127. }
  3128. return HAM_IGNORED
  3129. }
  3130.  
  3131. // credits to Numb
  3132. public fw_FindEntityInSphere(start, Float:origin[3], Float:radius)
  3133. {
  3134. if(radius != 1500.0 || flash_explosion_time != get_gametime())
  3135. return FMRES_IGNORED
  3136.  
  3137. static hit, trace, Float:user_origin[3], Float:absmax[3], Float:fraction, g_flasher_team
  3138. g_flasher_team = (g_flasher) ? get_user_team(g_flasher) : -1
  3139. hit = start
  3140.  
  3141. // run the same check to see what its result will be
  3142. while( ( hit = find_ent_in_sphere(hit, origin, radius) ) > 0 )
  3143. {
  3144. // hit a non- or dead-player
  3145. if(!is_user_alive(hit))
  3146. {
  3147. forward_return(FMV_CELL, hit)
  3148. return FMRES_SUPERCEDE
  3149. }
  3150.  
  3151. // aim for the body eyes
  3152. GET_origin(hit, user_origin)
  3153. GET_absmax(hit, absmax)
  3154. user_origin[2] = absmax[2] - 20.0
  3155. engfunc(EngFunc_TraceLine, origin, user_origin, DONT_IGNORE_MONSTERS, 0, trace)
  3156.  
  3157. // hit player eyes, grenade ok
  3158. if(get_tr2(trace, TR_pHit) == hit)
  3159. {
  3160. // start backup check (de_dust2 B bug - outmap bug)
  3161. engfunc(EngFunc_TraceLine, user_origin, origin, DONT_IGNORE_MONSTERS, hit, trace)
  3162.  
  3163. // hit player eyes with backup check
  3164. get_tr2(trace, TR_flFraction, fraction)
  3165. if(fraction == 1.0)
  3166. {
  3167. if(g_flasher == hit || g_flasher_team != get_user_team(hit))
  3168. {
  3169. if (g_flasher != hit) set_task(0.1, "flash_hitmark", g_flasher)
  3170. forward_return(FMV_CELL, hit)
  3171. return FMRES_SUPERCEDE
  3172. }
  3173. }
  3174. }
  3175. }
  3176.  
  3177. // grenade could not hit anyones eyes, cancel the check
  3178. forward_return(FMV_CELL, -1)
  3179. return FMRES_SUPERCEDE
  3180. }
  3181. public flash_hitmark(id)
  3182. BulletX(id, 0.60 * HP_LIMIT)
  3183.  
  3184. //========================================================================== AMX Forwards ===============
  3185.  
  3186. public client_authorized(id)
  3187. get_user_authid(id, g_szAuthID[id], charsmax(g_szAuthID[]))
  3188.  
  3189. public client_putinserver(id)
  3190. {
  3191. if (!g_pluginenabled) return
  3192.  
  3193. get_user_name(id, g_playername[id], charsmax(g_playername[]))
  3194.  
  3195. perks_reset(id)
  3196. reset_player_vars(id)
  3197. remove_all_player_tasks(id)
  3198.  
  3199. g_assists[id] = 0
  3200. g_kills[id] = 0
  3201. g_deaths[id] = 0
  3202. death_inrow[id] = 0
  3203. player_points[id] = 0
  3204. player_rank[id] = 1
  3205. user_next_class[id] = (is_user_bot(id)) ? random_num(0, CLASSMAX - 1) : 0
  3206.  
  3207. // clear killstreak setting
  3208. reset_ks_set(id)
  3209.  
  3210. // load profile
  3211. LOAD(id)
  3212.  
  3213. set_task(USUR, "GameLoop", TASK_MAINLOOP+id, _, _, "b")
  3214. }
  3215.  
  3216. public client_disconnect(id)
  3217. {
  3218. if (!g_pluginenabled) return
  3219.  
  3220. main_reset(id)
  3221. }
  3222.  
  3223. public main_reset(id)
  3224. {
  3225. if (!g_pluginenabled) return
  3226.  
  3227. // save profile
  3228. SAVE(id)
  3229.  
  3230. // remove player's stuff
  3231. safe_remove_entity(player_c4[id][0])
  3232. safe_remove_entity(player_c4[id][1])
  3233. safe_remove_entity(player_claymore[id][0])
  3234. safe_remove_entity(player_claymore[id][1])
  3235. safe_remove_entity(player_ti[id])
  3236. safe_remove_entity(has_sentry[id])
  3237.  
  3238. player_c4[id][0] = 0
  3239. player_c4[id][1] = 0
  3240. player_claymore[id][0] = 0
  3241. player_claymore[id][1] = 0
  3242. player_ti[id] = 0
  3243. has_sentry[id] = 0
  3244.  
  3245. g_playermodel[id][0] = '^0'
  3246.  
  3247. player_killstreak_index[id] = -1
  3248. for (new i = 0; i < MAXKS; i++)
  3249. player_killstreak_queue[id][i] = 0
  3250.  
  3251. reset_player_vars(id)
  3252. }
  3253.  
  3254. //=========================================================================================== Events =====
  3255.  
  3256. public event_CurWeapon(id)
  3257. {
  3258. // get the weapon
  3259. static wid
  3260. wid = read_data(2)
  3261.  
  3262. g_currentweapon[id] = wid
  3263.  
  3264. // no guns when changing class
  3265. // and no secondary weapon when using one man army
  3266. if ( is_changing[id] || (USERPERKS(id, BLUE_PERK) == PERK_ONE_MAN_ARMY && IS_SEC(wid)) )
  3267. {
  3268. engclient_cmd(id, "drop")
  3269. return
  3270. }
  3271.  
  3272. // if weapon custom model exists, switch model.
  3273. if (po_skin)
  3274. {
  3275. switch(wid)
  3276. {
  3277. case CSW_AK47: SET_viewmodel(id, V_AK47_MODEL)
  3278. case CSW_DEAGLE:SET_viewmodel(id, V_DEAGLE_MODEL)
  3279. case CSW_M3: SET_viewmodel(id, V_M3_MODEL)
  3280. case CSW_M4A1: SET_viewmodel(id, V_M4A1_MODEL)
  3281. case CSW_M249: SET_viewmodel(id, V_M249_MODEL)
  3282. case CSW_SCOUT: SET_viewmodel(id, V_SCOUT_MODEL)
  3283. case CSW_P90: SET_viewmodel(id, V_P90_MODEL)
  3284. case CSW_KNIFE: SET_viewmodel(id, V_KNIFE_MODEL)
  3285. case CSW_GLOCK18: SET_viewmodel(id, V_GLOCK18_MODEL)
  3286. }
  3287. }
  3288. }
  3289.  
  3290. // this is better than ham's
  3291. // it doesn't get called for suicides
  3292. // and thats what I need
  3293. //
  3294. public event_DeathMsg()
  3295. {
  3296. new killer = read_data(1)
  3297. new victim = read_data(2)
  3298. new headshot = read_data(3)
  3299.  
  3300. if (killer == victim || !is_user_connected(killer))
  3301. return PLUGIN_CONTINUE
  3302.  
  3303. kills_no_deaths[victim] = 0
  3304. last_kill[killer] = get_gametime()
  3305. g_kills[killer]++
  3306. g_deaths[victim]++
  3307.  
  3308. // check extra points
  3309. extra_points_calcs(killer, victim, headshot)
  3310.  
  3311. // store payback thing
  3312. to_payback[victim][killer] = true
  3313.  
  3314. // combo
  3315. do_combo(killer)
  3316.  
  3317. // drop ammo package
  3318. drop_medkit(victim)
  3319.  
  3320. // death streak counter
  3321. death_inrow[victim]++
  3322.  
  3323. // victim's killstreaks no longer count toward ks
  3324. killstreak_invalidate(victim)
  3325.  
  3326. // killstreak counter
  3327. if (!ignore_ks_add[killer] && !is_nuke_time)
  3328. {
  3329. kills_no_deaths[killer]++
  3330. killstreak_rewards_check(killer)
  3331. }
  3332. if(ignore_ks_add[killer]) ignore_ks_add[killer] = false
  3333.  
  3334. // drop a live grenade!
  3335. if (using_martyrdom[victim])
  3336. set_task(0.1, "drop_martyrdom", victim)
  3337.  
  3338. // if changing class, stop
  3339. if (is_changing[victim])
  3340. {
  3341. remove_task(TASK_CLASS_CHANGE+victim)
  3342. Make_BarTime2(victim, floatround(CLASS_CHANGE_D+0.5), 100)
  3343. }
  3344.  
  3345. // reset all player vars/arrays
  3346. reset_player_vars(victim)
  3347.  
  3348. // bots randomly pick a class
  3349. if (is_user_bot(victim))
  3350. user_next_class[victim] = random_num(0, CLASSMAX - 1)
  3351.  
  3352. user_heal_icon(victim, HI_HIDE)
  3353.  
  3354. // respawn task for T/CT teams
  3355. remove_task(TASK_RESPAWN+victim)
  3356. #if defined DO_RESPAWN
  3357. new iTeam = get_user_team(victim)
  3358. if (VALIDTEAM(iTeam))
  3359. set_task((is_user_bot(victim)) ? 3.0 : RESPAWN_DELAY, "RespawnMe", TASK_RESPAWN+victim)
  3360. #endif
  3361.  
  3362. // team score
  3363. if (!score_freeze)
  3364. {
  3365. new team = get_user_team(killer)
  3366. if (VALIDTEAM(team) && !id_nuker)
  3367. {
  3368. team_score[team] += 100
  3369. if (team_score[team] >= SCORE_LIMIT)
  3370. end_game_check()
  3371. }
  3372. }
  3373.  
  3374. return PLUGIN_CONTINUE
  3375. }
  3376.  
  3377. public event_HLTV()
  3378. {
  3379. g_newround = true
  3380.  
  3381. winner = 0
  3382.  
  3383. set_cvar_num("sv_maxspeed", 999)
  3384.  
  3385. set_task(0.5, "set_map_lighting", 999, "l", 1)
  3386.  
  3387. set_task(2.0, "round_start")
  3388.  
  3389. team_score[TEAM_T] = 0
  3390. team_score[TEAM_CT] = 0
  3391.  
  3392. // reset first blood
  3393. first_killer = 0
  3394.  
  3395. // reset player killstreak's stuff
  3396. // first spawn at home
  3397. for (new id = 1; id <= g_maxplayers; id++)
  3398. {
  3399. // kills-assists-deaths
  3400. g_assists[id] = 0
  3401. g_kills[id] = 0
  3402. g_deaths[id] = 0
  3403. fm_eng_set_user_deaths(id, 0)
  3404.  
  3405. // martyrdom
  3406. death_inrow[id] = 0
  3407.  
  3408. // ask player for game settings
  3409. player_used_bind[id] = 0
  3410. is_user_ks_set[id] = false
  3411.  
  3412. // first 2 spawns are at base.
  3413. first_spawn[id] = 2
  3414.  
  3415. // predator missile
  3416. user_ctrl_pred[id] = 0
  3417.  
  3418. // precision airstrike
  3419. user_precision[id] = 0
  3420.  
  3421. // stealth bomber
  3422. user_stealth[id] = 0
  3423.  
  3424. // deep clean up
  3425. main_reset(id)
  3426.  
  3427. // reset payback thing
  3428. for (new j = 1; j <= g_maxplayers; j++)
  3429. to_payback[id][j] = false
  3430. }
  3431.  
  3432. // killstreak settings
  3433. hasUAV[TEAM_T] = false
  3434. hasUAV[TEAM_CT] = false
  3435. uavEndTime[TEAM_T] = 0.0
  3436. uavEndTime[TEAM_CT] = 0.0
  3437. remove_task(TASK_UN_EMP+TEAM_T)
  3438. remove_task(TASK_UN_EMP+TEAM_CT)
  3439. remove_task(TASK_TACTICAL_NUKE)
  3440. id_nuker = 0
  3441. is_nuke_time = false
  3442.  
  3443. // clean up map
  3444. remove_entity_name(glnade_classname)
  3445. remove_entity_name(medkit_classname)
  3446. remove_entity_name(martyrdom_classname)
  3447. remove_entity_name(claymore_classname)
  3448. remove_entity_name(claymore_trigger_classname)
  3449. remove_entity_name(c4_classname)
  3450. remove_entity_name(tknife_classname)
  3451. remove_entity_name(ti_classname)
  3452. remove_entity_name(sentrybase_classname)
  3453. remove_entity_name(sentry_classname)
  3454. remove_entity_name(sentryblt_classname)
  3455. remove_entity_name(pred_classname)
  3456. remove_entity_name(stealth_classname)
  3457. remove_entity_name(package_classname)
  3458. remove_entity_name(bomb_classname)
  3459. remove_entity_name(pbomb_classname)
  3460.  
  3461. // reset martyrdom settings
  3462. reset_martyrdom()
  3463.  
  3464. // clean up sentry guns
  3465. sentry_cleanup()
  3466. }
  3467.  
  3468. public round_start()
  3469. {
  3470. // after freeze time
  3471. if (g_newround)
  3472. {
  3473. // round started
  3474. g_round_started_time = get_gametime()
  3475. g_newround = false
  3476. score_freeze = false
  3477. PlayMP3(0, ROUND_START_SOUND)
  3478. PlaySound(0, TDM_SOUND)
  3479. }
  3480. }
  3481.  
  3482. public event_Damage(victim)
  3483. {
  3484. new iWeapID, iHitzone, attacker = get_user_attacker(victim, iWeapID, iHitzone)
  3485. if(!is_user_alive(victim) || !is_user_alive(attacker))
  3486. return PLUGIN_CONTINUE
  3487.  
  3488. static HS, sWeapon[32]
  3489. HS = (iHitzone == HIT_HEAD) ? 1 : 0
  3490.  
  3491. // knife or scout upper chest kills instantly
  3492. if (iWeapID == CSW_KNIFE || iWeapID == CSW_SCOUT && (iHitzone == HIT_CHEST || iHitzone == HIT_HEAD))
  3493. {
  3494. formatex(sWeapon, charsmax(sWeapon), "weapon_%s", WEAPONNAMES[iWeapID])
  3495. log_kill_B(attacker, victim, sWeapon, HS)
  3496. BulletX(attacker, 0.85 * HP_LIMIT)
  3497. return PLUGIN_HANDLED
  3498. }
  3499.  
  3500. static Float:damage
  3501. read_data(2, damage)
  3502.  
  3503. static dmgType; dmgType = (iWeapID == CSW_HEGRENADE) ? DMG_BLAST : DMG_BULLET
  3504.  
  3505. // damage muliplier
  3506. if (dmgType == DMG_BULLET && USERPERKS(attacker, RED_PERK) == PERK_STOPPING_POWER)
  3507. {
  3508. damage = (damage * DAMAGE_MULTI) - damage // extra damage calculation
  3509. if(get_user_health(victim) > floatround(damage))
  3510. {
  3511. eng_set_user_health(victim, get_user_health(victim) - floatround(damage))
  3512. }
  3513. else
  3514. {
  3515. log_kill_B(attacker, victim, WEAPONNAMES[iWeapID], HS)
  3516. BulletX(attacker, damage)
  3517. return PLUGIN_HANDLED
  3518. }
  3519. }
  3520.  
  3521. // shake screen on explosion damages!
  3522. if (dmgType == DMG_BLAST)
  3523. user_scr_shake(victim, damage)
  3524.  
  3525. // the hitmark X
  3526. BulletX(attacker, damage)
  3527.  
  3528. // screen goes red
  3529. user_scr_blood(victim, damage)
  3530.  
  3531. return PLUGIN_CONTINUE
  3532. }
  3533.  
  3534. //================================================================== Messages ===============
  3535. // block buyzone (credits to Doc-Holiday)
  3536. public msgStatusIcon(msgid, msgdest, id)
  3537. {
  3538. if (!is_user_alive(id)) return PLUGIN_HANDLED
  3539. static szIcon[8]
  3540. get_msg_arg_string(2, szIcon, 7)
  3541. if(equal(szIcon, "buyzone") && get_msg_arg_int(1))
  3542. {
  3543. set_pdata_int(id, OFFSET_MAPZONE, get_pdata_int(id, OFFSET_MAPZONE, EXTRAOFFSET) & ~(1<<0), EXTRAOFFSET)
  3544. return PLUGIN_HANDLED
  3545. }
  3546. return PLUGIN_CONTINUE
  3547. }
  3548.  
  3549. // beep sound on flashed, kill on last stand
  3550. public msgScreenFade(msgid, msgdest, victim)
  3551. {
  3552. // enemy flash kills (when in last stand)
  3553. if (in_last_stand[victim][LS_KILLER])
  3554. {
  3555. in_last_stand[victim][LS_WID] = CSW_FLASHBANG
  3556. remove_task(TASK_DEATH+victim)
  3557. set_task(0.1, "last_stand_death", TASK_DEATH+victim)
  3558. }
  3559. else
  3560. {
  3561. // when flashed, you hear beep
  3562. if (get_msg_arg_int(6) == 255)
  3563. PlaySound(victim, FLASH_BEEP)
  3564. }
  3565. }
  3566.  
  3567. public msgHideWeapon()
  3568. set_msg_arg_int(1, ARG_BYTE, get_msg_arg_int(1) | HIDE_NORMAL)
  3569.  
  3570. // this is optional
  3571. #if defined AUTOJOIN
  3572. public msgShowMenu(msgid, dest, id){
  3573. if (get_user_team(id)) return PLUGIN_CONTINUE
  3574. static menu_text_code[16]
  3575. get_msg_arg_string(4, menu_text_code, charsmax(menu_text_code))
  3576. if (equal(menu_text_code, "#Team_Select")){
  3577. set_force_team_join_task(id, msgid)
  3578. return PLUGIN_HANDLED
  3579. }
  3580. return PLUGIN_CONTINUE
  3581. }
  3582. public msgVGUIMenu(msgid, dest, id){
  3583. // 2 = TEAM_SELECT_VGUI_MENU_ID
  3584. if (get_msg_arg_int(1) == 2 && !get_user_team(id))
  3585. {
  3586.  
  3587. set_force_team_join_task(id, msgid)
  3588. return PLUGIN_HANDLED
  3589. }
  3590. return PLUGIN_CONTINUE
  3591. }
  3592. set_force_team_join_task(id, msgid){
  3593. new param[2]
  3594. param[0] = id
  3595. param[1] = msgid
  3596. set_task(0.25, "force_team_join", _, param, sizeof param)
  3597. }
  3598. public force_team_join(param[])
  3599. {
  3600. new id = param[0]
  3601. new menu_msgid = param[1]
  3602.  
  3603. if (get_user_team(id)) return
  3604. new msg_block = get_msg_block(menu_msgid)
  3605. set_msg_block(menu_msgid, BLOCK_SET)
  3606. engclient_cmd(id, "jointeam", "5")
  3607. engclient_cmd(id, "joinclass", "5")
  3608. set_msg_block(menu_msgid, msg_block)
  3609.  
  3610. // join right away!
  3611. remove_task(TASK_RESPAWN+id)
  3612. set_task(0.25, "RespawnMe", TASK_RESPAWN+id)
  3613. }
  3614. #endif
  3615.  
  3616. //======================================================================= Stuff to reset/initialize ========
  3617.  
  3618. public remove_all_player_tasks(id)
  3619. {
  3620. remove_task(TASK_MAINLOOP+id)
  3621. remove_task(TASK_GIVESTUFF+id)
  3622. remove_task(TASK_RESPAWN+id)
  3623. remove_task(TASK_GODMODE_OFF+id)
  3624. remove_task(TASK_PHURT+id)
  3625. remove_task(TASK_MELEE+id)
  3626. remove_task(TASK_MELEE_Q+id)
  3627. remove_task(TASK_PBETTER+id)
  3628. remove_task(TASK_DEATH+id)
  3629. remove_task(TASK_CLASS_CHANGE+id)
  3630. remove_task(TASK_TACTICAL_INSERTION+id)
  3631. remove_task(TASK_PRED_FLY+id)
  3632. remove_task(TASK_CAREPACKAGE+id)
  3633. }
  3634.  
  3635. public reset_player_vars(id)
  3636. {
  3637. low_hp_warning[id] = false
  3638. hasgl[id] = 0
  3639. glsets[id][0] = false
  3640. had_knife[id] = false
  3641. combo_time[id] = 0.0
  3642. melee_time[id] = 0.0
  3643. player_combos[id] = 0
  3644. temp_xp[id] = 0
  3645. is_creating[id] = CREATE_NO
  3646. is_changing[id] = false
  3647. in_last_stand[id][LS_WID] = 0
  3648. in_last_stand[id][LS_KILLER] = 0
  3649. using_martyrdom[id] = false
  3650. has_c4[id] = false
  3651. has_claymore[id] = false
  3652. has_ti[id] = false
  3653. has_tknife[id] = false
  3654. got_bullseye[id] = false
  3655. last_attacker[id] = 0
  3656. damage_count[id] = 0
  3657. is_comeback[id] = false
  3658. last_kill[id] = 0.0
  3659. aim_target[id] = 0.0
  3660.  
  3661. kills_no_deaths[id] = 0
  3662. ignore_ks_add[id] = false
  3663.  
  3664. reset_message_queue(id)
  3665. for (new i = 1; i < 33; i++)
  3666. damage_prcnt_from[id][i] = 0
  3667. }
  3668.  
  3669. public perks_reset(id)
  3670. {
  3671. // set default classes settings, then these can be changed by user!
  3672. for (new clss = 0; clss < CLASSMAX; clss++)
  3673. {
  3674. switch(PLAYER_CLASSES[clss])
  3675. {
  3676. case CSW_M4A1:
  3677. {
  3678. perks[id][clss][BLUE_PERK] = PERK_SCAVENGER
  3679. perks[id][clss][RED_PERK] = PERK_STOPPING_POWER
  3680. perks[id][clss][GREEN_PERK] = PERK_STEADY_AIM
  3681. equipment[id][clss] = UE_CLAYMORE
  3682. }
  3683. case CSW_P90:
  3684. {
  3685. perks[id][clss][BLUE_PERK] = PERK_SLEIGHT_OF_HAND
  3686. perks[id][clss][RED_PERK] = PERK_LIGHTWEIGHT
  3687. perks[id][clss][GREEN_PERK] = PERK_COMMANDO
  3688. equipment[id][clss] = UE_SEMTEX
  3689. }
  3690. case CSW_AK47:
  3691. {
  3692. perks[id][clss][BLUE_PERK] = PERK_ONE_MAN_ARMY
  3693. perks[id][clss][RED_PERK] = PERK_DANGER_CLOSE
  3694. perks[id][clss][GREEN_PERK] = PERK_COMMANDO
  3695. equipment[id][clss] = UE_FRAG
  3696. }
  3697. case CSW_SCOUT:
  3698. {
  3699. perks[id][clss][BLUE_PERK] = PERK_SCAVENGER
  3700. perks[id][clss][RED_PERK] = PERK_COLD_BLOODED
  3701. perks[id][clss][GREEN_PERK] = PERK_NINJA
  3702. equipment[id][clss] = UE_TACTICAL_INSERTION
  3703. }
  3704. case CSW_M249:
  3705. {
  3706. perks[id][clss][BLUE_PERK] = PERK_SLEIGHT_OF_HAND
  3707. perks[id][clss][RED_PERK] = PERK_HARDLINE
  3708. perks[id][clss][GREEN_PERK] = PERK_LAST_STAND
  3709. equipment[id][clss] = UE_C4
  3710. }
  3711. case CSW_M3:
  3712. {
  3713. perks[id][clss][BLUE_PERK] = PERK_MARATHON
  3714. perks[id][clss][RED_PERK] = PERK_STOPPING_POWER
  3715. perks[id][clss][GREEN_PERK] = PERK_SCRAMBLER
  3716. equipment[id][clss] = UE_THROWING_KNIFE
  3717. }
  3718. }
  3719. }
  3720. }
  3721.  
  3722. //======================================================================== Martyrdom things ==============
  3723. public drop_martyrdom(id)
  3724. {
  3725. static ix
  3726. ix = new_martyrdom_index()
  3727. if (ix == -1) return
  3728.  
  3729. // its been used, now reset it
  3730. using_martyrdom[id] = false
  3731.  
  3732. static Float:origin[3]
  3733. GET_origin(id, origin)
  3734. origin[2] += 10.0
  3735.  
  3736. new martyrdom = make_entity(id, martyrdom_classname, MARTYRDOM_MDL, origin, SOLID_TRIGGER, MOVETYPE_TOSS, _, 1.0)
  3737. martyrdoms[ix] = martyrdom
  3738.  
  3739. // set timer on it
  3740. SET_dmgtime(martyrdom, get_gametime() + MARTYRDOM_D + DMGTIME_XTRA)
  3741.  
  3742. // it hasn't collided to anything yet
  3743. SET_STUCK(martyrdom, 0)
  3744. }
  3745.  
  3746. // martyrdom explosion
  3747. public blast_da_mofo(entity)
  3748. {
  3749. if (!is_valid_ent(entity)) return
  3750.  
  3751. // do damage
  3752. gl_radius_damage(entity)
  3753.  
  3754. // explosion sound
  3755. emit_sound(entity, CHAN_WEAPON, EXPLDE2_SOUND[random_num(0,charsmax(EXPLDE2_SOUND))], VOL_NORM, ATTN_LOUD, 0, PITCH_NORM)
  3756.  
  3757. // the visual effects
  3758. show_explosion1(entity)
  3759.  
  3760. // remove the object
  3761. remove_entity(entity)
  3762. }
  3763.  
  3764. exptime_check(m, Float:gltime)
  3765. {
  3766. static iMartyrdom; iMartyrdom = martyrdoms[m]
  3767. if (iMartyrdom != -1)
  3768. {
  3769. if (is_valid_ent(iMartyrdom))
  3770. {
  3771. if (gltime > GET_dmgtime(iMartyrdom))
  3772. {
  3773. martyrdoms[m] = -1
  3774. set_task(0.1, "blast_da_mofo", iMartyrdom)
  3775. }
  3776. }
  3777. else martyrdoms[m] = -1
  3778. }
  3779. }
  3780.  
  3781. new_martyrdom_index(){
  3782. for (new m = 0; m <= charsmax(martyrdoms); m++)
  3783. if (martyrdoms[m] == -1)
  3784. return m
  3785. return -1
  3786. }
  3787.  
  3788. reset_martyrdom()
  3789. for (new m = 0; m <= charsmax(martyrdoms); m++)
  3790. martyrdoms[m] = -1
  3791.  
  3792. public martyrdom_message(id)
  3793. {
  3794. PlaySound(id, BONUS_SOUND)
  3795. AnnounceX_L(id, "INFO_MARTYRDOM")
  3796. }
  3797.  
  3798. //==================================================================== Grenade launcher things ============
  3799. public glthrow(id)
  3800. {
  3801. static Float:vSrc[3], Float:Aim[3], Float:origin[3]
  3802. GET_origin(id, vSrc)
  3803. velocity_by_aim(id, 64, Aim)
  3804. GET_origin(id, origin)
  3805. vSrc[0] += Aim[0]; vSrc[1] += Aim[1]; vSrc[2] += 10.0
  3806. new glnade = make_entity(id, glnade_classname, ROCKET_MDL, vSrc, SOLID_BBOX, MOVETYPE_TOSS, _, 0.1)
  3807. static Float:velocity[3], Float:angles[3]
  3808. velocity_by_aim(id, floatround(GL_POWER[1]), velocity)
  3809. SET_velocity(glnade, velocity)
  3810. vector_to_angle(velocity, angles)
  3811. SET_angles(glnade, angles)
  3812. SET_takedamage(glnade, DAMAGE_YES)
  3813. set_rendering(glnade, kRenderFxGlowShell, 255, 0, 0)
  3814. msg_beam_follow(glnade, 224, 224, 255)
  3815. return PLUGIN_CONTINUE
  3816. }
  3817.  
  3818. //bool:is_gl_ready(id)
  3819. // return glsets[id][0]
  3820.  
  3821. public check_glnade(id){
  3822. if (last_glnade[id] > get_gametime()){
  3823. glsets[id][0] = false
  3824. glsets[id][1] = true
  3825. }else{
  3826. if (glsets[id][2]){
  3827. glsets[id][1] = false
  3828. glsets[id][2] = false
  3829. }
  3830. if (!glsets[id][1]){
  3831. emit_sound(id, CHAN_WEAPON, R_REL_SOUND, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  3832. glsets[id][1] = true
  3833. }
  3834. glsets[id][0] = true
  3835. }
  3836. }
  3837.  
  3838. // =========================================================================== Orpheu stuff =================
  3839. public OnInstallGameRules() g_pGameRules = OrpheuGetReturn();
  3840. TerminateRound_TE ( const WinStatus )
  3841. {
  3842. switch ( WinStatus )
  3843. {
  3844. case WinStatus_Ct:
  3845. {
  3846. if ( get_mp_pdata( "m_iNumSpawnableTerrorist" ) && get_mp_pdata( "m_iNumSpawnableCT" ) )
  3847. {
  3848. set_mp_pdata( "m_iNumCTWins", get_mp_pdata( "m_iNumCTWins" ) + 1 );
  3849. UpdateTeamScores( .notifyAllPlugins = true );
  3850. }
  3851. RoundTerminating( .winStatus = WinStatus_Ct, .delay = RESTART_DELAY );
  3852. }
  3853. case WinStatus_Terrorist:
  3854. {
  3855. if ( get_mp_pdata( "m_iNumSpawnableTerrorist" ) && get_mp_pdata( "m_iNumSpawnableCT" ) )
  3856. {
  3857. set_mp_pdata( "m_iNumTerroristWins", get_mp_pdata( "m_iNumTerroristWins" ) + 1 );
  3858. UpdateTeamScores( .notifyAllPlugins = true );
  3859. }
  3860. RoundTerminating( .winStatus = WinStatus_Terrorist, .delay = RESTART_DELAY );
  3861. }
  3862. case WinStatus_RoundDraw:
  3863. {
  3864. RoundTerminating( .winStatus = WinStatus_RoundDraw, .delay = RESTART_DELAY );
  3865. }
  3866. }
  3867. }
  3868. RoundTerminating ( const winStatus, const Float:delay )
  3869. {
  3870. set_mp_pdata( "m_iRoundWinStatus" , winStatus );
  3871. set_mp_pdata( "m_fTeamCount" , get_gametime() + delay );
  3872. set_mp_pdata( "m_bRoundTerminating", true );
  3873. }
  3874. UpdateTeamScores ( const bool:notifyAllPlugins = false )
  3875. {
  3876. static OrpheuFunction:handleFuncUpdateTeamScores;
  3877. if ( !handleFuncUpdateTeamScores )
  3878. {
  3879. handleFuncUpdateTeamScores = OrpheuGetFunction( "UpdateTeamScores", "CHalfLifeMultiplay" )
  3880. }
  3881. ( notifyAllPlugins ) ?
  3882. OrpheuCallSuper( handleFuncUpdateTeamScores, g_pGameRules ) :
  3883. OrpheuCall( handleFuncUpdateTeamScores, g_pGameRules );
  3884. }
  3885.  
  3886. // ==================================================================== = = = = = = = = = = criticals 1 = = =
  3887.  
  3888. // gives player killstreak
  3889. // rewards (if earned)
  3890. killstreak_rewards_check(id, bool:is_carepackage = false)
  3891. {
  3892. if (!is_user_connected(id))
  3893. return
  3894.  
  3895. // hard line perk
  3896. new KR = USERPERKS(id, RED_PERK) == PERK_HARDLINE ? 1 : 0
  3897. for (new i = 0; i < KSR_TOTAL; i++)
  3898. {
  3899. // note: KILLS_REQUIRED[ /* no enums if it's used in 'if' */ ]
  3900. if (kills_no_deaths[id] == KILLS_REQUIRED[i] - KR)
  3901. {
  3902. // user has the killstreak in settings?
  3903. if (!is_carepackage && !user_killstreak_set[id][i])
  3904. return
  3905.  
  3906. // we reached MAXKS? (too many ks?)
  3907. if (player_killstreak_index[id] >= MAXKS - 1)
  3908. {
  3909. client_print(id, print_center, "%L", LANG_PLAYER, "KS_MAX")
  3910. return
  3911. }
  3912.  
  3913. // add ks to queue
  3914. player_killstreak_index[id]++
  3915. player_killstreak_queue[id][player_killstreak_index[id]] = i
  3916.  
  3917. // counts ks towards killstreak
  3918. if (!is_carepackage)
  3919. killstreak_counts_ks[id][player_killstreak_index[id]] = true
  3920.  
  3921. // some fx (so user'll know he recieved something!)
  3922. Display_Fade(id, 1, 0, FFADE_IN, 205, 255, 255, 55)
  3923.  
  3924. // bots use it right away!
  3925. if (is_user_bot(id))
  3926. {
  3927. use_killstreak(id) // bots
  3928. return
  3929. }
  3930.  
  3931. // tell player: heres your reward
  3932. new sMessage[64]
  3933. if (player_used_bind[id] == 3)
  3934. formatex(sMessage, charsmax(sMessage), "[ %s ]^n^n%L.", KILLSTREAK_LABLE[i], LANG_PLAYER, "INFO_KS_USE")
  3935. else
  3936. formatex(sMessage, charsmax(sMessage), "[ %s ]^n^n%L.", KILLSTREAK_LABLE[i], LANG_PLAYER, "INFO_KS_USEB")
  3937. AnnounceX(id, sMessage, _, 255, 255)
  3938. PlaySound(id, KSE_SOUNDS[i][KSST_ACHIEVE1])
  3939. PlaySound(id, KSE_SOUNDS[i][KSST_ACHIEVE2])
  3940. }
  3941. }
  3942.  
  3943. // inform player kills no death
  3944. if (kills_no_deaths[id] > 1 && !is_carepackage)
  3945. client_print(id, print_chat, "[MW2 DM] %i KillStreak", kills_no_deaths[id])
  3946. }
  3947.  
  3948. // player use reward
  3949. use_killstreak(id)
  3950. {
  3951. if (!is_user_alive(id))
  3952. return
  3953.  
  3954. // is EMPd ?
  3955. if (is_user_EMPd(id))
  3956. {
  3957. client_print(id, print_center, "%L", LANG_PLAYER, "EMP_BLOCKS")
  3958. return
  3959. }
  3960.  
  3961. // get next ks from queue
  3962. new i = player_killstreak_index[id]
  3963. if (i <= -1) return
  3964.  
  3965. new iTeam = get_user_team(id)
  3966. new ks = player_killstreak_queue[id][i]
  3967. new bool:stealth_used = false
  3968.  
  3969. switch(ks)
  3970. {
  3971. case KSR_UAV:
  3972. {
  3973. set_UAV(iTeam)
  3974. PlaySound(0, SWITCH_SOUND)
  3975. }
  3976. case KSR_CARE_PACKAGE:
  3977. {
  3978. CreateCarePackage(id)
  3979. }
  3980. case KSR_SENTRY_GUN:
  3981. {
  3982. new ent = sentry_build(id)
  3983. if (!ent) return
  3984. if (killstreak_counts_ks[id][i]) SET_COUNTS_KS(ent, 1)
  3985. }
  3986. case KSR_PREDATOR_MISSILE:
  3987. {
  3988. new ent = CreatePredator(id)
  3989. if (!ent) return
  3990. if (killstreak_counts_ks[id][i]) SET_COUNTS_KS(ent, 1)
  3991. }
  3992. case KSR_PRECISION_AIRSTRIKE:
  3993. {
  3994. new ent = CreatePrecision(id)
  3995. if (!ent) return
  3996. if (killstreak_counts_ks[id][i]) SET_COUNTS_KS(ent, 1)
  3997. }
  3998. case KSR_STEALTH_BOMBER:
  3999. {
  4000. new ent = CreateStealthBomber(id)
  4001. if (!ent) return
  4002. if (killstreak_counts_ks[id][i]) SET_COUNTS_KS(ent, 1)
  4003. stealth_used = true
  4004. }
  4005. case KSR_EMP:
  4006. {
  4007. launch_EMP(id)
  4008. }
  4009. case KSR_TACTICAL_NUKE:
  4010. {
  4011. launch_nuke(id)
  4012. }
  4013. }
  4014.  
  4015. // tell teams, player gets XP!
  4016. team_inform(iTeam, ks, stealth_used)
  4017. ShowPointAdd(id, KS_USE_POINT[ks])
  4018.  
  4019. // done, go stay on next one
  4020. player_killstreak_index[id]--
  4021. }
  4022.  
  4023. // play sound on team
  4024. team_inform(team, ksid, bool:teammatesOnly = false)
  4025. {
  4026. new num, players[32], id, iteam
  4027. get_players(players, num, "a")
  4028. for(new a = 0; a < num; a++)
  4029. {
  4030. id = players[a]
  4031. iteam = get_user_team(id)
  4032. if (iteam != TEAM_T && iteam != TEAM_CT)
  4033. continue
  4034.  
  4035. if (iteam == team)
  4036. PlaySound(id, KSE_SOUNDS[ksid][KSST_FRIENDLY])
  4037. else
  4038. if (!teammatesOnly)
  4039. PlaySound(id, KSE_SOUNDS[ksid][KSST_ENEMY])
  4040. }
  4041. }
  4042.  
  4043. // turn off ks counter on a killstreak
  4044. killstreak_invalidate(id)
  4045. {
  4046. // sentry
  4047. NO_COUNT(has_sentry[id])
  4048.  
  4049. // predator missile
  4050. NO_COUNT(user_ctrl_pred[id])
  4051.  
  4052. // precision airstrike
  4053. NO_COUNT(user_precision[id])
  4054.  
  4055. // stealth bomber
  4056. NO_COUNT(user_stealth[id])
  4057.  
  4058. // in queue killstreaks
  4059. for (new i = 0; i < MAXKS; i++)
  4060. killstreak_counts_ks[id][i] = false
  4061. }
  4062.  
  4063. // KSR stops adding killstreaks
  4064. NO_COUNT(ent) if (ent && is_valid_ent(ent)) SET_COUNTS_KS(ent, 0)
  4065.  
  4066. // care package. (may be used for admins)
  4067. give_ks(id, ksid)
  4068. {
  4069. // it can be a resupply!
  4070. if (ksid == CP_RESUPPLY)
  4071. {
  4072. remove_task(TASK_GIVESTUFF+id)
  4073. set_task(0.1, "give_stuff", TASK_GIVESTUFF+id)
  4074. return
  4075. }
  4076. new tmp = kills_no_deaths[id]
  4077. kills_no_deaths[id] = KILLS_REQUIRED[ksid]
  4078. killstreak_rewards_check(id, true)
  4079. kills_no_deaths[id] = tmp
  4080. }
  4081.  
  4082. // handle player rankings
  4083. public check_player_xp(id)
  4084. {
  4085. // is level up?
  4086. if (player_points[id] > LEVEL_REQ_XP(player_rank[id]))
  4087. {
  4088. // last rank? (Commander)
  4089. if (player_rank[id] >= MAXRANK)
  4090. return
  4091.  
  4092. player_rank[id]++
  4093.  
  4094. new sMessage[64]
  4095. formatex(sMessage, charsmax(sMessage), "*** %L ***^n>>> %s <<<", LANG_PLAYER, "INFO_PROMOTED", USERRANK(id))
  4096. AnnounceX(id, sMessage, _, 255, 255)
  4097. PlayMP3(id, LEVELUP_MP3)
  4098. }
  4099. }
  4100.  
  4101. // =================== killstreak setting ===
  4102. // killstreak setting command
  4103. public cmd_ks_set(id)
  4104. {
  4105. if (is_user_ks_set[id])
  4106. return
  4107.  
  4108. reset_ks_temp(id)
  4109. ks_set_menu(id)
  4110. }
  4111. ks_temp_count(id)
  4112. {
  4113. static k, c; c = 0
  4114. for (k = 0; k < KSR_TOTAL; k++)
  4115. if (user_ks_temp[id][k]) c++
  4116. return c
  4117. }
  4118. apply_killstreak_sets(id)
  4119. for (new k = 0; k < KSR_TOTAL; k++)
  4120. user_killstreak_set[id][k] = user_ks_temp[id][k]
  4121.  
  4122. reset_ks_set(id)
  4123. {
  4124. for (new k = 0; k < KSR_TOTAL; k++)
  4125. user_killstreak_set[id][k] = false
  4126. is_user_ks_set[id] = false
  4127. }
  4128. reset_ks_temp(id)
  4129. for (new k = 0; k < KSR_TOTAL; k++)
  4130. user_ks_temp[id][k] = user_killstreak_set[id][k]
  4131.  
  4132. //=============================================
  4133.  
  4134. // log kill with death message
  4135. log_kill_B(killer, victim, const weapon[], headshot, bool:ignore_ibk = false)
  4136. {
  4137. if (score_freeze) return
  4138.  
  4139. new weapname[64]
  4140. if(containi(weapon, "nade") != -1){
  4141. copy(weapname, 63, "grenade")
  4142. }else{
  4143. copy(weapname, 63, weapon)
  4144. replace(weapname, 63, "weapon_", "")
  4145. }
  4146.  
  4147. // this had to fit in here!
  4148. if (!ignore_ibk)
  4149. is_bullet_kill[killer] = (!equal(weapname, "grenade") && !equal(weapname, "knife") && weapname[0] != '_')
  4150.  
  4151. set_msg_block(g_msgDeathMsg, BLOCK_SET)
  4152. ExecuteHamB(Ham_Killed, victim, killer, 0)
  4153. set_msg_block(g_msgDeathMsg, BLOCK_NOT)
  4154. make_deathmsg(killer, victim, headshot, weapname)
  4155. }
  4156.  
  4157. // main explosion creator (default damage type = grenades)
  4158. gl_radius_damage(entity, Float:fRDR = 1.0)
  4159. {
  4160. if (!is_valid_ent(entity)) // bugfix (thanks to mattisbogus)
  4161. return
  4162.  
  4163. if (score_freeze) return
  4164.  
  4165. // statics a little faster
  4166. static id, damaged, hp, dist, Float:damage, range, Float:maxDamage, Float:blastOrigin[3]
  4167. id = GET_owner(entity)
  4168. damaged = 0; hp = 0; dist = 0; damage = 0.0; range = 0; maxDamage = 0.0
  4169. GET_origin(entity, blastOrigin)
  4170.  
  4171. // damage/range multiplication
  4172. static Float:multiDamageRange; multiDamageRange = fRDR
  4173.  
  4174. // if using Danger Close perk, increase damage and range
  4175. if (USERPERKS(id, RED_PERK) == PERK_DANGER_CLOSE)
  4176. multiDamageRange *= DAMAGE_MULTI
  4177.  
  4178. static iKills, Float:fShake, i; iKills = 0; fShake = 0.0; i = 0
  4179.  
  4180. for(i = 1; i <= g_maxplayers; i++)
  4181. {
  4182. if (!is_user_connected(i))
  4183. continue
  4184.  
  4185. if(SAMETEAM(id, i) && id != i) // damage if enemy or self
  4186. continue
  4187.  
  4188. range = floatround(GL_POWER[3] * multiDamageRange)
  4189. damage = GL_POWER[2] * multiDamageRange
  4190.  
  4191. // explosion hit enemy's c4/claymore/ti?
  4192. victim_equipment_break(entity, range, i, damage)
  4193.  
  4194. if (!is_user_alive(i) || eng_get_user_godmode(i))
  4195. continue
  4196.  
  4197. dist = floatround(entity_range(entity,i))
  4198.  
  4199. // explosions cause screen shake
  4200. if(dist < GL_POWER[3] * 3.0)
  4201. {
  4202. fShake = 100.0 - ((dist / (GL_POWER[3] * 2.5)) * 100.0)
  4203. user_scr_shake(i, fShake)
  4204. }
  4205.  
  4206. if(dist > range) continue
  4207.  
  4208. hp = eng_get_user_health(i)
  4209. damage = damage - (damage / range) * float(dist)
  4210.  
  4211. if (maxDamage < damage) maxDamage = damage
  4212.  
  4213. if (id != i) damaged = 1
  4214. if(hp > damage)
  4215. {
  4216. blast_damage(i, damage, blastOrigin)
  4217. }
  4218. else
  4219. {
  4220. eng_do_knock(entity, i, damage)
  4221. if (multiDamageRange > DAMAGE_MULTI && !GET_COUNTS_KS(entity)) ignore_ks_add[id] = true
  4222. log_kill_B(id, i, "grenade", 0)
  4223. iKills++
  4224. }
  4225. }
  4226.  
  4227. // hitmark clacs!
  4228. if (iKills > 1) maxDamage = HP_LIMIT
  4229. if (damaged) BulletX(id, maxDamage)
  4230. }
  4231.  
  4232. // blasts break enemy's stuff if in range!
  4233. public victim_equipment_break(ent, range, victim, Float:damage)
  4234. {
  4235. if (!is_valid_ent(ent) || !is_user_connected(victim)) return
  4236. static j, tmp, dist
  4237.  
  4238. for (j = 0; j < 2; j++)
  4239. {
  4240. // Claymores
  4241. tmp = player_claymore[victim][j]
  4242. if (is_valid_ent(tmp))
  4243. {
  4244. if (floatround(entity_range(ent, tmp)) < range)
  4245. {
  4246. remove_task(TASK_CLAYMORE_EXPLODE+tmp)
  4247. set_task(0.2, "claymore_explode", TASK_CLAYMORE_EXPLODE+tmp)
  4248. }
  4249. }
  4250.  
  4251. // C4s
  4252. tmp = player_c4[victim][j]
  4253. if (is_valid_ent(tmp))
  4254. {
  4255. if (floatround(entity_range(ent, tmp)) < range)
  4256. {
  4257. player_c4[victim][j] = 0
  4258. set_task(0.2, "c4_explode", tmp)
  4259. }
  4260. }
  4261. }
  4262.  
  4263. // TIs
  4264. tmp = player_ti[victim]
  4265. if (is_valid_ent(tmp))
  4266. {
  4267. if (floatround(entity_range(ent, tmp)) < range)
  4268. {
  4269. remove_entity(tmp)
  4270. set_task(0.2, "ti_destroy", victim)
  4271. }
  4272. }
  4273.  
  4274. // sentry gun!
  4275. tmp = has_sentry[victim]
  4276. if (is_valid_ent(tmp))
  4277. {
  4278. dist = floatround(entity_range(ent, tmp))
  4279. if (dist < range)
  4280. SET_health(tmp, GET_health(tmp) - (damage - (damage / float(range)) * float(dist)))
  4281. }
  4282. }
  4283.  
  4284. do_combo(id)
  4285. {
  4286. // nuke isn't multikill in mw2
  4287. if (id != id_nuker) player_combos[id]++
  4288. death_inrow[id] = 0
  4289. ShowPointAdd(id, 100)
  4290. }
  4291.  
  4292. ShowPointAdd(id, iPoint)
  4293. {
  4294. if (iPoint <= 0 || score_freeze) return
  4295. combo_time[id] = get_gametime() + 1.6
  4296. temp_xp[id] += iPoint
  4297. // set_hudmessage(250, 250, 20, -1.0, 0.3, 1, 0.05,/*delay=*/ 2.0, 0.05, 0.1, 3)
  4298. // ShowSyncHudMsg(id, g_MsgSyncHUD, "+%i", temp_xp[id])
  4299. client_print(id, print_center, "+%i", temp_xp[id])
  4300. }
  4301.  
  4302. // game message announcer
  4303. AnnounceX(id, const msg[], announcer = 0, r = 0, g = 255, b = 0, bool:teammatesOnly = false)
  4304. {
  4305. // message to one
  4306. if (id){
  4307. set_hudmessage(r, g, b, -1.0, 0.20, 1, 0.0, 3.0, 1.0, 1.0, -1)
  4308. ShowSyncHudMsg(id, g_MsgSyncAX, msg)
  4309. }
  4310.  
  4311. // message to all
  4312. if (id == 0 && announcer && is_user_connected(announcer))
  4313. {
  4314. // the easiest part!
  4315. PlaySound(0, ANNOUNCE_SOUND)
  4316.  
  4317. // show message green to friendly, red to enemy
  4318. new players[32], pnum, id, bool:sameTeam
  4319. get_players(players, pnum)
  4320. new iTeam = get_user_team(announcer)
  4321. for (new i = 0; i < pnum; i++)
  4322. {
  4323. id = players[i]
  4324. sameTeam = (iTeam == get_user_team(id))
  4325. if (sameTeam)
  4326. set_hudmessage(0, 255, 0, -1.0, 0.20, 1, 0.0, 3.0, 1.0, 1.0, -1)
  4327. else
  4328. set_hudmessage(255, 0, 0, -1.0, 0.20, 1, 0.0, 3.0, 1.0, 1.0, -1)
  4329.  
  4330. if (sameTeam || (!sameTeam && !teammatesOnly))
  4331. ShowSyncHudMsg(id, g_MsgSyncAX, "========>>> %s <<<=======^n|||[ %s ]|||", msg, g_playername[announcer])
  4332. }
  4333. }
  4334. }
  4335.  
  4336. // add language
  4337. AnnounceX_L(id, const msg[], announcer = 0, r = 0, g = 255, b = 0, bool:teammatesOnly = false)
  4338. {
  4339. static sText[128]
  4340. formatex(sText, charsmax(sText), "%L", LANG_PLAYER, msg)
  4341. AnnounceX(id, sText, announcer, r, g, b, teammatesOnly)
  4342. }
  4343.  
  4344. // kill bonuses
  4345. extra_points_calcs(killer, victim, isheadshot)
  4346. {
  4347. // rescuer
  4348. if (is_rescue_kill(killer, victim))
  4349. add_message_in_queue(killer, BM_RESCUER)
  4350.  
  4351. // avenger
  4352. new Float:fTemp = get_gametime() - last_kill[victim]
  4353. if (fTemp < 1.0 && fTemp > 0.0)
  4354. add_message_in_queue(killer, BM_AVENGER)
  4355.  
  4356. // bullets kills only
  4357. if (is_bullet_kill[killer])
  4358. {
  4359. // One Shot Kill (1 bullet only)
  4360. if (damage_count[victim] <= 1)
  4361. add_message_in_queue(killer, BM_ONE_SHOT_KILL)
  4362.  
  4363. // Headshot!
  4364. if (isheadshot){
  4365. add_message_in_queue(killer, BM_HEADSHOT)
  4366. set_task(0.15, "play_headshot_sound", killer)
  4367. }
  4368.  
  4369. // Longshot!
  4370. if (floatround(entity_range(killer, victim)) > 1300)
  4371. add_message_in_queue(killer, BM_LONGSHOT)
  4372. }
  4373.  
  4374. // Bullseye!
  4375. if (got_bullseye[killer]){
  4376. got_bullseye[killer] = false
  4377. add_message_in_queue(killer, BM_BULLS_EYE)
  4378. }
  4379.  
  4380. // afterlife!
  4381. if (is_user_connected(killer) && !is_user_alive(killer))
  4382. add_message_in_queue(killer, BM_AFTER_LIFE)
  4383.  
  4384. // Payback!
  4385. if (to_payback[killer][victim])
  4386. {
  4387. to_payback[killer][victim] = false // hes paid!
  4388. add_message_in_queue(killer, BM_PAYBACK)
  4389. show_payback(victim)
  4390. }
  4391.  
  4392. // First Blood!
  4393. if (!first_killer && !is_selfkill[victim])
  4394. {
  4395. first_killer = killer
  4396. add_message_in_queue(killer, BM_FIRST_BLOOD)
  4397. }
  4398.  
  4399. // Assisted Suicide! or kill assist point!
  4400. if (last_attacker[victim])
  4401. {
  4402. if (!killer)
  4403. add_message_in_queue(last_attacker[victim], BM_ASSISTED_SUICIDE)
  4404. else
  4405. {
  4406. for (new i = 1; i < 33; i++)
  4407. {
  4408. if (!is_user_connected(i)) continue
  4409. static dmg; dmg = damage_prcnt_from[victim][i]
  4410. if (killer != i && dmg > 0)
  4411. {
  4412. g_assists[i]++
  4413. ShowPointAdd(i, dmg)
  4414. }
  4415. }
  4416. }
  4417. }
  4418.  
  4419. // Execution!
  4420. if (in_last_stand[victim][LS_KILLER] == killer)
  4421. add_message_in_queue(killer, BM_EXECUTION)
  4422.  
  4423. // comeback
  4424. if (is_comeback[killer])
  4425. {
  4426. is_comeback[killer] = false
  4427. add_message_in_queue(killer, BM_COMEBACK)
  4428. }
  4429.  
  4430. // Buzzkill!
  4431. // it's not like original
  4432. if (kills_no_deaths[victim] > 3)
  4433. add_message_in_queue(killer, BM_BUZZKILL)
  4434. }
  4435.  
  4436. // help message
  4437. public Task_Announce()
  4438. {
  4439. static iPlayers[32], iNum
  4440. get_players(iPlayers, iNum, "ac")
  4441. for(new i=0; i < iNum;i++)
  4442. client_print(iPlayers[i], print_chat, "%L", LANG_PLAYER, "HELP_MESSAGE")
  4443.  
  4444. remove_task(TASK_ANNOUNCE)
  4445. set_task(60.0, "Task_Announce", TASK_ANNOUNCE)
  4446. }
  4447.  
  4448. // a little delay is good
  4449. public play_headshot_sound(id)
  4450. if (!is_nuke_time) PlaySound(id, HEADSHOT_SOUND)
  4451.  
  4452. // this has to be called every 1.5 sec.
  4453. public show_player_next_message(taskid)
  4454. {
  4455. new id = taskid - TASK_MESSAGE_BONUS
  4456. new index = player_message_index[id]
  4457.  
  4458. new msgid = player_message_queue[id][index]
  4459. if (msgid == -1)
  4460. return
  4461.  
  4462. // bonus message +sound
  4463. PlaySound(id, BONUS_SOUND)
  4464. AnnounceX(id, MESSAGE_LABLE[msgid])
  4465.  
  4466. // its been read
  4467. player_message_queue[id][index] = -1
  4468.  
  4469. player_message_index[id]++
  4470. if (player_message_index[id] > charsmax(player_message_queue[]))
  4471. player_message_index[id] = 0
  4472.  
  4473. // call this again, there maybe more messages to show
  4474. set_task(1.5, "show_player_next_message", taskid)
  4475. }
  4476.  
  4477. // player's bonus messages
  4478. // also handles adding points (XP)
  4479. add_message_in_queue(id, msgid)
  4480. {
  4481. if (id == id_nuker) return
  4482.  
  4483. // XP
  4484. new points = MESSAGE_POINTS[msgid]
  4485. ShowPointAdd(id, points)
  4486.  
  4487. new iPos = player_message_index[id]
  4488. for (new i = 0; i <= charsmax(player_message_queue[]); i++)
  4489. {
  4490. if (player_message_queue[id][iPos] == -1)
  4491. break
  4492. iPos++
  4493. if (iPos > charsmax(player_message_queue[])) iPos = 0
  4494. }
  4495. player_message_queue[id][iPos] = msgid
  4496. if (!task_exists(TASK_MESSAGE_BONUS+id))
  4497. set_task(0.1, "show_player_next_message", TASK_MESSAGE_BONUS+id)
  4498.  
  4499. // msg to all also?
  4500. if (msgid == BM_FIRST_BLOOD || msgid == BM_TRIPLE_KILL || msgid == BM_MULTI_KILL)
  4501. AnnounceX(0, MESSAGE_LABLE[msgid], id)
  4502. }
  4503.  
  4504. reset_message_queue(id){
  4505. for (new i = 0; i <= charsmax(player_message_queue[]); i++)
  4506. player_message_queue[id][i] = -1
  4507. player_message_index[id] = 0
  4508. }
  4509.  
  4510. // load cod_mw2.ini (credits to MeRcyLeZZ)
  4511. load_cod_mw2_ini()
  4512. {
  4513. new path[64]
  4514. get_configsdir(path, charsmax(path))
  4515. format(path, charsmax(path), "%s/cod_mw2.ini", path)
  4516. if (!file_exists(path)){
  4517. new error[100]
  4518. formatex(error, charsmax(error), "Cannot load customization file %s!", path)
  4519. set_fail_state(error)
  4520. return
  4521. }
  4522. new linedata[1024], key[64], value[960]
  4523. new file = fopen(path, "rt")
  4524. while (file && !feof(file))
  4525. {
  4526. fgets(file, linedata, charsmax(linedata)) // read a line
  4527. replace(linedata, charsmax(linedata), "^n", "") // remove new-lines
  4528. if (!linedata[0] || linedata[0] == ';') continue // ignore empty or ;
  4529. strtok(linedata, key, charsmax(key), value, charsmax(value), '=') // get key / value
  4530. trim(key); trim(value) // trim spaces
  4531. if (equal(key, "ENABLE")) po_enable = str_to_num(value)
  4532. else if (equal(key, "MW2 SKIN")) po_skin = str_to_num(value)
  4533. else if (equal(key, "DIFFICULTY")) po_difficulty = str_to_float(value)
  4534. else if (equal(key, "START HP")) po_start_hp = str_to_num(value)
  4535. else if (equal(key, "MEDKIT HP")) po_medkit_hp = str_to_num(value)
  4536. else if (equal(key, "RANDOM SPAWN")) po_random_spawn = str_to_num(value)
  4537. else if (equal(key, "DESERT FX")) po_desert_fx = str_to_num(value)
  4538. else if (equal(key, "SQLX HOST")) copy(sqlx_host, charsmax(sqlx_host), value)
  4539. else if (equal(key, "SQLX USER")) copy(sqlx_user, charsmax(sqlx_user), value)
  4540. else if (equal(key, "SQLX PASS")) copy(sqlx_pass, charsmax(sqlx_pass), value)
  4541. else if (equal(key, "SQLX DB")) copy(sqlx_db, charsmax(sqlx_db), value)
  4542. }
  4543. if (file) fclose(file)
  4544.  
  4545. // cell min/max limits
  4546. po_start_hp = clamp(po_start_hp, 1, floatround(HP_LIMIT))
  4547. po_medkit_hp = clamp(po_medkit_hp, 0, 50)
  4548. new xcxcxc[64]
  4549. format(xcxcxc, 63, "------po: %i ---- des: %f", po_desert_fx, float(po_desert_fx) / 10000.0)
  4550. server_print(xcxcxc)
  4551. }
  4552.  
  4553. // round end stuff
  4554. end_game_check()
  4555. {
  4556. if (score_freeze || id_nuker) return
  4557.  
  4558. score_freeze = true
  4559. if (team_score[TEAM_T] > team_score[TEAM_CT]) // T win
  4560. {
  4561. // TerminateRound(RoundEndType_TeamExtermination, TeamWinning_Terrorist)
  4562. TerminateRound_TE(WinStatus_Terrorist)
  4563. round_end_sound(TEAM_T)
  4564. winner = TEAM_T
  4565. }
  4566. else if (team_score[TEAM_T] < team_score[TEAM_CT]) // CT win
  4567. {
  4568. // TerminateRound(RoundEndType_TeamExtermination, TeamWinning_Ct)
  4569. TerminateRound_TE(WinStatus_Ct)
  4570. round_end_sound(TEAM_CT)
  4571. winner = TEAM_CT
  4572. }
  4573. else if (team_score[TEAM_T] == team_score[TEAM_CT]) // Draw
  4574. {
  4575. // TerminateRound(RoundEndType_Draw)
  4576. TerminateRound_TE(WinStatus_RoundDraw)
  4577. round_end_sound()
  4578. winner = -1
  4579. }
  4580. round_end_stuff()
  4581. }
  4582.  
  4583. round_end_sound(team = 0)
  4584. {
  4585. new players[32], pnum, id, param[2]
  4586. get_players(players, pnum)
  4587.  
  4588. for (new i = 0; i < pnum; i++)
  4589. {
  4590. id = players[i]
  4591. if (!team)
  4592. {
  4593. PlayMP3(id, ROUND_NUKE_SOUND)
  4594. }
  4595. else if (team == get_user_team(id))
  4596. {
  4597. PlayMP3(id, ROUND_WIN_SOUND)
  4598. param[0] = id; param[1] = random_num(0,1)
  4599. set_task(1.5, "taskSound", _, param, 2)
  4600. }
  4601. else
  4602. {
  4603. PlayMP3(id, ROUND_LOSE_SOUND)
  4604. param[0] = id; param[1] = random_num(2,3)
  4605. set_task(1.5, "taskSound", _, param, 2)
  4606. }
  4607. }
  4608. }
  4609. public taskSound(param[])
  4610. {
  4611. new id = param[0]
  4612. new SNDid = param[1]
  4613. if (is_user_connected(id))
  4614. PlaySound(id, MEND_SOUND[SNDid])
  4615. }
  4616.  
  4617. round_end_stuff()
  4618. {
  4619. set_task(0.25, "set_map_lighting", 999, "z", 1)
  4620. set_task(0.25, "set_map_lighting", 999, "q", 1)
  4621. set_task(0.75, "set_map_lighting", 999, "g", 1)
  4622.  
  4623. // message_begin(MSG_ALL, SVC_FINALE)
  4624. // write_string("")
  4625. // message_end()
  4626.  
  4627. message_begin(MSG_ALL, g_msgHideWeapon)
  4628. write_byte((1<<0)|(1<<1)|(1<<3)|(1<<4)|(1<<5)|(1<<6)) // CAL, FLASH, RHA, TIMER, MONEY, CROSS
  4629. message_end()
  4630.  
  4631. for(new id = 1; id <= g_maxplayers; id++)
  4632. {
  4633. if(!is_user_alive(id))
  4634. continue
  4635.  
  4636. // stop fire
  4637. client_cmd(id, "-attack; -attack2")
  4638.  
  4639. // disallow fire till next round
  4640. // set_pdata_float(id, m_flNextAttack, 20.0, EXTRAOFFSET)
  4641.  
  4642. // godmode
  4643. eng_set_user_godmode(id, 1)
  4644. }
  4645. }
  4646.  
  4647. public set_map_lighting(lt[])
  4648. {
  4649. set_lights(lt)
  4650. }
  4651.  
  4652. // ============================= end round score board
  4653. show_main_score(id)
  4654. {
  4655. // not connected / not CT-T / no winner
  4656. if (!is_user_connected(id))
  4657. return
  4658.  
  4659. static iTeam; iTeam = get_user_team(id)
  4660. if (!VALIDTEAM(iTeam))
  4661. return
  4662.  
  4663. if (!VALIDTEAM(winner))
  4664. return
  4665.  
  4666. const SIZE = 1024
  4667. static msg[SIZE + 1], len; len = 0
  4668.  
  4669. // victory or defeat
  4670. if (iTeam == winner)
  4671. {
  4672. set_hudmessage(0, 255, 0, -1.0, 0.20, 1, 0.0, 3.0, 1.0, 1.0, -1)
  4673. copy(msg, charsmax(msg), "Victory!")
  4674. }
  4675. else
  4676. {
  4677. set_hudmessage(255, 0, 0, -1.0, 0.20, 1, 0.0, 3.0, 1.0, 1.0, -1)
  4678. copy(msg, charsmax(msg), "Defeat!")
  4679. }
  4680. ShowSyncHudMsg(id, g_MsgSyncAX, msg)
  4681.  
  4682. // get players list and sort by most kills
  4683. new players[32], pnum, player, sortT[16], sortCT[16], counterT, counterCT
  4684. get_players(players, pnum)
  4685. for (new i = 0; i < pnum; i++)
  4686. {
  4687. player = players[i]
  4688. switch(get_user_team(player))
  4689. {
  4690. case TEAM_T:
  4691. {
  4692. sortT[counterT] = player
  4693. counterT++
  4694. }
  4695. case TEAM_CT:
  4696. {
  4697. sortCT[counterCT] = player
  4698. counterCT++
  4699. }
  4700. }
  4701. }
  4702.  
  4703. // sort players by kills
  4704. bubble_sort_by_kills(sortT, counterT)
  4705. bubble_sort_by_kills(sortCT, counterCT)
  4706.  
  4707. len += formatex(msg[len], SIZE - len, " .: NEV :. ... OLESEK | FRAGLOPAS | HALALOK^n")
  4708.  
  4709. // T's
  4710. len += formatex(msg[len], SIZE - len, "_____________TERROROK_____________^n")
  4711. for (new t = 0; t < counterT; t++)
  4712. {
  4713. player = sortT[t]
  4714. len += formatex(msg[len], SIZE - len, "[ %s ... %i ... %i ... %i ]^n",
  4715. g_playername[player], g_kills[player], g_assists[player], g_deaths[player])
  4716. }
  4717.  
  4718. // CT's
  4719. len += formatex(msg[len], SIZE - len, "^n_____________COUNTERTERROROK______________^n")
  4720. for (new ct = 0; ct < counterCT; ct++)
  4721. {
  4722. player = sortCT[ct]
  4723. len += formatex(msg[len], SIZE - len, "[ %s ... %i ... %i ... %i ]^n",
  4724. g_playername[player], g_kills[player], g_assists[player], g_deaths[player])
  4725. }
  4726.  
  4727. set_hudmessage(25, 125, 225, 0.3, 0.3, 0, 6.0, 1.1, 0.0, 0.0, 1)
  4728. ShowSyncHudMsg(id, g_MsgSyncHUD, msg)
  4729. }
  4730.  
  4731. bubble_sort_by_kills(list[16], count)
  4732. {
  4733. if (count < 2) return
  4734. static temp, a, b
  4735. for (a = 0; a < count; a++)
  4736. {
  4737. for (b = a + 1; b < count; b++)
  4738. {
  4739. if (g_kills[list[a]] < g_kills[list[b]])
  4740. {
  4741. temp = list[a]
  4742. list[a] = list[b]
  4743. list[b] = temp
  4744. }
  4745. }
  4746. }
  4747. }
  4748.  
  4749. check_equipments(id)
  4750. {
  4751. if (!is_user_connected(id))
  4752. return
  4753.  
  4754. static ent, i
  4755. for (i = 0; i < 2; i++)
  4756. {
  4757. ent = player_c4[id][i]
  4758. if (is_valid_ent(ent) && GET_health(ent) <= 0.0)
  4759. {
  4760. player_c4[id][i] = 0
  4761. set_task(0.2, "c4_explode", ent)
  4762. }
  4763.  
  4764. ent = player_claymore[id][i]
  4765. if (is_valid_ent(ent) && GET_health(ent) <= 0.0 && !task_exists(TASK_CLAYMORE_EXPLODE+ent))
  4766. {
  4767. set_task(0.2, "claymore_explode", TASK_CLAYMORE_EXPLODE+ent)
  4768. }
  4769. }
  4770.  
  4771. ent = player_ti[id]
  4772. if (is_valid_ent(ent) && GET_health(ent) <= 0.0)
  4773. {
  4774. remove_entity(ent)
  4775. set_task(0.2, "ti_destroy", id)
  4776. }
  4777. }
  4778.  
  4779. // ============================================
  4780.  
  4781. // ==================================================================== = = = = = = = = = = criticals 2 = = =
  4782.  
  4783. //=== load / save ===
  4784. // save player data
  4785. public SAVE(id)
  4786. {
  4787. if (player_rank[id] == 1 && player_points[id] == 0)
  4788. return
  4789.  
  4790. #if defined _sqlx_included
  4791.  
  4792. SaveData(id)
  4793.  
  4794. #endif
  4795.  
  4796. #if defined _nvault_included
  4797.  
  4798. new szKey[40], szData[32]
  4799. formatex(szKey, charsmax(szKey), "%sMW2", g_szAuthID[id])
  4800. formatex(szData, charsmax(szData), "%d %d %d", player_rank[id], player_points[id], player_class[id])
  4801. nvault_set(g_vault, szKey, szData)
  4802.  
  4803. #endif
  4804. }
  4805.  
  4806. // retrieve player data
  4807. public LOAD(id)
  4808. {
  4809. #if defined _sqlx_included
  4810.  
  4811. LoadData(id)
  4812.  
  4813. #endif
  4814.  
  4815. #if defined _nvault_included
  4816.  
  4817. new szKey[40], szData[32]
  4818. formatex(szKey, charsmax(szKey), "%sMW2", g_szAuthID[id])
  4819. if (nvault_get(g_vault, szKey, szData, charsmax(szData)))
  4820. {
  4821. new params[3][32]
  4822. parse(szData, params[0], 31, params[1], 31, params[2], 31)
  4823. player_rank[id] = str_to_num(params[0])
  4824. if (!player_rank[id]) player_rank[id] = 1
  4825. player_points[id] = str_to_num(params[1])
  4826. player_class[id] = str_to_num(params[2])
  4827. user_next_class[id] = player_class[id]
  4828. }
  4829. // else no player data found
  4830.  
  4831. #endif
  4832. }
  4833. #if defined _sqlx_included
  4834. public MySql_Init()
  4835. {
  4836. g_SqlTuple = SQL_MakeDbTuple(sqlx_host,sqlx_user,sqlx_pass,sqlx_db)
  4837.  
  4838. new ErrorCode,Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,charsmax(g_Error))
  4839. if(SqlConnection == Empty_Handle)
  4840. {
  4841. set_fail_state(g_Error)
  4842. }
  4843. new Handle:Queries
  4844. Queries = SQL_PrepareQuery(SqlConnection,"CREATE TABLE IF NOT EXISTS mw2 (steamid varchar(32), rank TEXT(11), points INT(11), class INT(11))")
  4845.  
  4846. if(!SQL_Execute(Queries))
  4847. {
  4848. SQL_QueryError(Queries,g_Error,charsmax(g_Error))
  4849. set_fail_state(g_Error)
  4850. }
  4851.  
  4852. SQL_FreeHandle(Queries)
  4853. SQL_FreeHandle(SqlConnection)
  4854. }
  4855.  
  4856. public LoadData(id)
  4857. {
  4858. new ErrorCode,Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,charsmax(g_Error))
  4859.  
  4860. if(g_SqlTuple == Empty_Handle)
  4861. set_fail_state(g_Error)
  4862.  
  4863. new szSteamId[32], szTemp[512]
  4864. get_user_authid(id, szSteamId, charsmax(szSteamId))
  4865.  
  4866. new Data[1]
  4867. Data[0] = id
  4868.  
  4869. format(szTemp,charsmax(szTemp),"SELECT * FROM `mw2` WHERE (`mw2`.`steamid` = '%s')", szSteamId)
  4870. SQL_ThreadQuery(g_SqlTuple,"register_client",szTemp,Data,1)
  4871. SQL_FreeHandle(SqlConnection)
  4872. }
  4873.  
  4874. public register_client(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
  4875. {
  4876. if(FailState == TQUERY_CONNECT_FAILED)
  4877. {
  4878. log_amx("Load - Nem tudsz csatlakozni az SQL adatbazishoz. [%d] %s", Errcode, Error)
  4879. }
  4880. else if(FailState == TQUERY_QUERY_FAILED)
  4881. {
  4882. log_amx("Query betoltes sikertelen. [%d] %s", Errcode, Error)
  4883. }
  4884. new id = Data[0]
  4885.  
  4886. if(SQL_NumResults(Query) < 1)
  4887. {
  4888.  
  4889. new szSteamId[32]
  4890. get_user_authid(id, szSteamId, charsmax(szSteamId))
  4891.  
  4892. if (equal(szSteamId,"ID_PENDING"))
  4893. return PLUGIN_HANDLED
  4894.  
  4895. new szTemp[512]
  4896.  
  4897. new ErrorCode,Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,charsmax(g_Error))
  4898. if(g_SqlTuple == Empty_Handle)
  4899. set_fail_state(g_Error)
  4900.  
  4901. format(szTemp,charsmax(szTemp),"INSERT INTO `mw2`(`steamid`, `rank`, `points`, `class`) VALUES ('%s', '0', '0', '0')", szSteamId)
  4902. SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
  4903. server_print("seach information ")
  4904. SQL_FreeHandle(SqlConnection)
  4905. }
  4906. else
  4907. {
  4908.  
  4909. player_rank[id] = SQL_ReadResult(Query, 1)
  4910. player_points[id] = SQL_ReadResult(Query, 2)
  4911. player_class[id] = SQL_ReadResult(Query, 3)
  4912. user_next_class[id] = player_class[id]
  4913. server_print("read the result ")
  4914. }
  4915. return PLUGIN_CONTINUE
  4916. }
  4917.  
  4918. public IgnoreHandle(FailState,Handle:Query,Error[],Errcode,Data[],DataSize)
  4919. {
  4920. SQL_FreeHandle(Query)
  4921. return PLUGIN_HANDLED
  4922. }
  4923.  
  4924. public SaveData(id)
  4925. {
  4926. new ErrorCode,Handle:SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
  4927. if(g_SqlTuple == Empty_Handle)
  4928. set_fail_state(g_Error)
  4929.  
  4930. new szSteamId[32], szTemp[512]
  4931. get_user_authid(id, szSteamId, charsmax(szSteamId))
  4932.  
  4933. format(szTemp,charsmax(szTemp),"UPDATE `mw2` SET `rank` = '%d' , `points` = '%d' , `class` = '%d' WHERE `mw2`.`steamid` = '%s';", player_rank[id], player_points[id], player_class[id], szSteamId)
  4934. SQL_ThreadQuery(g_SqlTuple,"IgnoreHandle",szTemp)
  4935. SQL_FreeHandle(SqlConnection)
  4936. }
  4937. #endif
  4938.  
  4939.  
  4940. // this checks if wether or not
  4941. // the kill was a rescue
  4942. bool:is_rescue_kill(rescuer, enemy)
  4943. {
  4944. new num, players[32], teammate
  4945. get_players(players, num, "a")
  4946. for(new i = 0; i < num; i++)
  4947. {
  4948. teammate = players[i]
  4949.  
  4950. // ignore self and enemy's teammate
  4951. if (teammate == rescuer || !SAMETEAM(rescuer, teammate))
  4952. continue
  4953.  
  4954. // was enemy attacking my teamate?
  4955. if (last_attacker[teammate] == enemy)
  4956. return true
  4957. }
  4958. return false
  4959. }
  4960.  
  4961. // last stand's death time!
  4962. // the time has come, time to die!
  4963. public last_stand_death(taskid)
  4964. {
  4965. static id, attacker
  4966. id = taskid - TASK_DEATH
  4967. attacker = in_last_stand[id][LS_KILLER]
  4968. if(!in_last_stand[id][LS_KILLER] || !is_user_alive(id))
  4969. return
  4970.  
  4971. // put back on ground
  4972. new Float:origin[3]
  4973. GET_origin(id, origin)
  4974. origin[2] += 30.0
  4975. SET_origin(id, origin)
  4976.  
  4977. new iWeapon = in_last_stand[id][LS_WID]
  4978.  
  4979. // reset here first, for the execution XP
  4980. in_last_stand[id][LS_WID] = 0
  4981. in_last_stand[id][LS_KILLER] = 0
  4982.  
  4983. log_kill_B(attacker, id, WEAPONNAMES[iWeapon], 0, true)
  4984. }
  4985.  
  4986. // last stand
  4987. public do_last_stand(id)
  4988. {
  4989. ham_strip_user_weapon_all(id)
  4990. give_CSW(id, CSW_DEAGLE)
  4991. BP_refill(id, CSW_DEAGLE, 2)
  4992. ham_give_weapon(id, "weapon_hegrenade")
  4993. PlaySound(id, BONUS_SOUND)
  4994. AnnounceX_L(id, "INFO_LASTSTAND")
  4995. }
  4996.  
  4997. public give_medkit(id)
  4998. {
  4999. // give health?
  5000. if (po_medkit_hp)
  5001. eng_set_user_health(id, clamp(eng_get_user_health(id) + po_medkit_hp, 1, floatround(HP_LIMIT)))
  5002.  
  5003. BP_refill(id, CSW_DEAGLE)
  5004.  
  5005. if(USERPERKS(id, BLUE_PERK) == PERK_SCAVENGER)
  5006. {
  5007. PlaySound(id, MEDKIT_SOUND)
  5008. BP_refill(id)
  5009. if (hasgl[id] < GL_MAX) hasgl[id]++
  5010. ham_give_weapon(id, "weapon_flashbang")
  5011. ham_give_weapon(id, "weapon_flashbang")
  5012. //ham_give_weapon(id, "weapon_smokegrenade")
  5013.  
  5014. give_equipment(id)
  5015. }
  5016. }
  5017.  
  5018. public drop_medkit(id)
  5019. {
  5020. new Float:origin[3]
  5021. GET_origin(id, origin)
  5022. origin[2] += 10.0
  5023. new medkit = make_entity(0, medkit_classname, MEDKIT_MDL, origin, SOLID_TRIGGER, MOVETYPE_TOSS)
  5024. set_rendering(medkit, kRenderFxGlowShell, 50, 0, 200)
  5025. }
  5026.  
  5027. // this is called right after spawning
  5028. public give_stuff(taskid)
  5029. {
  5030. new id = taskid - TASK_GIVESTUFF
  5031. if(!is_user_alive(id)) return
  5032.  
  5033. eng_set_user_health(id, po_start_hp)
  5034. ham_give_weapon(id, "weapon_knife")
  5035. //ham_give_weapon(id, "weapon_smokegrenade")
  5036. ham_give_weapon(id, "weapon_flashbang")
  5037. ham_give_weapon(id, "weapon_flashbang")
  5038. eng_give_item(id, "item_kevlar")
  5039. eng_give_item(id, "item_assaultsuit")
  5040.  
  5041. new clss = player_class[id]
  5042. new iWid = PLAYER_CLASSES[clss]
  5043.  
  5044. give_CSW(id, iWid)
  5045.  
  5046. if (iWid == CSW_AK47 || iWid == CSW_M4A1)
  5047. hasgl[id] = GL_MAX
  5048.  
  5049. // give DEagle (oma has no secondary)
  5050. if (USERPERKS(id, BLUE_PERK) != PERK_ONE_MAN_ARMY)
  5051. {
  5052. give_CSW(id, CSW_DEAGLE)
  5053. give_CSW(id, CSW_GLOCK18)
  5054. }
  5055.  
  5056. give_equipment(id)
  5057.  
  5058. // if scavrnger on, 3 more ammo clips! otherwise only 2
  5059. new ammoCount = (USERPERKS(id, BLUE_PERK) == PERK_SCAVENGER) ? 5 : 2
  5060. BP_refill(id, _, ammoCount)
  5061.  
  5062. // extra grenade on scavenger
  5063. set_pdata_int(id, OFFSET_HE_AMMO, abs(ammoCount - 3), EXTRAOFFSET)
  5064. }
  5065.  
  5066. public give_equipment(id)
  5067. {
  5068. // give equipments
  5069. switch(USEREQUIP(id))
  5070. {
  5071. case UE_FRAG, UE_SEMTEX: ham_give_weapon(id, "weapon_hegrenade")
  5072. case UE_THROWING_KNIFE: has_tknife[id] = true
  5073. case UE_TACTICAL_INSERTION: has_ti[id] = true
  5074. case UE_CLAYMORE: has_claymore[id] = true
  5075. case UE_C4: has_c4[id] = true
  5076. }
  5077. }
  5078.  
  5079. // this returns something between 0.0 to 1.0
  5080. Float:get_damage_percentage(Float:fdamage)
  5081. {
  5082. static Float:start_hp; start_hp = float(po_start_hp)
  5083. return floatclamp(fdamage, 0.0, start_hp) / start_hp
  5084. }
  5085.  
  5086. // respawn
  5087. public RespawnMe(taskid)
  5088. {
  5089. if (score_freeze) return
  5090.  
  5091. new id = taskid - TASK_RESPAWN
  5092. if (!is_user_connected(id) || is_user_alive(id))
  5093. return
  5094.  
  5095. // no respawns when nuked
  5096. if (is_nuke_time) return
  5097.  
  5098. new iget_user_team = get_user_team(id)
  5099. if (iget_user_team != TEAM_T && iget_user_team != TEAM_CT)
  5100. return
  5101.  
  5102. ExecuteHam(Ham_CS_RoundRespawn, id)
  5103. }
  5104.  
  5105. public godmode_off(taskid){
  5106. new id = taskid - TASK_GODMODE_OFF
  5107. if (!is_user_alive(id)) return
  5108. eng_set_user_godmode(id, 0)
  5109. }
  5110.  
  5111. public wind_sound_loop()
  5112. PlaySound(0, WIND_SOUND)
  5113.  
  5114. public lhp_player_hurt(taskid){
  5115. new id = taskid - TASK_PHURT
  5116. if (!is_user_alive(id)) return
  5117. new ihp = eng_get_user_health(id)
  5118.  
  5119. for (new i = 0; i < 33; i++)
  5120. damage_prcnt_from[id][i] = floatround(float(damage_prcnt_from[id][i]) * float(ihp) / float(po_start_hp))
  5121.  
  5122. if(!low_hp_warning[id]){
  5123. PlaySound(id, SND_WARN[random_num(0,2)])
  5124. if (ihp > po_start_hp * 0.8) low_hp_warning[id] = true
  5125. }
  5126. }
  5127.  
  5128. public lhp_player_better(taskid){
  5129. new id = taskid - TASK_PBETTER
  5130. if (!is_user_alive(id)) return
  5131. if(low_hp_warning[id]){
  5132. PlaySound(id, SND_BETTER)
  5133. low_hp_warning[id] = false
  5134. SET_armorvalue(id, 100.0)
  5135.  
  5136. // user heath is back to normal
  5137. last_attacker[id] = 0
  5138. damage_count[id] = 0
  5139. for (new i = 1; i < 33; i++)
  5140. damage_prcnt_from[id][i] = 0
  5141. }
  5142. }
  5143.  
  5144. // for one man army
  5145. public change_player_class(taskid)
  5146. {
  5147. new id = taskid - TASK_CLASS_CHANGE
  5148. if (!is_user_alive(id))
  5149. return
  5150.  
  5151. is_changing[id] = false
  5152.  
  5153. handle_player_class(id)
  5154.  
  5155. client_print(id, print_center, "%L", LANG_PLAYER, "CLASS_CHANGED")
  5156. }
  5157.  
  5158. // give class things
  5159. handle_player_class(id)
  5160. {
  5161. // change class is done here
  5162. player_class[id] = user_next_class[id]
  5163.  
  5164. // give guns/ammo and stuff
  5165. remove_task(TASK_GIVESTUFF+id)
  5166. set_task(0.5, "give_stuff", TASK_GIVESTUFF+id)
  5167.  
  5168. // cold blooded?
  5169. set_rendering(id, _, 0, 0, 0)
  5170. if (USERPERKS(id, RED_PERK) == PERK_COLD_BLOODED)
  5171. set_rendering(id, _, _, _, _, kRenderTransTexture, 80)
  5172. }
  5173.  
  5174. // break, if breakable
  5175. breakable_check(iEnt, ent){
  5176. if(is_valid_ent(ent)){
  5177. static classname2[32]
  5178. GET_classname(ent, classname2)
  5179. if(equal(classname2, "func_breakable"))
  5180. force_use(iEnt, ent)
  5181. }
  5182. }
  5183.  
  5184. // help motd
  5185. help_motd(id){
  5186. new codmotd[2048], title[64], dpos = 0
  5187. formatex(title, charsmax(title), "[MW2 DM] %s", PLUGIN)
  5188. dpos += format(codmotd[dpos],2047-dpos,"<html><head><style type=^"text/css^">pre{color:#00FF00;}body{background:#000000;margin-left:16px;margin-top:1px;}</style></head><pre><body>")
  5189. dpos += format(codmotd[dpos],2047-dpos,"<b>%s</b>^n^n",title)
  5190. dpos += format(codmotd[dpos],2047-dpos,"%L:^n", LANG_PLAYER, "MOTD_L1")
  5191. dpos += format(codmotd[dpos],2047-dpos,"============^n^n")
  5192. dpos += format(codmotd[dpos],2047-dpos," <b>M</b> = %L^n", LANG_PLAYER, "MOTD_L2")
  5193. if (player_used_bind[id] == 3)
  5194. {
  5195. dpos += format(codmotd[dpos],2047-dpos," <b>F3</b> = %L^n", LANG_PLAYER, "MOTD_L3")
  5196. dpos += format(codmotd[dpos],2047-dpos," <b>F4</b> = %L^n", LANG_PLAYER, "MOTD_L4")
  5197. }
  5198. dpos += format(codmotd[dpos],2047-dpos," <b>E</b> = %L^n", LANG_PLAYER, "MOTD_L5")
  5199. dpos += format(codmotd[dpos],2047-dpos," <b>F</b> = %L^n", LANG_PLAYER, "MOTD_L6")
  5200. dpos += format(codmotd[dpos],2047-dpos," <b>C</b> = %L^n", LANG_PLAYER, "MOTD_L7")
  5201. if (player_used_bind[id] == 3)
  5202. {
  5203. dpos += format(codmotd[dpos],2047-dpos," <b>V</b> = %L^n", LANG_PLAYER, "MOTD_L8")
  5204. dpos += format(codmotd[dpos],2047-dpos," <b>X / Mouse3</b> = %L (M4A1/AK47)^n", LANG_PLAYER, "MOTD_L9")
  5205. }
  5206. dpos += format(codmotd[dpos],2047-dpos,"^n%L^n", LANG_PLAYER, "MOTD_L10")
  5207. show_motd(id, codmotd, title)
  5208. }
  5209.  
  5210. // ============================================================== = = = = = = = = = = stocks = = = = = = =
  5211.  
  5212. // my version of stuck check ( but still credits to 'NL)Ramon(NL' )
  5213. stock stuck_check(id)
  5214. {
  5215. if (!is_user_alive(id)) return
  5216.  
  5217. if (in_last_stand[id][LS_KILLER]) return
  5218.  
  5219. static Float:stuck[33], Float:curTime; curTime = get_gametime()
  5220. static Float:origin[3], Float:mins[3], hull, Float:vec[3], v
  5221. static const Float:size[][3] = {
  5222. {0.0, 0.0, 1.0}, {0.0, 0.0, -1.0}, {0.0, 1.0, 0.0}, {0.0, -1.0, 0.0}, {1.0, 0.0, 0.0}, {-1.0, 0.0, 0.0}, {-1.0, 1.0, 1.0}, {1.0, 1.0, 1.0}, {1.0, -1.0, 1.0}, {1.0, 1.0, -1.0}, {-1.0, -1.0, 1.0}, {1.0, -1.0, -1.0}, {-1.0, 1.0, -1.0}, {-1.0, -1.0, -1.0},
  5223. {0.0, 0.0, 2.0}, {0.0, 0.0, -2.0}, {0.0, 2.0, 0.0}, {0.0, -2.0, 0.0}, {2.0, 0.0, 0.0}, {-2.0, 0.0, 0.0}, {-2.0, 2.0, 2.0}, {2.0, 2.0, 2.0}, {2.0, -2.0, 2.0}, {2.0, 2.0, -2.0}, {-2.0, -2.0, 2.0}, {2.0, -2.0, -2.0}, {-2.0, 2.0, -2.0}, {-2.0, -2.0, -2.0},
  5224. {0.0, 0.0, 3.0}, {0.0, 0.0, -3.0}, {0.0, 3.0, 0.0}, {0.0, -3.0, 0.0}, {3.0, 0.0, 0.0}, {-3.0, 0.0, 0.0}, {-3.0, 3.0, 3.0}, {3.0, 3.0, 3.0}, {3.0, -3.0, 3.0}, {3.0, 3.0, -3.0}, {-3.0, -3.0, 3.0}, {3.0, -3.0, -3.0}, {-3.0, 3.0, -3.0}, {-3.0, -3.0, -3.0},
  5225. {0.0, 0.0, 4.0}, {0.0, 0.0, -4.0}, {0.0, 4.0, 0.0}, {0.0, -4.0, 0.0}, {4.0, 0.0, 0.0}, {-4.0, 0.0, 0.0}, {-4.0, 4.0, 4.0}, {4.0, 4.0, 4.0}, {4.0, -4.0, 4.0}, {4.0, 4.0, -4.0}, {-4.0, -4.0, 4.0}, {4.0, -4.0, -4.0}, {-4.0, 4.0, -4.0}, {-4.0, -4.0, -4.0},
  5226. {0.0, 0.0, 5.0}, {0.0, 0.0, -5.0}, {0.0, 5.0, 0.0}, {0.0, -5.0, 0.0}, {5.0, 0.0, 0.0}, {-5.0, 0.0, 0.0}, {-5.0, 5.0, 5.0}, {5.0, 5.0, 5.0}, {5.0, -5.0, 5.0}, {5.0, 5.0, -5.0}, {-5.0, -5.0, 5.0}, {5.0, -5.0, -5.0}, {-5.0, 5.0, -5.0}, {-5.0, -5.0, -5.0}
  5227. }
  5228.  
  5229. GET_origin(id, origin)
  5230. hull = GET_flags(id) & FL_DUCKING ? HULL_HEAD : HULL_HUMAN
  5231. if (!is_hull_vacant_2(origin, hull, id))
  5232. {
  5233. if (stuck[id] > curTime) return
  5234. stuck[id] = curTime + 0.5
  5235. GET_mins(id, mins)
  5236. vec[2] = origin[2]
  5237. for (v = 0; v < sizeof size; ++v)
  5238. {
  5239. vec[0] = origin[0] - mins[0] * size[v][0]
  5240. vec[1] = origin[1] - mins[1] * size[v][1]
  5241. vec[2] = origin[2] - mins[2] * size[v][2]
  5242. if (is_hull_vacant_2(vec, hull, id))
  5243. {
  5244. SET_origin(id, vec)
  5245. SET_velocity(id, Float:{0.0,0.0,0.0})
  5246. v = sizeof size
  5247. }
  5248. }
  5249. }
  5250. else stuck[id] = 0.0
  5251. }
  5252. stock bool:is_hull_vacant_2(const Float:origin[3], hull,id){
  5253. static tr; engfunc(EngFunc_TraceHull, origin, origin, 0, hull, id, tr)
  5254. return (!get_tr2(tr, TR_StartSolid) || !get_tr2(tr, TR_AllSolid))
  5255. }
  5256.  
  5257. // gives a player a weapon efficiently (XxAvalanchexX's version)
  5258. stock ham_give_weapon(id, const weapon[])
  5259. {
  5260. if (!is_user_alive(id))
  5261. return 0
  5262.  
  5263. if (!equal(weapon, "weapon_", 7))
  5264. return 0
  5265.  
  5266. new wEnt = create_entity(weapon)
  5267. if (!is_valid_ent(wEnt))
  5268. return 0
  5269.  
  5270. SET_spawnflags(wEnt, SF_NORESPAWN)
  5271. DispatchSpawn(wEnt)
  5272.  
  5273. if (!ExecuteHamB(Ham_AddPlayerItem, id, wEnt))
  5274. {
  5275. if (is_valid_ent(wEnt))
  5276. SET_flags(wEnt, GET_flags(wEnt) | FL_KILLME)
  5277.  
  5278. return 0
  5279. }
  5280.  
  5281. ExecuteHamB(Ham_Item_AttachToPlayer, wEnt, id)
  5282. return 1
  5283. }
  5284.  
  5285. // strip user weapon (ConnorMcLeod's version)
  5286. stock ham_strip_user_weapon(id, iCswId, iSlot = 0, bool:bSwitchIfActive = true)
  5287. {
  5288. if (!is_user_alive(id)) return 0
  5289. static iWeapon
  5290. if( !iSlot ) iSlot = WEAPONSLOT[iCswId]
  5291. iWeapon = get_pdata_cbase(id, m_rgpPlayerItems_Slot0 + iSlot, EXTRAOFFSET)
  5292. while( iWeapon > 0 )
  5293. {
  5294. if( get_pdata_int(iWeapon, m_iId, EXTRAOFFSET_WEAPONS) == iCswId )
  5295. {
  5296. break
  5297. }
  5298. iWeapon = get_pdata_cbase(iWeapon, m_pNext, EXTRAOFFSET_WEAPONS)
  5299. }
  5300. if( iWeapon > 0 )
  5301. {
  5302. if( bSwitchIfActive && get_pdata_cbase(id, m_pActiveItem, EXTRAOFFSET) == iWeapon )
  5303. {
  5304. ExecuteHamB(Ham_Weapon_RetireWeapon, iWeapon)
  5305. }
  5306.  
  5307. if( ExecuteHamB(Ham_RemovePlayerItem, id, iWeapon) )
  5308. {
  5309. user_has_weapon(id, iCswId, 0)
  5310. ExecuteHamB(Ham_Item_Kill, iWeapon)
  5311. return 1
  5312. }
  5313. }
  5314. return 0
  5315. }
  5316.  
  5317. // this is now mine :|
  5318. stock ham_strip_user_weapon_all(id)
  5319. {
  5320. static weapons[32], num, i, toRemove; num = 0
  5321. get_user_weapons(id, weapons, num)
  5322. for (i = 0; i < num; i++){
  5323. toRemove = weapons[i]
  5324. ham_strip_user_weapon(id, toRemove)
  5325. }
  5326. }
  5327.  
  5328. stock blast_damage(victim, Float:damage, Float:origin[3])
  5329. {
  5330. set_msg_block(g_msgDamage, BLOCK_ONCE)
  5331. fakedamage(victim, "grenade", damage, DMG_BLAST)
  5332. message_begin(MSG_ONE, g_msgDamage, _,victim)
  5333. write_byte(floatround(damage)+1)
  5334. write_byte(floatround(damage))
  5335. write_long(DMG_BLAST)
  5336. write_coord(floatround(origin[0]))
  5337. write_coord(floatround(origin[1]))
  5338. write_coord(floatround(origin[2]))
  5339. message_end()
  5340. }
  5341.  
  5342. // knock (credits to KleeneX)
  5343. stock eng_do_knock(attacker, victim, Float:fPower1)
  5344. {
  5345. new Float:damage = get_damage_percentage(fPower1) * 100
  5346. new Float:fPower2 = ( damage > 100.0 ? 100.0 : damage ) * 225.0
  5347. new Float:vec[3], Float:vicorigin[3], Float:attorigin[3]
  5348. new Float:oldvelo[3], Float:origin2[3], Float:largestnum = 0.0
  5349. GET_velocity(victim, oldvelo)
  5350. GET_origin(victim, vicorigin)
  5351. GET_origin(attacker, attorigin)
  5352. origin2[0] = vicorigin[0] - attorigin[0]
  5353. origin2[1] = vicorigin[1] - attorigin[1]
  5354. if(floatabs(origin2[0])>largestnum) largestnum = floatabs(origin2[0])
  5355. if(floatabs(origin2[1])>largestnum) largestnum = floatabs(origin2[1])
  5356. origin2[0] /= largestnum
  5357. origin2[1] /= largestnum
  5358. vec[0] = ( origin2[0] * fPower2 ) / floatround(entity_range(victim , attacker))
  5359. vec[1] = ( origin2[1] * fPower2 ) / floatround(entity_range(victim , attacker))
  5360. if(vec[0] <= 20.0 || vec[1] <= 20.0)
  5361. vec[2] = random_float(200.0 , 275.0)
  5362. vec[0] += oldvelo[0]
  5363. vec[1] += oldvelo[1]
  5364. SET_velocity(victim, vec)
  5365. }
  5366.  
  5367. stock user_scr_shake(id, Float:damage)
  5368. {
  5369. new Float:pct, shakeFreq, Float:velocity[3]
  5370. pct = get_damage_percentage(damage)
  5371. shakeFreq = floatround( pct * 10 * UNIT_SECOND )
  5372.  
  5373. message_begin(MSG_ONE_UNRELIABLE, g_msgScreenShake, _, id)
  5374. write_short(UNIT_SECOND * 8) // Amplitude
  5375. write_short(UNIT_SECOND) // Duration
  5376. write_short(shakeFreq) // Frequency
  5377. message_end()
  5378.  
  5379. // decrease player speed by given damage amount
  5380. GET_velocity(id, velocity)
  5381. velocity[0] *= (1.0 - pct)
  5382. velocity[1] *= (1.0 - pct)
  5383. SET_velocity(id, velocity)
  5384. }
  5385.  
  5386. stock user_scr_blood(id, Float:damage)
  5387. {
  5388. if (damage < 1.0) return
  5389. new Float:prc = get_damage_percentage(damage)
  5390. new damage_red = floatround(prc * 255)
  5391. new hold_time = 1 + floatround(prc * 2.0)
  5392. Display_Fade(id, 1, hold_time, FFADE_IN, damage_red, 0, 0, 155)
  5393. }
  5394.  
  5395. stock Display_Fade(id, duration, holdtime, fadetype, red, green, blue, alpha, bool:reliable = false)
  5396. {
  5397. message_begin((id) ? (reliable) ? MSG_ONE : MSG_ONE_UNRELIABLE : MSG_BROADCAST, g_msgScreenFade, _, id)
  5398. write_short(UNIT_SECOND * duration)
  5399. write_short(UNIT_SECOND * holdtime)
  5400. write_short(fadetype)
  5401. write_byte(red)
  5402. write_byte(green)
  5403. write_byte(blue)
  5404. write_byte(alpha)
  5405. message_end()
  5406. }
  5407.  
  5408. // explosion effect
  5409. stock show_explosion(origin[3])
  5410. {
  5411. message_begin(MSG_BROADCAST, SVC_TEMPENTITY, origin)
  5412. write_byte(TE_EXPLOSION)
  5413. write_coord(origin[0])
  5414. write_coord(origin[1])
  5415. write_coord(origin[2])
  5416. write_short(spr_explosion)
  5417. write_byte(30) // scale in 0.1's
  5418. write_byte(15) // framerate
  5419. write_byte(TE_EXPLFLAG_NOSOUND) // TE_EXPLFLAG_NONE with sound
  5420. message_end()
  5421. }
  5422.  
  5423. stock show_explosion1(ent)
  5424. {
  5425. static iOrigin[3]
  5426. get_origin_int(ent, iOrigin)
  5427. show_explosion(iOrigin)
  5428. }
  5429.  
  5430. stock show_explosion2(ent)
  5431. {
  5432. new iOrigin[3]
  5433. get_origin_int(ent, iOrigin)
  5434. show_explosion(iOrigin)
  5435. message_begin(MSG_ALL,SVC_TEMPENTITY,iOrigin)
  5436. write_byte(TE_BEAMCYLINDER)
  5437. write_coord(iOrigin[0])
  5438. write_coord(iOrigin[1])
  5439. write_coord(iOrigin[2])
  5440. write_coord(iOrigin[0])
  5441. write_coord(iOrigin[1])
  5442. write_coord(iOrigin[2]+200)
  5443. write_short(spr_white)
  5444. write_byte(0)
  5445. write_byte(1)
  5446. write_byte(6)
  5447. write_byte(8)
  5448. write_byte(1)
  5449. write_byte(255)
  5450. write_byte(255)
  5451. write_byte(192)
  5452. write_byte(128)
  5453. write_byte(5)
  5454. message_end()
  5455. }
  5456.  
  5457. stock show_payback(id)
  5458. {
  5459. new iOrigin[3]
  5460. get_origin_int(id, iOrigin)
  5461. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  5462. write_byte(TE_BLOODSPRITE)
  5463. write_coord(iOrigin[0])
  5464. write_coord(iOrigin[1])
  5465. write_coord(iOrigin[2])
  5466. write_short(spr_money)
  5467. write_short(spr_money)
  5468. write_byte(243)
  5469. write_byte(20)
  5470. message_end()
  5471. }
  5472.  
  5473. stock make_entity(iOwner, const szClassname[], const szModel[], Float:origin[3], iSolid, iMovetype, iHealth = 0, Float:fSize = 4.0){
  5474. static iEnt, Float:vSize1[3], Float:vSize2[3]
  5475. vSize1[0] = -fSize; vSize1[1] = -fSize; vSize1[2] = -fSize
  5476. vSize2[0] = fSize; vSize2[1] = fSize; vSize2[2] = fSize
  5477.  
  5478. if (iHealth){
  5479. iEnt = create_entity("func_breakable") // func_wall func_breakable
  5480. DispatchKeyValue(iEnt, "material", material_Computer)
  5481. SET_health(iEnt, float(iHealth))
  5482. SET_takedamage(iEnt, DAMAGE_YES)
  5483. }else{
  5484. iEnt = create_entity("info_target")
  5485. }
  5486.  
  5487. if (!iEnt) return 0
  5488. if (!iHealth) DispatchSpawn(iEnt)
  5489. SET_classname(iEnt, szClassname)
  5490. entity_set_model(iEnt, szModel)
  5491. entity_set_size(iEnt, vSize1, vSize2)
  5492. SET_origin(iEnt, origin)
  5493. SET_solid(iEnt, iSolid)
  5494. SET_movetype(iEnt, iMovetype)
  5495. SET_owner(iEnt, iOwner)
  5496. return iEnt
  5497. }
  5498.  
  5499. stock PlaySound(id, const soundFile[])
  5500. client_cmd(id, "spk ^"%s^"", soundFile)
  5501.  
  5502. stock PlayMP3(id, const mp3File[])
  5503. client_cmd(id, "mp3 lejatszo ^"sound/%s^"", mp3File)
  5504.  
  5505. stock user_heal_icon(id, mode)
  5506. {
  5507. message_begin(MSG_ONE_UNRELIABLE, g_msgStatusIcon, _, id)
  5508. write_byte(mode)
  5509. write_string("item_healthkit")
  5510. write_byte(10)
  5511. write_byte(10)
  5512. write_byte(10)
  5513. message_end()
  5514. }
  5515.  
  5516. stock get_origin_int(iEnt, origin[3])
  5517. {
  5518. if (!is_valid_ent(iEnt)) return
  5519. static Float:fOrigin[3]
  5520. GET_origin(iEnt, fOrigin)
  5521. FVecIVec(fOrigin, origin)
  5522. }
  5523.  
  5524. // show a hitmark
  5525. stock BulletX(id, Float:fDamage)
  5526. {
  5527. static hitmark
  5528. hitmark = clamp(floatround((fDamage / HP_LIMIT) * 4.1) - 1, 0, 3)
  5529.  
  5530. // dont show X when showing points / nuke
  5531. if (!id_nuker)
  5532. {
  5533. set_hudmessage(50, 100, 100, -1.0, 0.49, 2, 0.1,/*delay=*/ 0.20, 0.02, 0.02, 2)
  5534. ShowSyncHudMsg(id, g_MsgSyncHUD, "X")
  5535. }
  5536.  
  5537. PlaySound(id, BULLETX_SOUND[hitmark])
  5538. }
  5539.  
  5540. stock give_CSW(id, iCSW)
  5541. {
  5542. if (!id || !iCSW) return
  5543.  
  5544. new tmp[32]
  5545. formatex(tmp, 31, "weapon_%s", WEAPONNAMES[iCSW])
  5546. ham_give_weapon(id, tmp)
  5547. eng_give_item(id, tmp)
  5548. }
  5549.  
  5550. stock get_CSW_id(ent){
  5551. static wname[32] //, tmp[32]
  5552. for (new i = g_maxplayers + 1; i < g_maxentities; ++i)
  5553. {
  5554. if (is_valid_ent(i) && ent == GET_owner(i))
  5555. {
  5556. GET_classname(i, wname)
  5557. for (new j = 0; j <= charsmax(WEAPONNAMES); j++)
  5558. {
  5559. // formatex(tmp, charsmax(tmp), "weapon_%s", WEAPONNAMES[j])
  5560. if (contain(wname, WEAPONNAMES[j])) return j
  5561. }
  5562. }
  5563. }
  5564. return 0
  5565. }
  5566.  
  5567. // convert "weapon_*" to weapon id
  5568. // returns weapon id or 0 when fail.
  5569. stock weapon_str_to_id(const wname[])
  5570. {
  5571. for (new i = 0; i <= charsmax(WEAPONNAMES); i++)
  5572. if (equal(wname, WEAPONNAMES[i]))
  5573. return i
  5574. return 0
  5575. }
  5576.  
  5577. // hide weapon
  5578. stock set_hud_flags(id, iFlags)
  5579. {
  5580. message_begin(MSG_ONE, g_msgHideWeapon, _, id)
  5581. write_byte(iFlags)
  5582. message_end()
  5583. }
  5584.  
  5585. // smoke effect
  5586. stock show_smoke(origin[3])
  5587. {
  5588. message_begin(MSG_BROADCAST, SVC_TEMPENTITY, origin)
  5589. write_byte(TE_EXPLOSION)
  5590. write_coord(origin[0])
  5591. write_coord(origin[1])
  5592. write_coord(origin[2])
  5593. write_short(spr_smoke)
  5594. write_byte(15) // scale in 0.1's
  5595. write_byte(15) // framerate
  5596. write_byte(TE_EXPLFLAG_NOSOUND)
  5597. message_end()
  5598. }
  5599.  
  5600. // beam follow
  5601. stock msg_beam_follow(ent, r, g, b, iBullet = 0)
  5602. {
  5603. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  5604. write_byte(TE_BEAMFOLLOW)
  5605. write_short(ent)
  5606. write_short(spr_trail)
  5607. write_byte(iBullet ? 3 : 5)
  5608. write_byte(iBullet ? 2 : 3)
  5609. write_byte(r)
  5610. write_byte(g)
  5611. write_byte(b)
  5612. write_byte(iBullet ? 100 : 150)
  5613. message_end()
  5614. }
  5615.  
  5616. // critical
  5617. stock is_valid_player(id){
  5618. if (id > 0 && id <= g_maxplayers && is_valid_ent(id))
  5619. return id
  5620. return 0
  5621. }
  5622.  
  5623. // check/remove
  5624. stock safe_remove_entity(iEnt)
  5625. if (is_valid_ent(iEnt))
  5626. remove_entity(iEnt)
  5627.  
  5628. // one BP Ammo (credits to MeRcyLeZZ)
  5629. stock BP_refill(id, wid = 0, count = 1)
  5630. {
  5631. static weapons[32], num, i, weaponid, j; num = 0
  5632. if (wid)
  5633. {
  5634. if (user_has_weapon(id, wid))
  5635. for (j = 0; j < count; j++)
  5636. ExecuteHamB(Ham_GiveAmmo, id, AMMOPACK[weaponid], AMMOTYPE[weaponid], MAXBPAMMO[weaponid])
  5637. }
  5638. else
  5639. {
  5640. get_user_weapons(id, weapons, num)
  5641. for (i = 0; i < num; i++)
  5642. {
  5643. weaponid = weapons[i]
  5644. if (MAXBPAMMO[weaponid] <= 2) // Primary and secondary only
  5645. continue
  5646.  
  5647.  
  5648. for (j = 0; j < count; j++)
  5649. ExecuteHamB(Ham_GiveAmmo, id, AMMOPACK[weaponid], AMMOTYPE[weaponid], MAXBPAMMO[weaponid])
  5650. }
  5651. }
  5652. }
  5653.  
  5654. stock fm_eng_set_user_deaths(id, newdeaths)
  5655. {
  5656. if (!is_user_connected(id)) return
  5657. SET_frags(id, newdeaths)
  5658. set_pdata_int(id, OFFSET_CSDEATHS, newdeaths, EXTRAOFFSET)
  5659. message_begin(MSG_ALL, g_msgScoreInfo)
  5660. write_byte(id)
  5661. write_short(GET_frags(id))
  5662. write_short(g_deaths[id])
  5663. write_short(0)
  5664. write_short(get_user_team(id))
  5665. message_end()
  5666. }
  5667.  
  5668. //********************************************************************************************************
  5669. // =============================== fakemeta_util stocks converted to engine ==============================
  5670. //********************************************************************************************************
  5671.  
  5672. stock eng_set_user_godmode(index, godmode = 0) {
  5673. SET_takedamage(index, godmode == 1 ? DAMAGE_NO : DAMAGE_AIM);
  5674.  
  5675. return 1;
  5676. }
  5677. stock eng_get_user_godmode(index) {
  5678. return (GET_takedamage(index) == DAMAGE_NO);
  5679. }
  5680. stock eng_set_user_health(index, health) {
  5681. health > 0 ? SET_health(index, float(health)) : user_kill(index);
  5682.  
  5683. return 1;
  5684. }
  5685. stock eng_give_item(index, const item[]){
  5686. if (!is_user_alive(index)) return 0
  5687.  
  5688. if (!equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
  5689. return 0;
  5690.  
  5691. new ent = create_entity(item);
  5692. if (!is_valid_ent(ent))
  5693. return 0;
  5694.  
  5695. new Float:origin[3];
  5696. GET_origin(index, origin);
  5697. SET_origin(ent, origin);
  5698. SET_spawnflags(ent, GET_spawnflags(ent) | SF_NORESPAWN);
  5699. DispatchSpawn(ent);
  5700.  
  5701. new save = GET_solid(ent);
  5702. fake_touch(ent, index);
  5703. if (GET_solid(ent) != save)
  5704. return ent;
  5705.  
  5706. remove_entity(ent);
  5707.  
  5708. return -1;
  5709. }
  5710.  
  5711. // =========================================================================================== Fast reload
  5712. // increase reload speed when using Sleight Of Hand perk.
  5713. public Weapon_Reload(iEnt)
  5714. {
  5715. if (!is_valid_ent(iEnt)) return HAM_IGNORED
  5716. new id = get_pdata_cbase(iEnt, m_pPlayer, EXTRAOFFSET_WEAPONS)
  5717. if (!is_user_alive(id))
  5718. return HAM_IGNORED
  5719.  
  5720. if(get_pdata_int(iEnt, m_fInReload, EXTRAOFFSET_WEAPONS))
  5721. {
  5722. if (USERPERKS(id, BLUE_PERK) != PERK_SLEIGHT_OF_HAND)
  5723. return HAM_IGNORED
  5724.  
  5725. new Float:flNextAttack = get_pdata_float(id, m_flNextAttack, EXTRAOFFSET) * 0.2
  5726. set_pdata_float(id, m_flNextAttack, flNextAttack, EXTRAOFFSET)
  5727. new iSeconds = floatround(flNextAttack, floatround_ceil)
  5728. Make_BarTime2(id, iSeconds, 100 - floatround( (flNextAttack/iSeconds) * 100 ))
  5729.  
  5730. // if (GET_button(id) & IN_RELOAD)
  5731. // {
  5732. // // inform reload sound
  5733. // }
  5734. }
  5735. return HAM_IGNORED
  5736. }
  5737.  
  5738. Make_BarTime2(id, iSeconds, iPercent){
  5739. message_begin(MSG_ONE_UNRELIABLE, g_msgBarTime2, _, id)
  5740. write_short(iSeconds)
  5741. write_short(iPercent)
  5742. message_end()
  5743. }
  5744.  
  5745. // =========================================================================================== Random respawn
  5746. // Collect random spawn points
  5747. stock load_spawns(){
  5748. new cfgdir[32], mapname[32], filepath[100], linedata[64]
  5749. get_configsdir(cfgdir, charsmax(cfgdir))
  5750. get_mapname(mapname, charsmax(mapname))
  5751. formatex(filepath, charsmax(filepath), "%s/csdm/%s.spawns.cfg", cfgdir, mapname)
  5752.  
  5753. if (file_exists(filepath)){
  5754. new csdmdata[10][6], file = fopen(filepath,"rt")
  5755. while (file && !feof(file)){
  5756. fgets(file, linedata, charsmax(linedata))
  5757. if(!linedata[0] || str_count(linedata,' ') < 2) continue;
  5758. parse(linedata,csdmdata[0],5,csdmdata[1],5,csdmdata[2],5,csdmdata[3],5,csdmdata[4],5,csdmdata[5],5,csdmdata[6],5,csdmdata[7],5,csdmdata[8],5,csdmdata[9],5)
  5759. g_spawns[g_spawnCount][0] = floatstr(csdmdata[0])
  5760. g_spawns[g_spawnCount][1] = floatstr(csdmdata[1])
  5761. g_spawns[g_spawnCount][2] = floatstr(csdmdata[2])
  5762. g_spawnCount++
  5763. if (g_spawnCount >= sizeof g_spawns) break;
  5764. }
  5765. if (file) fclose(file)
  5766. }else{
  5767. collect_spawns_ent("info_player_start")
  5768. collect_spawns_ent("info_player_deathmatch")
  5769. }
  5770. collect_spawns_ent2("info_player_start")
  5771. collect_spawns_ent2("info_player_deathmatch")
  5772. }
  5773.  
  5774. // Collect spawn points from entity origins
  5775. stock collect_spawns_ent(const classname[]){
  5776. new ent = -1
  5777. while ((ent = find_ent_by_class(ent, classname)) != 0){
  5778. new Float:originF[3]
  5779. GET_origin(ent, originF)
  5780. g_spawns[g_spawnCount][0] = originF[0]
  5781. g_spawns[g_spawnCount][1] = originF[1]
  5782. g_spawns[g_spawnCount][2] = originF[2]
  5783. g_spawnCount++
  5784. if (g_spawnCount >= sizeof g_spawns) break;
  5785. }
  5786. }
  5787.  
  5788. // Collect spawn points from entity origins
  5789. stock collect_spawns_ent2(const classname[]){
  5790. new ent = -1
  5791. while ((ent = find_ent_by_class(ent, classname)) != 0){
  5792. new Float:originF[3]
  5793. GET_origin(ent, originF)
  5794. g_spawns2[g_spawnCount2][0] = originF[0]
  5795. g_spawns2[g_spawnCount2][1] = originF[1]
  5796. g_spawns2[g_spawnCount2][2] = originF[2]
  5797. g_spawnCount2++
  5798. if (g_spawnCount2 >= sizeof g_spawns2) break;
  5799. }
  5800. }
  5801.  
  5802. // Place user at a random spawn
  5803. public event_ResetHUD(id){
  5804. // hide money n stuff
  5805. set_hud_flags(id, HIDE_NORMAL)
  5806.  
  5807. new ti = player_ti[id]
  5808. if (is_valid_ent(ti)) // has tactical insertion?
  5809. {
  5810. // put player on top of ti
  5811. new Float:ti_origin[3]
  5812. GET_origin(ti, ti_origin)
  5813. ti_origin[2] += 50.0
  5814. SET_origin(id, ti_origin)
  5815.  
  5816. // put him in same direction he was when making ti
  5817. GET_angles(ti, ti_origin) // angles
  5818. SET_angles(id, ti_origin)
  5819.  
  5820. // remove ti
  5821. remove_entity(ti)
  5822. player_ti[id] = 0
  5823. return
  5824. }
  5825. else if (ti) player_ti[id] = 0 // bugfix
  5826.  
  5827. // first spawn at home
  5828. if (first_spawn[id] > 0){
  5829. first_spawn[id]--
  5830. return
  5831. }
  5832.  
  5833. // random spawn
  5834. static hull, sp_index, i
  5835. hull = (GET_flags(id) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN
  5836. if (!g_spawnCount || !po_random_spawn)
  5837. return
  5838. sp_index = random_num(0, g_spawnCount - 1)
  5839. for (i = sp_index + 1; /*no condition*/; i++){
  5840. if (i >= g_spawnCount) i = 0
  5841. if (is_hull_vacant(g_spawns[i], hull)){
  5842. SET_origin(id, g_spawns[i])
  5843. break;
  5844. }
  5845. if (i == sp_index) break;
  5846. }
  5847. }
  5848.  
  5849. // Checks if a space is vacant (credits to VEN)
  5850. stock bool:is_hull_vacant(Float:origin[3], hull){
  5851. engfunc(EngFunc_TraceHull, origin, origin, 0, hull, 0, 0)
  5852. if (!get_tr2(0, TR_StartSolid) && !get_tr2(0, TR_AllSolid) && get_tr2(0, TR_InOpen))
  5853. return true;
  5854. return false;
  5855. }
  5856.  
  5857. // Stock by (probably) Twilight Suzuka -counts number of chars in a string
  5858. stock str_count(const str[], searchchar){
  5859. new count, i, len = strlen(str)
  5860. for (i = 0; i <= len; i++){
  5861. if(str[i] == searchchar)
  5862. count++
  5863. }
  5864. return count;
  5865. }
  5866. //*****************************************************************************************************
  5867. //*****************************************************************************************************
  5868.  
  5869. //*************************************** Equipments things here **************************************
  5870.  
  5871. // semtex
  5872. public semtex_stick(taskid)
  5873. {
  5874. new semtex = taskid - TASK_SEMTEX_STICK
  5875. if (!is_valid_ent(semtex))
  5876. return
  5877. new victim = GET_ATTACHED(semtex)
  5878. if (!is_user_alive(victim))
  5879. return
  5880.  
  5881. static Float:victimOrigin[3]
  5882. GET_origin(victim, victimOrigin)
  5883. SET_origin(semtex, victimOrigin)
  5884.  
  5885. // loop this
  5886. set_task(0.1, "semtex_stick", taskid)
  5887. }
  5888.  
  5889. // tell attacker semtex got stuck
  5890. // to enemy player
  5891. public semtex_stuck_message(id)
  5892. add_message_in_queue(id, BM_STUCK)
  5893.  
  5894. // tell victim semtex got stuck
  5895. // to him (+sound +screen goes red)
  5896. public semtex_stuck_message_victim(id)
  5897. {
  5898. user_scr_blood(id, HP_LIMIT)
  5899. PlaySound(id, BADNEWS_SOUND)
  5900. AnnounceX_L(id, "INFO_STUCK", _, 255, 0, 0)
  5901. }
  5902.  
  5903. //================================================================================ THROWING KNIFE =======
  5904. public throw_knife(id)
  5905. {
  5906. if (!is_user_alive(id))
  5907. return
  5908.  
  5909. if (!has_tknife[id])
  5910. {
  5911. client_print(id, print_center, "%L", LANG_PLAYER, "TKNIFE_OUT")
  5912. return
  5913. }
  5914.  
  5915. has_tknife[id] = false
  5916.  
  5917. new Float:origin[3], Float:Aim[3]
  5918. GET_origin(id, origin)
  5919. velocity_by_aim(id, 64, Aim)
  5920. origin[0] += Aim[0]; origin[1] += Aim[1]
  5921.  
  5922. new tknife = make_entity(id, tknife_classname, TKNIFE_MODEL, origin, SOLID_SLIDEBOX, MOVETYPE_TOSS, _, 1.0)
  5923.  
  5924. new Float:velocity[3]
  5925. velocity_by_aim(id, 900, velocity)
  5926. SET_velocity(tknife, velocity)
  5927. vector_to_angle(velocity, Aim)
  5928. Aim[0] -= 90.0
  5929. SET_angles(tknife, Aim)
  5930. }
  5931.  
  5932. //================================================================================ TACTICAL INSERTION ====
  5933.  
  5934. public put_ti(id)
  5935. {
  5936. if (!is_user_alive(id))
  5937. return
  5938.  
  5939. if (task_exists(TASK_TACTICAL_INSERTION + id))
  5940. return
  5941.  
  5942. if (!has_ti[id])
  5943. {
  5944. client_print(id, print_center, "%L", LANG_PLAYER, "TI_OUT")
  5945. return
  5946. }
  5947.  
  5948. emit_sound(id, CHAN_ITEM, TI_SOUND, 0.5, ATTN_STATIC, 0, PITCH_NORM)
  5949. set_task(2.01, "ti_create", TASK_TACTICAL_INSERTION + id)
  5950. }
  5951.  
  5952. public ti_create(taskid)
  5953. {
  5954. new id = taskid - TASK_TACTICAL_INSERTION
  5955.  
  5956. if (!is_user_alive(id) || !has_ti[id])
  5957. return
  5958.  
  5959. has_ti[id] = false
  5960. if (player_ti[id]){
  5961. remove_entity(player_ti[id])
  5962. player_ti[id] = 0
  5963. }
  5964.  
  5965. new Float:origin[3]
  5966. GET_origin(id, origin)
  5967. new ti = make_entity(id, ti_classname, TI_MODEL, origin, SOLID_SLIDEBOX, MOVETYPE_TOSS, 1)
  5968. player_ti[id] = ti // store ent#
  5969.  
  5970. switch(get_user_team(id)){
  5971. case TEAM_T: set_rendering(ti, kRenderFxGlowShell, 255, 0, 0)
  5972. case TEAM_CT: set_rendering(ti, kRenderFxGlowShell, 0, 0, 255)
  5973. }
  5974.  
  5975. new Float:angles[3]
  5976. GET_angles(id, angles)
  5977. SET_angles(ti, angles)
  5978. }
  5979.  
  5980. public ti_destroy(victim)
  5981. {
  5982. if (!is_user_connected(victim) || !player_ti[victim]) return
  5983. player_ti[victim] = 0
  5984. PlaySound(victim, BADNEWS_SOUND)
  5985. AnnounceX(victim, "blocked your TI!", _, 255, 0, 0)
  5986. }
  5987.  
  5988. //=========================================================================================== C4 ============
  5989. public put_c4(id)
  5990. {
  5991. if (!is_user_alive(id))
  5992. return PLUGIN_HANDLED
  5993.  
  5994. // if player already had set 1/2 c4, if has c4 (in hud) continue
  5995. if (!has_c4[id])
  5996. {
  5997. client_print(id, print_center, "%L", LANG_PLAYER, "C4_OUT")
  5998. return PLUGIN_HANDLED
  5999. }
  6000. has_c4[id] = false
  6001.  
  6002. // find a free index, if there is none, detonate first one
  6003. new freeIndex
  6004. if (!player_c4[id][0]) freeIndex = 0
  6005. else if (!player_c4[id][1]) freeIndex = 1
  6006. else{
  6007. c4_explode(player_c4[id][0])
  6008. player_c4[id][0] = player_c4[id][1]
  6009. player_c4[id][1] = 0
  6010. freeIndex = 1
  6011. }
  6012.  
  6013. new Float:origin[3], Float:Aim[3]
  6014. GET_origin(id, origin)
  6015. velocity_by_aim(id, 64, Aim)
  6016. origin[0] += Aim[0]; origin[1] += Aim[1]
  6017.  
  6018. new c4 = make_entity(id, c4_classname, C4_MODEL, origin, SOLID_SLIDEBOX, MOVETYPE_TOSS, 1)
  6019. SET_STUCK(c4, 0)
  6020.  
  6021. player_c4[id][freeIndex] = c4 // store ent#
  6022.  
  6023. new Float:velocity[3]
  6024. velocity_by_aim(id, 500, velocity)
  6025. SET_velocity(c4, velocity)
  6026.  
  6027. PlaySound(id, THROW_SOUND)
  6028.  
  6029. return PLUGIN_HANDLED
  6030. }
  6031.  
  6032. public cmd_c4det(id)
  6033. {
  6034. if (!is_user_alive(id) || (!player_c4[id][0] && !player_c4[id][1]))
  6035. return PLUGIN_HANDLED
  6036.  
  6037. PlaySound(id, C4_TRIGGER_SOUND)
  6038. set_task(0.15, "c4detonate", id)
  6039. return PLUGIN_HANDLED
  6040. }
  6041.  
  6042. public c4detonate(id)
  6043. {
  6044. new ent, i
  6045. for (i = 0; i < 2; i++)
  6046. {
  6047. ent = player_c4[id][i]
  6048. if (is_valid_ent(ent))
  6049. {
  6050. c4_explode(ent)
  6051. player_c4[id][i] = 0
  6052. }
  6053. }
  6054. }
  6055.  
  6056. public c4_explode(ent)
  6057. {
  6058. if (!is_valid_ent(ent))
  6059. return
  6060.  
  6061. // do damage
  6062. gl_radius_damage(ent)
  6063.  
  6064. // explosion sound/fire
  6065. emit_sound(ent, CHAN_WEAPON, EXPLDE2_SOUND[random_num(0,charsmax(EXPLDE2_SOUND))], VOL_NORM, ATTN_LOUD, 0, PITCH_NORM)
  6066.  
  6067. show_explosion1(ent)
  6068.  
  6069. remove_entity(ent)
  6070. }
  6071.  
  6072.  
  6073. //=========================================================================================== CLAYMORE ====
  6074. public put_claymore(id)
  6075. {
  6076. if (!is_user_alive(id))
  6077. return PLUGIN_HANDLED
  6078.  
  6079. // if player already had set 1/2 claymores, if has claymore (in hud) continue
  6080. if (!has_claymore[id])
  6081. {
  6082. client_print(id, print_center, "%L", LANG_PLAYER, "CLAYMORE_OUT")
  6083. return PLUGIN_HANDLED
  6084. }
  6085. has_claymore[id] = false
  6086.  
  6087. // find a free index, if there is none, detonate first one
  6088. new freeIndex
  6089. if (!player_claymore[id][0]) freeIndex = 0
  6090. else if (!player_claymore[id][1]) freeIndex = 1
  6091. else{
  6092. claymore_explode(TASK_CLAYMORE_EXPLODE+player_claymore[id][0])
  6093. player_claymore[id][0] = player_claymore[id][1]
  6094. player_claymore[id][1] = 0
  6095. freeIndex = 1
  6096. }
  6097.  
  6098. new Float:origin[3], Float:Aim[3]
  6099. GET_origin(id, origin)
  6100. velocity_by_aim(id, 64, Aim)
  6101. origin[0] += Aim[0]; origin[1] += Aim[1]
  6102. new claymore = make_entity(id, claymore_classname, CLAYMORE_MODEL, origin, SOLID_SLIDEBOX, MOVETYPE_TOSS, 1, 8.0)
  6103. player_claymore[id][freeIndex] = claymore
  6104. SET_STUCK(claymore, 0)
  6105. SET_frame(claymore, 0.0)
  6106. SET_body(claymore, 3)
  6107. SET_sequence(claymore, 7)
  6108. SET_framerate(claymore, 0.0)
  6109. // set where it should face
  6110. new Float:playerAngle[3]
  6111. GET_angles(id, playerAngle)
  6112. playerAngle[0] = 0.0
  6113. SET_angles(claymore, playerAngle) // fix z axis
  6114.  
  6115. // make its trigger
  6116. velocity_by_aim(id, 80, Aim)
  6117. origin[0] += Aim[0]; origin[1] += Aim[1]
  6118. new claymore_t = make_entity(id, claymore_trigger_classname, CLAYMORE_TRIGGER_MODEL, origin, SOLID_TRIGGER, MOVETYPE_NONE, _, 64.0)
  6119. SET_TRIGGERED(claymore_t, 0)
  6120. SET_ATTACHED(claymore, claymore_t)
  6121. SET_ATTACHED(claymore_t, claymore)
  6122. SET_effects(claymore_t, GET_effects(claymore_t) | EF_NODRAW)
  6123. drop_to_floor(claymore_t)
  6124.  
  6125. return PLUGIN_HANDLED
  6126. }
  6127.  
  6128. public claymore_explode(taskid)
  6129. {
  6130. new cm = taskid - TASK_CLAYMORE_EXPLODE
  6131. if (!is_valid_ent(cm)) return
  6132. new cmt = GET_ATTACHED(cm)
  6133. if (!is_valid_ent(cmt)) return
  6134. new id = GET_owner(cm)
  6135. if (!is_user_connected(id)) return
  6136.  
  6137. // remove it from array
  6138. for (new i = 0; i < 2; i++)
  6139. if (player_claymore[id][i] == cm)
  6140. player_claymore[id][i] = 0
  6141.  
  6142. gl_radius_damage(cmt)
  6143.  
  6144. // fire sprite on cm, damage on trigger area
  6145. // explosion sound
  6146. emit_sound(cm, CHAN_WEAPON, EXPLDE2_SOUND[random_num(0,charsmax(EXPLDE2_SOUND))], VOL_NORM, ATTN_LOUD, 0, PITCH_NORM)
  6147.  
  6148. show_explosion1(cm)
  6149.  
  6150. remove_entity(cm)
  6151. remove_entity(cmt)
  6152. }
  6153.  
  6154. //*****************************************************************************************************
  6155. //*****************************************************************************************************
  6156.  
  6157. //********************************** Killstreak rewards things here ***********************************
  6158.  
  6159.  
  6160. //===================================================================================== UAV ===========
  6161. //************************************************************************************* ***********
  6162.  
  6163. // UAV ************************ turn off if EMPd
  6164. public radar_scan()
  6165. {
  6166. // if no team has UAV, zziiip
  6167. if (!hasUAV[TEAM_T] && !hasUAV[TEAM_CT])
  6168. return
  6169. static num, players[32], id, team; num = 0; id = 0; team = 0
  6170. get_players(players, num, "a")
  6171. for(new a = 0; a < num; a++)
  6172. {
  6173. id = players[a]; team = get_user_team(id)
  6174. if ((hasUAV[TEAM_T] && team == TEAM_T) || (hasUAV[TEAM_CT] && team == TEAM_CT))
  6175. user_UAV(id, team)
  6176. }
  6177. }
  6178.  
  6179. // > this shows enemy locations to player
  6180. // except enemy-players who have cold-blood perk!
  6181. user_UAV(id, team)
  6182. {
  6183. new PlayerCoords[3], num, players[32], i
  6184. get_players(players, num, "a")
  6185. for(new a = 0; a < num; a++)
  6186. {
  6187. i = players[a]
  6188.  
  6189. // don't show teammats/cold-blooded ones in radar
  6190. if (get_user_team(i) == team || USERPERKS(i, RED_PERK) == PERK_COLD_BLOODED)
  6191. continue
  6192.  
  6193. get_user_origin(i, PlayerCoords)
  6194. message_begin(MSG_ONE_UNRELIABLE, g_msgHostagePos, _, id)
  6195. write_byte(id)
  6196. write_byte(i)
  6197. write_coord(PlayerCoords[0])
  6198. write_coord(PlayerCoords[1])
  6199. write_coord(PlayerCoords[2])
  6200. message_end()
  6201. message_begin(MSG_ONE_UNRELIABLE, g_msgHostageK, _, id)
  6202. write_byte(i)
  6203. message_end()
  6204. }
  6205. }
  6206.  
  6207. // turn on UAV
  6208. set_UAV(team)
  6209. {
  6210. new Float:gltime = get_gametime()
  6211. hasUAV[team] = true
  6212. if (uavEndTime[team] > gltime)
  6213. uavEndTime[team] += UAV_DUR
  6214. else
  6215. uavEndTime[team] = gltime + UAV_DUR
  6216. }
  6217.  
  6218. // uav end time check (in server frame)
  6219. uav_endtime_check(iTeam)
  6220. {
  6221. if (uavEndTime[iTeam] < get_gametime() && hasUAV[iTeam])
  6222. {
  6223. hasUAV[iTeam] = false
  6224. uavEndTime[iTeam] = 0.0
  6225. }
  6226. }
  6227.  
  6228. //__________________________________________________________________________________________________________
  6229. //==================================================================================== CARE PACKAGE ========
  6230. //************************************************************************************ ********
  6231.  
  6232. CreateCarePackage(id)
  6233. {
  6234. if (!is_user_alive(id)) return
  6235.  
  6236. // make plane
  6237. new Float:Origin[3], Float: Angle[3], Float: Velocity[3]
  6238. velocity_by_aim(id, 1000, Velocity)
  6239. GET_origin(id, Origin)
  6240. GET_v_angle(id, Angle)
  6241. Origin[2] += PLANE_Z; Angle[0] = 0.0; Velocity[2] = Origin[2]
  6242. new ent = make_entity(id, stealth_classname, PACKAGE_HELI_MODEL, Origin, SOLID_BBOX, MOVETYPE_NOCLIP)
  6243. SET_velocity(ent, Velocity)
  6244. SET_angles(ent, Angle)
  6245. emit_sound(ent, CHAN_ITEM, STEALTH_FLYBY_SOUND, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  6246. set_task(4.5, "remove_plane", ent)
  6247.  
  6248. // drop package location/task
  6249. new iorigin[3]
  6250. if (is_user_bot(id))
  6251. get_user_origin(id, iorigin)
  6252. else
  6253. get_user_origin(id, iorigin, 3) // end position from eyes (hit point for weapon) origin
  6254. set_task(3.0, "airdrop", TASK_CAREPACKAGE+id, iorigin, 3)
  6255.  
  6256. // show smoke
  6257. show_smoke(iorigin)
  6258.  
  6259. new Float:puff_origin[3]
  6260. IVecFVec(iorigin, puff_origin)
  6261. emit_sound_amb(puff_origin, SMOKE_SOUND, 0.5, ATTN_LOUD, PITCH_NORM)
  6262. }
  6263. public remove_plane(ent) safe_remove_entity(ent)
  6264. public airdrop(const origin[3], taskid)
  6265. {
  6266. new id = taskid - TASK_CAREPACKAGE
  6267. new Float:fOrigin[3]
  6268. IVecFVec(origin, fOrigin)
  6269. fOrigin[2] += 150.0
  6270. new cp = make_entity(id, package_classname, PACKAGE_PACK_MODEL, fOrigin, SOLID_TRIGGER, MOVETYPE_TOSS, _, 16.0)
  6271.  
  6272. switch(get_user_team(id)){
  6273. case TEAM_T: set_rendering(cp, kRenderFxGlowShell, 255, 0, 0)
  6274. case TEAM_CT: set_rendering(cp, kRenderFxGlowShell, 0, 0, 255)
  6275. }
  6276.  
  6277. SET_CP_CONTAINS(cp, random_killstreak_reward())
  6278. }
  6279.  
  6280. // player picking up care package
  6281. care_package_check(id)
  6282. {
  6283. static iDiffrence, cp
  6284. iDiffrence = floatround((get_gametime() - cpd_time[id]) * 100.0)
  6285. cp = cpd_taking_package[id]
  6286. if (iDiffrence >= 0 && iDiffrence < 10 && is_valid_ent(cp))
  6287. {
  6288. new ks = GET_CP_CONTAINS(cp) - 100 // item in care package
  6289.  
  6290. if (GET_button(id)&IN_USE)
  6291. {
  6292. // care package pickup is faster for owner
  6293. new cp_owner = GET_owner(cp)
  6294. new iPerc
  6295. if (id == cp_owner)
  6296. iPerc = CP_TAKE_SPEED
  6297. else
  6298. iPerc = CP_STEAL_SPEED
  6299.  
  6300. cpd_progress[id] += iPerc
  6301.  
  6302. // player picked up package?
  6303. if (cpd_progress[id] >= 100)
  6304. {
  6305. cpd_progress[id] = 100
  6306.  
  6307. // was it stolen?
  6308. if (cp_owner != id)
  6309. {
  6310. if (SAMETEAM(id, cp_owner))
  6311. {
  6312. add_message_in_queue(cp_owner, BM_SHARE_PACKAGE)
  6313. }
  6314. else
  6315. {
  6316. add_message_in_queue(id, BM_HIJACKER)
  6317. new params[2]
  6318. params[0] = cp_owner
  6319. params[1] = id
  6320. set_task(0.1, "cp_steal_message_victim", _, params, sizeof params)
  6321. }
  6322. }
  6323.  
  6324. // give reward
  6325. give_ks(id, ks)
  6326. PlaySound(id, PICKUP_SOUND)
  6327. remove_entity(cp)
  6328. }
  6329. Make_BarTime2(id, floatround(100.0 / float(iPerc) * USUR), cpd_progress[id])
  6330. //client_print(id, print_center, "Picking up package... %i", cpd_progress[id])
  6331. }
  6332. else
  6333. {
  6334. if (ks == CP_RESUPPLY)
  6335. client_print(id, print_center, "%L %L", LANG_PLAYER, "INFO_CP_PICKUP", LANG_PLAYER, "KS_CP_RESUPPLY")
  6336. else
  6337. client_print(id, print_center, "%L [%s]", LANG_PLAYER, "INFO_CP_PICKUP", KILLSTREAK_LABLE[ks])
  6338. if (cpd_progress[id] > 0) Make_BarTime2(id, 1, 100)
  6339. cpd_progress[id] = 0
  6340. }
  6341. }
  6342. else
  6343. {
  6344. if (cpd_progress[id] > 0) Make_BarTime2(id, 1, 100)
  6345. cpd_progress[id] = 0
  6346. cpd_time[id] = 0.0
  6347. cpd_taking_package[id] = 0
  6348. }
  6349. }
  6350.  
  6351. // pick a random reward
  6352. random_killstreak_reward()
  6353. {
  6354. new chance, ks = CP_RESUPPLY
  6355. for (new i = 0; i < KSR_TOTAL; i++)
  6356. {
  6357. chance = CP_CHANCE[i]
  6358. if (chance && !random_num(0, 100 / chance)) ks = i
  6359. }
  6360. return 100 + ks
  6361. }
  6362.  
  6363. // tell victim package was stolen
  6364. public cp_steal_message_victim(params[])
  6365. {
  6366. new victim = params[0], stealer = params[1]
  6367. new sMessage[64]
  6368. if (is_user_connected(stealer))
  6369. formatex(sMessage, charsmax(sMessage), "[ %s, %L ]", g_playername[stealer], LANG_PLAYER, "KS_CP_TOOK")
  6370. else
  6371. formatex(sMessage, charsmax(sMessage), "[ %L ]", LANG_PLAYER, "KS_CP_TOOKB")
  6372.  
  6373. PlaySound(victim, BADNEWS_SOUND)
  6374. AnnounceX(victim, sMessage, _, 255, 0, 0)
  6375. }
  6376.  
  6377. //__________________________________________________________________________________________________________
  6378. //==================================================================================== SENTRY GUN ==========
  6379. //************************************************************************************ **********
  6380.  
  6381. public sentry_target_reset(taskid){
  6382. new ent = taskid - TASK_TARGET_RESET
  6383. if (!is_valid_ent(ent)) return
  6384. SET_SENTRY_TARGET(ent, 0)
  6385. }
  6386. public sentry_deactivate(taskid){
  6387. new ent = taskid - TASK_SENTRY_DEACTIVATE
  6388. if (!is_valid_ent(ent)) return
  6389. SET_SENTRY_ACTIVE(ent, 0)
  6390. SET_SENTRY_TILT_TURRET(ent, 0)
  6391.  
  6392. new id = GET_owner(ent)
  6393. if (!is_user_connected(id)) return
  6394. has_sentry[id] = 0
  6395.  
  6396. // break smoke effect
  6397. new iorigin[3]
  6398. get_origin_int(ent, iorigin)
  6399. show_smoke(iorigin)
  6400.  
  6401. // break sound
  6402. emit_sound(ent, CHAN_BODY, SENTRY_BREAK, 0.6, ATTN_NORM, 0, PITCH_NORM)
  6403.  
  6404. // tell player
  6405. client_print(id, print_center, "%L", LANG_PLAYER, "SENTRY_DEST")
  6406. }
  6407. public sentry_remove(taskid)
  6408. {
  6409. new ent = taskid - TASK_SENTRY_REMOVE
  6410. if (!is_valid_ent(ent)) return
  6411. new entbase = GET_ATTACHED(ent)
  6412. safe_remove_entity(ent)
  6413. safe_remove_entity(entbase)
  6414. }
  6415.  
  6416. // clean up
  6417. public sentry_cleanup()
  6418. {
  6419. new ent
  6420. for (new i = 1; i <= g_maxplayers; i++)
  6421. {
  6422. ent = has_sentry[i]
  6423. if (ent)
  6424. {
  6425. // remove it right away!
  6426. if (task_exists(TASK_SENTRY_REMOVE+ent))
  6427. remove_task(TASK_SENTRY_REMOVE+ent)
  6428. sentry_remove(TASK_SENTRY_REMOVE+ent)
  6429. }
  6430. has_sentry[i] = 0
  6431. }
  6432. }
  6433.  
  6434. // sentry and all equipments think!
  6435. public sentry_think()
  6436. {
  6437. static ent, entbase
  6438. for (new e = 1; e <= g_maxplayers; e++)
  6439. {
  6440. check_equipments(e)
  6441.  
  6442. ent = 0
  6443. entbase = 0
  6444. if (!is_valid_ent(has_sentry[e]))
  6445. continue
  6446.  
  6447. ent = has_sentry[e]
  6448.  
  6449. if (!GET_SENTRY_ACTIVE(ent))
  6450. continue
  6451.  
  6452. if (GET_health(ent) <= 0.0)
  6453. {
  6454. sentry_break(ent)
  6455. continue
  6456. }
  6457.  
  6458. entbase = GET_ATTACHED(ent)
  6459.  
  6460. new Float:sentryOrigin[3], Float:hitOrigin[3], hitent
  6461. GET_origin(entbase, sentryOrigin)
  6462. sentryOrigin[2] += 40.0
  6463.  
  6464. SET_origin(ent, sentryOrigin)
  6465. entity_set_size(ent, Float:{-20.0,-20.0,-20.0}, Float:{20.0,20.0,20.0}) // testt
  6466.  
  6467. new closestTarget = 0, Float:closestDistance, Float:distance, Float:closestOrigin[3], Float:targetOrigin[3]
  6468. new sentryTeam
  6469. sentryTeam = get_user_team(GET_owner(ent))
  6470.  
  6471. closestTarget = GET_SENTRY_TARGET(ent)
  6472.  
  6473. if (closestTarget == 0)
  6474. {
  6475. for (new i = 1; i <= g_maxplayers; i++)
  6476. {
  6477. if (!is_user_connected(i) || !is_user_alive(i) || get_user_team(i) == sentryTeam)
  6478. continue
  6479.  
  6480. // sentries don't see cold blooded ones!
  6481. if (USERPERKS(i, RED_PERK) == PERK_COLD_BLOODED)
  6482. continue
  6483.  
  6484. GET_origin(i, targetOrigin)
  6485. distance = vector_distance(sentryOrigin, targetOrigin)
  6486.  
  6487. if (distance > SENTRY_RANGE)
  6488. continue
  6489.  
  6490. hitent = trace_line(ent, sentryOrigin, targetOrigin, hitOrigin)
  6491. if (hitent == entbase)
  6492. hitent = trace_line(hitent, hitOrigin, targetOrigin, hitOrigin)
  6493.  
  6494. if (hitent == i)
  6495. {
  6496. closestOrigin = targetOrigin
  6497.  
  6498. if (distance < closestDistance || closestTarget == 0)
  6499. {
  6500. closestTarget = i
  6501. closestDistance = distance
  6502. }
  6503. }
  6504. }
  6505. // if just found one, make noise
  6506. if (closestTarget)
  6507. emit_sound(ent, CHAN_ITEM, SENTRY_SPOT, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  6508. }
  6509.  
  6510. if (closestTarget)
  6511. {
  6512. // change the target after x sec if target is hard to get
  6513. if (!task_exists(TASK_TARGET_RESET+ent))
  6514. set_task(SENTRY_RETARGET, "sentry_target_reset", TASK_TARGET_RESET+ent)
  6515.  
  6516. // store target id (in sentry entity)
  6517. SET_SENTRY_TARGET(ent, closestTarget)
  6518.  
  6519. // turn to target
  6520. GET_origin(closestTarget, targetOrigin)
  6521. sentry_turntotarget(ent, sentryOrigin, targetOrigin)
  6522.  
  6523. // shoot the mofo
  6524. sentry_fire(ent, sentryOrigin, targetOrigin)
  6525. }
  6526. }
  6527. }
  6528.  
  6529. sentry_turntotarget(ent, Float:sentryOrigin[3], Float:closestOrigin[3]){
  6530. new Float:newAngle[3]
  6531. GET_angles(ent, newAngle)
  6532. new Float:x = closestOrigin[0] - sentryOrigin[0]
  6533. new Float:z = closestOrigin[1] - sentryOrigin[1]
  6534. new Float:radians = floatatan(z/x, radian)
  6535. newAngle[1] = radians * (180.0 / M_PI)
  6536. if (closestOrigin[0] < sentryOrigin[0])
  6537. newAngle[1] -= 180.0
  6538. new Float:h = closestOrigin[2] - sentryOrigin[2]
  6539. new Float:b = vector_distance(sentryOrigin, closestOrigin)
  6540. radians = floatatan(h/b, radian)
  6541. new Float:degs = radians * (180.0 / M_PI)
  6542. new Float:degreeByte = 830.0/256.0 // SENTRYTILTRADIUS
  6543. new Float:tilt = 127.0 - degreeByte * degs
  6544. SET_SENTRY_TILT_TURRET(ent, floatround(tilt))
  6545. SET_angles(ent, newAngle)
  6546. }
  6547.  
  6548. sentry_fire(iEnt, Float:entity_origin[3], Float:target_origin[3]){
  6549. static blt, Float:speed = 2500.0
  6550. target_origin[2] -= 10.0
  6551. entity_origin[2] += 20.0
  6552. blt = make_entity(GET_owner(iEnt), sentryblt_classname, SENTRY_BLT, entity_origin, SOLID_BBOX, MOVETYPE_FLY, _, 2.0)
  6553. new Float:diff[3]
  6554. diff[0] = target_origin[0] - entity_origin[0]
  6555. diff[1] = target_origin[1] - entity_origin[1]
  6556. diff[2] = target_origin[2] - entity_origin[2]
  6557. new Float:length = floatsqroot(floatpower(diff[0], 2.0) + floatpower(diff[1], 2.0) + floatpower(diff[2], 2.0))
  6558. new Float:velocity[3]
  6559. velocity[0] = diff[0] * (speed / length) * random_float(0.95, 1.05)
  6560. velocity[1] = diff[1] * (speed / length)
  6561. velocity[2] = diff[2] * (speed / length) * random_float(0.95, 1.05)
  6562. SET_velocity(blt, velocity)
  6563. new Float:angles[3]
  6564. vector_to_angle(velocity, angles)
  6565. SET_angles(blt, angles)
  6566. msg_beam_follow(blt, 255, 255, 0, 1)
  6567. emit_sound(blt, CHAN_WEAPON, SENTRY_SHOOT, VOL_NORM, ATTN_NORM, 0, random_num(90, 110) /*PITCH_NORM*/)
  6568. }
  6569.  
  6570. // build sentry gun
  6571. public sentry_build(creator)
  6572. {
  6573. if (has_sentry[creator])
  6574. {
  6575. client_print(creator, print_chat, "%L", LANG_PLAYER, "SENTRY_LIMIT")
  6576. return 0
  6577. }
  6578.  
  6579. // throw it in front of player
  6580. new Float:origin[3], Float:Aim[3]
  6581. GET_origin(creator, origin)
  6582. velocity_by_aim(creator, 64, Aim)
  6583. origin[0] += Aim[0]; origin[1] += Aim[1]
  6584.  
  6585. // base
  6586. new entbase, ent
  6587. entbase = make_entity(creator, sentrybase_classname, SENRYBASE_MODEL, origin, SOLID_SLIDEBOX, MOVETYPE_TOSS)
  6588.  
  6589. // head
  6590. ent = make_entity(creator, sentry_classname, SENRY_MODEL, origin, SOLID_BBOX, MOVETYPE_FLY, SENTRY_HEALTH, 2.0)
  6591. GET_angles(creator, Aim)
  6592. Aim[0] = 0.0
  6593. SET_angles(ent, Aim)
  6594. SET_SENTRY_TILT_TURRET(ent, 127)
  6595. switch(get_user_team(creator)){
  6596. case TEAM_T: SET_colormap(ent, 0|(0<<8))
  6597. case TEAM_CT: SET_colormap(ent, 150|(160<<8))
  6598. }
  6599.  
  6600. // bind sentry head and base
  6601. SET_ATTACHED(ent, entbase)
  6602. SET_ATTACHED(entbase, ent)
  6603.  
  6604. // player has a sentry now
  6605. has_sentry[creator] = ent
  6606.  
  6607. // deactivition/remove tasks
  6608. set_task(SENTRY_LIFE, "sentry_deactivate", TASK_SENTRY_DEACTIVATE+ent)
  6609. set_task(SENTRY_LIFE + 5.0, "sentry_remove", TASK_SENTRY_REMOVE+ent)
  6610.  
  6611. // activate in 3 sec
  6612. set_task(3.0, "sentry_activate", TASK_SENTRY_ACTIVATE+ent)
  6613. SET_SENTRY_ACTIVE(ent, 0)
  6614.  
  6615. return ent
  6616. }
  6617.  
  6618. public sentry_activate(taskid)
  6619. {
  6620. new ent = taskid - TASK_SENTRY_ACTIVATE
  6621. if (!is_valid_ent(ent)) return
  6622.  
  6623. SET_SENTRY_ACTIVE(ent, 1)
  6624.  
  6625. // ready sound
  6626. emit_sound(ent, CHAN_BODY, SENTRY_READY, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  6627. }
  6628.  
  6629. sentry_break(ent)
  6630. {
  6631. if (!is_valid_ent(ent)) return
  6632. remove_task(TASK_SENTRY_DEACTIVATE+ent)
  6633. sentry_deactivate(TASK_SENTRY_DEACTIVATE+ent)
  6634. set_task(5.0, "sentry_remove", TASK_SENTRY_REMOVE+ent)
  6635. }
  6636.  
  6637. //__________________________________________________________________________________________________________
  6638. //================================================================================ PREDATOR MISSILE ========
  6639. //******************************************************************************** ********
  6640.  
  6641. public CreatePredator(id)
  6642. {
  6643. if (user_ctrl_pred[id]) return 0
  6644. new Float:Origin[3], Float:Angle[3], Float:Velocity[3]
  6645. velocity_by_aim(id, PREDATOR_SPEED, Velocity)
  6646. GET_origin(id, Origin)
  6647. GET_v_angle(id, Angle)
  6648. Angle[0] *= -1.0
  6649. new iPred = make_entity(id, pred_classname, ROCKET_MDL, Origin, SOLID_BBOX, MOVETYPE_FLY)
  6650. SET_velocity(iPred, Velocity)
  6651. SET_angles(iPred, Angle)
  6652. attach_view(id, iPred)
  6653. user_ctrl_pred[id] = iPred
  6654. user_pred_speed[id] = PREDATOR_SPEED
  6655. msg_beam_follow(iPred, 255, 255, 255)
  6656. SET_effects(iPred, EF_BRIGHTLIGHT)
  6657. set_rendering(iPred, kRenderFxGlowShell, 150, 150, 150) // thermal
  6658. Display_Fade(id, 0, 0, FFADE_STAYOUT, 150, 150, 150, 100, true) // thermal
  6659. emit_sound(iPred, CHAN_AUTO, PR_FLY_START, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  6660.  
  6661. set_task(1.5, "pred_fly_sound", TASK_PRED_FLY+id, _, _, "b")
  6662. return iPred
  6663. }
  6664.  
  6665. public pred_fly_sound(taskid)
  6666. {
  6667. new id = taskid - TASK_PRED_FLY
  6668. new ent = user_ctrl_pred[id]
  6669. if (!is_valid_ent(ent))
  6670. {
  6671. remove_task(taskid)
  6672. return
  6673. }
  6674. emit_sound(ent, CHAN_AUTO, PR_FLY, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  6675. }
  6676.  
  6677. //__________________________________________________________________________________________________________
  6678. //==================================================================================== EMP =================
  6679. //************************************************************************************ *****************
  6680.  
  6681. launch_EMP(id)
  6682. {
  6683. new enemyTeam = get_user_team(id) == TEAM_T ? TEAM_CT : TEAM_T
  6684. team_EMP(enemyTeam)
  6685.  
  6686. // destroy all UAVs
  6687. if (hasUAV[enemyTeam])
  6688. {
  6689. hasUAV[enemyTeam] = false
  6690. uavEndTime[enemyTeam] = 0.0
  6691. set_task(2.0, "destroyed_uavs", id)
  6692. }
  6693.  
  6694. // destroy all Sentry guns!
  6695. new ent
  6696. for (new i = 1; i < g_maxplayers; i++)
  6697. {
  6698. ent = has_sentry[i]
  6699. if (is_valid_ent(ent) && get_user_team(i) == enemyTeam)
  6700. sentry_break(ent)
  6701. }
  6702.  
  6703. AnnounceX(0, KILLSTREAK_LABLE[KSR_EMP], id)
  6704. }
  6705.  
  6706. // EMP a team
  6707. team_EMP(team)
  6708. {
  6709. new num, players[32]
  6710. switch(team)
  6711. {
  6712. case TEAM_T: set_EMP(TEAM_T)
  6713. case TEAM_CT: set_EMP(TEAM_CT)
  6714. default: return
  6715. }
  6716.  
  6717. get_players(players, num, "a")
  6718. for(new a = 0; a < num; a++)
  6719. {
  6720. new id = players[a]
  6721. Display_Fade(id, 1, 1, FFADE_IN, 255, 255, 225, 155)
  6722. if (get_user_team(id) == team)
  6723. set_hud_flags(id, EMP_HIDE_FLAGS)
  6724. }
  6725. }
  6726.  
  6727. set_EMP(team)
  6728. {
  6729. is_EMPd[team] = true
  6730. if (task_exists(TASK_UN_EMP+team)) remove_task(TASK_UN_EMP+team)
  6731. set_task(EMP_DUR, "team_unEMP", TASK_UN_EMP+team)
  6732. }
  6733.  
  6734. public team_unEMP(taskid)
  6735. {
  6736. new team = taskid - TASK_UN_EMP
  6737. is_EMPd[team] = false
  6738.  
  6739. new num, players[32]
  6740. get_players(players, num, "a")
  6741. for(new a = 0; a < num; a++)
  6742. {
  6743. new id = players[a]
  6744. if (is_user_alive(id) && get_user_team(id) == team)
  6745. set_hud_flags(id, HIDE_NORMAL)
  6746. }
  6747. }
  6748.  
  6749. bool:is_user_EMPd(id)
  6750. {
  6751. if (!is_user_connected(id)) return false
  6752. switch(get_user_team(id))
  6753. {
  6754. case TEAM_T: return is_EMPd[TEAM_T]
  6755. case TEAM_CT: return is_EMPd[TEAM_CT]
  6756. }
  6757. return false
  6758. }
  6759.  
  6760. public destroyed_uavs(id)
  6761. AnnounceX_L(0, "INFO_DESTUAV", id)
  6762.  
  6763. //__________________________________________________________________________________________________________
  6764. //=============================================================================== TACTICAL NUKE ============
  6765. //******************************************************************************* ************
  6766.  
  6767. public launch_nuke(id)
  6768. {
  6769. if (!is_user_alive(id))
  6770. return
  6771.  
  6772. if (id_nuker)
  6773. {
  6774. client_print(id, print_center, "%L", LANG_PLAYER, "NUKE_BLOCKED")
  6775. return
  6776. }
  6777.  
  6778. id_nuker = id
  6779. team_nuker = get_user_team(id)
  6780. nuke_countdown = 11
  6781. task_countdown()
  6782.  
  6783. AnnounceX(0, KILLSTREAK_LABLE[KSR_TACTICAL_NUKE], id)
  6784. }
  6785.  
  6786. public task_countdown()
  6787. {
  6788. nuke_countdown--
  6789. if (nuke_countdown > 0){
  6790. set_task(1.0, "task_countdown", TASK_TACTICAL_NUKE)
  6791. PlaySound(0, NUKE_ALARM_SOUND)
  6792. }
  6793. if (nuke_countdown == 2) Display_Fade(0, 4, 1, FFADE_OUT, 255, 255, 255, 225)
  6794. if (nuke_countdown == 0)
  6795. {
  6796. remove_task(TASK_TACTICAL_NUKE)
  6797. is_nuke_time = true
  6798. // nuke_explode = get_gametime() + 10.0
  6799. PlaySound(0, NUKE_HIT_SOUND)
  6800.  
  6801. // what if the mofo nuked and left?
  6802. if (!is_user_connected(id_nuker)) id_nuker = 0
  6803.  
  6804. // force win:
  6805. if (team_nuker == TEAM_CT) // CT
  6806. // TerminateRound(RoundEndType_TeamExtermination, TeamWinning_Ct)
  6807. TerminateRound_TE(WinStatus_Ct)
  6808. else if (team_nuker == TEAM_T) // T
  6809. // TerminateRound(RoundEndType_TeamExtermination, TeamWinning_Terrorist)
  6810. TerminateRound_TE(WinStatus_Terrorist)
  6811. else // Draw
  6812. // TerminateRound(RoundEndType_Draw) // this will never happen but just in case!
  6813. TerminateRound_TE(WinStatus_RoundDraw)
  6814.  
  6815. // kill all
  6816. new players[32], pnum
  6817. get_players(players, pnum, "a")
  6818. for (new i = 0; i < pnum; i++)
  6819. if (id_nuker && team_nuker != get_user_team(players[i]))
  6820. log_kill_B(id_nuker, players[i], "Tactical Nuke", 0)
  6821. else
  6822. user_kill(players[i])
  6823.  
  6824. // end sound
  6825. round_end_sound()
  6826. score_freeze = true
  6827. round_end_stuff()
  6828. //end_game_check
  6829. winner = team_nuker
  6830. }
  6831.  
  6832. // timer!
  6833. set_hudmessage(255, 255, 0, -1.0, 0.30, 1, 0.0, 3.0, 1.0, 1.0, -1)
  6834. new msg[32]; formatex(msg, charsmax(msg), "%s: %i", KILLSTREAK_LABLE[KSR_TACTICAL_NUKE], nuke_countdown)
  6835. ShowSyncHudMsg(0, g_MsgSyncHUD, msg)
  6836. }
  6837.  
  6838. //__________________________________________________________________________________________________________
  6839. //=============================================================================== STEALTH BOMBER ===========
  6840. //******************************************************************************* ***********
  6841.  
  6842. CreateStealthBomber(id)
  6843. {
  6844. if (!is_user_alive(id)) return 0
  6845.  
  6846. // make plane
  6847. new Float:Origin[3], Float: Angle[3], Float: Velocity[3]
  6848. velocity_by_aim(id, 1000, Velocity)
  6849. GET_origin(id, Origin)
  6850. GET_v_angle(id, Angle)
  6851. Origin[2] += PLANE_Z; Angle[0] = 0.0; Velocity[2] = Origin[2]
  6852. new ent = make_entity(id, stealth_classname, PACKAGE_HELI_MODEL, Origin, SOLID_BBOX, MOVETYPE_NOCLIP)
  6853. SET_velocity(ent, Velocity)
  6854. SET_angles(ent, Angle)
  6855. emit_sound(ent, CHAN_ITEM, STEALTH_FLYBY_SOUND, VOL_NORM, ATTN_LOUD, 0, PITCH_NORM)
  6856. set_task(4.5, "remove_plane", ent)
  6857.  
  6858. // bombing coordz
  6859. new iorigin[3], Float:fVelocity[3], iVelocity[3]
  6860. get_user_origin(id, iorigin, 3)
  6861. velocity_by_aim(id, 150, fVelocity)
  6862. FVecIVec(fVelocity, iVelocity)
  6863.  
  6864. // fly sound to all
  6865. new Float:fly_origin[3]
  6866. IVecFVec(iorigin, fly_origin)
  6867. emit_sound_amb(fly_origin, STEALTH_FLYBY_SOUND, VOL_NORM, ATTN_PREDATOR, PITCH_LOW)
  6868.  
  6869. new BombCoords[3]
  6870. for (new i = 0; i < MAXBOMBS; i++)
  6871. {
  6872. BombCoords[0] = iorigin[0] + iVelocity[0] * (i + 1)
  6873. BombCoords[1] = iorigin[1] + iVelocity[1] * (i + 1)
  6874. BombCoords[2] = iorigin[2] + BOMBSPACE
  6875. set_task(2.0 + (float(i) * 0.25), "blast_em_mofos", TASK_STEALTHBOMBER+id, BombCoords, 3)
  6876. }
  6877.  
  6878. user_stealth[id] = ent
  6879.  
  6880. AnnounceX(0, KILLSTREAK_LABLE[KSR_STEALTH_BOMBER], id, _, _, _, true)
  6881.  
  6882. return ent
  6883. }
  6884.  
  6885. // drop bombs on given origin
  6886. public blast_em_mofos(const origin[3], taskid)
  6887. {
  6888. new id = taskid - TASK_STEALTHBOMBER
  6889. new Float:fOrigin[3]
  6890. IVecFVec(origin, fOrigin)
  6891. new sb = make_entity(id, bomb_classname, ROCKET_MDL, fOrigin, SOLID_BBOX, MOVETYPE_TOSS, _, 1.0)
  6892.  
  6893. new plane = user_stealth[id]
  6894. if (!is_valid_ent(plane) || !is_valid_ent(sb))
  6895. {
  6896. safe_remove_entity(plane)
  6897. safe_remove_entity(sb)
  6898. user_stealth[id] = 0
  6899. }
  6900.  
  6901. SET_ATTACHED(sb, plane)
  6902. SET_angles(sb, Float:{90.0, 0.0, 0.0})
  6903. SET_takedamage(sb, DAMAGE_YES)
  6904. set_rendering(sb, kRenderFxGlowShell, 255, 0, 0)
  6905. msg_beam_follow(sb, 224, 224, 255)
  6906. }
  6907.  
  6908. //__________________________________________________________________________________________________________
  6909. //========================================================================== PRECISION AIRSTRIKE ===========
  6910. //************************************************************************** ***********
  6911.  
  6912. CreatePrecision(id)
  6913. {
  6914. if (!is_user_alive(id)) return 0
  6915.  
  6916. // make plane
  6917. new Float:Origin[3], Float: Angle[3], Float: Velocity[3]
  6918. velocity_by_aim(id, 1000, Velocity)
  6919. GET_origin(id, Origin)
  6920. GET_v_angle(id, Angle)
  6921. Origin[2] += PLANE_Z; Angle[0] = 0.0; Velocity[2] = Origin[2]
  6922. new ent = make_entity(id, stealth_classname, PACKAGE_HELI_MODEL, Origin, SOLID_BBOX, MOVETYPE_NOCLIP)
  6923. SET_velocity(ent, Velocity)
  6924. SET_angles(ent, Angle)
  6925. emit_sound(ent, CHAN_ITEM, STEALTH_FLYBY_SOUND, VOL_NORM, ATTN_LOUD, 0, PITCH_NORM)
  6926. set_task(4.5, "remove_plane", ent)
  6927.  
  6928. // bombing coordz
  6929. new iorigin[3], Float:fVelocity[3], iVelocity[3]
  6930. get_user_origin(id, iorigin, 3)
  6931. velocity_by_aim(id, 150, fVelocity)
  6932. FVecIVec(fVelocity, iVelocity)
  6933.  
  6934. new BombCoords[3]
  6935. for (new i = 0; i < P_MAXBOMBS; i++)
  6936. {
  6937. BombCoords[0] = iorigin[0] + iVelocity[0] * (i + 1)
  6938. BombCoords[1] = iorigin[1] + iVelocity[1] * (i + 1)
  6939. BombCoords[2] = iorigin[2] + P_BOMBSPACE
  6940. set_task(2.0 + (float(i) * 0.15), "drop_bombs", TASK_PRECISIONAIRSTRIKE+id, BombCoords, 3)
  6941. }
  6942.  
  6943. user_precision[id] = ent
  6944.  
  6945. return ent
  6946. }
  6947.  
  6948. // drop bombs on given origin
  6949. public drop_bombs(const origin[3], taskid)
  6950. {
  6951. new id = taskid - TASK_PRECISIONAIRSTRIKE
  6952. new Float:fOrigin[3]
  6953. IVecFVec(origin, fOrigin)
  6954. new pa = make_entity(id, pbomb_classname, ROCKET_MDL, fOrigin, SOLID_BBOX, MOVETYPE_TOSS, _, 1.0)
  6955.  
  6956. new plane = user_precision[id]
  6957. if (!is_valid_ent(plane) || !is_valid_ent(pa))
  6958. {
  6959. safe_remove_entity(plane)
  6960. safe_remove_entity(pa)
  6961. user_precision[id] = 0
  6962. }
  6963.  
  6964. SET_ATTACHED(pa, plane)
  6965. SET_angles(pa, Float:{90.0, 0.0, 0.0})
  6966. SET_takedamage(pa, DAMAGE_YES)
  6967. set_rendering(pa, kRenderFxGlowShell, 255, 0, 0)
  6968. msg_beam_follow(pa, 224, 224, 255)
  6969. }