Convert PIpe bomb

Unpaid Requests, Public Plugins
Post Reply
SobekPogrywamy
Member
Member
Poland
Posts: 24
Joined: 3 years ago
Contact:

Convert PIpe bomb

#1

Post by SobekPogrywamy » 3 years ago

Hello, can you convert this plugin into compatible with ur mod?

1, Need this item instead of a smokegranade
(hegrandae - fire
flash - frost
smoke - pipebomb)

2. second plugin - EXtra item PIPE

Im didnt need a mentalshield only a grenade
sry for my english ;v
  1. /*
  2.     -*- [ZP] Extra Item: Pipe Bomb -*-
  3.    
  4.     -*- Author: 4eRT -*-
  5.    
  6.     -*- About -*-
  7. This plugin is another extra item for Zombie Plague.
  8. It works like Pipe Bomb in Left 4 Dead.
  9.  
  10.     -*- Description -*-
  11. Plugin includes 2 extras: Pipe Bomb for Humans which
  12. drags zombies to nade on ground and then kills them
  13. (or hurts) and Mental Shield for Zombies which can
  14. block Pipe Bombs. All setting can be configured
  15. through the cvars.
  16.  
  17.     -*- Credits -*-
  18. MeRcyLeZZ - Great thanks for your ZP mode!!!
  19. frk_14 & Koshak - for pipe models
  20. crazyeffect - multilingual
  21. meTaLiCroSS - for optimization
  22.  
  23.     -*- Cvars -*-
  24.     Pipe Bomb:
  25. zp_pipe_enabled 1 // 0=off plugin 1=on
  26. zp_pipe_radius 200 // radius of pipe bomb area def=200
  27. zp_pipe_duration 10 // time before pipe explodes def=10
  28. zp_pipe_cost 15 // extras cost def=15
  29. zp_pipe_mode 1 // 1=hook zombies to nade and then make them super damage 2=hook zombies to nade and hurt them at the same time def=1
  30. zp_pipe_speed 90.0 // speed at which drags zombies def=80.0
  31. zp_pipe_damage 2200 // damage given to zombies def=2200
  32. zp_pipe_shake 1 // 1=shake zombies screen 0=not def=1
  33. zp_pipe_sound 1 //1=enable beep pipe sound 0=off def=1
  34. zp_pipe_hud 1 // 1=enable hud messages 0=off def=1
  35. zp_pipe_ap 0 // additional ammo packs if you killed zombie by Pipe
  36.     Mental Shield:
  37. zp_mshield_enabled 1 // 1=on plugin 0=off
  38. zp_mshield_cost 7 // extras cost def=7
  39. zp_mshield_hud 1 // 1=enable hud 0=off def=1
  40.  
  41.     -*- Modules -*-
  42. fakemeta
  43. hamsandwich
  44. engine
  45. fun
  46. cstrike
  47.  
  48.     -*- History -*-
  49. 0.1b (23.01.10)
  50. First release.
  51. 0.2b (24.01.10)
  52. Fixed some mistakes.
  53. 0.3b (24.01.10)
  54. Added models.
  55. 0.4b (25.01.10)
  56. Model bugs fixed.
  57. */
  58.  
  59. #include <amxmodx>
  60. #include <fakemeta>
  61. #include <hamsandwich>
  62. #include <engine>
  63. #include <zombieplague>
  64. #include <fun>
  65. #include <cstrike>
  66.  
  67. #define VERSION "0.4b"
  68.  
  69. const m_pPlayer = 41;
  70. new const NADE_TYPE_PIPE = 4327;
  71. new const NADE_DURATION_PIPE = pev_flSwimTime;
  72. new const g_trailspr[] ="sprites/laserbeam.spr";
  73. new const g_ringspr[] = "sprites/shockwave.spr";
  74. new const g_firespr[] = "sprites/zerogxplode.spr";
  75. new const g_sound[] = "items/pipe_beep.wav";
  76. new const g_vmodel[] = "models/zombie_plague/v_pipe.mdl";
  77. new const g_pmodel[] = "models/zombie_plague/p_pipe.mdl";
  78. new const g_wmodel[] = "models/zombie_plague/w_pipe.mdl";
  79. new const g_vflare[] = "models/zombie_plague/v_grenade_flare.mdl"; // type here your custom flare model to prevent bug. now uses default model
  80. new const g_extra_pipe[] = { "Pipe Bomb" };
  81. new const g_extra_shield[] = { "Mental Shield" };
  82. new cvar_duration, cvar_radius, cvar_enabled, cvar_sound, cvar_cost, cvar_mode, cvar_hud, cvar_damage, cvar_speed, cvar_shake, cvar_Scost, cvar_Senabled, cvar_Shud, cvar_extraap; // some cvars
  83. new g_msgsync, g_trail, g_ring, g_fire, g_score, g_death, g_shake, g_pipe, bool: g_has_pipe[33], bool: g_has_shield[33], g_mshield; // some vars
  84.  
  85. public plugin_init() {
  86.     register_plugin("[ZP] Extra: Pipe Bomb", VERSION, "4eRT");
  87.     register_forward(FM_SetModel,"fw_SetModel", 1);
  88.     register_dictionary("zp_extra_pipe.txt");
  89.     RegisterHam(Ham_Think, "grenade", "fw_ThinkGren");
  90.     RegisterHam(Ham_Spawn, "player", "fw_Spawn");
  91.     RegisterHam(Ham_Item_Deploy, "weapon_smokegrenade", "fw_smDeploy", 1);
  92.    
  93.     // Cvars
  94.     cvar_duration = register_cvar("zp_pipe_duration", "10");
  95.     cvar_radius = register_cvar ( "zp_pipe_radius", "200");
  96.     cvar_enabled = register_cvar("zp_pipe_enabled", "1");
  97.     cvar_cost = register_cvar("zp_pipe_cost", "15");
  98.     cvar_mode = register_cvar("zp_pipe_mode", "1");
  99.     cvar_sound = register_cvar("zp_pipe_sound", "1");
  100.     cvar_hud = register_cvar("zp_pipe_hud", "1");
  101.     cvar_damage = register_cvar("zp_pipe_damage", "2200");
  102.     cvar_speed = register_cvar("zp_pipe_speed", "90.0");
  103.     cvar_shake = register_cvar("zp_pipe_shake", "1");
  104.     cvar_extraap = register_cvar("zp_pipe_ap", "0");
  105.     cvar_Scost = register_cvar("zp_mshield_cost", "7");
  106.     cvar_Senabled = register_cvar("zp_mshield_enabled", "1");
  107.     cvar_Shud = register_cvar("zp_mshield_hud", "1");
  108.    
  109.     // Registering extra items
  110.     if(get_pcvar_num(cvar_enabled))
  111.         g_pipe = zp_register_extra_item(g_extra_pipe, get_pcvar_num(cvar_cost), ZP_TEAM_HUMAN);
  112.    
  113.     if(get_pcvar_num(cvar_Senabled))
  114.         g_mshield = zp_register_extra_item(g_extra_shield, get_pcvar_num(cvar_Scost), ZP_TEAM_ZOMBIE);
  115.    
  116.     g_msgsync = CreateHudSyncObj();
  117.     g_score = get_user_msgid("ScoreInfo");
  118.     g_death = get_user_msgid("DeathMsg");
  119.     g_shake = get_user_msgid("ScreenShake");
  120. }
  121.  
  122. public plugin_precache() {
  123.     precache_model(g_vmodel);
  124.     precache_model(g_pmodel);
  125.     precache_model(g_wmodel);
  126.     precache_model(g_vflare);
  127.     precache_sound(g_sound);
  128.     g_fire = precache_model(g_firespr);
  129.     g_trail = precache_model(g_trailspr);
  130.     g_ring = precache_model(g_ringspr);
  131. }
  132.  
  133. public replace_models(id)
  134. {
  135.     if(get_user_weapon(id) == CSW_SMOKEGRENADE)
  136.     {
  137.         set_pev(id, pev_viewmodel2, g_vmodel);
  138.         set_pev(id, pev_weaponmodel2, g_pmodel);
  139.     }
  140. }
  141.  
  142. public replace_models2(id)
  143.     if(get_user_weapon(id) == CSW_SMOKEGRENADE)
  144.         set_pev(id, pev_viewmodel2, g_vflare);
  145.  
  146. public fw_smDeploy(const iEntity)
  147. {
  148.     if(pev_valid(iEntity) != 2)
  149.         return HAM_IGNORED;
  150.    
  151.     new id = get_pdata_cbase(iEntity, m_pPlayer, 4);
  152.    
  153.     if(g_has_pipe[id] && !zp_get_user_zombie(id) && is_user_alive(id))
  154.     {
  155.         set_pev(id, pev_viewmodel2, g_vmodel);
  156.         set_pev(id, pev_weaponmodel2, g_pmodel);
  157.     }
  158.    
  159.     return HAM_IGNORED;
  160. }
  161.  
  162. public zp_extra_item_selected(id, item)
  163. {
  164.     if(item == g_pipe)
  165.     {
  166.         if(!get_pcvar_num(cvar_enabled))
  167.         {
  168.             client_print(id, print_chat, "[ZP] %L", id, "DISABLED");
  169.             return ZP_PLUGIN_HANDLED;
  170.         }
  171.        
  172.         if(g_has_pipe[id])
  173.         {
  174.             if(get_pcvar_num(cvar_hud) == 1)
  175.             {
  176.                 set_hudmessage(255, 0, 0, -1.0, 0.55, 0, 0.0, 2.0, 2.0, 1.0, -1);
  177.                 ShowSyncHudMsg(id, g_msgsync, "%L", id, "ALREADY");
  178.             }
  179.             else
  180.                 client_print(id, print_chat, "[ZP] %L", id, "ALREADY");
  181.    
  182.             return ZP_PLUGIN_HANDLED;
  183.         }
  184.    
  185.         g_has_pipe[id] = true;
  186.         new was = cs_get_user_bpammo(id, CSW_SMOKEGRENADE);
  187.  
  188.         if(was >= 1)
  189.             cs_set_user_bpammo(id, CSW_SMOKEGRENADE, was + 1);
  190.         else
  191.             give_item(id, "weapon_smokegrenade");
  192.        
  193.         replace_models(id);
  194.        
  195.         if(get_pcvar_num(cvar_hud) == 1)
  196.         {
  197.             new msg[32], hud = random_num(0, 1);
  198.    
  199.             if(hud == 0)
  200.                 formatex(msg, 31, "%L", id, "DANGEROUS");
  201.             else
  202.                 formatex(msg, 31, "%L", id, "GO_EXPLOSIVE");
  203.    
  204.             set_hudmessage(255, 0, 0, -1.0, 0.55, 0, 0.0, 3.0, 2.0, 1.0, -1);
  205.             ShowSyncHudMsg(id, g_msgsync, "%s", msg);
  206.         }
  207.     }
  208.    
  209.     if(item == g_mshield)
  210.     {
  211.         if(!get_pcvar_num(cvar_Senabled))
  212.         {
  213.             client_print(id, print_chat, "[ZP] %L", id, "MS_DISABLED");
  214.             return ZP_PLUGIN_HANDLED;
  215.         }
  216.        
  217.         if(g_has_shield[id])
  218.         {
  219.             if(get_pcvar_num(cvar_Shud))
  220.             {
  221.                 set_hudmessage(255, 0, 0, -1.0, 0.55, 0, 0.0, 2.0, 2.0, 1.0, -1);
  222.                 ShowSyncHudMsg(id, g_msgsync, "%L", id, "ALREADY");
  223.             }
  224.             else
  225.                 client_print(id, print_chat, "[ZP] %L", id, "ALREADY");
  226.        
  227.             return ZP_PLUGIN_HANDLED;
  228.         }
  229.    
  230.         g_has_shield[id] = true;
  231.    
  232.         if(get_pcvar_num(cvar_Shud))
  233.         {
  234.             set_hudmessage(255, 0, 0, -1.0, 0.55, 0, 0.0, 3.0, 2.0, 1.0, -1);
  235.             ShowSyncHudMsg(id, g_msgsync, "%L", id, "PROTECTED");
  236.         }
  237.         else
  238.             client_print(id, print_chat, "[ZP] %L", id, "PROTECTED");
  239.     }
  240.    
  241.     return PLUGIN_CONTINUE;
  242. }
  243.  
  244. public zp_user_infected_post(id)
  245. {
  246.     g_has_pipe[id] = false;
  247.     g_has_shield[id] = false;
  248. }
  249.        
  250. public fw_Spawn(id)
  251. {
  252.     g_has_pipe[id] = false;
  253.     g_has_shield[id] = false;
  254. }
  255.  
  256. public fw_SetModel(entity, const model[]) // Set smokegrenade pipes effects and type
  257. {
  258.     static Float:dmgtime, owner;
  259.     pev(entity, pev_dmgtime, dmgtime);
  260.     owner = pev(entity, pev_owner);
  261.    
  262.     if(!pev_valid(entity) || dmgtime == 0.0)
  263.         return FMRES_IGNORED;
  264.    
  265.     if (model[9] == 's' && model[10] == 'm' && g_has_pipe[owner])
  266.     {
  267.         g_has_pipe[owner] = false;
  268.         entity_set_model(entity, g_wmodel);
  269.         replace_models2(owner);
  270.        
  271.         set_rendering(entity, kRenderFxGlowShell, 128, 0, 0, kRenderNormal, 16);
  272.        
  273.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  274.         write_byte(TE_BEAMFOLLOW) // TE id
  275.         write_short(entity) // entity
  276.         write_short(g_trail) // sprite
  277.         write_byte(10) // life
  278.         write_byte(10) // width
  279.         write_byte(128) // r
  280.         write_byte(0) // g
  281.         write_byte(0) // b
  282.         write_byte(255) // brightness
  283.         message_end()
  284.        
  285.         set_pev(entity, pev_flTimeStepSound, NADE_TYPE_PIPE);
  286.        
  287.         return FMRES_SUPERCEDE;
  288.     }
  289.    
  290.     return FMRES_IGNORED;
  291. }
  292.  
  293. public fw_ThinkGren(entity) // Grenade think event
  294. {
  295.     if (!pev_valid(entity))
  296.         return HAM_IGNORED;
  297.    
  298.     static Float:dmgtime, Float: current_time, attacker;
  299.     pev(entity, pev_dmgtime, dmgtime);
  300.     current_time = get_gametime();
  301.     attacker = pev(entity, pev_owner);
  302.    
  303.     if(dmgtime > current_time)
  304.         return HAM_IGNORED;
  305.    
  306.     if(pev(entity, pev_flTimeStepSound) == NADE_TYPE_PIPE)
  307.     {
  308.         static duration;
  309.         duration = pev(entity, NADE_DURATION_PIPE);
  310.        
  311.         if (duration > 0)
  312.         {
  313.             new Float:originF[3]
  314.             pev(entity, pev_origin, originF);
  315.            
  316.             if (duration == 1)
  317.             {
  318.                 remove_task(entity);
  319.                 effect(originF);
  320.                
  321.                 if (get_pcvar_num(cvar_mode) == 1)
  322.                     kill(originF, attacker);
  323.                
  324.                 engfunc(EngFunc_RemoveEntity, entity);
  325.                 return HAM_SUPERCEDE;
  326.             }
  327.            
  328.             light(originF, duration);
  329.             set_task(0.1, "hook", entity, _, _, "b");
  330.            
  331.             if(get_pcvar_num(cvar_mode) == 2)
  332.                 set_task(1.0, "hurt", entity, _, _, "b");
  333.                
  334.             if(get_pcvar_num(cvar_sound))
  335.             {
  336.                 if(duration == 2)
  337.                     set_task(0.1, "beep", entity, _, _, "b");
  338.                 else
  339.                     emit_sound(entity, CHAN_WEAPON, g_sound, 1.0, ATTN_NORM, 0, PITCH_HIGH);
  340.             }
  341.            
  342.             set_pev(entity, NADE_DURATION_PIPE, --duration);
  343.             set_pev(entity, pev_dmgtime, current_time + 3.0);
  344.         } else if ((pev(entity, pev_flags) & FL_ONGROUND) && get_speed(entity) < 10)
  345.         {
  346.             set_pev(entity, NADE_DURATION_PIPE, 1 + get_pcvar_num(cvar_duration)/3);
  347.             set_pev(entity, pev_dmgtime, current_time + 0.1);
  348.         } else
  349.             set_pev(entity, pev_dmgtime, current_time + 0.5);
  350.     }
  351.    
  352.     return HAM_IGNORED;
  353. }
  354.  
  355. public beep(entity) // Plays loop beep sound before explosion
  356. {
  357.     //Bugfix
  358.     if (!pev_valid(entity))
  359.     {
  360.         remove_task(entity);
  361.         return;
  362.     }
  363.    
  364.     emit_sound(entity, CHAN_WEAPON, g_sound, 1.0, ATTN_NORM, 0, PITCH_HIGH);
  365. }
  366.  
  367. public hook(entity) // Magnet func. Hooks zombies to nade
  368. {
  369.     //Bugfix
  370.     if (!pev_valid(entity))
  371.     {
  372.         remove_task(entity);
  373.         return;
  374.     }
  375.    
  376.     static Float:originF[3], Float:radius, victim = -1;
  377.     radius = get_pcvar_float(cvar_radius);
  378.     pev(entity, pev_origin, originF);
  379.    
  380.     while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, radius)) != 0)
  381.     {
  382.         if (!is_user_alive(victim) || !zp_get_user_zombie(victim) || g_has_shield[victim])
  383.             continue;
  384.  
  385.         new Float:fl_Velocity[3];
  386.         new vicOrigin[3], originN[3];
  387.  
  388.         get_user_origin(victim, vicOrigin);
  389.         originN[0] = floatround(originF[0]);
  390.         originN[1] = floatround(originF[1]);
  391.         originN[2] = floatround(originF[2]);
  392.        
  393.         new distance = get_distance(originN, vicOrigin);
  394.  
  395.         if (distance > 1)
  396.         {
  397.             new Float:fl_Time = distance / get_pcvar_float(cvar_speed);
  398.  
  399.             fl_Velocity[0] = (originN[0] - vicOrigin[0]) / fl_Time;
  400.             fl_Velocity[1] = (originN[1] - vicOrigin[1]) / fl_Time;
  401.             fl_Velocity[2] = (originN[2] - vicOrigin[2]) / fl_Time;
  402.         } else
  403.         {
  404.             fl_Velocity[0] = 0.0
  405.             fl_Velocity[1] = 0.0
  406.             fl_Velocity[2] = 0.0
  407.         }
  408.  
  409.         entity_set_vector(victim, EV_VEC_velocity, fl_Velocity);
  410.        
  411.         if(get_pcvar_num(cvar_shake))
  412.         {
  413.             message_begin(MSG_ONE_UNRELIABLE, g_shake, _, victim)
  414.             write_short(1<<14) // amplitude
  415.             write_short(1<<14) // duration
  416.             write_short(1<<14) // frequency
  417.             message_end()
  418.         }
  419.     }
  420. }
  421.  
  422. public hurt(entity) // Hurts zombies if mode = 2
  423. {
  424.     //Bugfix
  425.     if (!pev_valid(entity))
  426.     {
  427.         remove_task(entity);
  428.         return;
  429.     }
  430.    
  431.     static Float:originF[3], Float:radius, victim = -1;
  432.     radius = get_pcvar_float(cvar_radius)/2.0;
  433.     pev(entity, pev_origin, originF);
  434.    
  435.     while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, radius)) != 0)
  436.     {
  437.         if (!is_user_alive(victim) || !zp_get_user_zombie(victim) || g_has_shield[victim])
  438.             continue;
  439.        
  440.         new Float:dam = get_pcvar_float(cvar_damage);
  441.        
  442.         if(get_user_health(victim) - get_pcvar_float(cvar_damage) > 0)
  443.             fakedamage(victim, "Pipe Bomb", dam, 256);
  444.     }
  445. }
  446.  
  447. public kill(const Float:originF[3], attacker) // Kills zombies in radius / 2 if mode = 1
  448. {
  449.     static Float:radius, victim = -1;
  450.     radius = get_pcvar_float(cvar_radius) / 2.0;
  451.    
  452.     while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, radius)) != 0)
  453.     {
  454.         if (!is_user_alive(victim) || !zp_get_user_zombie(victim) || g_has_shield[victim])
  455.             continue;
  456.        
  457.         new Float:dam = get_pcvar_float(cvar_damage);
  458.         set_msg_block(g_death, BLOCK_SET);
  459.         fakedamage(victim, "Pipe Bomb", dam, 256);
  460.         set_msg_block(g_death, BLOCK_NOT);
  461.        
  462.         if(get_user_health(victim) <= 0)
  463.         {
  464.             SendDeathMsg(attacker, victim);
  465.            
  466.             if(victim != attacker && !zp_get_user_zombie(attacker))
  467.                 UpdateFrags(attacker, 1, 1);
  468.             else
  469.                 UpdateFrags(attacker, -1, 1);
  470.         }
  471.     }
  472. }
  473.  
  474. public light(const Float:originF[3], duration)  // Blast ring and small red light around nade from zombie_plague40.sma. Great thx, MeRcyLeZZ!!! ;)
  475. {
  476.     // Lighting
  477.     engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, originF, 0);
  478.     write_byte(TE_DLIGHT); // TE id
  479.     engfunc(EngFunc_WriteCoord, originF[0]); // x
  480.     engfunc(EngFunc_WriteCoord, originF[1]); // y
  481.     engfunc(EngFunc_WriteCoord, originF[2]); // z
  482.     write_byte(5); // radius
  483.     write_byte(128); // r
  484.     write_byte(0); // g
  485.     write_byte(0); // b
  486.     write_byte(51); //life
  487.     write_byte((duration < 2) ? 3 : 0); //decay rate
  488.     message_end();
  489.    
  490.     // Smallest ring
  491.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  492.     write_byte(TE_BEAMCYLINDER) // TE id
  493.     engfunc(EngFunc_WriteCoord, originF[0]) // x
  494.     engfunc(EngFunc_WriteCoord, originF[1]) // y
  495.     engfunc(EngFunc_WriteCoord, originF[2]) // z
  496.     engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  497.     engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  498.     engfunc(EngFunc_WriteCoord, originF[2]+385.0) // z axis
  499.     write_short(g_ring) // sprite
  500.     write_byte(0) // startframe
  501.     write_byte(0) // framerate
  502.     write_byte(4) // life
  503.     write_byte(60) // width
  504.     write_byte(0) // noise
  505.     write_byte(128) // red
  506.     write_byte(0) // green
  507.     write_byte(0) // blue
  508.     write_byte(200) // brightness
  509.     write_byte(0) // speed
  510.     message_end()
  511.    
  512.     // Medium ring
  513.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  514.     write_byte(TE_BEAMCYLINDER) // TE id
  515.     engfunc(EngFunc_WriteCoord, originF[0]) // x
  516.     engfunc(EngFunc_WriteCoord, originF[1]) // y
  517.     engfunc(EngFunc_WriteCoord, originF[2]) // z
  518.     engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  519.     engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  520.     engfunc(EngFunc_WriteCoord, originF[2]+470.0) // z axis
  521.     write_short(g_ring) // sprite
  522.     write_byte(0) // startframe
  523.     write_byte(0) // framerate
  524.     write_byte(4) // life
  525.     write_byte(60) // width
  526.     write_byte(0) // noise
  527.     write_byte(128) // red
  528.     write_byte(0) // green
  529.     write_byte(0) // blue
  530.     write_byte(200) // brightness
  531.     write_byte(0) // speed
  532.     message_end()
  533.    
  534.     // Largest ring
  535.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  536.     write_byte(TE_BEAMCYLINDER) // TE id
  537.     engfunc(EngFunc_WriteCoord, originF[0]) // x
  538.     engfunc(EngFunc_WriteCoord, originF[1]) // y
  539.     engfunc(EngFunc_WriteCoord, originF[2]) // z
  540.     engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  541.     engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  542.     engfunc(EngFunc_WriteCoord, originF[2]+555.0) // z axis
  543.     write_short(g_ring) // sprite
  544.     write_byte(0) // startframe
  545.     write_byte(0) // framerate
  546.     write_byte(4) // life
  547.     write_byte(60) // width
  548.     write_byte(0) // noise
  549.     write_byte(128) // red
  550.     write_byte(0) // green
  551.     write_byte(0) // blue
  552.     write_byte(200) // brightness
  553.     write_byte(0) // speed
  554.     message_end()
  555. }
  556.  
  557. public effect(const Float:originF[3]) // Explosion effect
  558. {
  559.     // Largest ring
  560.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  561.     write_byte(TE_BEAMCYLINDER) // TE id
  562.     engfunc(EngFunc_WriteCoord, originF[0]) // x
  563.     engfunc(EngFunc_WriteCoord, originF[1]) // y
  564.     engfunc(EngFunc_WriteCoord, originF[2]) // z
  565.     engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  566.     engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  567.     engfunc(EngFunc_WriteCoord, originF[2]+555.0) // z axis
  568.     write_short(g_ring) // sprite
  569.     write_byte(0) // startframe
  570.     write_byte(0) // framerate
  571.     write_byte(4) // life
  572.     write_byte(60) // width
  573.     write_byte(0) // noise
  574.     write_byte(128) // red
  575.     write_byte(0) // green
  576.     write_byte(0) // blue
  577.     write_byte(200) // brightness
  578.     write_byte(0) // speed
  579.     message_end()
  580.    
  581.     // Explosion sprite
  582.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  583.     write_byte(TE_EXPLOSION)
  584.     engfunc(EngFunc_WriteCoord, originF[0])
  585.     engfunc(EngFunc_WriteCoord, originF[1])
  586.     engfunc(EngFunc_WriteCoord, originF[2])
  587.     write_short(g_fire) //sprite index
  588.     write_byte(25) // scale in 0.1's
  589.     write_byte(10) // framerate
  590.     write_byte(0) // flags
  591.     message_end()
  592. }
  593.  
  594. UpdateFrags(attacker, frags, scoreboard) // Updates attacker frags
  595. {
  596.     // Set attacker frags
  597.     set_pev(attacker, pev_frags, float(pev(attacker, pev_frags) + frags))
  598.    
  599.     if(get_pcvar_num(cvar_extraap) > 0)
  600.         zp_set_user_ammo_packs(attacker, zp_get_user_ammo_packs(attacker) + get_pcvar_num(cvar_extraap));
  601.        
  602.     // Update scoreboard with attacker and victim info
  603.     if (scoreboard)
  604.     {
  605.         message_begin(MSG_BROADCAST, g_score)
  606.         write_byte(attacker) // id
  607.         write_short(pev(attacker, pev_frags)) // frags
  608.         write_short(get_user_deaths(attacker)) // deaths
  609.         write_short(0) // class?
  610.         write_short(get_user_team(attacker)) // team
  611.         message_end()
  612.     }
  613. }
  614.  
  615. SendDeathMsg(attacker, victim) // Sends death message
  616. {
  617.     message_begin(MSG_BROADCAST, g_death)
  618.     write_byte(attacker) // killer
  619.     write_byte(victim) // victim
  620.     write_byte(0) // headshot flag
  621.     write_string("Pipe Bomb") // killer's weapon
  622.     message_end()
  623. }
  624. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  625. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
  626. */

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#2

Post by Raheem » 3 years ago

Hello, this is it as extra-item:
    1. /*
    2.     -*- [ZE] Extra Item: Pipe Bomb -*-
    3.    
    4.     -*- Author: 4eRT -*-
    5.    
    6.     -*- About -*-
    7. This plugin is another extra item for Zombie Plague.
    8. It works like Pipe Bomb in Left 4 Dead.
    9.  
    10.     -*- Description -*-
    11. Plugin includes 2 extras: Pipe Bomb for Humans which
    12. drags zombies to nade on ground and then kills them
    13. (or hurts) and Mental Shield for Zombies which can
    14. block Pipe Bombs. All setting can be configured
    15. through the cvars.
    16.  
    17.     -*- Credits -*-
    18. MeRcyLeZZ - Great thanks for your ZP mode!!!
    19. frk_14 & Koshak - for pipe models
    20. crazyeffect - multilingual
    21. meTaLiCroSS - for optimization
    22.  
    23.     -*- Cvars -*-
    24.     Pipe Bomb:
    25. zp_pipe_enabled 1 // 0=off plugin 1=on
    26. zp_pipe_radius 200 // radius of pipe bomb area def=200
    27. zp_pipe_duration 10 // time before pipe explodes def=10
    28. zp_pipe_cost 15 // extras cost def=15
    29. zp_pipe_mode 1 // 1=hook zombies to nade and then make them super damage 2=hook zombies to nade and hurt them at the same time def=1
    30. zp_pipe_speed 90.0 // speed at which drags zombies def=80.0
    31. zp_pipe_damage 2200 // damage given to zombies def=2200
    32. zp_pipe_shake 1 // 1=shake zombies screen 0=not def=1
    33. zp_pipe_sound 1 //1=enable beep pipe sound 0=off def=1
    34. zp_pipe_hud 1 // 1=enable hud messages 0=off def=1
    35. zp_pipe_ap 0 // additional ammo packs if you killed zombie by Pipe
    36.     Mental Shield:
    37. zp_mshield_enabled 1 // 1=on plugin 0=off
    38. zp_mshield_cost 7 // extras cost def=7
    39. zp_mshield_hud 1 // 1=enable hud 0=off def=1
    40.  
    41.     -*- Modules -*-
    42. fakemeta
    43. hamsandwich
    44. engine
    45. fun
    46. cstrike
    47.  
    48.     -*- History -*-
    49. 0.1b (23.01.10)
    50. First release.
    51. 0.2b (24.01.10)
    52. Fixed some mistakes.
    53. 0.3b (24.01.10)
    54. Added models.
    55. 0.4b (25.01.10)
    56. Model bugs fixed.
    57. */
    58.  
    59. #include <zombie_escape>
    60. #include <engine>
    61. #include <fun>
    62. #include <cstrike>
    63.  
    64. #define VERSION "0.4b"
    65.  
    66. const m_pPlayer = 41;
    67. new const NADE_TYPE_PIPE = 4327;
    68. new const NADE_DURATION_PIPE = pev_flSwimTime;
    69. new const g_trailspr[] ="sprites/laserbeam.spr";
    70. new const g_ringspr[] = "sprites/shockwave.spr";
    71. new const g_firespr[] = "sprites/zerogxplode.spr";
    72. new const g_sound[] = "items/pipe_beep.wav";
    73. new const g_vmodel[] = "models/zombie_plague/v_pipe.mdl";
    74. new const g_pmodel[] = "models/zombie_plague/p_pipe.mdl";
    75. new const g_wmodel[] = "models/zombie_plague/w_pipe.mdl";
    76. new const g_vflare[] = "models/zombie_plague/v_grenade_flare.mdl"; // type here your custom flare model to prevent bug. now uses default model
    77. new const g_extra_pipe[] = { "Pipe Bomb" };
    78. new const g_extra_shield[] = { "Mental Shield" };
    79. new cvar_duration, cvar_radius, cvar_enabled, cvar_sound, cvar_cost, cvar_mode, cvar_hud, cvar_damage, cvar_speed, cvar_shake, cvar_Scost, cvar_Senabled, cvar_Shud, cvar_extraap; // some cvars
    80. new g_msgsync, g_trail, g_ring, g_fire, g_score, g_death, g_shake, g_pipe, bool: g_has_pipe[33], bool: g_has_shield[33], g_mshield; // some vars
    81.  
    82. public plugin_init() {
    83.     register_plugin("[ZP] Extra: Pipe Bomb", VERSION, "4eRT");
    84.     register_forward(FM_SetModel,"fw_SetModel", 1);
    85.     register_dictionary("zp_extra_pipe.txt");
    86.     RegisterHam(Ham_Think, "grenade", "fw_ThinkGren");
    87.     RegisterHam(Ham_Spawn, "player", "fw_Spawn");
    88.     RegisterHam(Ham_Item_Deploy, "weapon_smokegrenade", "fw_smDeploy", 1);
    89.    
    90.     // Cvars
    91.     cvar_duration = register_cvar("ze_pipe_duration", "10");
    92.     cvar_radius = register_cvar ( "ze_pipe_radius", "200");
    93.     cvar_enabled = register_cvar("ze_pipe_enabled", "1");
    94.     cvar_cost = register_cvar("ze_pipe_cost", "15");
    95.     cvar_mode = register_cvar("ze_pipe_mode", "1");
    96.     cvar_sound = register_cvar("ze_pipe_sound", "1");
    97.     cvar_hud = register_cvar("ze_pipe_hud", "1");
    98.     cvar_damage = register_cvar("ze_pipe_damage", "2200");
    99.     cvar_speed = register_cvar("ze_pipe_speed", "90.0");
    100.     cvar_shake = register_cvar("ze_pipe_shake", "1");
    101.     cvar_extraap = register_cvar("ze_pipe_ap", "0");
    102.     cvar_Scost = register_cvar("ze_mshield_cost", "7");
    103.     //cvar_Senabled = register_cvar("zp_mshield_enabled", "1");
    104.     cvar_Shud = register_cvar("ze_mshield_hud", "1");
    105.    
    106.     // Registering extra items
    107.     if(get_pcvar_num(cvar_enabled))
    108.         g_pipe = ze_register_item(g_extra_pipe, get_pcvar_num(cvar_cost), 0);
    109.    
    110.    // if(get_pcvar_num(cvar_Senabled))
    111.        // g_mshield = zp_register_extra_item(g_extra_shield, get_pcvar_num(cvar_Scost), ZP_TEAM_ZOMBIE);
    112.    
    113.     g_msgsync = CreateHudSyncObj();
    114.     g_score = get_user_msgid("ScoreInfo");
    115.     g_death = get_user_msgid("DeathMsg");
    116.     g_shake = get_user_msgid("ScreenShake");
    117. }
    118.  
    119. public plugin_precache() {
    120.     precache_model(g_vmodel);
    121.     precache_model(g_pmodel);
    122.     precache_model(g_wmodel);
    123.     precache_model(g_vflare);
    124.     precache_sound(g_sound);
    125.     g_fire = precache_model(g_firespr);
    126.     g_trail = precache_model(g_trailspr);
    127.     g_ring = precache_model(g_ringspr);
    128. }
    129.  
    130. public replace_models(id)
    131. {
    132.     if(get_user_weapon(id) == CSW_SMOKEGRENADE)
    133.     {
    134.         set_pev(id, pev_viewmodel2, g_vmodel);
    135.         set_pev(id, pev_weaponmodel2, g_pmodel);
    136.     }
    137. }
    138.  
    139. public replace_models2(id)
    140.     if(get_user_weapon(id) == CSW_SMOKEGRENADE)
    141.         set_pev(id, pev_viewmodel2, g_vflare);
    142.  
    143. public fw_smDeploy(const iEntity)
    144. {
    145.     if(pev_valid(iEntity) != 2)
    146.         return HAM_IGNORED;
    147.    
    148.     new id = get_pdata_cbase(iEntity, m_pPlayer, 4);
    149.    
    150.     if(g_has_pipe[id] && !ze_is_user_zombie(id) && is_user_alive(id))
    151.     {
    152.         set_pev(id, pev_viewmodel2, g_vmodel);
    153.         set_pev(id, pev_weaponmodel2, g_pmodel);
    154.     }
    155.    
    156.     return HAM_IGNORED;
    157. }
    158.  
    159. public ze_select_item_pre(id, itemid)
    160. {
    161.     // Return Available and we will block it in Post, So it dosen't affect other plugins
    162.     if (itemid != g_pipe)
    163.         return ZE_ITEM_AVAILABLE;
    164.    
    165.     // Available for Humans only, So don't show it for zombies
    166.     if (ze_is_user_zombie(id))
    167.         return ZE_ITEM_DONT_SHOW;
    168.    
    169.     return ZE_ITEM_AVAILABLE;
    170. }
    171.  
    172. public ze_select_item_post(id, itemid)
    173. {
    174.     // This is not our item, Block it here
    175.     if (itemid != g_pipe)
    176.         return;
    177.    
    178.     if(!get_pcvar_num(cvar_enabled))
    179.     {
    180.         client_print(id, print_chat, "[ZE] %L", id, "DISABLED");
    181.         return;
    182.     }
    183.    
    184.     if(g_has_pipe[id])
    185.     {
    186.         if(get_pcvar_num(cvar_hud) == 1)
    187.         {
    188.             set_hudmessage(255, 0, 0, -1.0, 0.55, 0, 0.0, 2.0, 2.0, 1.0, -1);
    189.             ShowSyncHudMsg(id, g_msgsync, "%L", id, "ALREADY");
    190.         }
    191.         else
    192.             client_print(id, print_chat, "[ZE] %L", id, "ALREADY");
    193.  
    194.         return;
    195.     }
    196.  
    197.     g_has_pipe[id] = true;
    198.     new was = cs_get_user_bpammo(id, CSW_SMOKEGRENADE);
    199.  
    200.     if(was >= 1)
    201.         cs_set_user_bpammo(id, CSW_SMOKEGRENADE, was + 1);
    202.     else
    203.         give_item(id, "weapon_smokegrenade");
    204.    
    205.     replace_models(id);
    206.    
    207.     if(get_pcvar_num(cvar_hud) == 1)
    208.     {
    209.         new msg[32], hud = random_num(0, 1);
    210.  
    211.         if(hud == 0)
    212.             formatex(msg, 31, "%L", id, "DANGEROUS");
    213.         else
    214.             formatex(msg, 31, "%L", id, "GO_EXPLOSIVE");
    215.  
    216.         set_hudmessage(255, 0, 0, -1.0, 0.55, 0, 0.0, 3.0, 2.0, 1.0, -1);
    217.         ShowSyncHudMsg(id, g_msgsync, "%s", msg);
    218.     }
    219. }
    220.  
    221. public ze_user_infected(iVictim, iInfector)
    222. {
    223.     g_has_pipe[iVictim] = false;
    224.     g_has_shield[iVictim] = false;
    225. }
    226.        
    227. public fw_Spawn(id)
    228. {
    229.     g_has_pipe[id] = false;
    230.     g_has_shield[id] = false;
    231. }
    232.  
    233. public fw_SetModel(entity, const model[]) // Set smokegrenade pipes effects and type
    234. {
    235.     static Float:dmgtime, owner;
    236.     pev(entity, pev_dmgtime, dmgtime);
    237.     owner = pev(entity, pev_owner);
    238.    
    239.     if(!pev_valid(entity) || dmgtime == 0.0)
    240.         return FMRES_IGNORED;
    241.    
    242.     if (model[9] == 's' && model[10] == 'm' && g_has_pipe[owner])
    243.     {
    244.         g_has_pipe[owner] = false;
    245.         entity_set_model(entity, g_wmodel);
    246.         replace_models2(owner);
    247.        
    248.         set_rendering(entity, kRenderFxGlowShell, 128, 0, 0, kRenderNormal, 16);
    249.        
    250.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    251.         write_byte(TE_BEAMFOLLOW) // TE id
    252.         write_short(entity) // entity
    253.         write_short(g_trail) // sprite
    254.         write_byte(10) // life
    255.         write_byte(10) // width
    256.         write_byte(128) // r
    257.         write_byte(0) // g
    258.         write_byte(0) // b
    259.         write_byte(255) // brightness
    260.         message_end()
    261.        
    262.         set_pev(entity, pev_flTimeStepSound, NADE_TYPE_PIPE);
    263.        
    264.         return FMRES_SUPERCEDE;
    265.     }
    266.    
    267.     return FMRES_IGNORED;
    268. }
    269.  
    270. public fw_ThinkGren(entity) // Grenade think event
    271. {
    272.     if (!pev_valid(entity))
    273.         return HAM_IGNORED;
    274.    
    275.     static Float:dmgtime, Float: current_time, attacker;
    276.     pev(entity, pev_dmgtime, dmgtime);
    277.     current_time = get_gametime();
    278.     attacker = pev(entity, pev_owner);
    279.    
    280.     if(dmgtime > current_time)
    281.         return HAM_IGNORED;
    282.    
    283.     if(pev(entity, pev_flTimeStepSound) == NADE_TYPE_PIPE)
    284.     {
    285.         static duration;
    286.         duration = pev(entity, NADE_DURATION_PIPE);
    287.        
    288.         if (duration > 0)
    289.         {
    290.             new Float:originF[3]
    291.             pev(entity, pev_origin, originF);
    292.            
    293.             if (duration == 1)
    294.             {
    295.                 remove_task(entity);
    296.                 effect(originF);
    297.                
    298.                 if (get_pcvar_num(cvar_mode) == 1)
    299.                     kill(originF, attacker);
    300.                
    301.                 engfunc(EngFunc_RemoveEntity, entity);
    302.                 return HAM_SUPERCEDE;
    303.             }
    304.            
    305.             light(originF, duration);
    306.             set_task(0.1, "hook", entity, _, _, "b");
    307.            
    308.             if(get_pcvar_num(cvar_mode) == 2)
    309.                 set_task(1.0, "hurt", entity, _, _, "b");
    310.                
    311.             if(get_pcvar_num(cvar_sound))
    312.             {
    313.                 if(duration == 2)
    314.                     set_task(0.1, "beep", entity, _, _, "b");
    315.                 else
    316.                     emit_sound(entity, CHAN_WEAPON, g_sound, 1.0, ATTN_NORM, 0, PITCH_HIGH);
    317.             }
    318.            
    319.             set_pev(entity, NADE_DURATION_PIPE, --duration);
    320.             set_pev(entity, pev_dmgtime, current_time + 3.0);
    321.         } else if ((pev(entity, pev_flags) & FL_ONGROUND) && get_speed(entity) < 10)
    322.         {
    323.             set_pev(entity, NADE_DURATION_PIPE, 1 + get_pcvar_num(cvar_duration)/3);
    324.             set_pev(entity, pev_dmgtime, current_time + 0.1);
    325.         } else
    326.             set_pev(entity, pev_dmgtime, current_time + 0.5);
    327.     }
    328.    
    329.     return HAM_IGNORED;
    330. }
    331.  
    332. public beep(entity) // Plays loop beep sound before explosion
    333. {
    334.     //Bugfix
    335.     if (!pev_valid(entity))
    336.     {
    337.         remove_task(entity);
    338.         return;
    339.     }
    340.    
    341.     emit_sound(entity, CHAN_WEAPON, g_sound, 1.0, ATTN_NORM, 0, PITCH_HIGH);
    342. }
    343.  
    344. public hook(entity) // Magnet func. Hooks zombies to nade
    345. {
    346.     //Bugfix
    347.     if (!pev_valid(entity))
    348.     {
    349.         remove_task(entity);
    350.         return;
    351.     }
    352.    
    353.     static Float:originF[3], Float:radius, victim = -1;
    354.     radius = get_pcvar_float(cvar_radius);
    355.     pev(entity, pev_origin, originF);
    356.    
    357.     while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, radius)) != 0)
    358.     {
    359.         if (!is_user_alive(victim) || !ze_is_user_zombie(victim) || g_has_shield[victim])
    360.             continue;
    361.  
    362.         new Float:fl_Velocity[3];
    363.         new vicOrigin[3], originN[3];
    364.  
    365.         get_user_origin(victim, vicOrigin);
    366.         originN[0] = floatround(originF[0]);
    367.         originN[1] = floatround(originF[1]);
    368.         originN[2] = floatround(originF[2]);
    369.        
    370.         new distance = get_distance(originN, vicOrigin);
    371.  
    372.         if (distance > 1)
    373.         {
    374.             new Float:fl_Time = distance / get_pcvar_float(cvar_speed);
    375.  
    376.             fl_Velocity[0] = (originN[0] - vicOrigin[0]) / fl_Time;
    377.             fl_Velocity[1] = (originN[1] - vicOrigin[1]) / fl_Time;
    378.             fl_Velocity[2] = (originN[2] - vicOrigin[2]) / fl_Time;
    379.         } else
    380.         {
    381.             fl_Velocity[0] = 0.0
    382.             fl_Velocity[1] = 0.0
    383.             fl_Velocity[2] = 0.0
    384.         }
    385.  
    386.         entity_set_vector(victim, EV_VEC_velocity, fl_Velocity);
    387.        
    388.         if(get_pcvar_num(cvar_shake))
    389.         {
    390.             message_begin(MSG_ONE_UNRELIABLE, g_shake, _, victim)
    391.             write_short(1<<14) // amplitude
    392.             write_short(1<<14) // duration
    393.             write_short(1<<14) // frequency
    394.             message_end()
    395.         }
    396.     }
    397. }
    398.  
    399. public hurt(entity) // Hurts zombies if mode = 2
    400. {
    401.     //Bugfix
    402.     if (!pev_valid(entity))
    403.     {
    404.         remove_task(entity);
    405.         return;
    406.     }
    407.    
    408.     static Float:originF[3], Float:radius, victim = -1;
    409.     radius = get_pcvar_float(cvar_radius)/2.0;
    410.     pev(entity, pev_origin, originF);
    411.    
    412.     while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, radius)) != 0)
    413.     {
    414.         if (!is_user_alive(victim) || !ze_is_user_zombie(victim) || g_has_shield[victim])
    415.             continue;
    416.        
    417.         new Float:dam = get_pcvar_float(cvar_damage);
    418.        
    419.         if(get_user_health(victim) - get_pcvar_float(cvar_damage) > 0)
    420.             fakedamage(victim, "Pipe Bomb", dam, 256);
    421.     }
    422. }
    423.  
    424. public kill(const Float:originF[3], attacker) // Kills zombies in radius / 2 if mode = 1
    425. {
    426.     static Float:radius, victim = -1;
    427.     radius = get_pcvar_float(cvar_radius) / 2.0;
    428.    
    429.     while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, radius)) != 0)
    430.     {
    431.         if (!is_user_alive(victim) || !ze_is_user_zombie(victim) || g_has_shield[victim])
    432.             continue;
    433.        
    434.         new Float:dam = get_pcvar_float(cvar_damage);
    435.         set_msg_block(g_death, BLOCK_SET);
    436.         fakedamage(victim, "Pipe Bomb", dam, 256);
    437.         set_msg_block(g_death, BLOCK_NOT);
    438.        
    439.         if(get_user_health(victim) <= 0)
    440.         {
    441.             _SendDeathMsg(attacker, victim);
    442.            
    443.             if(victim != attacker && !ze_is_user_zombie(attacker))
    444.                 _UpdateFrags(attacker, 1, 1);
    445.             else
    446.                 _UpdateFrags(attacker, -1, 1);
    447.         }
    448.     }
    449. }
    450.  
    451. public light(const Float:originF[3], duration)  // Blast ring and small red light around nade from zombie_plague40.sma. Great thx, MeRcyLeZZ!!! ;)
    452. {
    453.     // Lighting
    454.     engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, originF, 0);
    455.     write_byte(TE_DLIGHT); // TE id
    456.     engfunc(EngFunc_WriteCoord, originF[0]); // x
    457.     engfunc(EngFunc_WriteCoord, originF[1]); // y
    458.     engfunc(EngFunc_WriteCoord, originF[2]); // z
    459.     write_byte(5); // radius
    460.     write_byte(128); // r
    461.     write_byte(0); // g
    462.     write_byte(0); // b
    463.     write_byte(51); //life
    464.     write_byte((duration < 2) ? 3 : 0); //decay rate
    465.     message_end();
    466.    
    467.     // Smallest ring
    468.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
    469.     write_byte(TE_BEAMCYLINDER) // TE id
    470.     engfunc(EngFunc_WriteCoord, originF[0]) // x
    471.     engfunc(EngFunc_WriteCoord, originF[1]) // y
    472.     engfunc(EngFunc_WriteCoord, originF[2]) // z
    473.     engfunc(EngFunc_WriteCoord, originF[0]) // x axis
    474.     engfunc(EngFunc_WriteCoord, originF[1]) // y axis
    475.     engfunc(EngFunc_WriteCoord, originF[2]+385.0) // z axis
    476.     write_short(g_ring) // sprite
    477.     write_byte(0) // startframe
    478.     write_byte(0) // framerate
    479.     write_byte(4) // life
    480.     write_byte(60) // width
    481.     write_byte(0) // noise
    482.     write_byte(128) // red
    483.     write_byte(0) // green
    484.     write_byte(0) // blue
    485.     write_byte(200) // brightness
    486.     write_byte(0) // speed
    487.     message_end()
    488.    
    489.     // Medium ring
    490.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
    491.     write_byte(TE_BEAMCYLINDER) // TE id
    492.     engfunc(EngFunc_WriteCoord, originF[0]) // x
    493.     engfunc(EngFunc_WriteCoord, originF[1]) // y
    494.     engfunc(EngFunc_WriteCoord, originF[2]) // z
    495.     engfunc(EngFunc_WriteCoord, originF[0]) // x axis
    496.     engfunc(EngFunc_WriteCoord, originF[1]) // y axis
    497.     engfunc(EngFunc_WriteCoord, originF[2]+470.0) // z axis
    498.     write_short(g_ring) // sprite
    499.     write_byte(0) // startframe
    500.     write_byte(0) // framerate
    501.     write_byte(4) // life
    502.     write_byte(60) // width
    503.     write_byte(0) // noise
    504.     write_byte(128) // red
    505.     write_byte(0) // green
    506.     write_byte(0) // blue
    507.     write_byte(200) // brightness
    508.     write_byte(0) // speed
    509.     message_end()
    510.    
    511.     // Largest ring
    512.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
    513.     write_byte(TE_BEAMCYLINDER) // TE id
    514.     engfunc(EngFunc_WriteCoord, originF[0]) // x
    515.     engfunc(EngFunc_WriteCoord, originF[1]) // y
    516.     engfunc(EngFunc_WriteCoord, originF[2]) // z
    517.     engfunc(EngFunc_WriteCoord, originF[0]) // x axis
    518.     engfunc(EngFunc_WriteCoord, originF[1]) // y axis
    519.     engfunc(EngFunc_WriteCoord, originF[2]+555.0) // z axis
    520.     write_short(g_ring) // sprite
    521.     write_byte(0) // startframe
    522.     write_byte(0) // framerate
    523.     write_byte(4) // life
    524.     write_byte(60) // width
    525.     write_byte(0) // noise
    526.     write_byte(128) // red
    527.     write_byte(0) // green
    528.     write_byte(0) // blue
    529.     write_byte(200) // brightness
    530.     write_byte(0) // speed
    531.     message_end()
    532. }
    533.  
    534. public effect(const Float:originF[3]) // Explosion effect
    535. {
    536.     // Largest ring
    537.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
    538.     write_byte(TE_BEAMCYLINDER) // TE id
    539.     engfunc(EngFunc_WriteCoord, originF[0]) // x
    540.     engfunc(EngFunc_WriteCoord, originF[1]) // y
    541.     engfunc(EngFunc_WriteCoord, originF[2]) // z
    542.     engfunc(EngFunc_WriteCoord, originF[0]) // x axis
    543.     engfunc(EngFunc_WriteCoord, originF[1]) // y axis
    544.     engfunc(EngFunc_WriteCoord, originF[2]+555.0) // z axis
    545.     write_short(g_ring) // sprite
    546.     write_byte(0) // startframe
    547.     write_byte(0) // framerate
    548.     write_byte(4) // life
    549.     write_byte(60) // width
    550.     write_byte(0) // noise
    551.     write_byte(128) // red
    552.     write_byte(0) // green
    553.     write_byte(0) // blue
    554.     write_byte(200) // brightness
    555.     write_byte(0) // speed
    556.     message_end()
    557.    
    558.     // Explosion sprite
    559.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
    560.     write_byte(TE_EXPLOSION)
    561.     engfunc(EngFunc_WriteCoord, originF[0])
    562.     engfunc(EngFunc_WriteCoord, originF[1])
    563.     engfunc(EngFunc_WriteCoord, originF[2])
    564.     write_short(g_fire) //sprite index
    565.     write_byte(25) // scale in 0.1's
    566.     write_byte(10) // framerate
    567.     write_byte(0) // flags
    568.     message_end()
    569. }
    570.  
    571. _UpdateFrags(attacker, frags, scoreboard) // Updates attacker frags
    572. {
    573.     // Set attacker frags
    574.     set_pev(attacker, pev_frags, float(pev(attacker, pev_frags) + frags))
    575.    
    576.     if(get_pcvar_num(cvar_extraap) > 0)
    577.         ze_set_escape_coins(attacker, ze_get_escape_coins(attacker) + get_pcvar_num(cvar_extraap));
    578.        
    579.     // Update scoreboard with attacker and victim info
    580.     if (scoreboard)
    581.     {
    582.         message_begin(MSG_BROADCAST, g_score)
    583.         write_byte(attacker) // id
    584.         write_short(pev(attacker, pev_frags)) // frags
    585.         write_short(get_user_deaths(attacker)) // deaths
    586.         write_short(0) // class?
    587.         write_short(get_user_team(attacker)) // team
    588.         message_end()
    589.     }
    590. }
    591.  
    592. _SendDeathMsg(attacker, victim) // Sends death message
    593. {
    594.     message_begin(MSG_BROADCAST, g_death)
    595.     write_byte(attacker) // killer
    596.     write_byte(victim) // victim
    597.     write_byte(0) // headshot flag
    598.     write_string("Pipe Bomb") // killer's weapon
    599.     message_end()
    600. }
Explain more what you need to do further.
He who fails to plan is planning to fail

SobekPogrywamy
Member
Member
Poland
Posts: 24
Joined: 3 years ago
Contact:

#3

Post by SobekPogrywamy » 3 years ago

Hello
Thanks for extra - items but nothing happens when throwing a grenade



For the second part of the plugin / a separate plugin I would like to get some similar to fire / frost
To make this grenade standard instead of flare

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#4

Post by Raheem » 3 years ago

SobekPogrywamy wrote: 3 years ago Hello
Thanks for extra - items but nothing happens when throwing a grenade



For the second part of the plugin / a separate plugin I would like to get some similar to fire / frost
To make this grenade standard instead of flare
In ze_frost.sma, find:
    1.     // Flashbang or Smoke
    2.     if ((model[9] == 'f' && model[10] == 'l') || (model[9] == 's' && model[10] == 'm'))
    3.     {
    4.         // Give it a glow
    5.         Set_Rendering(entity, kRenderFxGlowShell, 0, 100, 200, kRenderNormal, 16);
    6.        
    7.         // And a colored trail
    8.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    9.         write_byte(TE_BEAMFOLLOW) // TE id
    10.         write_short(entity) // entity
    11.         write_short(g_iTrailSpr) // sprite
    12.         write_byte(10) // life
    13.         write_byte(10) // width
    14.         write_byte(0) // r
    15.         write_byte(100) // g
    16.         write_byte(200) // b
    17.         write_byte(200) // brightness
    18.         message_end()
    19.        
    20.         // Set grenade type on the thrown grenade entity
    21.         set_entvar(entity, var_flTimeStepSound, 3333.0)
    22.     }
Edit to:
    1.     // Flashbang or Smoke
    2.     if ((model[9] == 'f' && model[10] == 'l'))
    3.     {
    4.         // Give it a glow
    5.         Set_Rendering(entity, kRenderFxGlowShell, 0, 100, 200, kRenderNormal, 16);
    6.        
    7.         // And a colored trail
    8.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
    9.         write_byte(TE_BEAMFOLLOW) // TE id
    10.         write_short(entity) // entity
    11.         write_short(g_iTrailSpr) // sprite
    12.         write_byte(10) // life
    13.         write_byte(10) // width
    14.         write_byte(0) // r
    15.         write_byte(100) // g
    16.         write_byte(200) // b
    17.         write_byte(200) // brightness
    18.         message_end()
    19.        
    20.         // Set grenade type on the thrown grenade entity
    21.         set_entvar(entity, var_flTimeStepSound, 3333.0)
    22.     }
Compile and try.
He who fails to plan is planning to fail

SobekPogrywamy
Member
Member
Poland
Posts: 24
Joined: 3 years ago
Contact:

#5

Post by SobekPogrywamy » 3 years ago

L 02/01/2021 - 19:17:59: Info (map "ze_egypt") (file "addons/amxmodx/logs/error_20210201.log")
L 02/01/2021 - 19:17:59: [AMXX] Displaying debug trace (plugin "ze_pipe.amxx", version "0.4b")
L 02/01/2021 - 19:17:59: [AMXX] Run time error 4: index out of bounds
L 02/01/2021 - 19:17:59: [AMXX] [0] ze_pipe.sma::fw_smDeploy (line 150)


not always.. but its bugged ;c


150 lane: if(g_has_pipe[id] && !ze_is_user_zombie(id) && is_user_alive(id))

User avatar
z0h1r-LK
Mod Developer
Mod Developer
Morocco
Posts: 473
Joined: 5 years ago
Location: The Red City ❤
Contact:

#6

Post by z0h1r-LK » 3 years ago

SobekPogrywamy wrote: 3 years ago L 02/01/2021 - 19:17:59: Info (map "ze_egypt") (file "addons/amxmodx/logs/error_20210201.log")
L 02/01/2021 - 19:17:59: [AMXX] Displaying debug trace (plugin "ze_pipe.amxx", version "0.4b")
L 02/01/2021 - 19:17:59: [AMXX] Run time error 4: index out of bounds
L 02/01/2021 - 19:17:59: [AMXX] [0] ze_pipe.sma::fw_smDeploy (line 150)


not always.. but its bugged ;c


150 lane: if(g_has_pipe[id] && !ze_is_user_zombie(id) && is_user_alive(id))
The version of amxmodx you are using

User avatar
z0h1r-LK
Mod Developer
Mod Developer
Morocco
Posts: 473
Joined: 5 years ago
Location: The Red City ❤
Contact:

#7

Post by z0h1r-LK » 3 years ago

1.8.3 ?

SobekPogrywamy
Member
Member
Poland
Posts: 24
Joined: 3 years ago
Contact:

#8

Post by SobekPogrywamy » 3 years ago

meta list
Currently loaded plugins:
description stat pend file vers src load unlod
[ 1] AMX Mod X RUN - amxmodx_mm_i386. v1.8.3-d ini Start ANY
[ 2] Reunion RUN - reunion_mm_i386. v0.1.0.9 ini Start Never
[ 3] ReAuthCheck RUN - reauthcheck_mm_i v0.1.6 ini Start Never
[ 4] Revoice RUN - revoice_mm_i386. v0.1.0.3 ini Start Never
[ 5] Ham Sandwich RUN - hamsandwich_amxx v1.8.3-d pl1 ANY ANY
[ 6] CSX RUN - csx_amxx_i386.so v1.8.3-d pl1 ANY ANY
[ 7] FakeMeta RUN - fakemeta_amxx_i3 v1.8.3-d pl1 ANY ANY
[ 8] ReAPI RUN - reapi_amxx_i386. v5.18.0. pl1 ANY Never
[ 9] MySQL RUN - mysql_amxx_i386. v1.8.3-d pl1 ANY ANY
[10] CStrike RUN - cstrike_amxx_i38 v1.8.3-d pl1 ANY ANY
[11] Engine RUN - engine_amxx_i386 v1.8.3-d pl1 ANY ANY
[12] Fun RUN - fun_amxx_i386.so v1.8.3-d pl1 ANY ANY
12 plugins, 12 running

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#9

Post by Raheem » 3 years ago

Post the code + the error debug.
He who fails to plan is planning to fail

SobekPogrywamy
Member
Member
Poland
Posts: 24
Joined: 3 years ago
Contact:

#10

Post by SobekPogrywamy » 3 years ago

Spoiler!
  1. [code]/*
  2.     -*- [ZE] Extra Item: Pipe Bomb -*-
  3.    
  4.     -*- Author: 4eRT -*-
  5.    
  6.     -*- About -*-
  7. This plugin is another extra item for Zombie Plague.
  8. It works like Pipe Bomb in Left 4 Dead.
  9.  
  10.     -*- Description -*-
  11. Plugin includes 2 extras: Pipe Bomb for Humans which
  12. drags zombies to nade on ground and then kills them
  13. (or hurts) and Mental Shield for Zombies which can
  14. block Pipe Bombs. All setting can be configured
  15. through the cvars.
  16.  
  17.     -*- Credits -*-
  18. MeRcyLeZZ - Great thanks for your ZP mode!!!
  19. frk_14 & Koshak - for pipe models
  20. crazyeffect - multilingual
  21. meTaLiCroSS - for optimization
  22.  
  23.     -*- Cvars -*-
  24.     Pipe Bomb:
  25. zp_pipe_enabled 1 // 0=off plugin 1=on
  26. zp_pipe_radius 200 // radius of pipe bomb area def=200
  27. zp_pipe_duration 10 // time before pipe explodes def=10
  28. zp_pipe_cost 15 // extras cost def=15
  29. zp_pipe_mode 1 // 1=hook zombies to nade and then make them super damage 2=hook zombies to nade and hurt them at the same time def=1
  30. zp_pipe_speed 90.0 // speed at which drags zombies def=80.0
  31. zp_pipe_damage 2200 // damage given to zombies def=2200
  32. zp_pipe_shake 1 // 1=shake zombies screen 0=not def=1
  33. zp_pipe_sound 1 //1=enable beep pipe sound 0=off def=1
  34. zp_pipe_hud 1 // 1=enable hud messages 0=off def=1
  35. zp_pipe_ap 0 // additional ammo packs if you killed zombie by Pipe
  36.     Mental Shield:
  37. zp_mshield_enabled 1 // 1=on plugin 0=off
  38. zp_mshield_cost 7 // extras cost def=7
  39. zp_mshield_hud 1 // 1=enable hud 0=off def=1
  40.  
  41.     -*- Modules -*-
  42. fakemeta
  43. hamsandwich
  44. engine
  45. fun
  46. cstrike
  47.  
  48.     -*- History -*-
  49. 0.1b (23.01.10)
  50. First release.
  51. 0.2b (24.01.10)
  52. Fixed some mistakes.
  53. 0.3b (24.01.10)
  54. Added models.
  55. 0.4b (25.01.10)
  56. Model bugs fixed.
  57. */
  58.  
  59. #include <zombie_escape>
  60. #include <engine>
  61. #include <fun>
  62. #include <cstrike>
  63.  
  64. #define VERSION "0.4b"
  65.  
  66. const m_pPlayer = 41;
  67. new const NADE_TYPE_PIPE = 4327;
  68. new const NADE_DURATION_PIPE = pev_flSwimTime;
  69. new const g_trailspr[] ="sprites/laserbeam.spr";
  70. new const g_ringspr[] = "sprites/shockwave.spr";
  71. new const g_firespr[] = "sprites/zerogxplode.spr";
  72. new const g_sound[] = "items/pipe_beep.wav";
  73. new const g_vmodel[] = "models/zombie_plague/v_pipe.mdl";
  74. new const g_pmodel[] = "models/zombie_plague/p_pipe.mdl";
  75. new const g_wmodel[] = "models/zombie_plague/w_pipe.mdl";
  76. new const g_extra_pipe[] = { "Pipe Bomb" };
  77. new cvar_duration, cvar_radius, cvar_enabled, cvar_sound, cvar_cost, cvar_mode, cvar_hud, cvar_damage, cvar_speed, cvar_shake, cvar_extraap; // some cvars
  78. new g_msgsync, g_trail, g_ring, g_fire, g_score, g_death, g_shake, g_pipe, bool: g_has_pipe[33] // some vars
  79.  
  80. public plugin_init() {
  81.     register_plugin("[ZP] Extra: Pipe Bomb", VERSION, "4eRT");
  82.     register_forward(FM_SetModel,"fw_SetModel", 1);
  83.     register_dictionary("zp_extra_pipe.txt");
  84.     RegisterHam(Ham_Think, "grenade", "fw_ThinkGren");
  85.     RegisterHam(Ham_Spawn, "player", "fw_Spawn");
  86.     RegisterHam(Ham_Item_Deploy, "weapon_smokegrenade", "fw_smDeploy", 1);
  87.    
  88.     // Cvars
  89.     cvar_duration = register_cvar("ze_pipe_duration", "10");
  90.     cvar_radius = register_cvar ( "ze_pipe_radius", "200");
  91.     cvar_enabled = register_cvar("ze_pipe_enabled", "1");
  92.     cvar_cost = register_cvar("ze_pipe_cost", "15");
  93.     cvar_mode = register_cvar("ze_pipe_mode", "1");
  94.     cvar_sound = register_cvar("ze_pipe_sound", "1");
  95.     cvar_hud = register_cvar("ze_pipe_hud", "1");
  96.     cvar_damage = register_cvar("ze_pipe_damage", "2200");
  97.     cvar_speed = register_cvar("ze_pipe_speed", "90.0");
  98.     cvar_shake = register_cvar("ze_pipe_shake", "1");
  99.     cvar_extraap = register_cvar("ze_pipe_ap", "0");
  100.  
  101.    
  102.     // Registering extra items
  103.     if(get_pcvar_num(cvar_enabled))
  104.         g_pipe = ze_register_item(g_extra_pipe, get_pcvar_num(cvar_cost), 0);
  105.     g_msgsync = CreateHudSyncObj();
  106.     g_score = get_user_msgid("ScoreInfo");
  107.     g_death = get_user_msgid("DeathMsg");
  108.     g_shake = get_user_msgid("ScreenShake");
  109. }
  110.  
  111. public plugin_precache() {
  112.     precache_model(g_vmodel);
  113.     precache_model(g_pmodel);
  114.     precache_model(g_wmodel);
  115.     precache_sound(g_sound);
  116.     g_fire = precache_model(g_firespr);
  117.     g_trail = precache_model(g_trailspr);
  118.     g_ring = precache_model(g_ringspr);
  119. }
  120.  
  121. public replace_models(id)
  122. {
  123.     if(get_user_weapon(id) == CSW_SMOKEGRENADE)
  124.     {
  125.         set_pev(id, pev_viewmodel2, g_vmodel);
  126.         set_pev(id, pev_weaponmodel2, g_pmodel);
  127.     }
  128. }
  129.  
  130.  
  131.  
  132. public fw_smDeploy(const iEntity)
  133. {
  134.     if(pev_valid(iEntity) != 2)
  135.         return HAM_IGNORED;
  136.    
  137.     new id = get_pdata_cbase(iEntity, m_pPlayer, 4);
  138.        if(0<id<33)
  139.    {
  140.     if(g_has_pipe[id] && !ze_is_user_zombie(id) && is_user_alive(id))
  141.     {
  142.         set_pev(id, pev_viewmodel2, g_vmodel);
  143.         set_pev(id, pev_weaponmodel2, g_pmodel);
  144.     }
  145.    
  146.     return HAM_IGNORED;
  147.     }
  148. return PLUGIN_HANDLED;
  149. }
  150. public ze_select_item_pre(id, itemid)
  151. {
  152.     // Return Available and we will block it in Post, So it dosen't affect other plugins
  153.     if (itemid != g_pipe)
  154.         return ZE_ITEM_AVAILABLE;
  155.    
  156.     // Available for Humans only, So don't show it for zombies
  157.     if (ze_is_user_zombie(id))
  158.         return ZE_ITEM_DONT_SHOW;
  159.    
  160.     return ZE_ITEM_AVAILABLE;
  161. }
  162.  
  163. public ze_select_item_post(id, itemid)
  164. {
  165.     // This is not our item, Block it here
  166.     if (itemid != g_pipe)
  167.         return;
  168.    
  169.     if(!get_pcvar_num(cvar_enabled))
  170.     {
  171.         client_print(id, print_chat, "[ZE] %L", id, "DISABLED");
  172.         return;
  173.     }
  174.    
  175.     if(g_has_pipe[id])
  176.     {
  177.         if(get_pcvar_num(cvar_hud) == 1)
  178.         {
  179.             set_hudmessage(255, 0, 0, -1.0, 0.55, 0, 0.0, 2.0, 2.0, 1.0, -1);
  180.             ShowSyncHudMsg(id, g_msgsync, "%L", id, "ALREADY");
  181.         }
  182.         else
  183.             client_print(id, print_chat, "[ZE] %L", id, "ALREADY");
  184.  
  185.         return;
  186.     }
  187.  
  188.     g_has_pipe[id] = true;
  189.     new was = cs_get_user_bpammo(id, CSW_SMOKEGRENADE);
  190.  
  191.     if(was >= 1)
  192.         cs_set_user_bpammo(id, CSW_SMOKEGRENADE, was + 1);
  193.     else
  194.         give_item(id, "weapon_smokegrenade");
  195.    
  196.     replace_models(id);
  197.    
  198.     if(get_pcvar_num(cvar_hud) == 1)
  199.     {
  200.         new msg[32], hud = random_num(0, 1);
  201.  
  202.         if(hud == 0)
  203.             formatex(msg, 31, "%L", id, "DANGEROUS");
  204.         else
  205.             formatex(msg, 31, "%L", id, "GO_EXPLOSIVE");
  206.  
  207.         set_hudmessage(255, 0, 0, -1.0, 0.55, 0, 0.0, 3.0, 2.0, 1.0, -1);
  208.         ShowSyncHudMsg(id, g_msgsync, "%s", msg);
  209.     }
  210. }
  211.  
  212. public ze_user_infected(iVictim, iInfector)
  213. {
  214.     g_has_pipe[iVictim] = false;
  215. }
  216.        
  217. public fw_Spawn(id)
  218. {
  219.     g_has_pipe[id] = false;
  220. }
  221.  
  222. public fw_SetModel(entity, const model[]) // Set smokegrenade pipes effects and type
  223. {
  224.     static Float:dmgtime, owner;
  225.     pev(entity, pev_dmgtime, dmgtime);
  226.     owner = pev(entity, pev_owner);
  227.    
  228.     if(!pev_valid(entity) || dmgtime == 0.0)
  229.         return FMRES_IGNORED;
  230.    
  231.     if (model[9] == 's' && model[10] == 'm' && g_has_pipe[owner])
  232.     {
  233.         g_has_pipe[owner] = false;
  234.         entity_set_model(entity, g_wmodel);
  235.        
  236.         set_rendering(entity, kRenderFxGlowShell, 128, 0, 0, kRenderNormal, 16);
  237.        
  238.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  239.         write_byte(TE_BEAMFOLLOW) // TE id
  240.         write_short(entity) // entity
  241.         write_short(g_trail) // sprite
  242.         write_byte(10) // life
  243.         write_byte(10) // width
  244.         write_byte(128) // r
  245.         write_byte(0) // g
  246.         write_byte(0) // b
  247.         write_byte(255) // brightness
  248.         message_end()
  249.        
  250.         set_pev(entity, pev_flTimeStepSound, NADE_TYPE_PIPE);
  251.        
  252.         return FMRES_SUPERCEDE;
  253.     }
  254.    
  255.     return FMRES_IGNORED;
  256. }
  257.  
  258. public fw_ThinkGren(entity) // Grenade think event
  259. {
  260.     if (!pev_valid(entity))
  261.         return HAM_IGNORED;
  262.    
  263.     static Float:dmgtime, Float: current_time, attacker;
  264.     pev(entity, pev_dmgtime, dmgtime);
  265.     current_time = get_gametime();
  266.     attacker = pev(entity, pev_owner);
  267.    
  268.     if(dmgtime > current_time)
  269.         return HAM_IGNORED;
  270.    
  271.     if(pev(entity, pev_flTimeStepSound) == NADE_TYPE_PIPE)
  272.     {
  273.         static duration;
  274.         duration = pev(entity, NADE_DURATION_PIPE);
  275.        
  276.         if (duration > 0)
  277.         {
  278.             new Float:originF[3]
  279.             pev(entity, pev_origin, originF);
  280.            
  281.             if (duration == 1)
  282.             {
  283.                 remove_task(entity);
  284.                 effect(originF);
  285.                
  286.                 if (get_pcvar_num(cvar_mode) == 1)
  287.                     kill(originF, attacker);
  288.                
  289.                 engfunc(EngFunc_RemoveEntity, entity);
  290.                 return HAM_SUPERCEDE;
  291.             }
  292.            
  293.             light(originF, duration);
  294.             set_task(0.1, "hook", entity, _, _, "b");
  295.            
  296.             if(get_pcvar_num(cvar_mode) == 2)
  297.                 set_task(1.0, "hurt", entity, _, _, "b");
  298.                
  299.             if(get_pcvar_num(cvar_sound))
  300.             {
  301.                 if(duration == 2)
  302.                     set_task(0.1, "beep", entity, _, _, "b");
  303.                 else
  304.                     emit_sound(entity, CHAN_WEAPON, g_sound, 1.0, ATTN_NORM, 0, PITCH_HIGH);
  305.             }
  306.            
  307.             set_pev(entity, NADE_DURATION_PIPE, --duration);
  308.             set_pev(entity, pev_dmgtime, current_time + 3.0);
  309.         } else if ((pev(entity, pev_flags) & FL_ONGROUND) && get_speed(entity) < 10)
  310.         {
  311.             set_pev(entity, NADE_DURATION_PIPE, 1 + get_pcvar_num(cvar_duration)/3);
  312.             set_pev(entity, pev_dmgtime, current_time + 0.1);
  313.         } else
  314.             set_pev(entity, pev_dmgtime, current_time + 0.5);
  315.     }
  316.    
  317.     return HAM_IGNORED;
  318. }
  319.  
  320. public beep(entity) // Plays loop beep sound before explosion
  321. {
  322.     //Bugfix
  323.     if (!pev_valid(entity))
  324.     {
  325.         remove_task(entity);
  326.         return;
  327.     }
  328.    
  329.     emit_sound(entity, CHAN_WEAPON, g_sound, 1.0, ATTN_NORM, 0, PITCH_HIGH);
  330. }
  331.  
  332. public hook(entity) // Magnet func. Hooks zombies to nade
  333. {
  334.     //Bugfix
  335.     if (!pev_valid(entity))
  336.     {
  337.         remove_task(entity);
  338.         return;
  339.     }
  340.    
  341.     static Float:originF[3], Float:radius, victim = -1;
  342.     radius = get_pcvar_float(cvar_radius);
  343.     pev(entity, pev_origin, originF);
  344.    
  345.     while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, radius)) != 0)
  346.     {
  347.         if (!is_user_alive(victim) || !ze_is_user_zombie(victim))
  348.             continue;
  349.  
  350.         new Float:fl_Velocity[3];
  351.         new vicOrigin[3], originN[3];
  352.  
  353.         get_user_origin(victim, vicOrigin);
  354.         originN[0] = floatround(originF[0]);
  355.         originN[1] = floatround(originF[1]);
  356.         originN[2] = floatround(originF[2]);
  357.        
  358.         new distance = get_distance(originN, vicOrigin);
  359.  
  360.         if (distance > 1)
  361.         {
  362.             new Float:fl_Time = distance / get_pcvar_float(cvar_speed);
  363.  
  364.             fl_Velocity[0] = (originN[0] - vicOrigin[0]) / fl_Time;
  365.             fl_Velocity[1] = (originN[1] - vicOrigin[1]) / fl_Time;
  366.             fl_Velocity[2] = (originN[2] - vicOrigin[2]) / fl_Time;
  367.         } else
  368.         {
  369.             fl_Velocity[0] = 0.0
  370.             fl_Velocity[1] = 0.0
  371.             fl_Velocity[2] = 0.0
  372.         }
  373.  
  374.         entity_set_vector(victim, EV_VEC_velocity, fl_Velocity);
  375.        
  376.         if(get_pcvar_num(cvar_shake))
  377.         {
  378.             message_begin(MSG_ONE_UNRELIABLE, g_shake, _, victim)
  379.             write_short(1<<14) // amplitude
  380.             write_short(1<<14) // duration
  381.             write_short(1<<14) // frequency
  382.             message_end()
  383.         }
  384.     }
  385. }
  386.  
  387. public hurt(entity) // Hurts zombies if mode = 2
  388. {
  389.     //Bugfix
  390.     if (!pev_valid(entity))
  391.     {
  392.         remove_task(entity);
  393.         return;
  394.     }
  395.    
  396.     static Float:originF[3], Float:radius, victim = -1;
  397.     radius = get_pcvar_float(cvar_radius)/2.0;
  398.     pev(entity, pev_origin, originF);
  399.    
  400.     while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, radius)) != 0)
  401.     {
  402.         if (!is_user_alive(victim) || !ze_is_user_zombie(victim))
  403.             continue;
  404.        
  405.         new Float:dam = get_pcvar_float(cvar_damage);
  406.        
  407.         if(get_user_health(victim) - get_pcvar_float(cvar_damage) > 0)
  408.             fakedamage(victim, "Pipe Bomb", dam, 256);
  409.     }
  410. }
  411.  
  412. public kill(const Float:originF[3], attacker) // Kills zombies in radius / 2 if mode = 1
  413. {
  414.     static Float:radius, victim = -1;
  415.     radius = get_pcvar_float(cvar_radius) / 2.0;
  416.    
  417.     while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, radius)) != 0)
  418.     {
  419.         if (!is_user_alive(victim) || !ze_is_user_zombie(victim))
  420.             continue;
  421.        
  422.         new Float:dam = get_pcvar_float(cvar_damage);
  423.         set_msg_block(g_death, BLOCK_SET);
  424.         fakedamage(victim, "Pipe Bomb", dam, 256);
  425.         set_msg_block(g_death, BLOCK_NOT);
  426.        
  427.         if(get_user_health(victim) <= 0)
  428.         {
  429.             _SendDeathMsg(attacker, victim);
  430.            
  431.             if(victim != attacker && !ze_is_user_zombie(attacker))
  432.                 _UpdateFrags(attacker, 1, 1);
  433.             else
  434.                 _UpdateFrags(attacker, -1, 1);
  435.         }
  436.     }
  437. }
  438.  
  439. public light(const Float:originF[3], duration)  // Blast ring and small red light around nade from zombie_plague40.sma. Great thx, MeRcyLeZZ!!! ;)
  440. {
  441.     // Lighting
  442.     engfunc(EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, originF, 0);
  443.     write_byte(TE_DLIGHT); // TE id
  444.     engfunc(EngFunc_WriteCoord, originF[0]); // x
  445.     engfunc(EngFunc_WriteCoord, originF[1]); // y
  446.     engfunc(EngFunc_WriteCoord, originF[2]); // z
  447.     write_byte(5); // radius
  448.     write_byte(128); // r
  449.     write_byte(0); // g
  450.     write_byte(0); // b
  451.     write_byte(51); //life
  452.     write_byte((duration < 2) ? 3 : 0); //decay rate
  453.     message_end();
  454.    
  455.     // Smallest ring
  456.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  457.     write_byte(TE_BEAMCYLINDER) // TE id
  458.     engfunc(EngFunc_WriteCoord, originF[0]) // x
  459.     engfunc(EngFunc_WriteCoord, originF[1]) // y
  460.     engfunc(EngFunc_WriteCoord, originF[2]) // z
  461.     engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  462.     engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  463.     engfunc(EngFunc_WriteCoord, originF[2]+385.0) // z axis
  464.     write_short(g_ring) // sprite
  465.     write_byte(0) // startframe
  466.     write_byte(0) // framerate
  467.     write_byte(4) // life
  468.     write_byte(60) // width
  469.     write_byte(0) // noise
  470.     write_byte(128) // red
  471.     write_byte(0) // green
  472.     write_byte(0) // blue
  473.     write_byte(200) // brightness
  474.     write_byte(0) // speed
  475.     message_end()
  476.    
  477.     // Medium ring
  478.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  479.     write_byte(TE_BEAMCYLINDER) // TE id
  480.     engfunc(EngFunc_WriteCoord, originF[0]) // x
  481.     engfunc(EngFunc_WriteCoord, originF[1]) // y
  482.     engfunc(EngFunc_WriteCoord, originF[2]) // z
  483.     engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  484.     engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  485.     engfunc(EngFunc_WriteCoord, originF[2]+470.0) // z axis
  486.     write_short(g_ring) // sprite
  487.     write_byte(0) // startframe
  488.     write_byte(0) // framerate
  489.     write_byte(4) // life
  490.     write_byte(60) // width
  491.     write_byte(0) // noise
  492.     write_byte(128) // red
  493.     write_byte(0) // green
  494.     write_byte(0) // blue
  495.     write_byte(200) // brightness
  496.     write_byte(0) // speed
  497.     message_end()
  498.    
  499.     // Largest ring
  500.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  501.     write_byte(TE_BEAMCYLINDER) // TE id
  502.     engfunc(EngFunc_WriteCoord, originF[0]) // x
  503.     engfunc(EngFunc_WriteCoord, originF[1]) // y
  504.     engfunc(EngFunc_WriteCoord, originF[2]) // z
  505.     engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  506.     engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  507.     engfunc(EngFunc_WriteCoord, originF[2]+555.0) // z axis
  508.     write_short(g_ring) // sprite
  509.     write_byte(0) // startframe
  510.     write_byte(0) // framerate
  511.     write_byte(4) // life
  512.     write_byte(60) // width
  513.     write_byte(0) // noise
  514.     write_byte(128) // red
  515.     write_byte(0) // green
  516.     write_byte(0) // blue
  517.     write_byte(200) // brightness
  518.     write_byte(0) // speed
  519.     message_end()
  520. }
  521.  
  522. public effect(const Float:originF[3]) // Explosion effect
  523. {
  524.     // Largest ring
  525.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  526.     write_byte(TE_BEAMCYLINDER) // TE id
  527.     engfunc(EngFunc_WriteCoord, originF[0]) // x
  528.     engfunc(EngFunc_WriteCoord, originF[1]) // y
  529.     engfunc(EngFunc_WriteCoord, originF[2]) // z
  530.     engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  531.     engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  532.     engfunc(EngFunc_WriteCoord, originF[2]+555.0) // z axis
  533.     write_short(g_ring) // sprite
  534.     write_byte(0) // startframe
  535.     write_byte(0) // framerate
  536.     write_byte(4) // life
  537.     write_byte(60) // width
  538.     write_byte(0) // noise
  539.     write_byte(128) // red
  540.     write_byte(0) // green
  541.     write_byte(0) // blue
  542.     write_byte(200) // brightness
  543.     write_byte(0) // speed
  544.     message_end()
  545.    
  546.     // Explosion sprite
  547.     engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  548.     write_byte(TE_EXPLOSION)
  549.     engfunc(EngFunc_WriteCoord, originF[0])
  550.     engfunc(EngFunc_WriteCoord, originF[1])
  551.     engfunc(EngFunc_WriteCoord, originF[2])
  552.     write_short(g_fire) //sprite index
  553.     write_byte(25) // scale in 0.1's
  554.     write_byte(10) // framerate
  555.     write_byte(0) // flags
  556.     message_end()
  557. }
  558.  
  559. _UpdateFrags(attacker, frags, scoreboard) // Updates attacker frags
  560. {
  561.     // Set attacker frags
  562.     set_pev(attacker, pev_frags, float(pev(attacker, pev_frags) + frags))
  563.    
  564.     if(get_pcvar_num(cvar_extraap) > 0)
  565.         ze_set_escape_coins(attacker, ze_get_escape_coins(attacker) + get_pcvar_num(cvar_extraap));
  566.        
  567.     // Update scoreboard with attacker and victim info
  568.     if (scoreboard)
  569.     {
  570.         message_begin(MSG_BROADCAST, g_score)
  571.         write_byte(attacker) // id
  572.         write_short(pev(attacker, pev_frags)) // frags
  573.         write_short(get_user_deaths(attacker)) // deaths
  574.         write_short(0) // class?
  575.         write_short(get_user_team(attacker)) // team
  576.         message_end()
  577.     }
  578. }
  579.  
  580. _SendDeathMsg(attacker, victim) // Sends death message
  581. {
  582.     message_begin(MSG_BROADCAST, g_death)
  583.     write_byte(attacker) // killer
  584.     write_byte(victim) // victim
  585.     write_byte(0) // headshot flag
  586.     write_string("Pipe Bomb") // killer's weapon
  587.     message_end()
  588. }[Codebox=amxx file=Untitled.amxx]
[/code][/Codebox]
with debug im didnt have any warnings etc..
just serwer say: Core dumped and off ;d

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#11

Post by Raheem » 3 years ago

It gives an error in the console, or crashed the server?
He who fails to plan is planning to fail

SobekPogrywamy
Member
Member
Poland
Posts: 24
Joined: 3 years ago
Contact:

#12

Post by SobekPogrywamy » 3 years ago

console:

Image

User avatar
Raheem
Mod Developer
Mod Developer
Posts: 2214
Joined: 7 years ago
Contact:

#13

Post by Raheem » 3 years ago

This surely because of removing the grenade entity, and this issue discussed here: viewtopic.php?f=14&t=3872
Need to back to the code author to refix it. And this issue seems to appear with ReHLDS only I think, but not with HLDS. The author I think also coded it in the past time and tested it only on HLDS.

The same issue was in the force field plugin, but I did a private fix (Not for sale or publish).
He who fails to plan is planning to fail

Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Who is online

Users browsing this forum: No registered users and 10 guests