Advertisement
Guest User

Edit Example xD

a guest
Aug 4th, 2015
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.14 KB | None | 0 0
  1. /*================================================================================
  2.  
  3. [ZP] Extra Item: Nitrogen Galil
  4. Copyright (C) 2009 By metallicawOw #, Buenos Aires, Argentina
  5.  
  6. This program is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program. If not, see <http://www.gnu.org/licenses/>.
  18.  
  19. In addition, as a special exception, the author gives permission to
  20. link the code of this program with the Half-Life Game Engine ("HL
  21. Engine") and Modified Game Libraries ("MODs") developed by Valve,
  22. L.L.C ("Valve"). You must obey the GNU General Public License in all
  23. respects for all of the code used other than the HL Engine and MODs
  24. from Valve. If you modify this file, you may extend this exception
  25. to your version of the file, but you are not obligated to do so. If
  26. you do not wish to do so, delete this exception statement from your
  27. version.
  28.  
  29. Description: When you buy this item you will Frost Zombies While Shooting Them
  30. With your Nitrogen Galil.
  31.  
  32. Changelog:
  33. v1.00: Creation of the plugin [24/11/09]
  34. v2.00: Fixed Some Bugs [6/12/09]
  35. v2.01: Added a Model to NG and Better Effects [6/12/09]
  36. v2.02: Added Frost Time in one Cvar [6/12/09]
  37. v2.03: Updated Some Things of Back Speed [20/12/09]
  38.  
  39. ML:
  40. [ES] // metallicawOw #
  41. [EN] // metallicawOw #
  42. [NL] // crazyeffect
  43. [PL] // MmikiM
  44.  
  45. =================================================================================*/
  46.  
  47. #include <amxmodx>
  48. #include <hamsandwich>
  49. #include <zombieplague>
  50. #include <fakemeta>
  51. #include <cstrike>
  52. #include <engine>
  53. #include <fun>
  54. #include <zmvip>
  55.  
  56. //___________/ Values \___________________________________________________________________________________________
  57. //**************************************************************************************************************************/
  58. new gc_itemID
  59. new bool:g_NitrogenGalil[33]
  60. new g_Weapon[33]
  61. new g_FrozeN[33]
  62. new NitrogenGalilSpr
  63. new g_msgScreenFade
  64. new g_iMaxPlayers
  65. new g_HudSync
  66. new FrostTime
  67. new BackSpeed1
  68. new BackSpeed2
  69.  
  70. const UNIT_SECOND = (1<<12)
  71.  
  72. //___________/ INIT \___________________________________________________________________________________________
  73. //**************************************************************************************************************************/
  74. public plugin_init()
  75. {
  76. register_plugin("[ZP] Extra Item: Nitrogen Galil", "2.03", "metallicawOw #")
  77.  
  78. // Cvars
  79. FrostTime = register_cvar("zp_ng_frost_time", "5.0") // Time to Remove the Frost Effect
  80. BackSpeed1 = register_cvar("zp_ng_back_spd_h", "240.0") // The Speed that Victim Recieve when is Human and g_FrozeN is false
  81. BackSpeed2 = register_cvar("zp_ng_back_spd_z", "230.0") // The Speed that Victim Recieve when is Zombie and g_FrozeN is false
  82.  
  83. // Message IDS
  84. g_HudSync = CreateHudSyncObj()
  85. g_iMaxPlayers = get_maxplayers()
  86. g_msgScreenFade = get_user_msgid("ScreenFade")
  87.  
  88. // ITEM NAME & COST
  89. gc_itemID = zv_register_extra_item("Nitrogen Galil", "Frosting zombies", 40, ZV_TEAM_HUMAN)
  90.  
  91. // Events
  92. register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
  93. register_event("CurWeapon", "event_CurWeapon", "b", "1=1")
  94.  
  95. // Forwards
  96. register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
  97.  
  98. // Hams
  99. RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  100.  
  101. // Lang
  102. register_dictionary("nitrogen_galil.txt")
  103.  
  104. }
  105.  
  106. //___________/ PRECACHE \___________________________________________________________________________________________
  107. //**************************************************************************************************************************/
  108. public plugin_precache()
  109. {
  110. // Models
  111. precache_model("models/zombie_plague/v_nitrogen_galil.mdl");
  112.  
  113. // Sounds
  114. precache_sound("warcraft3/impalehit.wav");
  115.  
  116. // Sprites
  117. NitrogenGalilSpr = precache_model("sprites/shockwave.spr");
  118. }
  119.  
  120. //___________/ Client PutinServer & Disconnect\___________________________________________________________________________________________
  121. //**************************************************************************************************************************/
  122. public client_putinserver(id)
  123. {
  124. g_NitrogenGalil[id] = false
  125. g_FrozeN[id] = false
  126. }
  127.  
  128. public client_disconnect(id)
  129. {
  130. g_NitrogenGalil[id] = false
  131. g_FrozeN[id] = false
  132. }
  133.  
  134. //___________/ ZP EXTRA ITEM SELECTED \___________________________________________________________________________________________
  135. //**************************************************************************************************************************/
  136. public zv_extra_item_selected(player, itemid)
  137. {
  138. // check if the selected item matches any of our registered ones
  139. if (itemid == gc_itemID)
  140. {
  141. client_print(player, print_chat, "%L", LANG_PLAYER, "PURCHASE_NG")
  142.  
  143. g_NitrogenGalil[player] = true
  144.  
  145. strip_user_weapons(player)
  146.  
  147. give_item(player, "weapon_knife")
  148.  
  149. give_item(player, "weapon_galil")
  150.  
  151. cs_set_user_bpammo(player, CSW_GALIL, 300)
  152.  
  153. new gcName[32]
  154.  
  155. get_user_name(player, gcName, charsmax(gcName))
  156.  
  157. set_hudmessage(34, 138, 255, -1.0, 0.17, 1, 0.0, 5.0, 1.0, 1.0, -1)
  158.  
  159. ShowSyncHudMsg(0, g_HudSync, "%L", LANG_PLAYER, "NOTICE_NG", gcName)
  160. }
  161. }
  162.  
  163. //___________/ ZP User Infected \___________________________________________________________________________________________
  164. //**************************************************************************************************************************/
  165. public zp_user_infected_post(infected, infector)
  166. {
  167. if (g_NitrogenGalil[infected])
  168. {
  169. g_NitrogenGalil[infected] = false
  170. }
  171. }
  172.  
  173. //___________/ Event Round Start \___________________________________________________________________________________________
  174. //**************************************************************************************************************************/
  175. public event_round_start()
  176. {
  177. for (new i = 1; i <= g_iMaxPlayers; i++)
  178. {
  179. if (!is_user_connected(i))
  180. continue
  181.  
  182. if (g_NitrogenGalil[i])
  183. {
  184. g_NitrogenGalil[i] = false
  185. }
  186. if(g_FrozeN[i])
  187. {
  188. g_FrozeN[i] = false
  189. }
  190. }
  191. }
  192.  
  193. //___________/ TakeDamage \___________________________________________________________________________________________
  194. //**************************************************************************************************************************/
  195. public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type)
  196. {
  197. if(!is_user_connected(attacker) || !is_user_connected(victim) || zp_get_user_nemesis(victim) || attacker == victim || !attacker)
  198. return HAM_IGNORED
  199.  
  200. // For Frost Effect Ring
  201. static Float:originF[3]
  202. pev(victim, pev_origin, originF)
  203.  
  204. // For Frost Effect Sound
  205. static originF2[3]
  206. get_user_origin(victim, originF2)
  207.  
  208. if (g_NitrogenGalil[attacker] && get_user_weapon(attacker) == CSW_GALIL)
  209. {
  210. FrostEffect(victim)
  211.  
  212. FrostEffectRing(originF)
  213.  
  214. FrostEffectSound(originF2)
  215.  
  216. client_print(attacker, print_center, "%L", LANG_PLAYER, "ENEMY_FROST_NG")
  217. }
  218. else
  219. {
  220. if(g_NitrogenGalil[attacker])
  221. {
  222. client_print(attacker, print_center, "%L", LANG_PLAYER, "ONLY_NG")
  223. }
  224. }
  225.  
  226.  
  227. if(zp_get_user_nemesis(victim))
  228. {
  229. client_print(attacker, print_center, "%L", LANG_PLAYER, "NEMESIS_INMUNE_NG")
  230.  
  231. return HAM_IGNORED
  232. }
  233. return PLUGIN_HANDLED;
  234. }
  235.  
  236. //___________/ Event Cur Weapon \___________________________________________________________________________________________
  237. //**************************************************************************************************************************/
  238. public event_CurWeapon(id)
  239. {
  240. if (!is_user_alive(id))
  241. return PLUGIN_CONTINUE
  242.  
  243. g_Weapon[id] = read_data(2)
  244.  
  245. if(zp_get_user_zombie(id) || zp_get_user_survivor(id))
  246. return PLUGIN_CONTINUE
  247.  
  248. if(!g_NitrogenGalil[id] || g_Weapon[id] != CSW_GALIL)
  249. return PLUGIN_CONTINUE
  250.  
  251. entity_set_string(id, EV_SZ_viewmodel, "models/zombie_plague/v_nitrogen_galil.mdl")
  252.  
  253. return PLUGIN_CONTINUE
  254. }
  255.  
  256. //___________/ Player Pre Think \___________________________________________________________________________________________
  257. //**************************************************************************************************************************/
  258. // Forward Player PreThink
  259. public fw_PlayerPreThink(id)
  260. {
  261. // Not alive
  262. if (!is_user_alive(id))
  263. return;
  264.  
  265. // Set Player MaxSpeed
  266. if (g_FrozeN[id])
  267. {
  268. set_pev(id, pev_velocity, Float:{0.0,0.0,0.0}) // stop motion
  269. set_pev(id, pev_maxspeed, 1.0) // prevent from moving
  270. }
  271. else
  272. {
  273. if(!zp_get_user_zombie(id))
  274. {
  275. set_pev(id, pev_maxspeed, get_pcvar_float(BackSpeed1)) // Change this in Cvar if you Want
  276. }
  277. else
  278. {
  279. set_pev(id, pev_maxspeed, get_pcvar_float(BackSpeed2)) // Change this in Cvar if you Want
  280. }
  281. }
  282. }
  283. //___________/ Effects \___________________________________________________________________________________________
  284. //**************************************************************************************************************************/
  285. // Frost Effect
  286. public FrostEffect(id)
  287. {
  288. // Only effect alive unfrozen zombies
  289. if (!is_user_alive(id) || !zp_get_user_zombie(id) || g_FrozeN[id])
  290. return;
  291.  
  292. message_begin(MSG_ONE_UNRELIABLE, g_msgScreenFade, _, id)
  293. write_short(UNIT_SECOND*1) // duration
  294. write_short(UNIT_SECOND*1) // hold time
  295. write_short(0x0000) // fade type
  296. write_byte(0) // red
  297. write_byte(50) // green
  298. write_byte(200) // blue
  299. write_byte(100) // alpha
  300. message_end()
  301.  
  302. // Light blue glow while frozen
  303. #if defined HANDLE_MODELS_ON_SEPARATE_ENT
  304. fm_set_rendering(g_ent_playermodel[id], kRenderFxGlowShell, 0, 100, 200, kRenderNormal, 25)
  305. #else
  306. fm_set_rendering(id, kRenderFxGlowShell, 0, 100, 200, kRenderNormal, 25)
  307. #endif
  308.  
  309. g_FrozeN[id] = true
  310. set_task(get_pcvar_float(FrostTime), "RemoveFrost", id) // Time to Remove Frost Effect
  311. }
  312.  
  313. // Frost Effect Sound
  314. public FrostEffectSound(iOrigin[3])
  315. {
  316. new Entity = create_entity("info_target")
  317.  
  318. new Float:flOrigin[3]
  319. IVecFVec(iOrigin, flOrigin)
  320.  
  321. entity_set_origin(Entity, flOrigin)
  322.  
  323. emit_sound(Entity, CHAN_WEAPON, "warcraft3/impalehit.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  324.  
  325. remove_entity(Entity)
  326. }
  327.  
  328. // Frost Effect Ring
  329. FrostEffectRing(const Float:originF3[3])
  330. {
  331. // Largest ring
  332. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF3, 0)
  333. write_byte(TE_BEAMCYLINDER) // TE id
  334. engfunc(EngFunc_WriteCoord, originF3[0]) // x
  335. engfunc(EngFunc_WriteCoord, originF3[1]) // y
  336. engfunc(EngFunc_WriteCoord, originF3[2]) // z
  337. engfunc(EngFunc_WriteCoord, originF3[0]) // x axis
  338. engfunc(EngFunc_WriteCoord, originF3[1]) // y axis
  339. engfunc(EngFunc_WriteCoord, originF3[2]+100.0) // z axis
  340. write_short(NitrogenGalilSpr) // sprite
  341. write_byte(0) // startframe
  342. write_byte(0) // framerate
  343. write_byte(4) // life
  344. write_byte(60) // width
  345. write_byte(0) // noise
  346. write_byte(41) // red
  347. write_byte(138) // green
  348. write_byte(255) // blue
  349. write_byte(200) // brightness
  350. write_byte(0) // speed
  351. message_end()
  352. }
  353.  
  354. // Remove Frost Effect
  355. public RemoveFrost(id)
  356. {
  357. // Not alive or not frozen anymore
  358. if (!is_user_alive(id) || !g_FrozeN[id])
  359. return;
  360.  
  361. // Unfreeze
  362. g_FrozeN[id] = false;
  363.  
  364. // Remove glow
  365. #if defined HANDLE_MODELS_ON_SEPARATE_ENT
  366. fm_set_rendering(g_ent_playermodel[id])
  367. #else
  368. fm_set_rendering(id)
  369. #endif
  370. }
  371.  
  372. // Set entity's rendering type (from fakemeta_util)
  373. stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
  374. {
  375. static Float:color[3]
  376. color[0] = float(r)
  377. color[1] = float(g)
  378. color[2] = float(b)
  379.  
  380. set_pev(entity, pev_renderfx, fx)
  381. set_pev(entity, pev_rendercolor, color)
  382. set_pev(entity, pev_rendermode, render)
  383. set_pev(entity, pev_renderamt, float(amount))
  384. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement