HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /* Plugin generated by AMXX-Studio */
  2. /*********************************************************************************
  3.  
  4. Superweapon -- M4 with M203 Edition
  5.  
  6. This plugin supply a sort of special weapon: M4A1 with M203 grenade launcher.
  7.  
  8. The M203 can launch 2 type of grenades: He-grenade & Gas-grenade.
  9.  
  10. He-grenade can hurt players spang with blast damage & Gas-grenade hurt player who touch the "gas".
  11.  
  12.  
  13.  
  14. ----------------------------------------------------------------------------------
  15. Modul & Require:
  16.  
  17. <amxmisc>
  18. <cstrike>
  19. <fakemeta>
  20.  
  21.  
  22.  
  23. ----------------------------------------------------------------------------------
  24. CAVR:
  25.  
  26.  
  27. SW_SpawnMode 0|1|2 //define superweapon spawn mode,
  28. //"0" means superweapon never spawn but can been buy by client command, (admin still can give it to any player by admin command)
  29. //"1" means auto, superweapon will auto spawn in general maps(DE|CS|AS|ES)
  30. //"2" means superweapon will auto spawn in all type of maps
  31.  
  32. SW_M4StripMode 0 //
  33. //"0" means only strip superweapon(still keep default m4a1)
  34. //"1" means strip the holder's superweapon & default m4a1
  35.  
  36.  
  37. SW_M4Price 8000 //m4 with m203's price, include all type of grenades with max amount
  38.  
  39. SW_MaxAmount_TE 3 //max amount of terrorists can holded m4 with m203
  40.  
  41.  
  42. SW_MaxAmount_CT 3 //max amount of cts can holded m4 with m203
  43.  
  44.  
  45. SW_GrenadeTK 0 //40mm hegrenade team kill,"0" is secundum server's rule, "1" is TK in any case
  46.  
  47.  
  48. SW_GrenadeRT 3.0 //grenade reload time
  49.  
  50.  
  51. SW_HeGrenadeMD 100 //40mm he grenade max damage
  52.  
  53.  
  54. SW_HeGrenadeDR 400 //40mm he grenade damage radius
  55.  
  56.  
  57. SW_HeGrenadeMC 3 //40mm he grenade's max amount can been carried
  58.  
  59.  
  60. SW_HeGrenadePR 500 //40mm he grenade's price
  61.  
  62.  
  63. SW_GasGrenadeMD 100 //40mm gas grenade max damage
  64.  
  65.  
  66. SW_GasGrenadeDR 100 //40mm gas grenade damage radius
  67.  
  68.  
  69. SW_GasGrenadeMC 1 //40mm gas grenade's max amount can been carried
  70.  
  71.  
  72. SW_GasGrenadePR 500 //40mm gas grenade's price
  73.  
  74.  
  75.  
  76.  
  77. ----------------------------------------------------------------------------------
  78. About the superweapon spawn:
  79.  
  80. Generally(can change by CVAR or Admin), superweapons will spawn after 1th round, stochastic
  81.  
  82. locality in map, with specifically amount(by CVAR setting).
  83.  
  84.  
  85.  
  86.  
  87. ----------------------------------------------------------------------------------
  88. Command:
  89.  
  90. 1.Admin command(ADMIN_IMMUNITY): give or strip player's superweapon
  91.  
  92. amx_sw_m4 <#id | name> <give | strip>
  93.  
  94. {<#playerindex|name(can be partial)> <g(means give M4A1/W M203)|s(means strip target's superweapon if he has>}")
  95.  
  96.  
  97. 2.Admin command(ADMIN_IMMUNITY): change superweapon mode
  98.  
  99. amx_sw_set <0 | 1 | 2>
  100.  
  101.  
  102. "0" means stop SW mode(also strip all sw)
  103.  
  104. "1" means start it by CVAR(SW_SpawnMode)'s setting
  105.  
  106. "2" means start anywise
  107.  
  108.  
  109. 3.Player command:
  110.  
  111.  
  112. (a)open superweapon menu
  113.  
  114. When player's Current weapon is "superweapon", press "spray key" will openning menu of grenade setting,
  115.  
  116. menu include:
  117.  
  118. (1).Switch current grenade type to he-grenade
  119. (2).Switch current grenade type to gas-grenade
  120. (3).Setting|Offload muffler
  121. (4).Buy he-grenade
  122. (5).Buy gas-grenade
  123.  
  124.  
  125. (b)
  126.  
  127. When sw spawn mode is "0", player type "say /buyswm4" can buy sw by certain condition
  128.  
  129. 4.Fire 40mm grenade:
  130.  
  131. press "+attack2" key to launch grenade
  132.  
  133.  
  134.  
  135.  
  136. ----------------------------------------------------------------------------------
  137. Credit:
  138.  
  139. code and more: VEN & more
  140.  
  141. model maker: Ankalar, CJ, TinSoldier, S7ok3, Dirtball, Pr0d!gy, Ritual, Rob O, Jennifer!!,
  142. SureShot, Nightshade, Sas.stu, -X-, Vunsata
  143.  
  144.  
  145.  
  146. *********************************************************************************/
  147.  
  148. #include <amxmodx>
  149. #include <amxmisc>
  150. #include <cstrike>
  151. #include <fakemeta>
  152.  
  153. #define PLUGIN "Ryu_SuperWeapon"
  154. #define VERSION "0.4"
  155. #define AUTHOR "CZ*Ryu"
  156.  
  157. #define MAXPLAYERS 32
  158. #define MAXNUM 64
  159.  
  160. #define SW_BOX_PARAM_NOTOUCH 0
  161. #define SW_BOX_PARAM_TRIGGER 1
  162.  
  163. #define SW_BOX_SILEN_OFF 0
  164. #define SW_BOX_SILEN_ON 1
  165.  
  166. //grenade tyep, ItemPickup & Scenario: grenade type(he|gasun-use) sprite string num constant,
  167. #define TYPE_HENADE 0
  168. #define TYPE_GASNADE 1
  169. #define TYPE_INCENDIARY 2
  170. #define NOT_SHOW_NUM 10
  171.  
  172. //team kill check constant
  173. #define HURT_ENEMY 0
  174. #define HURT_TEAMMATE 1
  175. #define HURT_SELF 2
  176. #define HURT_NONE 3
  177.  
  178. //effect entity
  179. #define EFFECT_EXPLO 0
  180. #define EFFECT_BLOOD 1
  181.  
  182. #pragma dynamic 32768
  183.  
  184.  
  185. //common value
  186. new iRoundCount
  187. new iServerTK //expression of server's team-kill rule
  188.  
  189. new bool:bIsCsSeries = false
  190. new bool:bHasNewWeapon = true
  191. new bool:bRightMapType = false
  192. new bool:bSpawnSwBox
  193.  
  194. //team
  195. new const TE = 1
  196. new const CT = 2
  197. new const SPECTATOR = 3
  198.  
  199. //icon state constant
  200. new const CLEAR = 0
  201. new const SHOW = 1
  202.  
  203. //take count of superweapon
  204. new const COUNT = 1
  205.  
  206. //task id
  207. new const iTaskSpanwSwBox = 33333
  208. new const iTaskBuyTimeOver = 33334
  209.  
  210. //message id
  211. new iDeathMsgID
  212. new iItemPickupMsgID
  213. new iSayTextMsgID
  214. new iScenarioMsgID
  215. new iStatusIconMsgID
  216.  
  217. new const sNadeStateString[2][] = {"dmg_rad", "item_healthkit"}//,"dmg_heat"}
  218.  
  219. //------ pcvar -------------------------------
  220. new cvar_SwSpawnMode_num
  221. new cvar_SwM4Price_num
  222. new cvar_SwM4StripMode_num
  223. new cvar_SwMaxHolders_TE_num
  224. new cvar_SwMaxHolders_CT_num
  225. new cvar_SwNadeReloadTime_flo
  226. new cvar_SwNadeTeamKill_num
  227. //40mm hegrenade
  228. new cvar_SwNadeMaxDmg_HE_num
  229. new cvar_SwNadeDmgRadius_HE_num
  230. new cvar_SwNadeMaxCarried_HE_num
  231. new cvar_SwNadePrice_HE_num
  232. //40mm gas grenade
  233. new cvar_SwNadeMaxDmg_GAS_num
  234. new cvar_SwNadeDmgRadius_GAS_num
  235. new cvar_SwNadeMaxCarried_GAS_num
  236. new cvar_SwNadePrice_GAS_num
  237.  
  238.  
  239. new iSwSpawnMode
  240. new iSwM4Price
  241. new iSwM4StripMode
  242. new bool:bSwNadeTK
  243. new Float:fSwNadeReloadTime //grenade reload time
  244. new iSwNadePrice[2] //[0] is hegrenade's price, [1] store gas grenade's
  245. new iSwNadeMaxCarried[2] //how many grenades can been tote, [0] is hegrenade, [1] store gas grenade
  246. new Float:fSwNadeMaxDmg_HE //hegrenade max damage
  247. new sSwNadeMaxDmg_GAS[4] //gas grenade max damage
  248. new Float:fSwNadeDmgRadius[2] //grenade damage radius
  249.  
  250.  
  251. //---------------------------------------------
  252.  
  253. //correlative variable of superweapon spawn
  254. new iInfoEntAmount //count of player spawn points
  255. new Float:fInfoEntOrigin[MAXNUM][3] //origin of player spawn points
  256. new iGhostEntID[MAXNUM] //assistant entity(for get superweapon spawn point) id
  257. new bool:bGhostEntRemoved = false
  258. new const sGhostEntClassname[] = "Sw_AssistEntity"
  259.  
  260.  
  261. new const sSwClassname_Prefix[] = "Sw_"
  262.  
  263. new const sSwM4BoxClassname[] = "Sw_Box_M4withM203"
  264. new const sSwM4BoxSpriteClassname[] = "Sw_Sprite"
  265. new sSwM4BoxSprite[] = "sprites/3dmflaora.spr"
  266. new iSwM4MaxAmount //max sueprweapon amount
  267. new iSwM4MaxTeamHolders[4] //max sueprweapon amount of each team(te|ct) can hold
  268. new iSwM4CurTeamHolders[4] //current amount of each team hold
  269. new const iSwM4WeaponID = CSW_M4A1
  270. new sSwM4WeaponName[] = "weapon_m4a1"
  271. new const sSwM4Model_v[] = "models/v_m4a1_sw.mdl"
  272. new const sSwM4Model_p[] = "models/p_m4a1_sw.mdl"
  273. new const sSwM4Model_w[] = "models/w_m4a1_sw.mdl"
  274.  
  275.  
  276. //some player personal parameter
  277. new iUserHoldSwM4[MAXPLAYERS+1] = 0 //player(id) has superweapon?
  278. new iUserNadeCurType[MAXPLAYERS+1] //player current animated type of grenade
  279. new iUserNadeAmount[MAXPLAYERS+1][3] //player's 40mm grenade amount, [0] is "he", [1] is "gas"
  280. new iUserTouchTimes[MAXPLAYERS+1]
  281. new iUserHasHurtEnt[MAXPLAYERS+1]
  282. new iSwM4SilenStatus[MAXPLAYERS+1]
  283. new iSwM4ClipAmmo[MAXPLAYERS+1]
  284. new iSwM4BpAmmo[MAXPLAYERS+1]
  285. new bool:bRestartAttempt[MAXPLAYERS+1]
  286.  
  287.  
  288. new bool:bInBuyzone[MAXPLAYERS+1] = true
  289. new bool:bNadeReloaded[MAXPLAYERS+1] = true
  290. new bool:bInBuyTime
  291. new bool:bInFreezeTime
  292.  
  293.  
  294. //grenade's value
  295. //menu
  296. new iSwNadeMenuID
  297. new sSwNadeMenuBody[512]
  298. new sSwNadeMenuTitle[] = "M4withM203"
  299. new iMenuKeys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_0
  300.  
  301. new iSwNadeSprite_Trail
  302. new iSwNadeSprite_GasExplode
  303. new iSwNadeSprite_GasFog
  304.  
  305. new const sSwNadeClassname[2][] = {"Sw_Grenade_HE","Sw_Grenade_GAS"} //40mm grenade(type he & gas) of m203
  306. new const sSwNadeFakeGasClassname[] = "Sw_FakeGas"
  307. new const sSwNadeFakeHurtClassname[] = "Sw_HurtEnt"
  308. new const sSwNadeSprite_Trail[] = "sprites/smoke.spr"
  309. new const sSwNadeSprite_GasExplode[] = "sprites/WXplo1.spr"
  310. new const sSwNadeSprite_GasFog[] = "sprites/fakefog.spr"
  311. new const sSwNadeModel_w[] = "models/grenade.mdl"
  312. new sSwNadeSound_Launch[] = "launch40mm.wav"
  313. new sSwNadeSound_Buy[] = "items/gunpickup2.wav"
  314. new sSwNadeSound_Change[] = "items/gunpickup1.wav"
  315. new sSwNadeSound_GasExplode[] = "weapons/sg_explode.wav"
  316. new sSwNadeSound_UseUp[] = "weapons/dryfire_rifle.wav"
  317.  
  318. new sMsgCannotGetSw[] = "^x03 It is max amount of^x03 your team^x04 can took superweapons now, cannot take more."
  319. new sMsgStripSw[] = "^x03 Bocsi! A csapatod ma'r ele'rte a korla'tot."
  320. new sMsgNotInBuyzone[] = "^x04 Csak^x03 buyzonaban"
  321. new sMsgNotInBuyTime[] = "^x03 Va'sa'rla'si ido lejart!"
  322.  
  323. //some common constant
  324. new const sClassname[] = "classname"
  325. new const sWeaponbox[] = "weaponbox"
  326. new const sPlayer[] = "player"
  327. new const sFuncBreakable[] = "func_breakable"
  328. new const sFuncPushable[] = "func_pushable"
  329. new const sHostageEntity[] = "hostage_entity"
  330. new const sMonsterScientist[] = "monster_scientist"
  331.  
  332. new const sInfoPlayerStart[] = "info_player_start"
  333. new const sInfoPlayerDeathmatch[] = "info_player_deathmatch"
  334.  
  335. new const sNamedEntEnvSprite[] = "env_sprite"
  336. new const sNamedEntEnvExplosion[] = "env_explosion"
  337. new const sNamedEntEnvBlood[] = "env_blood"
  338. new const sNamedEntInfoTarget[] = "info_target"
  339. new const sNamedEntTriggerHurt[] = "trigger_hurt"
  340.  
  341. new const sModel_Weaponbox_w[] = "models/w_weaponbox.mdl"
  342. new const sModel_M4_w[] = "models/w_m4a1.mdl"
  343. new const sModel_Prefix_w[] = "models/w_"
  344.  
  345. new iSwEffectID[2]
  346. new const sSwEffectClassname[] = "Sw_EffectEnt"
  347.  
  348. //stock const
  349. stock const pev_SwBox_Param_e = pev_euser1
  350. stock const pev_SwBox_Silen_e = pev_euser2
  351. stock const pev_SwBox_ClipAmmo_e = pev_euser3
  352. stock const pev_SwBox_BpAmmo_e = pev_euser4
  353. stock const pev_SwBox_HeAmount_i = pev_iuser1
  354. stock const pev_SwBox_GasAmount_i = pev_iuser2
  355. stock const pev_SwNade_HurtEnt_i = pev_iuser1
  356. //stock const pev_SwNade_ExploPoint_v = pev_vuser1
  357.  
  358.  
  359. new const iPrimaryWeaponTable[] = {
  360. CSW_AK47,
  361. CSW_M4A1,
  362. CSW_AWP,
  363. CSW_MP5NAVY,
  364. CSW_SG552,
  365. CSW_AUG,
  366. CSW_SCOUT,
  367. CSW_UMP45,
  368. CSW_P90,
  369. CSW_M249,
  370. CSW_M3,
  371. CSW_XM1014,
  372. CSW_TMP,
  373. CSW_MAC10,
  374. CSW_G3SG1,
  375. CSW_SG550,
  376. CSW_GALIL,
  377. CSW_FAMAS,
  378. 2 //shield
  379. }
  380.  
  381. public plugin_init()
  382. {
  383. register_plugin(PLUGIN, VERSION, AUTHOR)
  384.  
  385. iDeathMsgID = get_user_msgid("DeathMsg")
  386. iItemPickupMsgID = get_user_msgid("ItemPickup")
  387. iSayTextMsgID = get_user_msgid("SayText")
  388. iScenarioMsgID = get_user_msgid("Scenario")
  389. iStatusIconMsgID = get_user_msgid("StatusIcon")
  390.  
  391. register_event("HLTV", "event_new_round", "a", "1=0", "2=0")
  392. register_event("ResetHUD", "event_client_spawn", "be")
  393. register_event("CurWeapon", "event_check_superweapon", "be", "1>0", "2=22")
  394. register_event("TextMsg", "event_reset_round", "a", "2&#Game_C", "2&#Game_w")
  395. register_event("StatusIcon", "event_check_in_buyzone", "be", "2=buyzone")
  396. register_event("DeathMsg", "event_DeathMsg", "a")//, "4=65536")//DMG_NERVEGAS
  397.  
  398. register_logevent("logevent_round_start", 2, "0=World triggered", "1=Round_Start")
  399.  
  400. register_forward(FM_Touch, "forward_touch")
  401. register_forward(FM_SetModel, "forward_reset_model")
  402. register_forward(FM_CmdStart, "forward_CmdStart")
  403. register_forward(FM_Think, "forward_SW_think")
  404.  
  405. iSwNadeMenuID = register_menuid(sSwNadeMenuTitle)
  406. register_menucmd(iSwNadeMenuID, 1023, "menu_SwGrenade_option")
  407.  
  408. register_clcmd("fullupdate", "hook_clcmd_fullupdate")
  409. register_concmd("amx_sw_m4", "hook_concmd_sw_m4",ADMIN_IMMUNITY, "{<#playerindex|name(can be partial)> <g(means give M4A1/W M203)|s(means strip target's superweapon if he has>}")
  410. register_concmd("amx_sw_set", "hook_concmd_sw_set",ADMIN_IMMUNITY, "{<0>|<1>|<2>, ^"0^" stop SW mode(also strip all sw) & ^"1^" start it by SW_SpawnMode's setting & ^"2^" start anywise}")
  411. register_clcmd("say /buyswm4", "hook_clcmd_buyswm4")
  412.  
  413. cvar_SwSpawnMode_num = register_cvar("SW_SpawnMode", "0")//define superweapon appear mode,
  414. //"0" means superweapon never spawn but can been buy by client command, (admin still can give it to any player by admin command)
  415. //"1" means auto, superweapon will auto spawn in general maps
  416. //"2" means superweapon will auto spawn in all type of maps
  417.  
  418. cvar_SwM4Price_num = register_cvar("SW_M4Price", "8000")//m4 with m203's price, include all type of grenades with max amount
  419.  
  420. cvar_SwM4StripMode_num = register_cvar("SW_M4StripMode", "1")
  421. //"0" means only strip superweapon(still keep default m4a1)
  422. //"1" means strip the holder's superweapon & default m4a1
  423.  
  424. cvar_SwMaxHolders_TE_num = register_cvar("SW_MaxAmount_TE", "3")//max amount of terrorists can holded m4 with m203
  425. cvar_SwMaxHolders_CT_num = register_cvar("SW_MaxAmount_CT", "3")//max amount of cts can holded m4 with m203
  426.  
  427. cvar_SwNadeTeamKill_num = register_cvar("SW_GrenadeTK", "0")//grenade team kill,"0" is secundum server's rule, "1" is TK in any case
  428. cvar_SwNadeReloadTime_flo = register_cvar("SW_GrenadeRT", "3.0")//grenade reload time
  429.  
  430. cvar_SwNadeMaxDmg_HE_num = register_cvar("SW_HeGrenadeMD", "100") //40mm he grenade max damage
  431. cvar_SwNadeDmgRadius_HE_num = register_cvar("SW_HeGrenadeDR", "400") //40mm he grenade damage radius
  432. cvar_SwNadeMaxCarried_HE_num = register_cvar("SW_HeGrenadeMC", "2") //40mm he grenade's max amount can been took
  433. cvar_SwNadePrice_HE_num = register_cvar("SW_HeGrenadePR", "500") //40mm he grenade's price
  434.  
  435. cvar_SwNadeMaxDmg_GAS_num = register_cvar("SW_GasGrenadeMD", "100") //40mm gas grenade max damage
  436. cvar_SwNadeDmgRadius_GAS_num = register_cvar("SW_GasGrenadeDR", "100") //40mm gas grenade damage radius
  437. cvar_SwNadeMaxCarried_GAS_num = register_cvar("SW_GasGrenadeMC", "1") //40mm gas grenade's max amount can been took
  438. cvar_SwNadePrice_GAS_num = register_cvar("SW_GasGrenadePR", "500") //40mm gas grenade's price
  439.  
  440. iInfoEntAmount = get_InfoEnt_origin()
  441.  
  442. new len = format(sSwNadeMenuBody, 511, "\w[M4A1 granatveto beallitasok ]^n^n")
  443. len += format(sSwNadeMenuBody[len], 511 - len, "\y1.Robbano gra'na't beta'raza'sa^n")
  444. len += format(sSwNadeMenuBody[len], 511 - len, "\y2.Ga'z gra'na't beta'raza'sa^n")
  445. len += format(sSwNadeMenuBody[len], 511 - len, "\y3.Hangtompito' le|felszerele's^n")
  446. len += format(sSwNadeMenuBody[len], 511 - len, "\w4.Va'sa'ro'l robbano gra'na'tot^n")
  447. len += format(sSwNadeMenuBody[len], 511 - len, "\w5.Va'sa'ro'l ga'z gra'na'tot^n^n")
  448. format(sSwNadeMenuBody[len], 511 - len, "\r0.Kilep")
  449.  
  450. iSwSpawnMode = get_pcvar_num(cvar_SwSpawnMode_num)
  451. switch ( iSwSpawnMode )
  452. {
  453. case 0:
  454. {
  455. bSpawnSwBox = false
  456. bRightMapType = false
  457. }
  458. case 1:
  459. {
  460. bRightMapType = ( engfunc(EngFunc_FindEntityByString, -1, sClassname, sHostageEntity)
  461. || engfunc(EngFunc_FindEntityByString, -1, sClassname, sMonsterScientist)
  462. || engfunc(EngFunc_FindEntityByString, -1, sClassname, "func_hostage_rescue")
  463. || engfunc(EngFunc_FindEntityByString, -1, sClassname, "info_hostage_rescue")
  464. || engfunc(EngFunc_FindEntityByString, -1, sClassname, "func_bomb_target")
  465. || engfunc(EngFunc_FindEntityByString, -1, sClassname, "info_bomb_target")
  466. || engfunc(EngFunc_FindEntityByString, -1, sClassname, "func_vip_start")
  467. || engfunc(EngFunc_FindEntityByString, -1, sClassname, "info_vip_start")
  468. || engfunc(EngFunc_FindEntityByString, -1, sClassname, "func_vip_safetyzone")
  469. || engfunc(EngFunc_FindEntityByString, -1, sClassname, "func_escapezone") )?true:false
  470. bSpawnSwBox = bRightMapType
  471. }
  472. case 2:
  473. {
  474. bSpawnSwBox = true
  475. bRightMapType = true
  476. }
  477. }
  478.  
  479. iServerTK = HURT_TEAMMATE
  480. if ( cvar_exists("mp_friendlyfire") )
  481. iServerTK = ( get_cvar_num("mp_friendlyfire") )?HURT_TEAMMATE:HURT_NONE
  482. }
  483.  
  484. public plugin_precache()
  485. {
  486. new sModName[32]
  487. get_modname(sModName,31)
  488. if ( equal(sModName,"cstrike") || equal(sModName,"czero") )
  489. bIsCsSeries = true
  490. else if ( equal(sModName,"csv15") || equal(sModName,"cs13") )
  491. {
  492. bIsCsSeries = true
  493. bHasNewWeapon = false
  494. }
  495. if ( !bIsCsSeries )
  496. pause("ae")
  497.  
  498. precache_model(sSwM4Model_v)
  499. precache_model(sSwM4Model_p)
  500. precache_model(sSwM4Model_w)
  501.  
  502. precache_model(sSwNadeModel_w)
  503.  
  504. precache_sound(sSwNadeSound_Launch)
  505. precache_sound(sSwNadeSound_Buy) //buy grenades
  506. precache_sound(sSwNadeSound_Change) //grenades type change
  507. precache_sound(sSwNadeSound_GasExplode)
  508. precache_sound(sSwNadeSound_UseUp)
  509.  
  510. precache_model(sSwM4BoxSprite)
  511. iSwNadeSprite_Trail = precache_model(sSwNadeSprite_Trail)
  512. iSwNadeSprite_GasExplode = precache_model(sSwNadeSprite_GasExplode)
  513. iSwNadeSprite_GasFog = precache_model(sSwNadeSprite_GasFog)
  514.  
  515. return PLUGIN_CONTINUE
  516. }
  517.  
  518. public event_new_round()
  519. {
  520. iRoundCount++
  521. new iSpawnAmount = get_cvar_param()
  522. new iMaxEntities = global_get(glb_maxEntities)
  523. new i,sClass[32]
  524. for ( i=MAXPLAYERS+1; i<iMaxEntities; i++ )
  525. {
  526. if ( !pev_valid(i) )
  527. continue
  528. pev(i, pev_classname, sClass, sizeof sClass - 1 )
  529. if ( equal(sClass, sSwClassname_Prefix, 3) )
  530. engfunc(EngFunc_RemoveEntity, i)
  531. }
  532. create_effect_entity()
  533. if ( !bGhostEntRemoved )
  534. bGhostEntRemoved = remove_GhostEnt()
  535. if ( bSpawnSwBox && iRoundCount > 1 && iSpawnAmount > 0 )
  536. bGhostEntRemoved = bool:spawn_GhostEnt(iSpawnAmount)
  537. return PLUGIN_CONTINUE
  538. }
  539.  
  540. public hook_clcmd_fullupdate(id)
  541. {
  542. return PLUGIN_HANDLED
  543. }
  544.  
  545. public event_client_spawn(id)
  546. {
  547. new iMenuID,iKeys
  548. get_user_menu(id, iMenuID, iKeys)
  549. if ( iMenuID == iSwNadeMenuID )
  550. client_cmd(id, "slot10")
  551.  
  552. if ( bRestartAttempt[id] )
  553. {
  554. bRestartAttempt[id] = false
  555. return
  556. }
  557.  
  558. iUserHasHurtEnt[id] = 0
  559. bNadeReloaded[id] = true
  560. if ( iUserHoldSwM4[id] > MAXPLAYERS && pev(id, pev_weapons) & (1<<iSwM4WeaponID) )
  561. {
  562. iUserNadeCurType[id] = TYPE_HENADE
  563. manage_StatusIcon_hud(id, SHOW, iUserNadeAmount[id][TYPE_HENADE])
  564. manage_Scenario_hud(id, SHOW)
  565. engclient_cmd(id, sSwM4WeaponName)
  566. }
  567. else
  568. reset_player(id)
  569. }
  570.  
  571. public event_check_in_buyzone(id)
  572. {//check superweapon holder in buyzone
  573. bInBuyzone[id] = bool:read_data(1)
  574. }
  575.  
  576. public event_check_superweapon(id)
  577. {
  578. if ( iUserHoldSwM4[id] < MAXPLAYERS )
  579. return
  580. iSwM4ClipAmmo[id] = read_data(3)
  581. reset_superweapon(id)
  582. }
  583.  
  584. public logevent_round_start()
  585. {
  586. new message[128]
  587. format(message, 127, "^x04 Az^x03 M4A1^x04 gra'na'tveto^x03 bea'llita'saihoz^x04, nyomd^x03 ^"a T betut^" ")
  588. color_saytext(message, MSG_ALL, _, 4)
  589. if ( iSwSpawnMode == 0 )
  590. {
  591. format(message, 127, "^x04 M203 va'sa'rla'sahoz^x03 ird be /buyswm4^x04 <---ezt")
  592. color_saytext(message, MSG_ALL, _, 1)
  593. }
  594. bInFreezeTime = false
  595. }
  596.  
  597. public event_DeathMsg()
  598. {
  599. remove_HurtEnt(read_data(2))
  600. }
  601.  
  602. public client_disconnect(id)
  603. {
  604. bInBuyzone[id] = false
  605. bNadeReloaded[id] = true
  606. remove_HurtEnt(id)
  607. }
  608.  
  609. public event_reset_round()
  610. {
  611. iRoundCount = 0
  612. bGhostEntRemoved = false
  613.  
  614. for ( new i=1; i<=MAXPLAYERS; i++ )
  615. {
  616. iUserHoldSwM4[i] = 0
  617. iUserNadeAmount[i][TYPE_HENADE] = 0
  618. iUserNadeAmount[i][TYPE_GASNADE] =0
  619. iUserTouchTimes[i] = 0
  620. bNadeReloaded[i] = true
  621. if ( is_user_alive(i) )
  622. bRestartAttempt[i] = true
  623. }
  624. return PLUGIN_CONTINUE
  625. }
  626.  
  627. public hook_clcmd_buyswm4(id)
  628. {
  629. if ( iSwSpawnMode != 0 )
  630. {
  631. client_print(id, print_center, "Ebben a modban ez a fegyver nem veheto!")
  632. return PLUGIN_HANDLED
  633. }
  634. if ( iUserHoldSwM4[id] > MAXPLAYERS || !is_user_alive(id) )
  635. return PLUGIN_HANDLED
  636. if ( !bInBuyTime )
  637. {
  638. color_saytext(sMsgNotInBuyTime, MSG_ONE, id, 4)
  639. return PLUGIN_HANDLED
  640. }
  641. if ( !bInBuyzone[id] )
  642. {
  643. color_saytext(sMsgNotInBuyzone, MSG_ONE, id)
  644. return PLUGIN_HANDLED
  645. }
  646. new iMoney = cs_get_user_money(id)
  647. if ( iMoney < iSwM4Price )
  648. {
  649. new message[64]
  650. format(message, 63, "^x04 Nincs ele'g pe'nzed^x03 Az M4A1^x04 $%d-be kerul", iSwM4Price)
  651. color_saytext(message, MSG_ONE, id)
  652. return PLUGIN_HANDLED
  653. }
  654. new iTeam = get_user_team(id)
  655. if ( iSwM4CurTeamHolders[iTeam] >= iSwM4MaxTeamHolders[iTeam] )
  656. {
  657. color_saytext(sMsgCannotGetSw, MSG_ONE,id)
  658. return PLUGIN_HANDLED
  659. }
  660. if ( give_superweapon(id, iTeam) > MAXPLAYERS )
  661. cs_set_user_money(id, iMoney - iSwM4Price, 1)
  662. return PLUGIN_HANDLED
  663. }
  664.  
  665. public hook_concmd_sw_set(id, level, cid)
  666. {
  667. if ( !cmd_access(id, level, cid, 2) )
  668. return PLUGIN_HANDLED
  669. new arg[128],iParam
  670. read_argv(1,arg,1)
  671. iParam = str_to_num(arg[0])
  672. if ( (2 < iParam < 0) )
  673. return PLUGIN_HANDLED
  674. switch ( iParam )
  675. {
  676. case 0:
  677. {
  678. bSpawnSwBox = false
  679. iParam = -1
  680. while ( (iParam = engfunc(EngFunc_FindEntityByString, iParam, sClassname, sSwM4BoxClassname)) > MAXPLAYERS )
  681. remove_superweapon_box(iParam)
  682. for ( iParam=1; iParam<=MAXPLAYERS; iParam++ )
  683. {
  684. if ( is_user_alive(iParam) )
  685. {
  686. reset_player(iParam, COUNT)
  687. engclient_cmd(iParam, "lastinv")
  688. engclient_cmd(iParam, "lastinv")
  689. }
  690. }
  691. format(arg, 127, "^x04*** OMG! ***")
  692. color_saytext(arg, MSG_ALL, _, 1)
  693. }
  694. case 1:
  695. bSpawnSwBox = iSwSpawnMode > 0?bRightMapType:false
  696. case 2:
  697. bSpawnSwBox = true
  698. }
  699.  
  700. if ( bSpawnSwBox )
  701. format(arg, 127, "^x04*** LOL! ***")
  702. else
  703. format(arg, 127, "^x04*** OMG! ***")
  704. color_saytext(arg, MSG_ALL, _, 1)
  705. return PLUGIN_HANDLED
  706. }
  707.  
  708. public hook_concmd_sw_m4(id, level, cid)
  709. {//admin command for giving superweapon
  710. if ( !cmd_access(id, level, cid, 3) )
  711. return PLUGIN_HANDLED
  712. new target,arg[128]
  713. read_argv(1,arg,31)
  714. if ( arg[0] == '#' )
  715. {
  716. new sz[31]
  717. copy(sz, sizeof(arg)-1, arg[1])
  718. target = str_to_num(sz)
  719. }
  720. else
  721. target = find_player("bl", arg)
  722. if ( !is_user_alive(target) )
  723. return PLUGIN_HANDLED
  724.  
  725. read_argv(2,arg,1)
  726. switch ( arg[0] )
  727. {
  728. case 's':
  729. {
  730. if ( iUserHoldSwM4[target] <= MAXPLAYERS )
  731. return PLUGIN_HANDLED
  732. switch ( iSwM4StripMode )
  733. {
  734. case 0://strip sw & keep default m4
  735. {
  736. reset_player(target, COUNT)
  737. engclient_cmd(target, "lastinv")
  738. engclient_cmd(target, "lastinv")
  739. }
  740. case 1://strip m4
  741. {
  742. iUserHoldSwM4[target] *= -1
  743. engclient_cmd(target, "drop", sSwM4WeaponName)
  744. }
  745. }
  746. console_print(id, "target: %d --- command: strip --- strip mode: %d", target, iSwM4StripMode)
  747. }
  748. case 'g':
  749. {
  750. if ( iUserHoldSwM4[target] > MAXPLAYERS )
  751. return PLUGIN_HANDLED
  752. new i,num = bHasNewWeapon?19:16
  753. new iTeam = get_user_team(target)
  754. new iParam = engfunc(EngFunc_FindEntityByString, -1, sClassname, sSwM4BoxClassname)
  755. if ( iParam > MAXPLAYERS )
  756. remove_superweapon_box(iParam)//remove one superweapon box for keep total amount
  757. else//if cannot find superweapon box, strip any teammate or other superweapon holder for keep total amount
  758. {
  759. iParam = 0
  760. for ( i=1; i<=MAXPLAYERS; i++ )
  761. {
  762. if ( iUserHoldSwM4[i] <= MAXPLAYERS )
  763. continue
  764. iParam = i
  765. if ( get_user_team(iParam) == iTeam )//strip teammate's sueprweapon first, for keep max team sw amount
  766. break
  767. }
  768. if ( iParam && is_user_alive(iParam) )
  769. {
  770. reset_player(iParam, COUNT)
  771. engclient_cmd(iParam, "lastinv")
  772. engclient_cmd(iParam, "lastinv")
  773. color_saytext(sMsgStripSw, MSG_ONE, iParam, 1)
  774. }
  775. }
  776. if ( cs_get_user_hasprim(target) )
  777. {
  778. for ( i=0; i<num; i++ )
  779. {//check & drop prim weapon from the player who gave superweapon
  780. iParam = iPrimaryWeaponTable[i]
  781. if ( pev(target, pev_weapons) & (1<<iParam) )
  782. {
  783. get_weaponname(iParam, arg, 31)
  784. engclient_cmd(target, "drop", arg)
  785. break
  786. }
  787. }
  788. }
  789. give_superweapon(target, iTeam)
  790. console_print(id, "target: %d --- command: give", target)
  791. console_print(id, "teamholders: %d", iSwM4CurTeamHolders[iTeam])
  792. }
  793. }
  794. return PLUGIN_HANDLED
  795. }
  796.  
  797. public task_buy_time_over()
  798. {
  799. bInBuyTime = false
  800. }
  801.  
  802. public task_spawn_SwBox(param[])
  803. {
  804. new iSpawnAmount = param[0]
  805. new iCount,ent,iSpriteEnt,Float:fOrigin[3]
  806.  
  807. while ( iCount++ <= iSpawnAmount )
  808. {
  809. ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, sNamedEntInfoTarget))
  810. if ( ent <= MAXPLAYERS )
  811. continue
  812. iSpriteEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, sNamedEntEnvSprite))
  813. if ( iSpriteEnt <= MAXPLAYERS )
  814. {
  815. engfunc(EngFunc_RemoveEntity, ent)
  816. continue
  817. }
  818. fm_set_kvd(iSpriteEnt, "renderfx", "14", sNamedEntEnvSprite)
  819. fm_set_kvd(iSpriteEnt, "rendermode", "5", sNamedEntEnvSprite)//kRenderTransAdd
  820. fm_set_kvd(iSpriteEnt, "renderamt", "100", sNamedEntEnvSprite)//transparence(1~255)
  821. fm_set_kvd(iSpriteEnt, "rendercolor", "50 255 50", sNamedEntEnvSprite)
  822. fm_set_kvd(iSpriteEnt, "framerate", "2", sNamedEntEnvSprite)
  823. fm_set_kvd(iSpriteEnt, "model", sSwM4BoxSprite, sNamedEntEnvSprite)
  824. fm_set_kvd(iSpriteEnt, "scale", "1.3", sNamedEntEnvSprite)
  825. set_pev(iSpriteEnt, pev_spawnflags, pev(iSpriteEnt, pev_spawnflags) | SF_SPRITE_STARTON)
  826. set_pev(iSpriteEnt, pev_spawnflags, pev(iSpriteEnt, pev_spawnflags) | SF_SPRITE_TEMPORARY)
  827. dllfunc(DLLFunc_Spawn, iSpriteEnt)
  828.  
  829. pev(iGhostEntID[random(iInfoEntAmount)], pev_origin, fOrigin)
  830.  
  831. set_pev(ent, pev_classname, sSwM4BoxClassname)
  832. engfunc(EngFunc_SetModel, ent, sSwM4Model_w)
  833. set_pev(ent, pev_origin, fOrigin)
  834. set_pev(ent, pev_mins, {-16.0,-16.0,-16.0})
  835. set_pev(ent, pev_maxs, {16.0,16.0,16.0})
  836. set_pev(ent, pev_solid, SOLID_TRIGGER)
  837. set_pev(ent, pev_movetype, MOVETYPE_BOUNCE)
  838.  
  839. set_pev(ent, pev_SwBox_Param_e, iSpriteEnt)//stroe effect sprite entity id
  840. set_pev(ent, pev_SwBox_ClipAmmo_e, 30)
  841. set_pev(ent, pev_SwBox_BpAmmo_e, 90)
  842. set_pev(ent, pev_SwBox_HeAmount_i, iSwNadeMaxCarried[TYPE_HENADE])
  843. set_pev(ent, pev_SwBox_GasAmount_i, iSwNadeMaxCarried[TYPE_GASNADE])
  844.  
  845. set_pev(iSpriteEnt, pev_classname, sSwM4BoxSpriteClassname)
  846. set_pev(iSpriteEnt, pev_origin, fOrigin)
  847. set_pev(iSpriteEnt, pev_aiment, ent)
  848. set_pev(iSpriteEnt, pev_movetype, MOVETYPE_FOLLOW)
  849.  
  850. set_pev(ent, pev_nextthink, fCurrentTime() + 1.5)
  851. }
  852. set_hudmessage(0, 255, 0, -1.0, 0.00, 1, 6.0, 15.0, 0.15, 0.15, 4)
  853. show_hudmessage(0,"SuperWeapon^nM4A1 w/ M203 : gra'na't vetovell...")
  854. bGhostEntRemoved = remove_GhostEnt()
  855.  
  856. return PLUGIN_CONTINUE
  857. }
  858.  
  859. public forward_reset_model(iEnt, sModel[])
  860. {
  861. if ( iEnt <= MAXPLAYERS || equal(sModel, sModel_Weaponbox_w) )
  862. return FMRES_IGNORED
  863.  
  864. //switch ( bInBuyTime )
  865.  
  866. if ( equal(sModel, sModel_Prefix_w, 9) )
  867. {
  868. static classname[32]
  869. pev(iEnt, pev_classname, classname, sizeof classname - 1)
  870. if ( !equal(classname, sWeaponbox) )//filtrate throwed grenades
  871. return FMRES_IGNORED
  872. static owner
  873. owner = pev(iEnt, pev_owner)
  874. if ( (0 < owner <= MAXPLAYERS) && iUserHoldSwM4[owner] != 0 )
  875. {
  876. new bool:bOwnerAlive = bool:is_user_alive(owner)
  877. if ( equal(sModel, sModel_M4_w) )
  878. {
  879. if ( iUserHoldSwM4[owner] > MAXPLAYERS )
  880. {
  881. new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, sNamedEntInfoTarget))
  882. if ( !pev_valid(ent) )
  883. return FMRES_IGNORED
  884. new Float:fVector[3]
  885. set_pev(ent, pev_classname, sSwM4BoxClassname)
  886. engfunc(EngFunc_SetModel, ent, sSwM4Model_w)
  887. set_pev(ent, pev_solid, SOLID_TRIGGER)
  888. set_pev(ent, pev_SwBox_Param_e, SW_BOX_PARAM_NOTOUCH)
  889. set_pev(ent, pev_SwBox_Silen_e, iSwM4SilenStatus[owner])
  890. set_pev(ent, pev_SwBox_ClipAmmo_e, iSwM4ClipAmmo[owner])
  891. set_pev(ent, pev_SwBox_BpAmmo_e, !bOwnerAlive?0:iSwM4BpAmmo[owner])
  892. set_pev(ent, pev_SwBox_HeAmount_i, iUserNadeAmount[owner][TYPE_HENADE])
  893. set_pev(ent, pev_SwBox_GasAmount_i, iUserNadeAmount[owner][TYPE_GASNADE])
  894.  
  895. //reset_player(owner, COUNT)
  896.  
  897. set_pev(ent, pev_movetype, MOVETYPE_TOSS)
  898. pev(iEnt, pev_origin, fVector)
  899. set_pev(ent, pev_origin, fVector)
  900. pev(iEnt, pev_angles, fVector)
  901. set_pev(ent, pev_angles, fVector)
  902. pev(iEnt, pev_velocity, fVector)
  903. set_pev(ent, pev_velocity, fVector)
  904.  
  905. set_pev(ent, pev_nextthink, fCurrentTime() + 0.5)
  906. }
  907. set_pev(iEnt, pev_nextthink, fCurrentTime())
  908. reset_player(owner, COUNT)
  909. }
  910. else if ( bOwnerAlive && pev(owner, pev_weapons) & (1<<iSwM4WeaponID) )
  911. reset_superweapon(owner)
  912. }
  913. }
  914. return FMRES_IGNORED
  915. }
  916.  
  917. public forward_SW_think(ent)
  918. {
  919. if ( ent <= MAXPLAYERS )
  920. return
  921. static classname[32]
  922. pev(ent, pev_classname, classname, sizeof classname - 1)
  923. if ( !equal(classname, sSwClassname_Prefix, 3) )
  924. return
  925. switch ( classname[3] )
  926. {
  927. case 'H'://hurt entity
  928. {
  929. iUserHasHurtEnt[pev(ent, pev_owner)] = 0
  930. engfunc(EngFunc_RemoveEntity, ent)
  931. }
  932. case 'F'://"fake gas" entity
  933. engfunc(EngFunc_RemoveEntity, ent)
  934. case 'B'://"fake weapon box"
  935. {
  936. new iParam = pev(ent, pev_SwBox_Param_e)
  937. switch ( iParam )
  938. {
  939. case SW_BOX_PARAM_NOTOUCH: set_pev(ent, pev_SwBox_Param_e, SW_BOX_PARAM_TRIGGER)//delay for "touch"
  940. case SW_BOX_PARAM_TRIGGER: return//is dropped by player
  941. default://spawn by system
  942. {
  943. new Float:fVector[3]
  944. fVector[0] = random_float(0.0, 359.99)
  945. fVector[1] = random_float(0.0, 359.99)
  946. fVector[2] = random_float(0.0, 359.99)
  947. set_pev(ent, pev_angles, fVector)
  948. fVector[0] = random_float(-300.0, 300.0)
  949. fVector[1] = random_float(-300.0, 300.0)
  950. fVector[2] = random_float(-300.0, 300.0)
  951. set_pev(ent, pev_velocity, fVector)
  952. set_pev(ent, pev_nextthink, fCurrentTime() + 1.0)
  953. }
  954. }
  955. }
  956. }
  957. }
  958.  
  959. public forward_CmdStart(id, uc_handle, seed)
  960. {//check M203 launched
  961. if ( !is_user_alive(id) || !iUserHoldSwM4[id] )
  962. return
  963. static cmd,type
  964. if ( get_user_weapon(id, cmd, type) != iSwM4WeaponID )
  965. return
  966. if ( (cmd = get_uc(uc_handle, UC_Buttons)) & IN_ATTACK2 )
  967. {
  968. cmd &= ~IN_ATTACK2
  969. set_uc(uc_handle, UC_Buttons, cmd)
  970. if ( bInFreezeTime || !bNadeReloaded[id] )
  971. return
  972. type = iUserNadeCurType[id]
  973. if ( iUserNadeAmount[id][type] < 1 )
  974. {
  975. emit_sound(id, CHAN_WEAPON, sSwNadeSound_UseUp, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  976. return
  977. }
  978. launch_grenade(id, type)
  979. return
  980. }
  981. if ( get_uc(uc_handle, UC_Impulse) == 201 )
  982. {
  983. set_uc(uc_handle, UC_Impulse, 0)
  984. show_menu(id, iMenuKeys, sSwNadeMenuBody, -1, sSwNadeMenuTitle)
  985. }
  986. }
  987.  
  988. public menu_SwGrenade_option(id, iKey)
  989. {
  990. if ( !iUserHoldSwM4[id] || !is_user_alive(id) )
  991. {
  992. client_cmd(id, "slot10")
  993. return PLUGIN_HANDLED
  994. }
  995. new bool:HoldMenu = false
  996. switch ( iKey )
  997. {
  998. case 0:
  999. {
  1000. manage_StatusIcon_hud(id, CLEAR, iUserNadeAmount[id][iUserNadeCurType[id]])
  1001. iUserNadeCurType[id] = TYPE_HENADE
  1002. manage_StatusIcon_hud(id, SHOW, iUserNadeAmount[id][TYPE_HENADE])
  1003. manage_Scenario_hud(id, SHOW)
  1004. }
  1005. case 1:
  1006. {
  1007. manage_StatusIcon_hud(id, CLEAR, iUserNadeAmount[id][iUserNadeCurType[id]])
  1008. iUserNadeCurType[id] = TYPE_GASNADE
  1009. manage_StatusIcon_hud(id, SHOW, iUserNadeAmount[id][TYPE_GASNADE])
  1010. manage_Scenario_hud(id, SHOW)
  1011. }
  1012. case 2:
  1013. {
  1014. engclient_cmd(id, sSwM4WeaponName)
  1015. new iWeaponID = iUserHoldSwM4[id]
  1016. new iSilen = abs(iSwM4SilenStatus[id] - 1)
  1017. cs_set_weapon_silen(iWeaponID, iSilen, 0)
  1018. iSwM4SilenStatus[id] = iSilen
  1019. engclient_cmd(id, "lastinv")
  1020. client_cmd(id, sSwM4WeaponName)
  1021. }
  1022. case 3:
  1023. HoldMenu = bool:check_buy_grenade(id, TYPE_HENADE)
  1024. case 4:
  1025. HoldMenu = bool:check_buy_grenade(id, TYPE_GASNADE)
  1026. default:
  1027. return PLUGIN_HANDLED
  1028. }
  1029. if ( HoldMenu )
  1030. {
  1031. new clip,ammo
  1032. if ( get_user_weapon(id, clip, ammo) == iSwM4WeaponID )
  1033. show_menu(id, iMenuKeys, sSwNadeMenuBody, -1, sSwNadeMenuTitle)
  1034. return PLUGIN_HANDLED
  1035. }
  1036. if ( iKey == 3 || iKey == 4 )//cannot buy
  1037. client_cmd(id, "slot10")
  1038. else if ( iKey != 2 )//just change grenade estate(he|gas)
  1039. emit_sound(id, CHAN_VOICE, sSwNadeSound_Change, VOL_NORM, ATTN_NONE, 0, PITCH_NORM)
  1040. return PLUGIN_HANDLED
  1041. }
  1042.  
  1043. public launch_grenade(id, type)
  1044. {//check grenade amount & launch
  1045. new Float: fOrigin[3], Float:fAngle[3],Float: fVelocity[3]
  1046. pev(id, pev_origin, fOrigin)
  1047. pev(id, pev_view_ofs, fAngle)
  1048. fOrigin[0] += fAngle[0]
  1049. fOrigin[1] += fAngle[1]
  1050. fOrigin[2] += fAngle[2]
  1051. fm_velocity_by_aim(id, 2.0, fVelocity, fAngle)
  1052. fAngle[0] *= -1.0
  1053. //create hurt ent
  1054. new iHurtEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, sNamedEntTriggerHurt))
  1055. if ( iHurtEnt <= MAXPLAYERS )
  1056. return
  1057. fm_set_kvd(iHurtEnt, "dmg", "100.0", sNamedEntTriggerHurt)
  1058. fm_set_kvd(iHurtEnt, "damagetype", "64", sNamedEntTriggerHurt)//in many case, DMG_BULLET cannot break the breakable object at once, so use DMG_BLAST)
  1059. set_pev(iHurtEnt, pev_spawnflags, pev(iHurtEnt, pev_spawnflags) | SF_TRIGGER_HURT_NO_CLIENTS)
  1060. set_pev(iHurtEnt, pev_spawnflags, pev(iHurtEnt, pev_spawnflags) | SF_TRIGGER_HURT_TARGETONCE)
  1061. dllfunc(DLLFunc_Spawn, iHurtEnt)
  1062. //create grenade ent
  1063. new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, sNamedEntInfoTarget))
  1064. if ( ent <= MAXPLAYERS )
  1065. {
  1066. engfunc(EngFunc_RemoveEntity, iHurtEnt)
  1067. return
  1068. }
  1069. set_pev(ent, pev_classname, sSwNadeClassname[type])
  1070. engfunc(EngFunc_SetModel, ent, sSwNadeModel_w)
  1071. set_pev(ent, pev_mins, Float:{-1.0, -1.0, -1.0})
  1072. set_pev(ent, pev_maxs, Float:{1.0, 1.0, 1.0})
  1073. set_pev(ent, pev_origin, fOrigin)
  1074. fOrigin[0] += fVelocity[0]
  1075. fOrigin[1] += fVelocity[1]
  1076. fOrigin[2] += fVelocity[2]
  1077. set_pev(iHurtEnt, pev_origin, fOrigin)
  1078. set_pev(iHurtEnt, pev_movetype, MOVETYPE_TOSS)
  1079. set_pev(ent, pev_movetype, MOVETYPE_BOUNCE)
  1080. set_pev(iHurtEnt, pev_gravity, 0.55)//"0.55" is the gravity param of grenade which throw by player
  1081. set_pev(ent, pev_gravity, 0.55)
  1082. fVelocity[0] *= 1000.0
  1083. fVelocity[1] *= 1000.0
  1084. fVelocity[2] *= 1000.0
  1085. set_pev(iHurtEnt, pev_velocity, fVelocity)
  1086. set_pev(ent, pev_velocity, fVelocity)
  1087. set_pev(ent, pev_owner, id)
  1088. set_pev(ent, pev_angles, fAngle)
  1089. set_pev(ent, pev_solid, SOLID_BBOX)
  1090. set_pev(ent, pev_SwNade_HurtEnt_i, iHurtEnt)//store the enitty id
  1091.  
  1092. emit_sound(id, CHAN_VOICE, sSwNadeSound_Launch, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)//launch sound
  1093.  
  1094. bNadeReloaded[id] = false
  1095. manage_StatusIcon_hud(id, CLEAR, iUserNadeAmount[id][iUserNadeCurType[id]])
  1096. iUserNadeAmount[id][type]--
  1097. manage_StatusIcon_hud(id, SHOW, iUserNadeAmount[id][type])
  1098. remove_task(id)
  1099. set_task(fSwNadeReloadTime, "task_m203_reloaded", id)//fake reload
  1100. //show grenade trail
  1101. message_begin( MSG_BROADCAST, SVC_TEMPENTITY )
  1102. write_byte(TE_BEAMFOLLOW)
  1103. write_short(ent)//entity
  1104. write_short(iSwNadeSprite_Trail)//model
  1105. write_byte(6)//10)//life
  1106. write_byte(3)//5)//width
  1107. write_byte(abs(type-1) * 100)//r, hegrenade
  1108. write_byte(type * 100)//g, gas-grenade
  1109. write_byte(0)//b
  1110. write_byte(100)//brightness
  1111. message_end()//move PHS/PVS data sending into here (SEND_ALL, SEND_PVS, SEND_PHS)
  1112.  
  1113. new message[64]
  1114. if ( iUserNadeAmount[id][type] < 1 )
  1115. {
  1116. switch ( type )
  1117. {
  1118. case TYPE_HENADE:
  1119. {
  1120. message[0] = 0x03
  1121. format(message[1], 62, " *** Kifogyott a 40milime'teres robbano gra'na't ***")
  1122. }
  1123. case TYPE_GASNADE:
  1124. {
  1125. message[0] = 0x04
  1126. format(message[1], 62, " *** kifogyott a 40milime'teres gaz gra'na't ***")
  1127. }
  1128. //case TYPE_INCENDIARY:
  1129. }
  1130. color_saytext(message, MSG_ONE, id, 1)
  1131. return
  1132. }
  1133. format(message, 63, "^x03 M203 tarazas...")
  1134. color_saytext(message, MSG_ONE, id, 3)
  1135. return
  1136. }
  1137.  
  1138. public task_m203_reloaded(id)
  1139. {
  1140. if ( !bNadeReloaded[id] )
  1141. bNadeReloaded[id] = true
  1142. if ( is_user_alive(id) )
  1143. {
  1144. new type = iUserNadeCurType[id]
  1145. manage_StatusIcon_hud(id, CLEAR, iUserNadeAmount[id][type])
  1146. manage_StatusIcon_hud(id, SHOW, iUserNadeAmount[id][type])//reset estate of reloadded
  1147. }
  1148. }
  1149.  
  1150. public forward_touch(ptr, ptd)
  1151. {
  1152. if ( !pev_valid(ptr) )
  1153. return FMRES_IGNORED
  1154.  
  1155. static classname[32]
  1156. pev(ptr, pev_classname, classname, sizeof classname - 1)
  1157. if ( equal(classname, sSwClassname_Prefix, 3) )
  1158. {//"Sw_Grenade_HE" | "Sw_Grenade_GAS" | "Sw_FakeGas" | "Sw_Box_M4withM203"
  1159. new iParam,Float:fVector[3]
  1160. switch ( classname[3] )
  1161. {
  1162. case 'G'://it is grenade launch by m203
  1163. {
  1164. switch ( classname[11] )
  1165. {
  1166. case 'H'://hegrenade
  1167. grenade_explode(ptr, TYPE_HENADE)
  1168. case 'G'://gas-grenade
  1169. {
  1170. pev(ptr, pev_velocity, fVector)
  1171. if ( pev(ptr, pev_SwNade_HurtEnt_i) > MAXPLAYERS )//first time touch
  1172. {
  1173. //engfunc(EngFunc_RemoveEntity, pev(ptr, pev_SwNade_HurtEnt_i))// iParam)
  1174. //set_pev(ptr, pev_SwNade_HurtEnt_i, 0)
  1175. fVector[0] *= 0.01
  1176. fVector[1] *= 0.01
  1177. fVector[2] *= 0.01
  1178. set_pev(ptr, pev_velocity, fVector)
  1179. grenade_explode(ptr, TYPE_GASNADE)
  1180. }
  1181. else
  1182. {
  1183. fVector[0] *= 0.8
  1184. fVector[1] *= 0.8
  1185. fVector[2] *= 0.45
  1186. set_pev(ptr, pev_velocity, fVector)
  1187. }
  1188. return FMRES_SUPERCEDE
  1189. }
  1190. }
  1191. }
  1192. case 'F'://it is "fake gas" entity
  1193. {
  1194. if ( !pev_valid(ptd) || !is_user_alive(ptd) || iUserHasHurtEnt[ptd] > MAXPLAYERS )
  1195. return FMRES_IGNORED
  1196.  
  1197. pev(ptr, pev_origin, fVector)
  1198. //pev(ptr, pev_SwNade_ExploPoint_v, fVector)
  1199. if ( estimate_take_hurt(fVector, ptd, ptr) != 1.0 )
  1200. return FMRES_IGNORED
  1201.  
  1202. iParam = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, sNamedEntTriggerHurt))
  1203. if ( iParam <= MAXPLAYERS )
  1204. return FMRES_IGNORED
  1205. iUserHasHurtEnt[ptd] = iParam
  1206. set_pev(iParam, pev_owner, ptd)
  1207. set_pev(iParam, pev_classname, sSwNadeFakeHurtClassname)
  1208.  
  1209. fm_set_kvd(iParam, "delay", "1.5", sNamedEntTriggerHurt)
  1210. fm_set_kvd(iParam, "dmg", sSwNadeMaxDmg_GAS, sNamedEntTriggerHurt)
  1211. fm_set_kvd(iParam, "damagetype", "65536", sNamedEntTriggerHurt)//damage type DMG_NERVEGAS
  1212. //fm_set_kvd(iParam, "master",
  1213. set_pev(iParam, pev_spawnflags, pev(iParam, pev_spawnflags) | SF_TRIGGER_HURT_CLIENTONLYFIRE)
  1214. set_pev(iParam, pev_spawnflags, pev(iParam, pev_spawnflags) | SF_TRIGGER_HURT_CLIENTONLYTOUCH)
  1215. dllfunc(DLLFunc_Spawn, iParam)
  1216.  
  1217. pev(ptd, pev_origin, fVector)
  1218. set_pev(iParam, pev_origin, fVector)
  1219. set_pev(iParam, pev_aiment, ptd)
  1220. set_pev(iParam, pev_movetype, MOVETYPE_FOLLOW)
  1221. set_pev(iParam, pev_nextthink, fCurrentTime() + 3.0)
  1222. }
  1223. case 'B'://fake superwepaon box
  1224. {
  1225. if ( pev(ptr, pev_SwBox_Param_e) != SW_BOX_PARAM_NOTOUCH && is_user_alive(ptd) && !iUserHoldSwM4[ptd] && !cs_get_user_vip(ptd) && !cs_get_user_hasprim(ptd) )
  1226. {
  1227. iParam = get_user_team(ptd)
  1228. if ( iSwM4CurTeamHolders[iParam] < iSwM4MaxTeamHolders[iParam] )
  1229. {
  1230. if ( give_superweapon(ptd, iParam, ptr) > MAXPLAYERS )
  1231. remove_superweapon_box(ptr)
  1232. }
  1233. else if ( iUserTouchTimes[ptd] < 3 )
  1234. {
  1235. iUserTouchTimes[ptd]++
  1236. color_saytext(sMsgCannotGetSw, MSG_ONE_UNRELIABLE, ptd)
  1237. }
  1238. }
  1239. }
  1240. }
  1241. }
  1242. return FMRES_IGNORED
  1243. }
  1244.  
  1245. public grenade_explode(ptr, type)
  1246. {
  1247. new Float:fPoint[3]
  1248. engfunc(EngFunc_RemoveEntity, pev(ptr, pev_SwNade_HurtEnt_i))
  1249. set_pev(ptr, pev_SwNade_HurtEnt_i, 0)
  1250. if ( type == TYPE_GASNADE )
  1251. {
  1252. pev(ptr, pev_angles, fPoint)
  1253. fPoint[1] += 90.0
  1254. set_pev(ptr, pev_angles, fPoint)
  1255.  
  1256. message_begin(MSG_BROADCAST, SVC_TEMPENTITY, _)
  1257. write_byte(TE_KILLBEAM)
  1258. write_short(ptr)//entity
  1259. message_end()
  1260.  
  1261. if ( task_exists(ptr) )
  1262. remove_task(ptr)
  1263. set_task(1.5, "task_gas_explode", ptr)
  1264. return
  1265. }
  1266. new attacker = pev(ptr, pev_owner)
  1267. new iAttackerTeam = get_user_team(attacker)
  1268. new victim = -1
  1269. new Float:fOrigin[3],Float:fDistance,Float:fDamage,Float:fTakeDamage
  1270. new AttackerName[32],classname[32]
  1271. new iParam,iTeamKill
  1272.  
  1273. pev(ptr, pev_origin, fPoint)
  1274. fPoint[2] += 1.0
  1275. manage_effect_env(EFFECT_EXPLO, fPoint, ptr)
  1276. engfunc(EngFunc_RemoveEntity, ptr)
  1277.  
  1278. get_user_name(attacker, AttackerName, 31)
  1279. while ( ( victim = engfunc(EngFunc_FindEntityInSphere, victim, fPoint, fSwNadeDmgRadius[TYPE_HENADE]) ) > 0 )
  1280. {//check things in damage radius
  1281. if ( !pev_valid(victim) )
  1282. continue
  1283. pev(victim, pev_takedamage, fTakeDamage)
  1284. if ( fTakeDamage == DAMAGE_NO )//godmode?
  1285. continue
  1286. pev(victim, pev_classname, classname, 31)
  1287. iParam = 0
  1288. if ( equal(classname, sPlayer) && is_user_alive(victim) )
  1289. iParam = 1
  1290. else if ( equal(classname, sFuncBreakable) || equal(classname, sFuncPushable) )
  1291. iParam = 2
  1292. else if ( equal(classname, sHostageEntity) || equal(classname, sMonsterScientist) )
  1293. iParam = 3
  1294. if ( !iParam )
  1295. continue//if not right ent, ignored
  1296.  
  1297. pev(victim, pev_origin, fOrigin)
  1298. fDistance = get_distance_f(fOrigin, fPoint)
  1299. fDamage = fSwNadeMaxDmg_HE - floatmul(fSwNadeMaxDmg_HE, floatdiv(fDistance, fSwNadeDmgRadius[TYPE_HENADE]))//get the damage value
  1300. fDamage *= estimate_take_hurt(fPoint, victim, 0)//adjust
  1301. if ( fDamage < 0 && iParam != 2 )
  1302. continue
  1303. switch ( iParam )
  1304. {
  1305. case 1://player
  1306. {
  1307. //if ( is_user_alive(victim) )
  1308. //{
  1309. manage_effect_action(victim, fOrigin, fPoint, fDistance, fDamage * 8.0)
  1310. iTeamKill = check_team_kill(attacker, victim, iAttackerTeam)
  1311. if ( iTeamKill != 3 )
  1312. {
  1313. manage_effect_env(EFFECT_BLOOD, fOrigin, victim)//make bloody effect
  1314. manage_player_damage(attacker, victim, iTeamKill, fDamage, AttackerName)
  1315. }
  1316. //}
  1317. }
  1318. case 2://breakable|pushable ent
  1319. {
  1320. if( fDamage <= 0 )
  1321. fDamage = floatdiv(fSwNadeMaxDmg_HE, 2.0)
  1322. fm_fakedamage(victim, "grenade", fDamage, DMG_BLAST)
  1323. }
  1324. case 3://hostage
  1325. {
  1326. manage_effect_action(victim, fOrigin, fPoint, fDistance, fDamage * 8.0)
  1327. client_print(0, print_chat, "%s eltalaltad a tuszokat!.", AttackerName)
  1328. fm_fakedamage(victim, "grenade", fDamage, DMG_BLAST)//64)
  1329. }
  1330. }
  1331. }
  1332. return
  1333. }
  1334.  
  1335. public task_gas_explode(ent)
  1336. {
  1337. if ( !pev_valid(ent) )
  1338. return
  1339.  
  1340. new Float:fExplodePoint[3],iOrigin[3],iParam
  1341. pev(ent, pev_origin, fExplodePoint)
  1342. fExplodePoint[2] += 1.0
  1343. engfunc(EngFunc_RemoveEntity, ent)
  1344.  
  1345. iOrigin[0] = floatround(fExplodePoint[0])
  1346. iOrigin[1] = floatround(fExplodePoint[1])
  1347. iOrigin[2] = floatround(fExplodePoint[2])
  1348. /*
  1349. TE_EXPLOSION 3 // Additive sprite, 2 dynamic lights, flickering particles, explosion sound, move vertically 8 pps
  1350. The Explosion effect has some flags to control performance/aesthetic features:
  1351. TE_EXPLFLAG_NONE 0 // All flags clear makes default Half-Life explosion
  1352. TE_EXPLFLAG_NOADDITIVE 1 // Sprite will be drawn opaque (ensure that the sprite you send is a non-additive sprite)
  1353. TE_EXPLFLAG_NODLIGHTS 2 // Do not render dynamic lights
  1354. TE_EXPLFLAG_NOSOUND 4 // Do not play client explosion sound
  1355. TE_EXPLFLAG_NOPARTICLES 8 // Do not draw particles
  1356. */
  1357. message_begin(MSG_BROADCAST, SVC_TEMPENTITY, iOrigin)
  1358. write_byte(TE_EXPLOSION)
  1359. write_coord(iOrigin[0])//position.x)
  1360. write_coord(iOrigin[1])//position.y)
  1361. write_coord(iOrigin[2])//position.z)
  1362. write_short(iSwNadeSprite_GasExplode)//sprite index)
  1363. write_byte(10)//scale in 0.1's)
  1364. write_byte(0)//framerate)
  1365. write_byte(4)//flags)
  1366. message_end()
  1367.  
  1368. iParam = engfunc(EngFunc_PointContents, fExplodePoint)
  1369. if ( iParam == CONTENTS_WATER || iParam == CONTENTS_LAVA )
  1370. return
  1371. new Float:fParam,Float:fMins[3],Float:fMaxs[3],iFakeGas
  1372. emit_sound(0, CHAN_VOICE, sSwNadeSound_GasExplode, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  1373. fParam = fSwNadeDmgRadius[TYPE_GASNADE]
  1374. iParam = floatround(fParam)
  1375. /*
  1376. to keep network traffic low, this message has associated flags that fit into a byte:
  1377. TEFIRE_FLAG_ALLFLOAT 1 // All sprites will drift upwards as they animate
  1378. TEFIRE_FLAG_SOMEFLOAT 2 // Some of the sprites will drift upwards. (50% chance)
  1379. TEFIRE_FLAG_LOOP 4 // If set, sprite plays at 15 fps, otherwise plays at whatever rate stretches the animation over the sprite's duration.
  1380. TEFIRE_FLAG_ALPHA 8 // If set, sprite is rendered alpha blended at 50% else, opaque
  1381. TEFIRE_FLAG_PLANAR 16 // If set, all fire sprites have same initial Z instead of randomly filling a cube.
  1382. */
  1383. message_begin(MSG_BROADCAST, SVC_TEMPENTITY, iOrigin)
  1384. write_byte(TE_FIREFIELD)
  1385. write_coord(iOrigin[0])
  1386. write_coord(iOrigin[1])
  1387. write_coord(iOrigin[2])
  1388. write_short(iParam)//radius) (fire is made in a square around origin. -radius, -radius to radius, radius)
  1389. write_short(iSwNadeSprite_GasFog)//modelindex)
  1390. write_byte(10)//count)
  1391. write_byte(24)//flags)
  1392. write_byte(150)//duration (in seconds) * 10) (will be randomized a bit)
  1393. message_end()
  1394.  
  1395. fMaxs[0] = fParam
  1396. fMaxs[1] = fParam
  1397. fMaxs[2] = 30.0
  1398.  
  1399. fMins[0] = fMaxs[0] * -1.0
  1400. fMins[1] = fMaxs[1] * -1.0
  1401. fMins[2] = fMaxs[2] * -1.0
  1402.  
  1403. iFakeGas = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, sNamedEntInfoTarget))//sNamedEntTriggerHurt))//sNamedEntInfoTarget))
  1404. if ( iFakeGas <= MAXPLAYERS )
  1405. return
  1406. set_pev(iFakeGas, pev_classname, sSwNadeFakeGasClassname)
  1407. engfunc(EngFunc_SetModel, iFakeGas, sSwNadeModel_w)
  1408. set_pev(iFakeGas, pev_mins, fMins)
  1409. set_pev(iFakeGas, pev_maxs, fMaxs)
  1410. set_pev(iFakeGas, pev_effects, EF_NODRAW)
  1411. set_pev(iFakeGas, pev_solid, SOLID_TRIGGER)
  1412. set_pev(iFakeGas, pev_movetype, MOVETYPE_FLY)
  1413. //set_pev(iFakeGas, pev_SwNade_ExploPoint_v, fExplodePoint)//store explode origin
  1414. set_pev(iFakeGas, pev_origin, fExplodePoint)
  1415. set_pev(iFakeGas, pev_nextthink, fCurrentTime() + 15.0)
  1416. }
  1417.  
  1418. /*
  1419. waterlevel 0 - not in water
  1420. waterlevel 1 - feet in water
  1421. waterlevel 2 - waist in water
  1422. waterlevel 3 - head in water
  1423.  
  1424. EngFunc_TraceLine,// void ) (const float *v1, const float *v2, int fNoMonsters, edict_t *pentToSkip, TraceResult *ptr);
  1425.  
  1426. dont_ignore_monsters = 0
  1427. ignore_monsters = 1
  1428. missile = 2
  1429.  
  1430. Returned by TraceLine
  1431. typedef struct
  1432. {
  1433. int fAllSolid; // if true, plane is not valid
  1434. int fStartSolid; // if true, the initial point was in a solid area
  1435. int fInOpen;
  1436. int fInWater;
  1437. float flFraction; // time completed, 1.0 = didn't hit anything
  1438. vec3_t vecEndPos; // final position
  1439. float flPlaneDist;
  1440. vec3_t vecPlaneNormal; // surface normal at impact
  1441. edict_t *pHit; // entity the surface is on
  1442. int iHitgroup; // 0 == generic, non zero is specific body part
  1443. } TraceResult;
  1444.  
  1445. from : combat.cpp
  1446.  
  1447. //
  1448. // RadiusDamage - this entity is exploding, or otherwise needs to inflict damage upon entities within a certain range.
  1449. //
  1450. // only damage ents that can clearly be seen by the explosion!
  1451.  
  1452.  
  1453. void RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, float flRadius, int iClassIgnore, int bitsDamageType )
  1454. {
  1455. CBaseEntity *pEntity = NULL;
  1456. TraceResult tr;
  1457. float flAdjustedDamage, falloff;
  1458. Vector vecSpot;
  1459.  
  1460. if ( flRadius )
  1461. falloff = flDamage / flRadius;
  1462. else
  1463. falloff = 1.0;
  1464.  
  1465. int bInWater = (UTIL_PointContents ( vecSrc ) == CONTENTS_WATER);
  1466.  
  1467. vecSrc.z += 1;// in case grenade is lying on the ground
  1468.  
  1469. if ( !pevAttacker )
  1470. pevAttacker = pevInflictor;
  1471.  
  1472. // iterate on all entities in the vicinity.
  1473. while ((pEntity = UTIL_FindEntityInSphere( pEntity, vecSrc, flRadius )) != NULL)
  1474. {
  1475. if ( pEntity->pev->takedamage != DAMAGE_NO )
  1476. {
  1477. // UNDONE: this should check a damage mask, not an ignore
  1478. if ( iClassIgnore != CLASS_NONE && pEntity->Classify() == iClassIgnore )
  1479. {// houndeyes don't hurt other houndeyes with their attack
  1480. continue;
  1481. }
  1482.  
  1483. // blast's don't tavel into or out of water
  1484. if (bInWater && pEntity->pev->waterlevel == 0)
  1485. continue;
  1486. if (!bInWater && pEntity->pev->waterlevel == 3)
  1487. continue;
  1488.  
  1489. vecSpot = pEntity->BodyTarget( vecSrc );
  1490.  
  1491. UTIL_TraceLine ( vecSrc, vecSpot, dont_ignore_monsters, ENT(pevInflictor), &tr );
  1492.  
  1493. if ( tr.flFraction == 1.0 || tr.pHit == pEntity->edict() )
  1494. {// the explosion can 'see' this entity, so hurt them!
  1495. if (tr.fStartSolid)
  1496. {
  1497. // if we're stuck inside them, fixup the position and distance
  1498. tr.vecEndPos = vecSrc;
  1499. tr.flFraction = 0.0;
  1500. }
  1501.  
  1502. // decrease damage for an ent that's farther from the bomb.
  1503. flAdjustedDamage = ( vecSrc - tr.vecEndPos ).Length() * falloff;
  1504. flAdjustedDamage = flDamage - flAdjustedDamage;
  1505.  
  1506. if ( flAdjustedDamage < 0 )
  1507. {
  1508. flAdjustedDamage = 0;
  1509. }
  1510.  
  1511. // ALERT( at_console, "hit %s\n", STRING( pEntity->pev->classname ) );
  1512. if (tr.flFraction != 1.0)
  1513. {
  1514. ClearMultiDamage( );
  1515. pEntity->TraceAttack( pevInflictor, flAdjustedDamage, (tr.vecEndPos - vecSrc).Normalize( ), &tr, bitsDamageType );
  1516. ApplyMultiDamage( pevInflictor, pevAttacker );
  1517. }
  1518. else
  1519. {
  1520. pEntity->TakeDamage ( pevInflictor, pevAttacker, flAdjustedDamage, bitsDamageType );
  1521. }
  1522. }
  1523. }
  1524. }
  1525. }
  1526. */
  1527.  
  1528. ////////////////// stock ///////////////////////////
  1529.  
  1530. stock get_InfoEnt_origin()
  1531. {
  1532. new num =0,ent = -1
  1533. while ( (ent = engfunc(EngFunc_FindEntityByString, ent, sClassname, sInfoPlayerStart)) > 0 )
  1534. {
  1535. pev(ent, pev_origin, fInfoEntOrigin[num])
  1536. num++
  1537. if ( num >= floatround(float(MAXNUM) * 0.5) )
  1538. break
  1539. }
  1540. ent = -1
  1541. while ( (ent = engfunc(EngFunc_FindEntityByString, ent, sClassname, sInfoPlayerDeathmatch)) > 0 )
  1542. {
  1543. pev(ent, pev_origin, fInfoEntOrigin[num])
  1544. num++
  1545. if ( num >= MAXNUM )
  1546. break
  1547. }
  1548. return num
  1549. }
  1550.  
  1551. stock spawn_GhostEnt(iSpawnAmount)
  1552. {//for get "superweapon box"'s spawn ponit
  1553. new num,ent,Float:velocity[3]//,Float:origin[3]
  1554. while ( (ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, sNamedEntInfoTarget))) > MAXPLAYERS )
  1555. {
  1556. set_pev(ent, pev_classname, sGhostEntClassname)
  1557. set_pev(ent, pev_origin, fInfoEntOrigin[random(iInfoEntAmount)])
  1558. set_pev(ent, pev_solid, SOLID_TRIGGER)
  1559. set_pev(ent, pev_movetype, MOVETYPE_BOUNCE)
  1560. set_pev(ent, pev_mins, Float:{-16.0,-16.0,-16.0})
  1561. set_pev(ent, pev_maxs, Float:{16.0,16.0,16.0})
  1562.  
  1563. velocity[0] = float( (2500 + random(501)) * (!random(2)?- 1:1) )
  1564. velocity[1] = float( (2500 + random(501)) * (!random(2)? -1:1) )
  1565. velocity[2] = float( (2500 + random(501)) * (!random(2)? -1:1) )
  1566.  
  1567. set_pev(ent, pev_velocity, velocity)
  1568. iGhostEntID[num] = ent
  1569. num++
  1570. if ( num >= iInfoEntAmount )
  1571. break
  1572. }
  1573.  
  1574. if ( task_exists(iTaskSpanwSwBox) )
  1575. remove_task(iTaskSpanwSwBox)
  1576. new param[1]
  1577. param[0] = iSpawnAmount
  1578. set_task(3.5, "task_spawn_SwBox", iTaskSpanwSwBox, param, 1)
  1579.  
  1580. return 0
  1581. }
  1582.  
  1583. stock bool:remove_GhostEnt()
  1584. {
  1585. new ent = -1
  1586. while ( (ent = engfunc(EngFunc_FindEntityByString, ent, sClassname, sGhostEntClassname)) > MAXPLAYERS )
  1587. engfunc(EngFunc_RemoveEntity, ent)
  1588. return true
  1589. }
  1590.  
  1591. stock get_cvar_param()
  1592. {
  1593. new iTeam,i
  1594.  
  1595. iSwM4Price = get_pcvar_num(cvar_SwM4Price_num)
  1596. iSwM4StripMode = get_pcvar_num(cvar_SwM4StripMode_num)
  1597.  
  1598. iSwM4MaxAmount = (iSwM4MaxTeamHolders[TE] = get_pcvar_num(cvar_SwMaxHolders_TE_num)) + (iSwM4MaxTeamHolders[CT] = get_pcvar_num(cvar_SwMaxHolders_CT_num))
  1599.  
  1600. bSwNadeTK = bool:get_pcvar_num(cvar_SwNadeTeamKill_num)
  1601. fSwNadeReloadTime = get_pcvar_float(cvar_SwNadeReloadTime_flo)
  1602.  
  1603. fSwNadeMaxDmg_HE = float(get_pcvar_num(cvar_SwNadeMaxDmg_HE_num)*2)
  1604. fSwNadeDmgRadius[TYPE_HENADE] = float(get_pcvar_num(cvar_SwNadeDmgRadius_HE_num))
  1605. iSwNadeMaxCarried[TYPE_HENADE] = get_pcvar_num(cvar_SwNadeMaxCarried_HE_num)
  1606. iSwNadePrice[TYPE_HENADE] = get_pcvar_num(cvar_SwNadePrice_HE_num)
  1607.  
  1608. num_to_str(floatround(float(get_pcvar_num(cvar_SwNadeMaxDmg_GAS_num)) / 7.0), sSwNadeMaxDmg_GAS, sizeof sSwNadeMaxDmg_GAS - 1)
  1609. fSwNadeDmgRadius[TYPE_GASNADE] = float(get_pcvar_num(cvar_SwNadeDmgRadius_GAS_num))
  1610. iSwNadeMaxCarried[TYPE_GASNADE] = get_pcvar_num(cvar_SwNadeMaxCarried_GAS_num)
  1611. iSwNadePrice[TYPE_GASNADE] = get_pcvar_num(cvar_SwNadePrice_GAS_num)
  1612.  
  1613. bInBuyTime = true
  1614. bInFreezeTime = true
  1615.  
  1616. if ( task_exists(iTaskBuyTimeOver) )
  1617. remove_task(iTaskBuyTimeOver)
  1618. set_task((get_cvar_float("mp_buytime") * 60.0), "task_buy_time_over",iTaskBuyTimeOver)
  1619.  
  1620.  
  1621. iSwM4CurTeamHolders[TE] = 0
  1622. iSwM4CurTeamHolders[CT] = 0
  1623.  
  1624. for ( i=1; i<=MAXPLAYERS; i++ )
  1625. {
  1626. if ( !iUserHoldSwM4[i] )
  1627. continue
  1628. if ( !is_user_alive(i) )
  1629. {
  1630. iUserHoldSwM4[i] = 0
  1631. continue
  1632. }
  1633. iTeam = get_user_team(i)
  1634. if ( iSwM4CurTeamHolders[iTeam] >= iSwM4MaxTeamHolders[iTeam] || !(pev(i, pev_weapons) & (1<<iSwM4WeaponID)) )
  1635. {
  1636. iUserHoldSwM4[i] = 0
  1637. continue
  1638. }
  1639. iSwM4CurTeamHolders[iTeam]++
  1640. }
  1641. return (iSwM4MaxAmount - iSwM4CurTeamHolders[TE] - iSwM4CurTeamHolders[CT])
  1642. }
  1643.  
  1644. stock create_effect_entity()
  1645. {
  1646. new iEnt = -1
  1647. while ( (iEnt = engfunc(EngFunc_FindEntityByString, iEnt, sClassname, sSwEffectClassname)) > MAXPLAYERS )
  1648. engfunc(EngFunc_RemoveEntity, iEnt)
  1649. //explosion
  1650. iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, sNamedEntEnvExplosion))
  1651. if ( iEnt <= MAXPLAYERS )
  1652. create_effect_entity()
  1653. fm_set_kvd(iEnt, "iMagnitude", "100", sNamedEntEnvExplosion)//flSpriteScale = ( m_iMagnitude - 50) * 0.6;
  1654. set_pev(iEnt, pev_spawnflags, pev(iEnt, pev_spawnflags) | SF_ENVEXPLOSION_NODAMAGE)
  1655. set_pev(iEnt, pev_spawnflags, pev(iEnt, pev_spawnflags) | SF_ENVEXPLOSION_REPEATABLE)
  1656. dllfunc(DLLFunc_Spawn, iEnt)
  1657. set_pev(iEnt, pev_classname, sSwEffectClassname)
  1658. set_pev(iEnt, pev_origin, {8192,8192,8192})
  1659. iSwEffectID[EFFECT_EXPLO] = iEnt
  1660. //blood
  1661. iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, sNamedEntEnvBlood))
  1662. if ( iEnt <= MAXPLAYERS )
  1663. create_effect_entity()
  1664. fm_set_kvd(iEnt, "color", "2", sNamedEntEnvBlood)//black/white = 0, yellow = 1, red = 2
  1665. fm_set_kvd(iEnt, "amount", "100", sNamedEntEnvBlood)
  1666. set_pev(iEnt, pev_spawnflags, pev(iEnt, pev_spawnflags) | SF_BLOOD_RANDOM)
  1667. set_pev(iEnt, pev_spawnflags, pev(iEnt, pev_spawnflags) | SF_BLOOD_DECAL)
  1668. dllfunc(DLLFunc_Spawn, iEnt)
  1669. set_pev(iEnt, pev_classname, sSwEffectClassname)
  1670. set_pev(iEnt, pev_origin, {8192,8192,8192})
  1671. iSwEffectID[EFFECT_BLOOD] = iEnt
  1672. return 1
  1673. }
  1674.  
  1675. stock check_buy_grenade(id, type)
  1676. {
  1677. new message[64]
  1678. if ( !bInBuyTime )
  1679. {
  1680. color_saytext(sMsgNotInBuyTime, MSG_ONE, id, 4)
  1681. return 0
  1682. }
  1683. if ( !bInBuyzone[id] )
  1684. {
  1685. color_saytext(sMsgNotInBuyzone, MSG_ONE, id)
  1686. return 0
  1687. }
  1688. if( cs_get_user_money(id) < iSwNadePrice[type] )
  1689. {
  1690. switch ( type )
  1691. {
  1692. case TYPE_HENADE:
  1693. format(message, 63, "^x01 Nincs ele'g pe'nzed,^x03 robbano gra'na'tra^x01 $%d-ba kerul", iSwNadePrice[TYPE_HENADE])
  1694. case TYPE_GASNADE:
  1695. format(message, 63, "^x01 Nincs ele'g pe'nzed,^x04 ga'z gra'na'tra^x01 $%d-ba kerul", iSwNadePrice[TYPE_GASNADE])
  1696. }
  1697. color_saytext(message, MSG_ONE, id, 1)
  1698. return 0
  1699. }
  1700. if ( iUserNadeAmount[id][type] >= iSwNadeMaxCarried[type] )
  1701. {
  1702. switch ( type )
  1703. {
  1704. case TYPE_HENADE:
  1705. format(message, 63, "^x01 Ele'rted a korla'tot^x03 nem vehetsz %d-ne'l tobb gra'na'tot", iSwNadeMaxCarried[TYPE_HENADE])
  1706. case TYPE_GASNADE:
  1707. format(message, 63, "^x01 Ele'rted a korla'tot^x03 nem vehetsz %d-ne'l tobb ga'z gra'na'tot", iSwNadeMaxCarried[TYPE_GASNADE])
  1708. }
  1709. color_saytext(message, MSG_ONE, id, 1)
  1710. return 0
  1711. }
  1712. emit_sound(id, CHAN_VOICE, sSwNadeSound_Buy, VOL_NORM, ATTN_NONE, 0, PITCH_NORM)
  1713. manage_StatusIcon_hud(id, CLEAR, iUserNadeAmount[id][iUserNadeCurType[id]])
  1714. iUserNadeAmount[id][type]++
  1715. iUserNadeCurType[id] = type
  1716. manage_StatusIcon_hud(id, SHOW, iUserNadeAmount[id][type])//show number of grenade on left middle screen
  1717. manage_ItemPickup_hud(id, type)//show fake ammo icon on right screen
  1718. manage_Scenario_hud(id, SHOW)
  1719. return cs_set_user_money(id, cs_get_user_money(id) - iSwNadePrice[type], 1)//set player's money
  1720. }
  1721.  
  1722. stock manage_effect_env(iEffect, Float:fOrigin[3], iUserEnt)
  1723. {
  1724. if ( !iUserEnt )
  1725. return 0
  1726. new param = iSwEffectID[iEffect]
  1727. if ( param <= MAXPLAYERS )
  1728. {
  1729. create_effect_entity()
  1730. manage_effect_env(iEffect, fOrigin, iUserEnt)
  1731. }
  1732. set_pev(param, pev_origin, fOrigin)
  1733. dllfunc(DLLFunc_Use, param, iUserEnt)
  1734. set_pev(param, pev_origin, {8192.0,8192.0,8192.0})
  1735. return 1
  1736. }
  1737.  
  1738. stock manage_effect_action(iEnt, Float:fEntOrigin[3], Float:fPoint[3], Float:fDistance, Float:fDamage)
  1739. {
  1740. new Float:fTime = floatdiv(fDistance, fDamage)
  1741. new Float:fVelocity[3]
  1742. fVelocity[0] = floatdiv((fEntOrigin[0] - fPoint[0]), fTime)
  1743. fVelocity[1] = floatdiv((fEntOrigin[1] - fPoint[1]), fTime)
  1744. fVelocity[2] = floatdiv((fEntOrigin[2] - fPoint[2]), fTime)
  1745. set_pev(iEnt, pev_velocity, fVelocity)
  1746. return 1
  1747. }
  1748.  
  1749. stock Float:estimate_take_hurt(Float:fPoint[3], ent, ignored)
  1750. {
  1751. new Float:fOrigin[3]
  1752. new tr
  1753. new Float:fFraction
  1754. pev(ent, pev_origin, fOrigin)
  1755. //UTIL_TraceLine ( vecSpot, vecSpot + Vector ( 0, 0, -40 ), ignore_monsters, ENT(pev), & tr)
  1756. engfunc(EngFunc_TraceLine, fPoint, fOrigin, DONT_IGNORE_MONSTERS, ignored, tr)
  1757. get_tr2(tr, TR_flFraction, fFraction)
  1758. if ( fFraction == 1.0 || get_tr2( tr, TR_pHit ) == ent )//no valid enity between the explode point & player
  1759. return 1.0
  1760. return 0.6//if has fraise, lessen blast hurt
  1761. }
  1762.  
  1763. stock Float:fCurrentTime()
  1764. {
  1765. new Float:fTime
  1766. global_get(glb_time, fTime)
  1767. return fTime
  1768. }
  1769.  
  1770. stock remove_HurtEnt(id)
  1771. {
  1772. new ent = iUserHasHurtEnt[id]
  1773. iUserHasHurtEnt[id] = 0
  1774. if ( !pev_valid(ent) )
  1775. return 0
  1776. new classname[16]
  1777. pev(ent, pev_classname, classname, sizeof classname - 1 )
  1778. if ( equal(classname, sSwNadeFakeHurtClassname) )
  1779. engfunc(EngFunc_RemoveEntity, ent)
  1780. return 1
  1781. }
  1782.  
  1783. stock emake_deathmsg(killer, victim, headshot, weapon[])
  1784. {//Thanks VEN & dutchmeat !
  1785. emessage_begin(MSG_ALL,iDeathMsgID,{0,0,0},0)
  1786. ewrite_byte(killer)
  1787. ewrite_byte(victim)
  1788.  
  1789. ewrite_byte(headshot)
  1790. /*
  1791. new mod_name[32]
  1792. get_modname(mod_name,31)
  1793. if ( equal(mod_name,"cstrike") || equal(mod_name,"czero") || equal(mod_name,"csv15") || equal(mod_name,"cs13") )
  1794. ewrite_byte(headshot)
  1795. */
  1796.  
  1797. ewrite_string(weapon)
  1798. emessage_end()
  1799. return 1
  1800. }
  1801.  
  1802. stock reset_superweapon(id)
  1803. {
  1804. set_pev(id, pev_viewmodel2, sSwM4Model_v)
  1805. set_pev(id, pev_weaponmodel2, sSwM4Model_p)
  1806. iSwM4BpAmmo[id] = cs_get_user_bpammo(id, iSwM4WeaponID)
  1807. return 1
  1808. }
  1809.  
  1810. stock reset_player(id, count = 0, iTeam = 0)
  1811. {
  1812. new type = iUserNadeCurType[id]
  1813. manage_StatusIcon_hud(id, CLEAR, iUserNadeAmount[id][type])
  1814. manage_Scenario_hud(id, CLEAR)
  1815. iUserHoldSwM4[id] = 0
  1816. iUserNadeAmount[id][TYPE_HENADE] = 0
  1817. iUserNadeAmount[id][TYPE_GASNADE] = 0
  1818. iUserTouchTimes[id] = 0
  1819. if ( !iTeam )
  1820. iTeam = get_user_team(id)
  1821. if ( count == COUNT && ( iTeam == TE || iTeam == CT ) )
  1822. iSwM4CurTeamHolders[iTeam]--
  1823. new iMenuID,iKeys
  1824. get_user_menu(id, iMenuID, iKeys)
  1825. if ( iMenuID == iSwNadeMenuID )
  1826. client_cmd(id, "slot10")
  1827. return iTeam
  1828. }
  1829.  
  1830. stock remove_superweapon_box(ent)
  1831. {
  1832. if ( ent <= MAXPLAYERS )
  1833. return 0
  1834. new iSpriteEnt = pev(ent, pev_SwBox_Param_e)
  1835. if ( iSpriteEnt > MAXPLAYERS )
  1836. engfunc(EngFunc_RemoveEntity, iSpriteEnt)
  1837. engfunc(EngFunc_RemoveEntity, ent)
  1838. return 1
  1839. }
  1840.  
  1841. stock give_superweapon(id, iTeam, ptr = 0)
  1842. {
  1843. if ( !iTeam || iTeam == SPECTATOR )
  1844. return 0
  1845. new ent = fm_give_item(id, sSwM4WeaponName)
  1846. if ( ent <= MAXPLAYERS )
  1847. return 0
  1848. if ( ptr > MAXPLAYERS )
  1849. {//by "pickup"
  1850. new bpammo = clamp((cs_get_user_bpammo(id, iSwM4WeaponID) + pev(ptr, pev_SwBox_BpAmmo_e)), 0, 90)
  1851. new iSilen = pev(ptr, pev_SwBox_Silen_e)
  1852. iUserNadeAmount[id][TYPE_HENADE] = pev(ptr, pev_SwBox_HeAmount_i)
  1853. iUserNadeAmount[id][TYPE_GASNADE] = pev(ptr, pev_SwBox_GasAmount_i)
  1854. iSwM4SilenStatus[id] = iSilen
  1855. cs_set_weapon_silen(ent, iSilen, 0)
  1856. cs_set_weapon_ammo(ent, pev(ptr, pev_SwBox_ClipAmmo_e))
  1857. cs_set_user_bpammo(id, iSwM4WeaponID, bpammo)
  1858. }
  1859. else
  1860. {//by admin command or buy
  1861. iUserNadeAmount[id][TYPE_HENADE] = iSwNadeMaxCarried[TYPE_HENADE]
  1862. iUserNadeAmount[id][TYPE_GASNADE] = iSwNadeMaxCarried[TYPE_GASNADE]
  1863. cs_set_user_bpammo(id, iSwM4WeaponID, 90)
  1864. }
  1865. iSwM4CurTeamHolders[iTeam]++
  1866. iUserHoldSwM4[id] = ent
  1867. //bNadeReloaded[id] = true
  1868. iUserNadeCurType[id] = TYPE_HENADE
  1869. manage_StatusIcon_hud(id, SHOW, iUserNadeAmount[id][TYPE_HENADE])
  1870. manage_Scenario_hud(id, SHOW)
  1871. engclient_cmd(id, "lastinv")
  1872. client_cmd(id, sSwM4WeaponName)
  1873. return ent
  1874. }
  1875.  
  1876. stock manage_StatusIcon_hud(id, act, amount)
  1877. {//grenade number on the player's left middle screen
  1878. if ( !is_user_connected(id) )//|| !is_user_alive(id) )
  1879. return 0
  1880. new icon[16]
  1881. new type = iUserNadeCurType[id]
  1882. //new IconStatus = act
  1883. new green = amount > 0?160:0
  1884. if ( act == SHOW )
  1885. {
  1886. if ( !iUserHoldSwM4[id] || !is_user_alive(id) )
  1887. act = CLEAR
  1888. else
  1889. act = !bNadeReloaded[id] && amount?2:1//flash or not
  1890. }
  1891. amount >= NOT_SHOW_NUM?format(icon, 15, sNadeStateString[type]):format(icon, 15, "number_%d", amount)
  1892. message_begin(MSG_ONE, iStatusIconMsgID, _, id)
  1893. write_byte(act)// status
  1894. write_string(icon)// sprite name
  1895. write_byte(abs(green - 160))// red
  1896. write_byte(green)// green
  1897. write_byte(0)// blue
  1898. return message_end()
  1899. }
  1900.  
  1901. stock manage_ItemPickup_hud(id,type)
  1902. {
  1903. if ( !is_user_connected(id) && !is_user_alive(id) )
  1904. return 0
  1905. //show fake hegrenade|gas-grenade ammo, on right screen
  1906. message_begin(MSG_ONE, iItemPickupMsgID, _, id)
  1907. write_string(sNadeStateString[type])
  1908. return message_end()
  1909. }
  1910.  
  1911. stock manage_Scenario_hud(id, act)
  1912. {//show current grenade state on down screen front of "money" icon
  1913. if ( !is_user_connected(id) && !is_user_alive(id) )
  1914. return 0
  1915.  
  1916. if ( act == CLEAR )
  1917. {
  1918. message_begin(MSG_ONE, iScenarioMsgID, _, id)
  1919. write_byte(0)// Active
  1920. return message_end()
  1921. }
  1922. new type = iUserNadeCurType[id]
  1923. message_begin(MSG_ONE, iScenarioMsgID, _, id)
  1924. write_byte(1)// Active
  1925. write_string(sNadeStateString[type])// Sprite
  1926. write_byte(100)// Alpha
  1927. write_short(0)// FlashRate
  1928. write_short(0)// Unknown
  1929. return message_end()
  1930. }
  1931.  
  1932. stock check_team_kill(attacker, victim, iAttackerTeam)
  1933. {
  1934. if ( attacker == victim )
  1935. return HURT_SELF
  1936. if ( iAttackerTeam == get_user_team(victim) )
  1937. {
  1938. if ( bSwNadeTK )//force TK?
  1939. return HURT_TEAMMATE
  1940. return iServerTK//by server TK rule
  1941. }
  1942. return HURT_ENEMY
  1943. }
  1944.  
  1945.  
  1946. stock manage_player_damage(attacker, victim, iTeamKill, Float:damage, AttackerName[])
  1947. {
  1948. fm_fakedamage(victim, "grenade", damage, DMG_BLAST)//64
  1949. if ( iTeamKill == HURT_TEAMMATE )
  1950. client_print(0,print_chat,"%s attacked a teammate",AttackerName)
  1951. if( is_user_alive(victim) )
  1952. return 0
  1953. emake_deathmsg(attacker, victim, 0, "grenade")//make death message
  1954. if ( !is_user_connected(attacker) )
  1955. return 0
  1956. switch ( iTeamKill )
  1957. {
  1958. case HURT_ENEMY:
  1959. {
  1960. set_pev(attacker, pev_frags, pev(attacker, pev_frags) + 1.0)
  1961. cs_set_user_money(attacker, cs_get_user_money(attacker)+300, 1)
  1962. }
  1963. case HURT_TEAMMATE:
  1964. {
  1965. set_pev(attacker, pev_frags, pev(attacker, pev_frags) - 1.0)
  1966. cs_set_user_money(attacker, cs_get_user_money(attacker)-3300, 1)
  1967. }
  1968. default:{}// return 0
  1969. }
  1970. return 1
  1971. }
  1972.  
  1973. ////////////////////////////// color_saytext ////////////////////////////////////////////
  1974. /*
  1975. color_by_team = 1 use TE's team-color(red)
  1976. color_by_team = 2 use CT's team-color(blue)
  1977. color_by_team = 3 use SPEC's team-color(gray)
  1978. color_by_team = 4 use everyone's team-color(TE use red, CT use blue, SPECTATOR use gray)
  1979. */
  1980. stock color_saytext(message[], dest, id = 0, color_by_team = 0 )
  1981. {
  1982. if ( (dest == MSG_ONE || dest == MSG_ONE_UNRELIABLE ) && !id )
  1983. return 0
  1984. new pList[32],pNum,i,color
  1985. if ( color_by_team > 3 )//by current definiens, affirm MSG_ALL
  1986. {
  1987. get_players(pList, pNum)
  1988. for ( i=0; i<pNum; i++ )
  1989. {
  1990. color = pList[i]
  1991. message_begin(MSG_ONE, iSayTextMsgID, {0,0,0}, color)
  1992. write_byte(color)
  1993. write_string(message)
  1994. message_end()
  1995. }
  1996. return 1
  1997. }
  1998. if ( color_by_team && color_by_team < 3 )//if use te or ct's team-color
  1999. {
  2000. new iParam
  2001. get_players(pList, pNum)
  2002. for ( i=0; i<pNum; i++ )
  2003. {
  2004. iParam = pList[i]
  2005. if ( get_user_team(iParam) == color_by_team )
  2006. {
  2007. color = iParam
  2008. break
  2009. }
  2010. }
  2011. }
  2012. if ( !color )//if cannot find any player by team or not const id, use gray color
  2013. color = (color_by_team == 3 || !id )?33:id
  2014. message_begin(dest, iSayTextMsgID, {0,0,0}, (dest == MSG_ONE || dest == MSG_ONE_UNRELIABLE)?id: 0)
  2015. write_byte(color)
  2016. write_string(message)
  2017. return message_end()
  2018. }
  2019.  
  2020. /////////////////// VEN's Fakemeta Utilities,thanks ////////////////////////////////////
  2021.  
  2022. stock fm_velocity_by_aim(iIndex, Float:fDistance, Float:fVelocity[3], Float:fViewAngle[3])
  2023. {
  2024. //new Float:fViewAngle[3]
  2025. pev(iIndex, pev_v_angle, fViewAngle)
  2026. fVelocity[0] = floatcos(fViewAngle[1], degrees) * fDistance
  2027. fVelocity[1] = floatsin(fViewAngle[1], degrees) * fDistance
  2028. fVelocity[2] = floatcos(fViewAngle[0]+90.0, degrees) * fDistance
  2029. return 1
  2030. }
  2031.  
  2032. stock fm_find_ent_by_owner(index, const classname[], owner, jghgtype = 0)
  2033. {
  2034. new strtype[11] = "classname", ent = index
  2035. switch (jghgtype)
  2036. {
  2037. case 1: copy(strtype, 6, "target")
  2038. case 2: copy(strtype, 10, "targetname")
  2039. }
  2040. while ((ent = engfunc(EngFunc_FindEntityByString, ent, strtype, classname)) && pev(ent, pev_owner) != owner) {}
  2041. return ent
  2042. }
  2043.  
  2044. /*
  2045. stock fm_find_ent_by_model(index, const classname[], const model[])
  2046. {
  2047. new ent = index, mdl[72]
  2048. while ( (ent = engfunc(EngFunc_FindEntityByString, ent, sClassname, classname)) > 0 )
  2049. {
  2050. pev(ent, pev_model, mdl, 71)
  2051. if ( equal(mdl, model) )
  2052. return ent
  2053. }
  2054. return 0
  2055. }
  2056. */
  2057.  
  2058. stock fm_set_kvd(entity, const key[], const value[], const classname[] = "")
  2059. {
  2060. if ( classname[0] )
  2061. set_kvd(0, KV_ClassName, classname)
  2062. else
  2063. {
  2064. new class[32]
  2065. pev(entity, pev_classname, class, 31)
  2066. set_kvd(0, KV_ClassName, class)
  2067. }
  2068. set_kvd(0, KV_KeyName, key)
  2069. set_kvd(0, KV_Value, value)
  2070. set_kvd(0, KV_fHandled, 0)
  2071. return dllfunc(DLLFunc_KeyValue, entity, 0)
  2072. }
  2073.  
  2074. stock fm_fakedamage(victim, const classname[], Float:takedmgdamage, damagetype)
  2075. {
  2076. new entity = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, sNamedEntTriggerHurt))
  2077. if ( !entity )
  2078. return 0
  2079. new value[16]
  2080. format(value, 15, "%f", floatmul(takedmgdamage, 2.0))
  2081. fm_set_kvd(entity, "dmg", value, sNamedEntTriggerHurt)
  2082. format(value, 15, "%i", damagetype)
  2083. fm_set_kvd(entity, "damagetype", value, sNamedEntTriggerHurt)
  2084. fm_set_kvd(entity, "origin", "8192 8192 8192", sNamedEntTriggerHurt)
  2085. dllfunc(DLLFunc_Spawn, entity)
  2086. set_pev(entity, pev_classname, classname)
  2087. dllfunc(DLLFunc_Touch, entity, victim)
  2088. engfunc(EngFunc_RemoveEntity, entity)
  2089. return 1
  2090. }
  2091.  
  2092. stock fm_give_item(index, const item[])
  2093. {
  2094. if ( !equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10) )
  2095. return 0
  2096. new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, item))
  2097. if ( !pev_valid(ent) )
  2098. return 0
  2099. new Float:origin[3]
  2100. pev(index, pev_origin, origin)
  2101. set_pev(ent, pev_origin, origin)
  2102. set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)
  2103. dllfunc(DLLFunc_Spawn, ent)
  2104. new save = pev(ent, pev_solid)
  2105. dllfunc(DLLFunc_Touch, ent, index)
  2106. if (pev(ent, pev_solid) != save)
  2107. return ent
  2108. engfunc(EngFunc_RemoveEntity, ent)
  2109. return -1
  2110. }
  2111. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  2112. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1038\\ f0\\ fs16 \n\\ par }
  2113. */
  2114.