Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.40 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <hamsandwich>
  4. #include <zombieplague>
  5. #include <csx>
  6.  
  7. #define fm_create_entity(%1) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, %1))
  8.  
  9. new const NADE_TYPE_STRIPBOMB= 7777
  10. new const sprite_grenade_trail[] = "sprites/laserbeam.spr"
  11. new const sprite_grenade_ring[] = "sprites/shockwave.spr"
  12. new const model_grenade_infect[] = "models/v_grenade_astrip.mdl"
  13. new const bcost = 5;
  14.  
  15. new nick_p[ 32 ]
  16.  
  17. new g_trailSpr, g_exploSpr, item_id, cvar_enabled, cvar_mode, cvar_radius, cvar_max
  18. new has_bomb[33],had_bombs[33];
  19.  
  20. public plugin_init()
  21. {
  22.     register_plugin("[ZP] Extra Item: Strip Bomb", "1.6", "Hezerf")
  23.    
  24.     RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
  25.     RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
  26.  
  27.     //RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_smokegrenade", "smokeThrown" )
  28.    
  29.     register_forward(FM_SetModel, "fw_SetModel")
  30.    
  31.     register_message(get_user_msgid("CurWeapon"), "message_cur_weapon")
  32.    
  33.     register_event("HLTV","Event_New_Round","a", "1=0", "2=0")
  34.    
  35.     cvar_enabled = register_cvar("zp_strip_bomb", "1")
  36.     cvar_mode = register_cvar("zp_strip_mode", "0")
  37.     cvar_radius = register_cvar("zp_strip_radius", "250.0")
  38.     cvar_max = register_cvar("zp_strip_max","5")
  39. }
  40.  
  41. public plugin_precache()
  42. {
  43.     g_trailSpr = engfunc(EngFunc_PrecacheModel, sprite_grenade_trail)
  44.     g_exploSpr = engfunc(EngFunc_PrecacheModel, sprite_grenade_ring)
  45.    
  46.     engfunc(EngFunc_PrecacheModel, model_grenade_infect)
  47.    
  48.     item_id = zp_register_extra_item("Strip Bomb", bcost, ZP_TEAM_ZOMBIE)
  49. }
  50.  
  51. public client_disconnect(id)
  52. {
  53.     has_bomb[id] = 0;
  54.     had_bombs[id] = 0;
  55. }
  56.  
  57. public Event_New_Round()
  58. {
  59.     arrayset(had_bombs,0,32);
  60.     arrayset(has_bomb,0,32);
  61. }
  62. public grenade_throw( index, greindex, wId )
  63. {
  64.     if( wId == CSW_SMOKEGRENADE )
  65.     {
  66.         get_user_name( index, nick_p, charsmax( nick_p ) )
  67.         client_print( 0, print_chat, "[MILF] %s je bacio bombu!" )
  68.     }
  69. }
  70. public zp_extra_item_selected(player, itemid)
  71. {
  72.     if(itemid != item_id)
  73.         return;
  74.     if(get_pcvar_num(cvar_max) == had_bombs[player])
  75.     {
  76.         zp_set_user_ammo_packs(player,zp_get_user_ammo_packs(player) + bcost)
  77.         client_print(player, print_chat, "[ZP] You can't buy Strip Bomb !")
  78.         return;
  79.     }
  80.    
  81.     has_bomb[player] = 1
  82.     had_bombs[player]++;
  83.     fm_strip_user_gun(player, 9)
  84.     fm_give_item(player, "weapon_smokegrenade")
  85. }
  86. public fw_PlayerKilled(victim, attacker, shouldgib)
  87.     has_bomb[victim] = 0;
  88.  
  89. public fw_ThinkGrenade(entity)
  90. {  
  91.     if(!pev_valid(entity))
  92.         return HAM_IGNORED
  93.    
  94.     static Float:dmgtime   
  95.     pev(entity, pev_dmgtime, dmgtime)
  96.    
  97.     if (dmgtime > get_gametime())
  98.         return HAM_IGNORED 
  99.    
  100.     if(pev(entity, pev_flTimeStepSound) == NADE_TYPE_STRIPBOMB)
  101.     {
  102.         stripbomb_explode(entity)
  103.        
  104.         return HAM_SUPERCEDE
  105.     }
  106.    
  107.     return HAM_IGNORED  
  108. }
  109.  
  110. public fw_SetModel(entity, const model[])
  111. {
  112.     static Float:dmgtime
  113.     pev(entity, pev_dmgtime, dmgtime)
  114.    
  115.     new owner = pev(entity, pev_owner)
  116.    
  117.     if(!get_pcvar_num(cvar_enabled) || !dmgtime || !(equal(model[7], "w_sm", 4)) || !zp_get_user_zombie(owner) || !has_bomb[owner])
  118.         return;
  119.    
  120.     fm_set_rendering(entity, kRenderFxGlowShell, 255, 128, 0, kRenderNormal, 16)
  121.    
  122.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  123.     write_byte(TE_BEAMFOLLOW) // TE id
  124.     write_short(entity) // entity
  125.     write_short(g_trailSpr) // sprite
  126.     write_byte(10) // life
  127.     write_byte(10) // width
  128.     write_byte(255) // r
  129.     write_byte(128) // g
  130.     write_byte(0) // b
  131.     write_byte(200) // brightness
  132.     message_end()
  133.    
  134.     set_pev(entity, pev_flTimeStepSound, NADE_TYPE_STRIPBOMB)
  135. }
  136.  
  137. public stripbomb_explode(ent)
  138. {
  139.     if (!zp_has_round_started())
  140.         return;
  141.    
  142.     static Float:originF[3]
  143.     pev(ent, pev_origin, originF)
  144.    
  145.     create_blast(originF)
  146.    
  147.     //engfunc(EngFunc_EmitSound, ent, CHAN_WEAPON, grenade_infect[random_num(0, sizeof grenade_infect - 1)], 1.0, ATTN_NORM, 0, PITCH_NORM)
  148.    
  149.     static attacker
  150.     attacker = pev(ent, pev_owner)
  151.    
  152.     has_bomb[attacker] = 0
  153.    
  154.     static victim
  155.     victim = -1
  156.     while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, get_pcvar_float(cvar_radius))) != 0)
  157.     {
  158.         if (!is_user_alive(victim) || zp_get_user_zombie(victim))
  159.             continue;
  160.        
  161.         switch(get_pcvar_num(cvar_mode))
  162.         {
  163.             case 0 :
  164.             {
  165.                 if (pev(victim, pev_armorvalue) <= 0)
  166.                     continue;
  167.                
  168.                 set_pev(victim, pev_armorvalue, 0);
  169.             }
  170.             case 1 :
  171.             {
  172.                 fm_strip_user_weapons(victim)
  173.                 fm_give_item(victim, "weapon_knife")
  174.             }
  175.             case 2 :
  176.             {
  177.                 if (pev(victim, pev_armorvalue) > 0)               
  178.                     set_pev(victim, pev_armorvalue, 0)
  179.                
  180.                 fm_strip_user_weapons(victim)
  181.                 fm_give_item(victim, "weapon_knife")
  182.             }
  183.         }
  184.     }
  185.    
  186.     engfunc(EngFunc_RemoveEntity, ent)
  187. }
  188.  
  189. public create_blast(const Float:originF[3])
  190. {
  191.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  192.     write_byte(TE_BEAMCYLINDER) // TE id
  193.     engfunc(EngFunc_WriteCoord, originF[0]) // x
  194.     engfunc(EngFunc_WriteCoord, originF[1]) // y
  195.     engfunc(EngFunc_WriteCoord, originF[2]) // z
  196.     engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  197.     engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  198.     engfunc(EngFunc_WriteCoord, originF[2]+385.0) // z axis
  199.     write_short(g_exploSpr) // sprite
  200.     write_byte(0) // startframe
  201.     write_byte(0) // framerate
  202.     write_byte(4) // life
  203.     write_byte(60) // width
  204.     write_byte(0) // noise
  205.     write_byte(255) // red
  206.     write_byte(128) // green
  207.     write_byte(0) // blue
  208.     write_byte(200) // brightness
  209.     write_byte(0) // speed
  210.     message_end()
  211.    
  212.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  213.     write_byte(TE_BEAMCYLINDER) // TE id
  214.     engfunc(EngFunc_WriteCoord, originF[0]) // x
  215.     engfunc(EngFunc_WriteCoord, originF[1]) // y
  216.     engfunc(EngFunc_WriteCoord, originF[2]) // z
  217.     engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  218.     engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  219.     engfunc(EngFunc_WriteCoord, originF[2]+470.0) // z axis
  220.     write_short(g_exploSpr) // sprite
  221.     write_byte(0) // startframe
  222.     write_byte(0) // framerate
  223.     write_byte(4) // life
  224.     write_byte(60) // width
  225.     write_byte(0) // noise
  226.     write_byte(255) // red
  227.     write_byte(164) // green
  228.     write_byte(0) // blue
  229.     write_byte(200) // brightness
  230.     write_byte(0) // speed
  231.     message_end()
  232.    
  233.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  234.     write_byte(TE_BEAMCYLINDER) // TE id
  235.     engfunc(EngFunc_WriteCoord, originF[0]) // x
  236.     engfunc(EngFunc_WriteCoord, originF[1]) // y
  237.     engfunc(EngFunc_WriteCoord, originF[2]) // z
  238.     engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  239.     engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  240.     engfunc(EngFunc_WriteCoord, originF[2]+555.0) // z axis
  241.     write_short(g_exploSpr) // sprite
  242.     write_byte(0) // startframe
  243.     write_byte(0) // framerate
  244.     write_byte(4) // life
  245.     write_byte(60) // width
  246.     write_byte(0) // noise
  247.     write_byte(255) // red
  248.     write_byte(200) // green
  249.     write_byte(0) // blue
  250.     write_byte(200) // brightness
  251.     write_byte(0) // speed
  252.     message_end()
  253. }
  254.  
  255. public replace_models(id)
  256. {
  257.     if (!is_user_alive(id) || get_user_weapon(id) != CSW_SMOKEGRENADE || !has_bomb[id])
  258.         return
  259.    
  260.     set_pev(id, pev_viewmodel2, model_grenade_infect)
  261. }
  262.  
  263. public message_cur_weapon(msg_id, msg_dest, msg_entity)
  264.     replace_models(msg_entity);
  265.  
  266. // Stocks from fakemeta_util
  267. stock bool:fm_strip_user_gun(index, wid = 0, const wname[] = "")
  268. {
  269.     new ent_class[32];
  270.     if (!wid && wname[0])
  271.         copy(ent_class, sizeof ent_class - 1, wname);
  272.     else
  273.     {
  274.         new weapon = wid, clip, ammo;
  275.         if (!weapon && !(weapon = get_user_weapon(index, clip, ammo)))
  276.             return false;
  277.        
  278.         get_weaponname(weapon, ent_class, sizeof ent_class - 1);
  279.     }
  280.    
  281.     new ent_weap = fm_find_ent_by_owner(-1, ent_class, index);
  282.     if (!ent_weap)
  283.         return false;
  284.    
  285.     engclient_cmd(index, "drop", ent_class);
  286.    
  287.     new ent_box = pev(ent_weap, pev_owner);
  288.     if (!ent_box || ent_box == index)
  289.         return false;
  290.    
  291.     dllfunc(DLLFunc_Think, ent_box);
  292.    
  293.     return true;
  294. }
  295.  
  296. stock fm_give_item(index, const item[])
  297. {
  298.     if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))
  299.         return 0;
  300.  
  301.     new ent = fm_create_entity(item);
  302.     if (!pev_valid(ent))
  303.         return 0;
  304.    
  305.     new Float:origin[3];
  306.     pev(index, pev_origin, origin);
  307.     set_pev(ent, pev_origin, origin);
  308.     set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN);
  309.     dllfunc(DLLFunc_Spawn, ent);
  310.    
  311.     new save = pev(ent, pev_solid);
  312.     dllfunc(DLLFunc_Touch, ent, index);
  313.     if (pev(ent, pev_solid) != save)
  314.         return ent;
  315.    
  316.     engfunc(EngFunc_RemoveEntity, ent);
  317.    
  318.     return -1;
  319. }
  320.  
  321. stock fm_set_rendering(entity, fx = kRenderFxNone, r = 255, g = 255, b = 255, render = kRenderNormal, amount = 16)
  322. {
  323.     new Float:RenderColor[3];
  324.     RenderColor[0] = float(r);
  325.     RenderColor[1] = float(g);
  326.     RenderColor[2] = float(b);
  327.    
  328.     set_pev(entity, pev_renderfx, fx);
  329.     set_pev(entity, pev_rendercolor, RenderColor);
  330.     set_pev(entity, pev_rendermode, render);
  331.     set_pev(entity, pev_renderamt, float(amount));
  332.    
  333.     return 1;
  334. }
  335.  
  336. stock fm_strip_user_weapons(index)
  337. {
  338.     new ent = fm_create_entity("player_weaponstrip");
  339.     if (!pev_valid(ent))
  340.         return 0;
  341.    
  342.     dllfunc(DLLFunc_Spawn, ent);
  343.     dllfunc(DLLFunc_Use, ent, index);
  344.     engfunc(EngFunc_RemoveEntity, ent);
  345.    
  346.     return 1;
  347. }
  348.  
  349. stock fm_find_ent_by_owner(index, const classname[], owner, jghgtype = 0)
  350. {
  351.     new strtype[11] = "classname", ent = index;
  352.     switch (jghgtype)
  353.     {
  354.         case 1: strtype = "target";
  355.         case 2: strtype = "targetname";
  356.     }
  357.    
  358.     while ((ent = engfunc(EngFunc_FindEntityByString, ent, strtype, classname)) && pev(ent, pev_owner) != owner) {}
  359.    
  360.     return ent;
  361. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement