Advertisement
Guest User

Assasin

a guest
Aug 14th, 2012
19
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.79 KB | None | 0 0
  1. /* Plugin generated by AMXX-Studio */
  2.  
  3. #include <amxmodx>
  4. #include <amxmisc>
  5. #include <engine>
  6. #include <cstrike>
  7. #include <fakemeta>
  8. #include <fun>
  9. #include <colorchat>
  10. #include <codmod>
  11. #include <hamsandwich>
  12.  
  13. #define POKAZ_STATUS 2895
  14. #define MINIMUM_FALL_SPEED 300
  15. #define MAXIMUM_DAMAGE_FROM_JUMP 70.0
  16.  
  17. #define DAMAGE 30.0
  18. #define DELAY 0.2
  19.  
  20. new const nazwa[] = "Assasin [VIP]";
  21. new const opis[] = "Ma 20 nozy do rzucania, jest niewidzialny, po skoczeniu komus na glowe zabija go, nie slychac jego krokow, zostawia slady za soba.";
  22. new const bronie = 1<<CSW_KNIFE;
  23. new const zdrowie = -95;
  24. new const kondycja = 0;
  25. new const inteligencja = 0;
  26. new const wytrzymalosc = 10;
  27.  
  28. new noze[33], bool: ma_klase[33], skoki[33], SyncHudObj
  29. new blood
  30. new blood2
  31. new amx_headsplash;
  32. new Float:falling_speed[33];
  33. new Float:damage_after[33][33];
  34.  
  35. new decals[2] = {107,108}
  36.  
  37.  
  38. new bool:g_isDying[33]
  39. new g_decalSwitch[33]
  40.  
  41.  
  42. public plugin_init() {
  43. register_plugin(nazwa, "1.0", "_nothing_");
  44. register_cvar("amx_knifedamage_mw2","55")
  45. register_cvar("amx_knifespeed_mw2","700")
  46. register_cvar("amx_knifegravity_mw2","0.3")
  47. RegisterHam(Ham_Spawn, "player", "Spawn", 1)
  48. register_event("HLTV", "Nowa_Runda", "a", "1=0", "2=0")
  49. register_touch("throw_knife", "player", "knife_touch")
  50. register_touch("throw_knife", "worldspawn", "touchWorld")
  51. register_touch("throw_knife", "func_wall", "touchWorld")
  52. register_touch("throw_knife", "func_wall_toggle", "touchWorld")
  53. amx_headsplash = register_cvar("amx_headsplash", "1");
  54. register_forward(FM_Touch, "forward_touch");
  55. register_forward(FM_PlayerPreThink, "forward_PlayerPreThink");
  56. SyncHudObj = CreateHudSyncObj();
  57. register_forward(FM_PlayerPreThink, "PlayerPreThink");
  58. register_event("DeathMsg","death_event","a")
  59. cod_register_class(nazwa, opis, bronie, zdrowie, kondycja, inteligencja, wytrzymalosc);
  60. }
  61. public plugin_precache(){
  62. precache_model("models/w_throw.mdl");
  63. blood = precache_model("sprites/blood.spr")
  64. blood2 = precache_model("sprites/bloodspray.spr")
  65. precache_sound("player/headshot1.wav")
  66. precache_sound("player/die1.wav")
  67. }
  68. public cod_class_enabled(id)
  69. {
  70. if(!(get_user_flags(id) & ADMIN_LEVEL_H))
  71. {
  72. client_print(id, print_chat, "[Nozownik] Nie masz uprawnien, aby uzywac tej klasy.")
  73. return COD_STOP;
  74. }
  75. noze[id] = 20;
  76. ma_klase[id] = true;
  77. g_isDying[id] = true;
  78. set_task(0.1, "pokaz_informacje", id+POKAZ_STATUS, _, _, "b");
  79. set_user_footsteps(id, 1);
  80. new param[1];
  81. param[0] = id
  82. set_task(0.2, "make_footsteps", 4247545+id, param, 1, "b");
  83. set_user_rendering(id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 0);
  84.  
  85. return COD_CONTINUE;
  86. }
  87. public pokaz_informacje(id)
  88. {
  89. id -= POKAZ_STATUS
  90. if(is_user_alive(id))
  91. {
  92. set_hudmessage(0, 255, 0, 0.02, 0.5, 0, 0.1, 0.3, 0.0, 0.0);
  93. ShowSyncHudMsg(id, SyncHudObj, "[Noze : %d / 20]", noze[id])
  94. }
  95. }
  96. public Spawn(id)
  97. {
  98. if(ma_klase[id])
  99. {
  100. noze[id] = 20
  101. new param[1]
  102. param[0] = id
  103. if(!task_exists(id + POKAZ_STATUS))
  104. set_task(0.1, "pokaz_informacje", id+POKAZ_STATUS, _, _, "b");
  105. if(!task_exists(4247545 + id))
  106. set_task(0.2, "make_footsteps", 4247545+id, param, 1, "b")
  107. strip_user_weapons(id)
  108. give_item(id, "weapon_knife");
  109. g_isDying[id] = true
  110. set_user_footsteps(id, 1);
  111. set_user_rendering(id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 0);
  112. }
  113. }
  114. public client_disconnect(id)
  115. noze[id] = 0
  116. public client_connect(id)
  117. noze[id] = 0
  118.  
  119. public cod_class_disabled(id)
  120. {
  121. g_isDying[id] = false
  122. noze[id] = 0
  123. ma_klase[id] = false
  124. set_user_footsteps(id,0)
  125. remove_task(id + POKAZ_STATUS)
  126. remove_task(4247545+id)
  127. set_user_rendering(id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 255);
  128. }
  129. public Nowa_Runda()
  130. {
  131. new iEnt = find_ent_by_class(-1, "throw_knife");
  132. while(iEnt > 0)
  133. {
  134. remove_entity(iEnt);
  135. iEnt = find_ent_by_class(iEnt, "throw_knife");
  136. }
  137.  
  138. }
  139. public cod_class_skill_used(id)
  140. {
  141. paint_fire(id)
  142. }
  143. public touchWorld(Toucher, Touched){
  144. remove_entity(Toucher)
  145. return PLUGIN_HANDLED;
  146.  
  147. }
  148.  
  149. public knife_touch(Toucher, Touched){
  150. new kid = entity_get_edict(Toucher, EV_ENT_owner)
  151. new vic = entity_get_edict(Toucher, EV_ENT_enemy)
  152. if(is_user_alive(Touched))
  153. {
  154. new bool:zyje = true;
  155. if(kid == Touched || vic == Touched)
  156. {
  157. return ;
  158. }
  159. if(get_cvar_num("mp_friendlyfire") == 0 && get_user_team(Touched) == get_user_team(kid))
  160. {
  161. return ;
  162. }
  163.  
  164. new Float:Random_Float[3]
  165. for(new i = 0; i < 3; i++) Random_Float[i] = random_float(-50.0, 50.0)
  166. Punch_View(Touched, Random_Float)
  167.  
  168. if(get_cvar_num("amx_knifedamage_mw2") >= get_user_health(Touched)){
  169. zyje = false;
  170. }
  171. new origin[3];
  172. get_user_origin(Touched,origin)
  173. origin[2] += 25
  174. if(zyje == true){
  175. if(get_user_team(Touched) == get_user_team(kid))
  176. {
  177. new name[33]
  178. get_user_name(kid,name,32)
  179. client_print(0,print_chat,"%s attacked a teammate",name)
  180. }
  181. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  182. write_byte(TE_BLOODSPRITE)
  183. write_coord(origin[0])
  184. write_coord(origin[1])
  185. write_coord(origin[2])
  186. write_short(blood2)
  187. write_short(blood)
  188. write_byte(229)
  189. write_byte(25)
  190. message_end()
  191. set_user_health(Touched,get_user_health(Touched) - get_cvar_num("amx_knifedamage_mw2"));
  192. emit_sound(Touched, CHAN_ITEM, "player/headshot1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
  193. cod_inflict_damage(Toucher, Touched, 100.0, 1.0, 0, 0)
  194. //cod_set_user_xp(kid, cod_get_user_xp(kid) + 100)
  195. }
  196.  
  197. else
  198. {
  199. if(get_user_team(Touched) == get_user_team(kid)) {
  200. set_user_frags(kid, get_user_frags(kid) - 1)
  201. client_print(kid,print_center,"You killed a teammate")
  202. }
  203. else {
  204. set_user_frags(kid, get_user_frags(kid) + 1)
  205. cod_set_user_xp(kid, cod_get_user_xp(kid) + 10)
  206. }
  207.  
  208. new gmsgScoreInfo = get_user_msgid("ScoreInfo")
  209. new gmsgDeathMsg = get_user_msgid("DeathMsg")
  210.  
  211.  
  212.  
  213. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  214. write_byte(TE_BLOODSPRITE)
  215. write_coord(origin[0])
  216. write_coord(origin[1])
  217. write_coord(origin[2])
  218. write_short(blood2)
  219. write_short(blood)
  220. write_byte(229)
  221. write_byte(25)
  222. message_end()
  223.  
  224. set_msg_block(gmsgDeathMsg,BLOCK_ONCE)
  225. set_msg_block(gmsgScoreInfo,BLOCK_ONCE)
  226. user_kill(Touched,1)
  227.  
  228. message_begin(MSG_ALL,gmsgScoreInfo)
  229. write_byte(kid)
  230. write_short(get_user_frags(kid))
  231. write_short(get_user_deaths(kid))
  232. write_short(0)
  233. write_short(get_user_team(kid))
  234. message_end()
  235.  
  236. message_begin(MSG_ALL,gmsgScoreInfo)
  237. write_byte(Touched)
  238. write_short(get_user_frags(Touched))
  239. write_short(get_user_deaths(Touched))
  240. write_short(0)
  241. write_short(get_user_team(Touched))
  242. message_end()
  243.  
  244. message_begin(MSG_ALL,gmsgDeathMsg,{0,0,0},0)
  245. write_byte(kid)
  246. write_byte(Touched)
  247. write_byte(0)
  248. write_string("knife")
  249. message_end()
  250. emit_sound(Touched, CHAN_ITEM, "player/die1.wav", 1.0, ATTN_NORM, 0, PITCH_NORM)
  251. }
  252. //usuwam noz
  253. remove_entity(Toucher)
  254. }
  255. }
  256.  
  257. public paint_fire(id)
  258. {
  259. new ent = create_entity("info_target")
  260. if (pev_valid(ent) && is_user_alive(id) && ma_klase[id] && noze[id] > 0)
  261. {
  262.  
  263. new Float:vangles[3], Float:nvelocity[3], Float:voriginf[3], vorigin[3];
  264.  
  265. set_pev(ent, pev_owner, id);
  266. set_pev(ent, pev_classname, "throw_knife");
  267. engfunc(EngFunc_SetModel, ent, "models/w_throw.mdl");
  268. set_pev(ent, pev_gravity, get_cvar_float("amx_knifegravity_mw2"));
  269. set_user_rendering(id, kRenderFxNone, 0, 0, 0, kRenderTransAlpha, 0);
  270. get_user_origin(id, vorigin, 1);
  271.  
  272. IVecFVec(vorigin, voriginf);
  273. set_pev(ent,pev_origin,voriginf)
  274.  
  275. static Float:player_angles[3]
  276. pev(id, pev_angles, player_angles)
  277. player_angles[2] = 0.0
  278. set_pev(ent, pev_angles, player_angles);
  279.  
  280. pev(id, pev_v_angle, vangles);
  281. set_pev(ent, pev_v_angle, vangles);
  282. pev(id, pev_view_ofs, vangles);
  283. set_pev(ent, pev_view_ofs, vangles);
  284.  
  285. new veloc = get_cvar_num("amx_knifespeed_mw2")
  286.  
  287. set_pev(ent, pev_movetype, MOVETYPE_TOSS);
  288. set_pev(ent, pev_solid, 2);
  289. velocity_by_aim(id, veloc, nvelocity);
  290.  
  291. set_pev(ent, pev_velocity, nvelocity);
  292. set_pev(ent, pev_effects, pev(ent, pev_effects) & ~EF_NODRAW);
  293. set_pev(ent,pev_sequence,0)
  294. set_pev(ent,pev_framerate,1.0)
  295.  
  296. entity_set_edict(ent, EV_ENT_owner, id)
  297. noze[id]-= 1
  298. }
  299. return ent;
  300. }
  301.  
  302. public Punch_View(id, Float:ViewAngle[3])
  303. {
  304. set_pev(id, pev_punchangle, ViewAngle)
  305. }
  306. public forward_touch(toucher, touched) // This function is called every time a player touches another player.
  307. {
  308. // NOTE: The toucher is the player standing/falling on top of the other (touched) player's head.
  309. if(!is_user_alive(toucher) || !is_user_alive(touched)) // The touching players can't be dead.
  310. return;
  311.  
  312. if(!get_pcvar_num(amx_headsplash)) // If the plugin is disabled, stop messing with things.
  313. return;
  314. if(!ma_klase[toucher])
  315. return;
  316.  
  317. if(falling_speed[touched]) // Check if the touched player is falling. If he/she is, don't continue.
  318. return;
  319.  
  320. if(get_user_team(toucher) == get_user_team(touched) && !get_cvar_num("mp_friendlyfire")) // If the touchers are in the same team and friendly fire is off, don't continue.
  321. return;
  322.  
  323. new touched_origin[3], toucher_origin[3];
  324. get_user_origin(touched, touched_origin); // Get the origins of the players so it's possible to check if the toucher is standing on the touched's head.
  325. get_user_origin(toucher, toucher_origin);
  326.  
  327. new Float:toucher_minsize[3], Float:touched_minsize[3];
  328. pev(toucher,pev_mins,toucher_minsize);
  329. pev(touched,pev_mins,touched_minsize); // If touche*_minsize is equal to -18.0, touche* is crouching.
  330.  
  331. if(touched_minsize[2] != -18.0) // If the touched player IS NOT crouching, check if the toucher is on his/her head.
  332. {
  333. if(!(toucher_origin[2] == touched_origin[2]+72 && toucher_minsize[2] != -18.0) && !(toucher_origin[2] == touched_origin[2]+54 && toucher_minsize[2] == -18.0))
  334. {
  335. return;
  336. }
  337. }
  338. else // If the touched player is crouching, check if the toucher is on his/her head
  339. {
  340. if(!(toucher_origin[2] == touched_origin[2]+68 && toucher_minsize[2] != -18.0) && !(toucher_origin[2] == touched_origin[2]+50 && toucher_minsize[2] == -18.0))
  341. {
  342. return;
  343. }
  344. }
  345.  
  346. if(falling_speed[toucher] >= MINIMUM_FALL_SPEED) // If the toucher is falling in the required speed or faster, then landing on top of the touched's head, do some damage to the touched. MUHAHAHAHAHA!!!
  347. {
  348. new Float:damage = ((falling_speed[toucher] - MINIMUM_FALL_SPEED + 30) * (falling_speed[toucher] - MINIMUM_FALL_SPEED + 30)) / 1300;
  349. if(damage > MAXIMUM_DAMAGE_FROM_JUMP) // Make shure that the touched player don't take too much damage.
  350. damage = MAXIMUM_DAMAGE_FROM_JUMP;
  351. damage_player(touched, toucher, damage); // Damage or kill the touched player.
  352. damage_after[toucher][touched] = 0.0; // Reset.
  353. }
  354. if(is_user_alive(touched) && damage_after[toucher][touched] <= get_gametime()) // This makes shure that you won't get damaged every frame you have some one on your head. It also makes shure that players won't get damaged faster on fast servers than laggy servers.
  355. {
  356. damage_after[toucher][touched] = get_gametime() + DELAY;
  357. damage_player(touched, toucher, DAMAGE); // Damage or kill the touched player.
  358. }
  359. }
  360.  
  361. public forward_PlayerPreThink(id) // This is called every time before a player "thinks". A player thinks many times per second.
  362. {
  363. //falling_speed[id] = entity_get_float(id, EV_FL_flFallVelocity); // Store the falling speed of the soon to be "thinking" player.
  364. pev(id, pev_flFallVelocity, falling_speed[id])
  365. }
  366.  
  367. public damage_player(pwned, pwnzor, Float:damage) // Damages or kills a player. Home made HAX
  368. {
  369. new health = get_user_health(pwned);
  370. if(get_user_team(pwned) == get_user_team(pwnzor)) // If both players are in the same team, reduce the damage.
  371. damage /= 1.4;
  372. new CsArmorType:armortype;
  373. cs_get_user_armor(pwned, armortype);
  374. if(armortype == CS_ARMOR_VESTHELM)
  375. damage *= 0.7;
  376. if(health > damage)
  377. {
  378. new pwned_origin[3];
  379. get_user_origin(pwned, pwned_origin);
  380. message_begin(MSG_BROADCAST, SVC_TEMPENTITY); // BLOOOOOOOOOOOD!!
  381. write_byte(TE_BLOODSPRITE);
  382. write_coord(pwned_origin[0]+8);
  383. write_coord(pwned_origin[1]);
  384. write_coord(pwned_origin[2]+26);
  385. write_short(blood2);
  386. write_short(blood);
  387. write_byte(248);
  388. write_byte(4);
  389. message_end();
  390.  
  391. new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "trigger_hurt"));
  392. if(!ent)
  393. return;
  394. new value[16];
  395. float_to_str(damage * 2, value, sizeof value - 1);
  396. set_kvd(0, KV_ClassName, "trigger_hurt");
  397. set_kvd(0, KV_KeyName, "dmg");
  398. set_kvd(0, KV_Value, value);
  399. set_kvd(0, KV_fHandled, 0);
  400. dllfunc(DLLFunc_KeyValue, ent, 0);
  401. num_to_str(DMG_GENERIC, value, sizeof value - 1);
  402. set_kvd(0, KV_ClassName, "trigger_hurt");
  403. set_kvd(0, KV_KeyName, "damagetype");
  404. set_kvd(0, KV_Value, value);
  405. set_kvd(0, KV_fHandled, 0);
  406. dllfunc(DLLFunc_KeyValue, ent, 0);
  407. set_kvd(0, KV_ClassName, "trigger_hurt");
  408. set_kvd(0, KV_KeyName, "origin");
  409. set_kvd(0, KV_Value, "8192 8192 8192");
  410. set_kvd(0, KV_fHandled, 0);
  411. dllfunc(DLLFunc_KeyValue, ent, 0);
  412. dllfunc(DLLFunc_Spawn, ent);
  413. set_pev(ent, pev_classname, "head_splash");
  414. dllfunc(DLLFunc_Touch, ent, pwned);
  415. engfunc(EngFunc_RemoveEntity, ent);
  416. }
  417. else
  418. {
  419. new pwned_origin[3];
  420. get_user_origin(pwned, pwned_origin);
  421. message_begin(MSG_BROADCAST, SVC_TEMPENTITY); // BLOOOOOOOOOOOD!!
  422. write_byte(TE_BLOODSPRITE);
  423. write_coord(pwned_origin[0]+8);
  424. write_coord(pwned_origin[1]);
  425. write_coord(pwned_origin[2]+26);
  426. write_short(blood2);
  427. write_short(blood);
  428. write_byte(248);
  429. write_byte(12);
  430. message_end();
  431.  
  432. set_pev(pwned, pev_frags, float(get_user_frags(pwned) + 1));
  433. user_silentkill(pwned);
  434. make_deathmsg(pwnzor, pwned, 1, "his/her feet :)");
  435. if(get_user_team(pwnzor) != get_user_team(pwned)) // If it was a team kill, the pwnzor's money should get reduced instead of increased.
  436. {
  437. set_pev(pwnzor, pev_frags, float(get_user_frags(pwnzor) + 1));
  438. cs_set_user_money(pwnzor, cs_get_user_money(pwnzor) + 300);
  439. cod_set_user_xp(pwnzor, cod_get_user_xp(pwnzor) + 10)
  440. }
  441. else
  442. {
  443. set_pev(pwnzor, pev_frags, float(get_user_frags(pwnzor) - 1));
  444. cs_set_user_money(pwnzor, cs_get_user_money(pwnzor) - 300);
  445. }
  446.  
  447. message_begin(MSG_ALL, get_user_msgid("ScoreInfo")); // Fixes the scoreboard.
  448. write_byte(pwnzor);
  449. write_short(get_user_frags(pwnzor));
  450. write_short(cs_get_user_deaths(pwnzor));
  451. write_short(0);
  452. write_short(get_user_team(pwnzor));
  453. message_end();
  454.  
  455. message_begin(MSG_ALL, get_user_msgid("ScoreInfo"));
  456. write_byte(pwned);
  457. write_short(get_user_frags(pwned));
  458. write_short(cs_get_user_deaths(pwned));
  459. write_short(0);
  460. write_short(get_user_team(pwned));
  461. message_end();
  462. set_pev(pwned, pev_frags, float(get_user_frags(pwned) - 1));
  463. }
  464. }
  465. public death_event()
  466. {
  467. new kid = read_data(1)
  468. new id = read_data(2)
  469. if(g_isDying[id])
  470. {
  471. g_isDying[id] = false
  472. remove_task(4247545+id)
  473. }
  474. if( kid != id && is_user_alive(kid) && ma_klase[id])
  475. {
  476. cod_set_user_xp(kid, cod_get_user_xp(kid) + 30)
  477. }
  478. }
  479. public make_footsteps(param[])
  480. {
  481. new id = param[0]
  482. if(!is_user_alive(id) || get_cvar_num("ftw_active") == 1 || get_speed(id) < 120) return
  483. new origin[3]
  484. get_user_origin(id, origin)
  485. if(entity_get_int(id, EV_INT_bInDuck) == 1)
  486. origin[2] -= 18
  487. else
  488. origin[2] -= 36
  489. new Float:velocity[3]
  490. new Float:ent_angles[3]
  491. new Float:ent_origin[3]
  492. new ent
  493.  
  494. entity_get_vector(id, EV_VEC_v_angle, ent_angles)
  495. entity_get_vector(id, EV_VEC_origin, ent_origin)
  496.  
  497. ent = create_entity("info_target")
  498. if(ent > 0)
  499. {
  500. ent_angles[0] = 0.0
  501. if(g_decalSwitch[id] == 0) ent_angles[1] -= 90
  502. else ent_angles[1] += 90
  503. entity_set_vector(ent, EV_VEC_origin, ent_origin)
  504. entity_set_vector(ent, EV_VEC_v_angle, ent_angles)
  505. VelocityByAim(ent, 12, velocity)
  506. remove_entity(ent)
  507. }
  508. message_begin(MSG_BROADCAST, SVC_TEMPENTITY, origin)
  509. write_byte(116)
  510. write_coord(origin[0] + floatround(velocity[0]))
  511. write_coord(origin[1] + floatround(velocity[1]))
  512. write_coord(origin[2])
  513. write_byte(decals[g_decalSwitch[id]])
  514. message_end()
  515. g_decalSwitch[id] = 1 - g_decalSwitch[id]
  516. return
  517. }
  518. public PlayerPreThink(id)
  519. {
  520. if(!ma_klase[id])
  521. return PLUGIN_CONTINUE;
  522.  
  523. new button = pev(id, pev_button);
  524. new oldbutton = pev(id, pev_oldbuttons);
  525. new flags = pev(id, pev_flags);
  526.  
  527. if((button & IN_JUMP) && !(flags & FL_ONGROUND) && !(oldbutton & IN_JUMP) && skoki[id])
  528. {
  529. skoki[id]--;
  530. new Float:velocity[3];
  531. pev(id, pev_velocity, velocity);
  532. velocity[2] = random_float(265.0,285.0);
  533. set_pev(id, pev_velocity, velocity);
  534. }
  535. else if(flags & FL_ONGROUND)
  536. skoki[id] = 3;
  537.  
  538. return PLUGIN_CONTINUE;
  539. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement