daily pastebin goal
94%
SHARE
TWEET

Untitled

a guest Dec 16th, 2018 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <amxmodx>
  2. #include <engine>
  3. #include <hamsandwich>
  4. #include <fakemeta_util>
  5. #include <dhudmessage>
  6. #include <zombieplague>
  7.  
  8. // *** Настройки *** //
  9. #define NAME "AIR \rStrike" // Nume˛ Extra items
  10. #define COST 500 // Pret˛ Extra items
  11. #define COUNT 2 // De cate ori se poate cumpara pe runda
  12. #define DAMAGE 99990 // Damage de o bomba
  13. #define RELOADING 60 // Reincarcare in secunde
  14. #define TIMER 5 // Timpul de asteptare in secunde
  15. #define DEATHMSG // Schimba icoana la omor în col?ul din dreapta sus? (Dacă nu, ?terge?i această linie)
  16.  
  17. #define CLASSNAME "air_rocket228"
  18. #define ROCKET_MODEL "models/air_rocket.mdl"
  19. #define LAUNCH_SOUND "launch_rockets.wav"
  20. #define LAUNCH_BEEP "launch_beep.wav"
  21.  
  22. #define DMG_HEGRENADE (1<<24)
  23. #define TASK_HUD 981623
  24.  
  25. new const Float:g_fOffsetCoord[9][2] =
  26. {
  27.     {0.0, 0.0},
  28.     {-100.0, -100.0},
  29.     {100.0, 100.0},
  30.     {-100.0, 100.0},
  31.     {100.0, -100.0},
  32.    
  33.     {0.0, 160.0},
  34.     {0.0, -160.0},
  35.     {160.0, 0.0},
  36.     {-160.0, 0.0}
  37. }
  38.  
  39. new g_iSprExp, g_iSprTrail, g_iSprShockWave
  40. new g_iTimer, Float:g_fBlockBuy, g_iBlockBuyCount[33], Float:g_fCentreOrigin[3]
  41. new g_iMaxPlayers, g_iItem
  42.  
  43. #if defined DEATHMSG
  44.     new HamHook:g_iHamHookKilledPost
  45. #endif
  46.  
  47. public plugin_init()
  48. {
  49.     register_plugin("[ZP] Air Strike", "1.0", "Dorus")
  50.     register_event("HLTV", "NewRound", "a", "1=0", "2=0")
  51.    
  52.     register_touch(CLASSNAME, "*", "fw_RocketTouch")
  53.     RegisterHam(Ham_Think, "info_target", "Ham_HookThink")
  54.    
  55.     #if defined DEATHMSG
  56.         register_message(get_user_msgid("DeathMsg"), "Msg_DeathMsg")
  57.         DisableHamForward((g_iHamHookKilledPost = RegisterHam(Ham_Killed, "player", "Ham_Killed_Post", 1)))
  58.     #endif
  59.    
  60.     g_iItem = zp_register_extra_item(NAME, COST, ZP_TEAM_HUMAN)
  61.     g_iMaxPlayers = get_maxplayers()
  62.     g_fBlockBuy = get_gametime()
  63. }
  64.  
  65. public plugin_precache()
  66. {
  67.     precache_sound(LAUNCH_SOUND)
  68.     precache_sound(LAUNCH_BEEP)
  69.    
  70.     precache_model(ROCKET_MODEL)
  71.     g_iSprExp = precache_model("sprites/zerogxplode.spr")
  72.     g_iSprTrail = precache_model("sprites/xbeam3.spr")
  73.     g_iSprShockWave = precache_model("sprites/shockwave.spr")
  74. }
  75.  
  76. public client_putinserver(id)
  77. {
  78.     g_iBlockBuyCount[id] = COUNT
  79. }
  80.  
  81. public zp_extra_item_selected(id, iItemid)
  82. {
  83.     if(iItemid == g_iItem)
  84.     {
  85.         if(!is_user_alive(id) || zp_get_user_zombie(id))
  86.             return PLUGIN_HANDLED
  87.        
  88.         if(g_iBlockBuyCount[id] < 1)
  89.         {
  90.             ChatColor(id, "TEST 1 !y[!tАвиаудар!y] Можно покупать !g%d раз(Đ°) !yĐ·Đ° раунд", COUNT)
  91.             client_print(id, print_center, "You use all. Limit per Round %d", COUNT)
  92.             return ZP_PLUGIN_HANDLED
  93.         }
  94.        
  95.         if(g_fBlockBuy > get_gametime())
  96.         {
  97.             ChatColor(id, "!y[!tAir Strike!y] Time Left to recharge !g%d second !y", floatround(g_fBlockBuy - get_gametime()))
  98.             client_print(id, print_center, "Time left to recharge Air Strike [ %d ] second ", floatround(g_fBlockBuy - get_gametime()))
  99.             return ZP_PLUGIN_HANDLED
  100.         }
  101.        
  102.         fm_get_aim_origin(id, g_fCentreOrigin)
  103.         g_iTimer = TIMER
  104.         LaunchDHud(id+TASK_HUD)
  105.        
  106.         new szName[32]
  107.         get_user_name(id, szName, charsmax(szName))
  108.         ChatColor(id, "!y[!tATENTIE !y] Sergent !g%s !yLaunch the Air Strike", szName)
  109.        
  110.         g_fBlockBuy = get_gametime() + float(RELOADING) + TIMER
  111.         g_iBlockBuyCount[id]--
  112.     }
  113.    
  114.     return PLUGIN_HANDLED
  115. }
  116.  
  117. public NewRound()
  118. {
  119.     for(new id = 1; id <= g_iMaxPlayers; id++)
  120.     {
  121.         if(task_exists(id+TASK_HUD))
  122.             remove_task(id+TASK_HUD)
  123.     }
  124.    
  125.     static iEnt
  126.     iEnt = -1
  127.     while((iEnt = engfunc(EngFunc_FindEntityByString, iEnt, "classname", CLASSNAME)))
  128.     {
  129.         if(is_valid_ent(iEnt))
  130.             engfunc(EngFunc_RemoveEntity, iEnt)
  131.     }
  132.    
  133.     arrayset(g_iBlockBuyCount, COUNT, sizeof(g_iBlockBuyCount))
  134.    
  135.     g_fBlockBuy = get_gametime()
  136. }
  137.  
  138. public LaunchDHud(iTask)
  139. {
  140.     static id
  141.     id = iTask - TASK_HUD
  142.    
  143.     if(g_iTimer <= 0)
  144.     {
  145.         set_dhudmessage(255, 0, 0, -1.0, 0.40, 0, 1.0, 1.5, 0.1, 0.2)
  146.         show_dhudmessage(0, "TEST 6 WARNING !!! ^n Air Strike is Activated.")
  147.         g_iTimer = TIMER
  148.         LaunchRocket(id)
  149.     }
  150.     else
  151.     {
  152.         set_dhudmessage(255, 0, 0, -1.0, 0.40, 0, 1.0, 0.9, 0.1, 0.2)
  153.         show_dhudmessage(0, "Time Left launch Air:^n%d second", g_iTimer--)
  154.        
  155.         set_task(1.0, "LaunchDHud", id+TASK_HUD)
  156.        
  157.         emit_sound(0, CHAN_VOICE, LAUNCH_BEEP, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  158.        
  159.         CreateBeamCylinder(g_fCentreOrigin, g_iSprShockWave, 200.0, 10, 10, 255, 0, 0, 100)
  160.     }
  161. }
  162.    
  163. public LaunchRocket(id)
  164. {  
  165.     static iEnt, Float:tmp_fVelocity[3] = {0.0, 0.0, 0.0}
  166.     new Float:tmp_fNewOrigin[3], Float:fRoofOrigin[3]
  167.    
  168.     emit_sound(id, CHAN_VOICE, LAUNCH_SOUND, VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  169.    
  170.     for(new i = 0; i < 9; i++)
  171.     {
  172.         tmp_fNewOrigin[0] = g_fCentreOrigin[0] + g_fOffsetCoord[i][0]
  173.         tmp_fNewOrigin[1] = g_fCentreOrigin[1] + g_fOffsetCoord[i][1]
  174.         tmp_fNewOrigin[2] = g_fCentreOrigin[2]
  175.        
  176.         iEnt = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
  177.         if(!pev_valid(iEnt))
  178.             return
  179.        
  180.         fRoofOrigin = get_origin_to_roof(iEnt, tmp_fNewOrigin)
  181.         fRoofOrigin[2] -= random_float(0.0, 50.0)
  182.        
  183.         engfunc(EngFunc_SetModel, iEnt, ROCKET_MODEL)
  184.         set_pev(iEnt, pev_solid, SOLID_TRIGGER)
  185.         set_pev(iEnt, pev_movetype, MOVETYPE_FLY)
  186.         set_pev(iEnt, pev_size, Float:{-1.0, -1.0, -1.0}, Float:{1.0, 1.0, 5.0})
  187.        
  188.         tmp_fVelocity[2] = random_float(-500.0, -450.0)
  189.         set_pev(iEnt, pev_velocity, tmp_fVelocity)
  190.        
  191.         set_pev(iEnt, pev_classname, CLASSNAME)
  192.         set_pev(iEnt, pev_origin, fRoofOrigin)
  193.         set_pev(iEnt, pev_owner, id)
  194.        
  195.         set_pev(iEnt, pev_nextthink, get_gametime() + 0.5)
  196.     }
  197. }
  198.  
  199. public Ham_HookThink(iEnt)
  200. {
  201.     if(!pev_valid(iEnt))
  202.         return HAM_IGNORED
  203.        
  204.     new szClassName[64]
  205.     pev(iEnt, pev_classname, szClassName, charsmax(szClassName))
  206.    
  207.     if(!equal(szClassName, CLASSNAME))
  208.         return HAM_IGNORED
  209.    
  210.     CreateBeamFollow(iEnt, g_iSprTrail, 10, 5, 255, 255, 255, 255)
  211.     set_pev(iEnt, pev_nextthink, 0)
  212.    
  213.     return HAM_IGNORED
  214. }
  215.  
  216. public fw_RocketTouch(iEnt, iTouch)
  217. {
  218.     if(!pev_valid(iEnt))
  219.         return
  220.        
  221.     static Float:fOrigin[3], iOwner
  222.     pev(iEnt, pev_origin, fOrigin)
  223.    
  224.     iOwner = pev(iEnt, pev_owner)
  225.    
  226.     CreateExplosion(fOrigin, g_iSprExp, 30, 30, 0)
  227.     CreateBeamCylinder(fOrigin, g_iSprShockWave, 70.0, 6, 30, 248, 255, 175, 100)
  228.    
  229.     new iVictim = -1
  230.     while((iVictim = find_ent_in_sphere(iVictim, fOrigin, 200.0)) != 0)
  231.     {
  232.         if(!is_user_alive(iVictim) || !zp_get_user_zombie(iVictim))
  233.             continue
  234.        
  235.         ExecuteHamB(Ham_TakeDamage, iVictim, iEnt, iOwner, float(DAMAGE), DMG_HEGRENADE)
  236.     }
  237.    
  238.     engfunc(EngFunc_RemoveEntity, iEnt)
  239. }
  240.  
  241. #if defined DEATHMSG
  242. public Msg_DeathMsg()
  243. {
  244.     new iAttacker = get_msg_arg_int(1)
  245.     new szClassName[16], szName[32], szBuffer[64]
  246.  
  247.     get_msg_arg_string(4, szClassName, charsmax(szClassName))
  248.     get_user_name(iAttacker, szName, charsmax(szName))
  249.    
  250.     if(equal(szClassName, CLASSNAME))
  251.     {
  252.         formatex(szBuffer, charsmax(szBuffer), "%s (Авиаудар)", szName)
  253.        
  254.         set_user_fake_name(iAttacker, szBuffer)
  255.         EnableHamForward(g_iHamHookKilledPost)
  256.  
  257.         set_msg_arg_string(4, "teammate")
  258.     }
  259. }
  260.  
  261. public Ham_Killed_Post(iVictim, iAttacker, iGib)
  262. {
  263.     DisableHamForward(g_iHamHookKilledPost)
  264.     reset_user_info(iAttacker)
  265.     dllfunc(DLLFunc_ClientUserInfoChanged, iAttacker, engfunc(EngFunc_GetInfoKeyBuffer, iAttacker))
  266. }
  267.  
  268. stock reset_user_info(iPlayer)
  269. {
  270.     new szUserInfo[256]
  271.     copy_infokey_buffer(engfunc(EngFunc_GetInfoKeyBuffer, iPlayer), szUserInfo, charsmax(szUserInfo))
  272.  
  273.     message_begin(MSG_ALL, SVC_UPDATEUSERINFO)
  274.     write_byte(iPlayer - 1)
  275.     write_long(get_user_userid(iPlayer))
  276.     write_string(szUserInfo)
  277.     write_long(0)
  278.     write_long(0)
  279.     write_long(0)
  280.     write_long(0)
  281.     message_end()
  282. }
  283.  
  284. stock set_user_fake_name(iPlayer, szName[])
  285. {
  286.     message_begin(MSG_ALL, SVC_UPDATEUSERINFO)
  287.     write_byte(iPlayer - 1)
  288.     write_long(get_user_userid(iPlayer))
  289.     write_char('\')
  290.     write_char('n')
  291.     write_char('a')
  292.     write_char('m')
  293.     write_char('e')
  294.     write_char('\')
  295.     write_string(szName)
  296.     for(new i; i < 16; i++) write_byte(0)
  297.     message_end()
  298. }
  299. #endif
  300.  
  301. stock Float:get_origin_to_roof(iEnt, Float:fStart[])
  302. {
  303.     new Float:fDest[3] = {0.0, 0.0, 9999.0}
  304.     xs_vec_add(fStart, fDest, fDest)
  305.    
  306.     engfunc(EngFunc_TraceLine, fStart, fDest, 0, iEnt, 0)
  307.     new Float:fOrigin[3]   
  308.     get_tr2(0, TR_vecEndPos, fOrigin)
  309.    
  310.     return fOrigin
  311. }
  312.  
  313. stock CreateExplosion(Float:fOrigin[], iSprite, iScale, iFramerate, iFlags)
  314. {
  315.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  316.     write_byte(TE_EXPLOSION)
  317.     engfunc(EngFunc_WriteCoord, fOrigin[0])
  318.     engfunc(EngFunc_WriteCoord, fOrigin[1])
  319.     engfunc(EngFunc_WriteCoord, fOrigin[2])
  320.     write_short(iSprite)
  321.     write_byte(iScale)
  322.     write_byte(iFramerate)
  323.     write_byte(iFlags)
  324.     message_end()
  325. }
  326.  
  327. stock CreateBeamFollow(iEnt, iSprite, iLife, iWidth, iRed, iGreen, iBlue, iBrightness)
  328. {
  329.     message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  330.     write_byte(TE_BEAMFOLLOW)
  331.     write_short(iEnt)
  332.     write_short(iSprite)
  333.     write_byte(iLife)
  334.     write_byte(iWidth)
  335.     write_byte(iRed)
  336.     write_byte(iGreen)
  337.     write_byte(iBlue)
  338.     write_byte(iBrightness)
  339.     message_end()
  340. }
  341.  
  342. stock CreateBeamCylinder(Float:fOrigin[3], iSprite, Float:fRadius, iLife, iWidth, iRed, iGreen, iBlue, iBrightness)
  343. {
  344.     engfunc(EngFunc_MessageBegin, MSG_BROADCAST, SVC_TEMPENTITY, fOrigin, 0)
  345.     write_byte(TE_BEAMCYLINDER)
  346.     engfunc(EngFunc_WriteCoord, fOrigin[0])
  347.     engfunc(EngFunc_WriteCoord, fOrigin[1])
  348.     engfunc(EngFunc_WriteCoord, fOrigin[2])
  349.     engfunc(EngFunc_WriteCoord, fOrigin[0])
  350.     engfunc(EngFunc_WriteCoord, fOrigin[1])
  351.     engfunc(EngFunc_WriteCoord, fOrigin[2]+fRadius)
  352.     write_short(iSprite)
  353.     write_byte(0) // start framerate
  354.     write_byte(0) // framerate
  355.     write_byte(iLife)
  356.     write_byte(iWidth)
  357.     write_byte(0) // amplitude
  358.     write_byte(iRed)
  359.     write_byte(iGreen)
  360.     write_byte(iBlue)
  361.     write_byte(iBrightness)
  362.     write_byte(0) // speed
  363.     message_end()
  364. }
  365.  
  366. stock ChatColor(const id, const szInput[], any:...)
  367. {
  368.     new iCount = 1, iPlayers[32]
  369.     static szMsg[191]
  370.  
  371.     vformat(szMsg, 190, szInput, 3)
  372.  
  373.     replace_all(szMsg, 190, "!g", "^4") // Зелёный
  374.     replace_all(szMsg, 190, "!y", "^1") // Стандартный
  375.     replace_all(szMsg, 190, "!t", "^3") // Цвет команды
  376.  
  377.     if(id) iPlayers[0] = id; else get_players(iPlayers, iCount, "ch")
  378.     {
  379.         for(new i = 0; i < iCount; i++)
  380.         {
  381.             if(is_user_connected(iPlayers[i]))
  382.             {
  383.                 message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, iPlayers[i])
  384.                 write_byte(iPlayers[i]);
  385.                 write_string(szMsg);
  386.                 message_end();
  387.             }
  388.         }
  389.     }
  390. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top