daily pastebin goal
11%
SHARE
TWEET

Untitled

a guest Feb 23rd, 2019 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <fakemeta>
  4. #include <engine>
  5. #include <cstrike>
  6. #include <csx>
  7. #include <xs>
  8.  
  9. #define FLAMETHROWER_LEVEL ADMIN_LEVEL_A
  10.  
  11. new wpn_ft
  12. new sprite_fire, sprite_burn, sprite_xplo
  13. new g_freezetime, g_restarted
  14. new Float:g_starttime
  15. new g_enabled, g_client_buy, g_damage, g_xplode_dmg
  16. new g_cost, g_fuelcost, g_fueltank, g_ft_buyzone, g_buytime, g_damage_dis, g_splash_dis
  17. new g_buyzone[33], g_FuelTank[33], g_Activated[33]
  18. new Float:g_Delay[33]
  19. new g_hasFlamethrower[33], g_FireFlamethrower[33], g_BuyFuel[33]
  20.  
  21. new g_item_name[] = { "Flamethrower" }
  22. new g_itemid_flamethrower, g_admin_can_buy, g_ammo_after_kill, g_frags_after_kill
  23.  
  24. static PLUGIN_NAME[]    = "[ZP] Extra : Flamethrower"
  25. static PLUGIN_AUTHOR[]  = "The_Thing"
  26. static PLUGIN_VERSION[] = "0.8"
  27. new const spr_beam[] = "sprites/plasma/plasma_beam.spr"
  28. new g_sprBeam
  29.  
  30. public plugin_init()
  31. {
  32.     register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
  33.     register_cvar("ft_version", PLUGIN_VERSION, FCVAR_SERVER)
  34.    
  35.     g_enabled = register_cvar("zp_ft_enable",           "1")
  36.     g_admin_can_buy = register_cvar("zp_ft_admin_can_buy",      "0")
  37.     g_client_buy = register_cvar("zp_ft_client_buy",        "1")
  38.     g_ft_buyzone = register_cvar("zp_ft_obey_buyzone",      "0")
  39.     g_buytime = register_cvar("zp_ft_obey_buytime",             "0")
  40.     g_cost = register_cvar("zp_ft_cost",                "25")
  41.     g_fuelcost = register_cvar("zp_ft_fuelcost",            "5")
  42.     g_fueltank = register_cvar("zp_ft_fueltank",            "55")
  43.     g_damage = register_cvar("zp_ft_damage",            "250")
  44.     g_xplode_dmg = register_cvar("zp_ft_xplode_dmg",        "90")
  45.     g_damage_dis = register_cvar("zp_ft_damage_dis",        "120")
  46.     g_splash_dis = register_cvar("zp_ft_splash_dis",        "40")
  47.     g_ammo_after_kill = register_cvar("zp_ft_ammo_after_kill",  "15")
  48.     g_frags_after_kill = register_cvar("zp_ft_frags_after_kill",    "5")
  49.  
  50.     register_concmd("bft",      "cmd_BuyFlamethrower",  ADMIN_USER, "- Buys a flamethrower")
  51.     register_clcmd("say dajitem","dajitem")
  52.     register_clcmd("say /bft",  "cmd_BuyFlamethrower",  ADMIN_USER, "- Buys a flamethrower")
  53.     register_clcmd("say_team /bft", "cmd_BuyFlamethrower",  ADMIN_USER, "- Buys a flamethrower")
  54.     register_clcmd("ft_give",   "cmd_GiveFlamethrowers",ADMIN_BAN,  "<@all/ct>/userid - Gives free flamethrowers")
  55.        
  56.     register_event("DeathMsg",      "Event_DeathMsg",   "a")
  57.     register_event("CurWeapon",     "Event_CurWeapon",  "be",   "1=1")
  58.     register_event("StatusIcon",    "Event_BuyZone",    "b",    "2=buyzone")
  59.     register_event("HLTV",      "Event_NewRound",   "a",    "1=0", "2=0")
  60.     register_event("TextMsg",   "Event_WeaponDrop",     "be",   "2=#Weapon_Cannot_Be_Dropped")
  61.     register_event("TextMsg",   "Event_GameRestart",    "a",    "2=#Game_Commencing",   "2=#Game_will_restart_in")
  62.     register_logevent("LogEvent_RoundStart",         2,     "0=World triggered",    "1=Round_Start")
  63.    
  64.     register_forward(FM_CmdStart,       "fw_CmdStart")
  65.     register_forward(FM_PlayerPostThink,    "fw_PlayerPostThink")
  66.     register_forward(FM_UpdateClientData,   "fw_UpdateClientData_Post", 1)
  67.    
  68.     register_think("flamethrower", "think_Flamethrower")
  69.     register_touch("flamethrower", "player", "touch_Flamethrower")
  70.     wpn_ft = custom_weapon_add("weapon_flamethrower", 0, "flamethrower")
  71.    
  72.     if(!get_pcvar_num(g_enabled)) pause("ad", PLUGIN_NAME)
  73. }
  74.  
  75. public plugin_precache()
  76. {
  77.     precache_sound("flamethrower.wav")
  78.     precache_sound("items/ammopickup2.wav")
  79.    
  80.     sprite_xplo = precache_model("sprites/zerogxplode.spr")
  81.     sprite_fire = precache_model("sprites/explode1.spr")
  82.     sprite_burn = precache_model("sprites/xfire.spr")
  83.     g_sprBeam = precache_model(spr_beam)
  84.    
  85.     precache_model("models/v_knife.mdl")
  86.     precache_model("models/p_knife.mdl")
  87.     precache_model("models/shield/v_shield_knife.mdl")
  88.     precache_model("models/shield/p_shield_knife.mdl")
  89.     precache_model("models/w_egon.mdl")
  90.     precache_model("models/v_egon.mdl")
  91.     precache_model("models/p_egon.mdl")
  92. }
  93.  
  94. public cmd_GiveFlamethrowers(id, level, cid)
  95. {
  96.     if(!cmd_access(id, level, cid, 2))
  97.         return PLUGIN_HANDLED
  98.  
  99.     new Arg1[64], target
  100.     read_argv(1, Arg1, 63)
  101.    
  102.     new adminName[32]
  103.     get_user_name(id, adminName, 31)
  104.    
  105.     new targetTeam
  106.     new Players[32], iNum
  107.     if(Arg1[0] == '@')
  108.     {
  109.         if(equali(Arg1[1], "all"))
  110.         {
  111.             targetTeam = 0
  112.             get_players(Players, iNum, "a")
  113.         }
  114.        
  115.         else if(equali(Arg1[1], "ct"))
  116.         {
  117.             targetTeam = 2
  118.             get_players(Players, iNum, "ae" , "ct")
  119.         }
  120.        
  121.         for(new i = 0; i < iNum; ++i)
  122.         {
  123.             target = Players[i]
  124.            
  125.             g_hasFlamethrower[target] = 1
  126.             g_FuelTank[target] = get_pcvar_num(g_fueltank)
  127.            
  128.             new temp[2], weaponID = get_user_weapon(target, temp[0], temp[1])
  129.             if(weaponID == CSW_KNIFE)
  130.             {
  131.                 g_Activated[target] = true
  132.                 set_flamethrower_model(target)
  133.             }
  134.            
  135.             client_cmd(target, "spk items/ammopickup2")
  136.             client_print(target, print_chat, "[ZP] You have been given a flamethrower (press 3 to use)")
  137.         }
  138.        
  139.         switch(targetTeam)
  140.         {
  141.             case 0: client_print(0, print_chat, "Admin: %s has given everyone a flamethrower", adminName)
  142.             case 2: client_print(0, print_chat, "Admin: %s has given all ct's a flamethrower", adminName)
  143.         }
  144.     }
  145.     else
  146.     {
  147.         target = cmd_target(id, Arg1, 0)
  148.         if(!is_user_connected(target) || !is_user_alive(target))
  149.             return PLUGIN_HANDLED
  150.    
  151.         new targetName[32]
  152.         get_user_name(target, targetName, 31)
  153.        
  154.         g_hasFlamethrower[target] = 1
  155.         g_FuelTank[target] = get_pcvar_num(g_fueltank)
  156.        
  157.         new temp[2], weaponID = get_user_weapon(target, temp[0], temp[1])
  158.         if(weaponID == CSW_KNIFE)
  159.         {
  160.             g_Activated[target] = true
  161.             set_flamethrower_model(target)
  162.             entity_set_int(id, EV_INT_weaponanim, 9)
  163.         }
  164.            
  165.         client_cmd(target, "spk items/ammopickup2")
  166.         client_print(target, print_chat, "[ZP] You have been given a flamethrower (press 3 to use)")
  167.         client_print(target, print_chat, "[ZP] Admin: %s has given you a flamethrower", adminName)
  168.     }
  169.     return PLUGIN_HANDLED
  170. }
  171.  
  172. public cmd_BuyFlamethrower(id)
  173. {
  174.     if(!get_pcvar_num(g_client_buy))
  175.         return PLUGIN_CONTINUE
  176.        
  177.     if (!get_pcvar_num(g_admin_can_buy) && (!access(id, ADMIN_LEVEL_A)))
  178.         return PLUGIN_HANDLED
  179.        
  180.     if(get_pcvar_num(g_ft_buyzone))
  181.     {
  182.         if(!g_buyzone[id])
  183.         {
  184.             client_print(id, print_center, "[ZP] You need to be in the buyzone")
  185.             return PLUGIN_HANDLED
  186.         }
  187.     }
  188.    
  189.     if(get_pcvar_num(g_buytime))
  190.     {
  191.         new Float:fBuyTime = get_cvar_float("mp_buytime") * 60
  192.         if(!g_freezetime && (get_gametime() - g_starttime) > fBuyTime)
  193.         {
  194.             client_print(id, print_center, "[ZP] %d seconds have passed.^nYou can't buy anything now!", floatround(fBuyTime))
  195.             return PLUGIN_HANDLED
  196.         }
  197.     }
  198.    
  199.     new iMoney = cs_get_user_money(id)
  200.     new iCost = get_pcvar_num(g_cost)
  201.    
  202.     if(!is_user_alive(id))
  203.         client_print(id, print_center, "[ZP] You cant buy when your dead!")
  204.     else if(g_hasFlamethrower[id])
  205.         client_print(id, print_center, "[ZP] You already own that weapon.")
  206.     else if(iMoney < iCost)
  207.         client_print(id, print_center, "[ZP] You don't have enough ammo packs (%d)", iCost)
  208.     else
  209.     {
  210.         g_hasFlamethrower[id] = 1
  211.         g_FuelTank[id] = get_pcvar_num(g_fueltank)
  212.        
  213.         new temp[2], weaponID = get_user_weapon(id, temp[0], temp[1])
  214.         if(weaponID == CSW_KNIFE)
  215.         {
  216.             g_Activated[id] = true
  217.             set_flamethrower_model(id)
  218.         }
  219.        
  220.             cs_set_user_money(id, iMoney - iCost)
  221.         client_cmd(id, "spk items/ammopickup2")
  222.         client_print(id, print_chat, "[ZP] You bought a flamethrower (press 3 to use)")
  223.     }
  224.    
  225.     if (g_hasFlamethrower[id])
  226.     {
  227.         new temp[2], weaponID = get_user_weapon(id, temp[0], temp[1])
  228.         if(weaponID == CSW_KNIFE)
  229.         {
  230.             g_Activated[id] = false
  231.             set_knife_model(id)
  232.         }
  233.     }
  234.     return PLUGIN_HANDLED
  235. }
  236.  
  237. public dajitem(player)
  238. {
  239.     if (!get_pcvar_num(g_admin_can_buy) && (!access(player, ADMIN_LEVEL_A)))
  240.             return PLUGIN_HANDLED
  241.  
  242.         if ( is_user_alive(player))
  243.         {
  244.             g_hasFlamethrower[player] = 1
  245.             g_FuelTank[player] = get_pcvar_num(g_fueltank)
  246.         }
  247.        
  248.         client_cmd(player, "spk items/ammopickup2")
  249.         client_print(player, print_chat, "[ZP] You bought a flamethrower (press 3 to use)")
  250.        
  251.    
  252.     return PLUGIN_CONTINUE
  253. }
  254.  
  255. public Event_BuyZone(id)
  256. {
  257.     g_buyzone[id] = read_data(1)
  258. }
  259.  
  260. public Event_GameRestart()
  261. {
  262.     g_restarted = 1
  263. }
  264.  
  265. public Event_NewRound()
  266. {
  267.     if(g_restarted)
  268.     {
  269.         new Players[32], iNum = 0
  270.         get_players(Players, iNum)
  271.         for(new i = 0; i < iNum; i++)
  272.         {
  273.             new id = Players[i]
  274.            
  275.             g_FuelTank[id] = 0
  276.             g_Activated[id] = 0
  277.             g_hasFlamethrower[id] = 0
  278.    
  279.             new temp[2], weaponID = get_user_weapon(id, temp[0], temp[1])
  280.             if(weaponID == CSW_KNIFE) set_knife_model(id)
  281.            
  282.             g_restarted = 0
  283.         }
  284.     }
  285.    
  286.     new flamethrowers = -1
  287.     while((flamethrowers = find_ent_by_class(flamethrowers, "flamethrower")))
  288.         remove_entity(flamethrowers)
  289.    
  290.     g_freezetime = 1
  291. }
  292.  
  293. public LogEvent_RoundStart()
  294. {
  295.     g_freezetime = 0
  296.     g_starttime = get_gametime()
  297. }
  298.  
  299. public Event_WeaponDrop(id)
  300. {
  301.     if(!is_user_alive(id) || !g_Activated[id])
  302.         return PLUGIN_CONTINUE
  303.    
  304.     drop_flamethrower(id)
  305.     client_print(id, print_center, "")
  306.    
  307.     new flamethrowers = -1
  308.     while((flamethrowers = find_ent_by_class(flamethrowers, "flamethrower")))
  309.         remove_entity(flamethrowers)
  310.    
  311.     return PLUGIN_HANDLED
  312. }
  313.  
  314. public Event_DeathMsg()
  315. {
  316.     new id = read_data(2)
  317.     if(!is_user_connected(id) || !g_hasFlamethrower[id])
  318.     {
  319.         return PLUGIN_CONTINUE
  320.     }
  321.    
  322.     drop_flamethrower(id)
  323.    
  324.     new flamethrowers = -1
  325.     while((flamethrowers = find_ent_by_class(flamethrowers, "flamethrower")))
  326.         remove_entity(flamethrowers)
  327.        
  328.     return PLUGIN_CONTINUE
  329. }
  330.  
  331. public Event_CurWeapon(id)
  332. {
  333.     if(!is_user_alive(id) || !g_hasFlamethrower[id])
  334.         return PLUGIN_CONTINUE
  335.        
  336.     if (!get_pcvar_num(g_admin_can_buy) && (!access(id, ADMIN_LEVEL_A)))
  337.         return PLUGIN_HANDLED
  338.    
  339.     new WeaponID = read_data(2)
  340.     switch(WeaponID)
  341.     {
  342.         case CSW_KNIFE:
  343.         {
  344.             set_task(0.3, "task_ActivateFlamethrower", id)
  345.             set_flamethrower_model(id)
  346.             entity_set_int(id, EV_INT_weaponanim, 9)
  347.         }
  348.         default: g_Activated[id] = 0
  349.     }
  350.     return PLUGIN_CONTINUE
  351. }
  352.  
  353. public touch_Flamethrower(ent, id)
  354. {
  355.     if(!is_valid_ent(ent) || !is_user_alive(id))
  356.         return PLUGIN_CONTINUE
  357.        
  358.     if (!get_pcvar_num(g_admin_can_buy) && (!access(id, ADMIN_LEVEL_A)))
  359.         return PLUGIN_HANDLED
  360.    
  361.     if(g_hasFlamethrower[id])
  362.         return PLUGIN_CONTINUE
  363.    
  364.     if(has_shield(id))
  365.         return PLUGIN_CONTINUE
  366.    
  367.     g_hasFlamethrower[id] = 1
  368.     client_cmd(id, "spk items/ammopickup2")
  369.     g_FuelTank[id] = entity_get_int(ent, EV_INT_iuser4)
  370.     show_fuel_percentage(id)
  371.    
  372.     new temp[2], weaponID = get_user_weapon(id, temp[0], temp[1])
  373.     if(weaponID == CSW_KNIFE)
  374.     {
  375.         g_Activated[id] = true
  376.         set_flamethrower_model(id)
  377.         entity_set_int(id, EV_INT_weaponanim, 9)
  378.     }
  379.     remove_entity(ent)
  380.    
  381.     return PLUGIN_CONTINUE
  382. }
  383.  
  384. public fw_UpdateClientData_Post(id, sendweapons, cd_handle)
  385. {
  386.     if(!g_hasFlamethrower[id] || !g_Activated[id])
  387.         return FMRES_IGNORED
  388.        
  389.     set_cd(cd_handle, CD_ID, 0)
  390.     return FMRES_HANDLED
  391. }
  392.  
  393. public fw_CmdStart(id, uc_handle, seed)
  394. {
  395.     if(!g_hasFlamethrower[id] || !g_Activated[id])
  396.         return FMRES_IGNORED
  397.    
  398.     new buttons = get_uc(uc_handle, UC_Buttons)
  399.     if(buttons & IN_ATTACK)
  400.     {
  401.         g_FireFlamethrower[id] = 1
  402.    
  403.         buttons &= ~IN_ATTACK
  404.         set_uc(uc_handle, UC_Buttons, buttons)
  405.     } else
  406.         g_FireFlamethrower[id] = 0
  407.        
  408.     if(buttons & IN_ATTACK2)
  409.     {
  410.         g_BuyFuel[id] = 1
  411.        
  412.         buttons &= ~IN_ATTACK2
  413.         set_uc(uc_handle, UC_Buttons, buttons)
  414.     } else
  415.         g_BuyFuel[id] = 0
  416.     return FMRES_HANDLED
  417. }
  418.  
  419. public fw_PlayerPostThink(id)
  420. {
  421.     if(!is_user_connected(id) || !is_user_alive(id))
  422.         return FMRES_IGNORED
  423.        
  424.     if(!get_pcvar_num(g_admin_can_buy) && (!access(id, ADMIN_LEVEL_A)))
  425.         return FMRES_IGNORED
  426.        
  427.     if(!g_hasFlamethrower[id] || !g_Activated[id])
  428.         return FMRES_IGNORED
  429.        
  430.     if(entity_get_int(id, EV_INT_waterlevel) > 1)
  431.         return FMRES_IGNORED
  432.  
  433.     if(has_shield(id))
  434.     {
  435.         drop_flamethrower(id)
  436.         return FMRES_IGNORED
  437.     }
  438.        
  439.     if(g_BuyFuel[id])
  440.     {
  441.         if((g_Delay[id] + 0.2) < get_gametime())
  442.         {
  443.             buy_fuel(id)
  444.             g_Delay[id] = get_gametime()
  445.         }
  446.     }
  447.    
  448.     if(g_FireFlamethrower[id])
  449.     {
  450.         if(g_FuelTank[id] > 0)
  451.         {
  452.             if((g_Delay[id] + 0.2) < get_gametime())
  453.             {
  454.                 g_FuelTank[id] -= 1
  455.                 g_Delay[id] = get_gametime()
  456.             }
  457.            
  458.             new Float:fOrigin[3], Float:fVelocity[3]
  459.             entity_get_vector(id,EV_VEC_origin, fOrigin)
  460.             VelocityByAim(id, 35, fVelocity)
  461.        
  462.             new Float:fTemp[3], iFireOrigin[3]
  463.             xs_vec_add(fOrigin, fVelocity, fTemp)
  464.             FVecIVec(fTemp, iFireOrigin)
  465.            
  466.             new Float:fFireVelocity[3], iFireVelocity[3]
  467.             VelocityByAim(id, get_pcvar_num(g_damage_dis), fFireVelocity)
  468.             FVecIVec(fFireVelocity, iFireVelocity)
  469.            
  470.             create_flames_n_sounds(id, iFireOrigin, iFireVelocity)
  471.            
  472.             new doDamage
  473.             switch(get_cvar_num("mp_friendlyfire"))
  474.             {
  475.                 case 0: doDamage = 0
  476.                 case 1: doDamage = 1
  477.             }
  478.            
  479.             show_fuel_percentage(id)
  480.             direct_damage(id, doDamage)
  481.             indirect_damage(id, doDamage)
  482.             custom_weapon_shot(wpn_ft, id)
  483.         } else
  484.             client_print(id, print_center, "Sorry, Out of Fuel")
  485.     }
  486.     return FMRES_IGNORED
  487. }
  488.  
  489. public think_Flamethrower(ent)
  490. {
  491.     if(is_valid_ent(ent) && entity_get_float(ent, EV_FL_health) < 950.0)
  492.     {
  493.         new Float:fOrigin[3], iOrigin[3]
  494.         entity_get_vector(ent, EV_VEC_origin, fOrigin)
  495.         FVecIVec(fOrigin, iOrigin)
  496.    
  497.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  498.         write_byte(99)
  499.         write_short(ent)
  500.         message_end()
  501.    
  502.         message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  503.         write_byte(3)
  504.         write_coord(iOrigin[0])
  505.         write_coord(iOrigin[1])
  506.         write_coord(iOrigin[2])
  507.         write_short(sprite_xplo)
  508.         write_byte(50)
  509.         write_byte(15)
  510.         write_byte(0)
  511.         message_end()
  512.        
  513.         RadiusDamage(fOrigin, get_pcvar_num(g_xplode_dmg), entity_get_int(ent, EV_INT_iuser4))
  514.         remove_entity(ent)
  515.     }
  516.     if(is_valid_ent(ent)) entity_set_float(ent, EV_FL_nextthink, halflife_time() + 0.01)
  517. }
  518.  
  519. public create_flames_n_sounds(id, iStartOrigin[3], velocity[3])
  520. {
  521.     message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  522.     write_byte(0)    
  523.     write_coord(iStartOrigin[0])
  524.     write_coord(iStartOrigin[1])
  525.     write_coord(iStartOrigin[2])
  526.     write_coord(velocity[0])
  527.     write_coord(velocity[1])
  528.     write_coord(velocity[2] + 5)
  529.     write_short(g_sprBeam)
  530.     write_byte(1)
  531.     write_byte(5)
  532.     write_byte(10)
  533.     write_byte(25)
  534.     write_byte(0)
  535.     write_byte(0)    
  536.     write_byte(255)      
  537.     write_byte(0)      
  538.     write_byte(100)
  539.     write_byte(0)
  540.     message_end()
  541.    
  542.     emit_sound(id, CHAN_WEAPON, "flamethrower.wav", VOL_NORM, ATTN_NORM, 0, PITCH_NORM)
  543. }
  544.  
  545. public direct_damage(id, doDamage)
  546. {
  547.     new ent, body
  548.     get_user_aiming(id, ent, body, get_pcvar_num(g_damage_dis) + 5000)
  549.    
  550.     if(ent > 0 && is_user_alive(ent) && !(get_user_team(ent) == get_user_team(id)))
  551.     {
  552.         if(!doDamage)
  553.         {
  554.             damage_user(id, ent, get_pcvar_num(g_damage))
  555.             custom_weapon_dmg(wpn_ft, id, ent, get_pcvar_num(g_damage))
  556.         }
  557.         else
  558.         {
  559.             damage_user(id, ent, get_pcvar_num(g_damage))  
  560.             custom_weapon_dmg(wpn_ft, id, ent, get_pcvar_num(g_damage))
  561.         }
  562.     }
  563. }
  564.  
  565. public indirect_damage(id, doDamage)
  566. {
  567.     new Players[32], iNum
  568.     get_players(Players, iNum, "a")
  569.     for(new i = 0; i < iNum; ++i) if(id != Players[i])
  570.     {
  571.         new target = Players[i]
  572.    
  573.         new Float:fOrigin[3], Float:fOrigin2[3]
  574.         entity_get_vector(id,EV_VEC_origin, fOrigin)
  575.         entity_get_vector(target, EV_VEC_origin, fOrigin2)
  576.            
  577.         new temp[3], Float:fAim[3]
  578.         get_user_origin(id, temp, 3)
  579.         IVecFVec(temp, fAim)
  580.        
  581.         new Float:fDistance = get_pcvar_num(g_damage_dis) + 500.0
  582.         if(get_distance_f(fOrigin, fOrigin2) > fDistance)
  583.             continue
  584.        
  585.         new iDistance = get_distance_to_line(fOrigin, fOrigin2, fAim)
  586.         if(iDistance > get_pcvar_num(g_splash_dis) || iDistance < 0 || !fm_is_ent_visible(id, target))
  587.             continue
  588.            
  589.         if(!doDamage)
  590.         {
  591.             if(get_user_team(id) != get_user_team(target))
  592.             {
  593.                 damage_user(id, target, get_pcvar_num(g_damage))
  594.                 custom_weapon_dmg(wpn_ft, id, target, get_pcvar_num(g_damage))
  595.             }
  596.         }
  597.         else
  598.         {
  599.             damage_user(id, target, get_pcvar_num(g_damage) / 2)
  600.             custom_weapon_dmg(wpn_ft, id, target, get_pcvar_num(g_damage) / 2)
  601.         }
  602.     }
  603. }
  604.  
  605. public buy_fuel(id)
  606. {
  607.     if(get_pcvar_num(g_ft_buyzone) && !g_buyzone[id])
  608.         return PLUGIN_CONTINUE
  609.        
  610.     new Float:fBuyTime = get_cvar_float("mp_buytime") * 60
  611.     if(get_pcvar_num(g_buytime) && !g_freezetime
  612.     && (get_gametime() - g_starttime) > fBuyTime)
  613.         return PLUGIN_CONTINUE
  614.  
  615.     if(g_FuelTank[id] >= get_pcvar_num(g_fueltank))
  616.         return PLUGIN_CONTINUE
  617.                
  618.     new iMoney = cs_get_user_money(id)
  619.     new iCost = get_pcvar_num(g_fuelcost)
  620.     if(iMoney >= iCost)
  621.     {
  622.         g_FuelTank[id] += 1
  623.         show_fuel_percentage(id)
  624.         cs_set_user_money(id, iMoney - iCost)
  625.  
  626.         return PLUGIN_CONTINUE
  627.     }  
  628.     return PLUGIN_CONTINUE
  629. }
  630.  
  631. public drop_flamethrower(id)
  632. {
  633.     new Float:fVelocity[3], Float:fOrigin[3]
  634.     entity_get_vector(id, EV_VEC_origin, fOrigin)
  635.     VelocityByAim(id, 34, fVelocity)
  636.    
  637.     fOrigin[0] += fVelocity[0]
  638.     fOrigin[1] += fVelocity[1]
  639.  
  640.     VelocityByAim(id, 300, fVelocity)
  641.    
  642.     new ent = create_entity("info_target")
  643.     if(is_valid_ent(ent))
  644.     {
  645.         entity_set_string(ent, EV_SZ_classname, "flamethrower")
  646.         entity_set_model(ent, "models/w_egon.mdl")
  647.         entity_set_int(ent, EV_INT_movetype, MOVETYPE_TOSS)
  648.         entity_set_int(ent, EV_INT_solid, SOLID_TRIGGER)
  649.         entity_set_vector(ent, EV_VEC_origin, fOrigin)
  650.         entity_set_vector(ent, EV_VEC_velocity, fVelocity)
  651.         entity_set_int(ent, EV_INT_iuser4, g_FuelTank[id])
  652.         entity_set_float(ent, EV_FL_takedamage, 1.0)
  653.         entity_set_float(ent, EV_FL_health, 1000.0)
  654.         entity_set_size(ent, Float:{-2.5, -2.5, -1.5}, Float:{2.5, 2.5, 1.5})
  655.         entity_set_float(ent, EV_FL_nextthink, halflife_time() + 0.01)
  656.     }
  657.    
  658.     g_FuelTank[id] = 0
  659.     g_Activated[id] = 0
  660.     g_hasFlamethrower[id] = 0
  661.    
  662.     if(has_shield(id))
  663.         set_shield_model(id)
  664.     else
  665.         set_knife_model(id)
  666.        
  667.     return PLUGIN_CONTINUE
  668. }
  669.  
  670. public task_ActivateFlamethrower(id)
  671. {
  672.     if(!is_user_connected(id) || !is_user_alive(id))
  673.         return PLUGIN_CONTINUE
  674.    
  675.     new temp[2], weaponID = get_user_weapon(id, temp[0], temp[1])
  676.     if(weaponID == CSW_KNIFE) g_Activated[id] = 1
  677.        
  678.     return PLUGIN_CONTINUE
  679. }
  680.  
  681. public show_fuel_percentage(id)
  682. {
  683.     set_hudmessage(255, 170, 0, 0.91, 0.95, _, _, 1.0, _, _, 4)
  684.     show_hudmessage(id, "Fuel Tank: %d%%", get_percent(g_FuelTank[id], get_pcvar_num(g_fueltank)))
  685. }
  686.  
  687. public set_flamethrower_model(id)
  688. {
  689.     entity_set_string(id, EV_SZ_viewmodel, "models/v_egon.mdl")
  690.     entity_set_string(id, EV_SZ_weaponmodel, "models/p_egon.mdl")
  691. }
  692.  
  693. public set_knife_model(id)
  694. {
  695.     entity_set_string(id, EV_SZ_viewmodel, "models/v_knife.mdl")
  696.     entity_set_string(id, EV_SZ_weaponmodel, "models/p_knife.mdl") 
  697. }
  698.  
  699. public set_shield_model(id)
  700. {
  701.     entity_set_string(id, EV_SZ_viewmodel, "models/shield/v_shield_knife.mdl")
  702.     entity_set_string(id, EV_SZ_weaponmodel, "models/shield/p_shield_knife.mdl")
  703. }
  704.  
  705. stock damage_user(id, victim, damage)
  706. {
  707.     new iHealth = get_user_health(victim)
  708.     if(iHealth > damage)
  709.         fakedamage(victim, "weapon_flamethrower", float(damage), DMG_BURN)
  710.     else
  711.     {
  712.         user_silentkill(victim)
  713.         make_deathmsg(id, victim, 0, "flamethrower")
  714.        
  715.         new iOrigin[3]
  716.         get_user_origin(victim, iOrigin, 0)
  717.        
  718.         message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  719.         write_byte(17)
  720.         write_coord(iOrigin[0])
  721.         write_coord(iOrigin[1])
  722.         write_coord(iOrigin[2] + 10)
  723.         write_short(sprite_burn)
  724.         write_byte(30)
  725.         write_byte(40)
  726.         message_end()
  727.            
  728.         if(get_user_team(id) != get_user_team(victim))
  729.         {
  730.             fm_set_user_frags(id, get_user_frags(id) + get_pcvar_num(g_frags_after_kill))
  731.         }
  732.        
  733.         message_begin(MSG_ALL, get_user_msgid("ScoreInfo"))
  734.         write_byte(id)
  735.         write_short(get_user_frags(id))
  736.         write_short(get_user_deaths(id))
  737.         write_short(0)
  738.         write_short(get_user_team(id))
  739.         message_end()
  740.        
  741.         message_begin(MSG_ALL, get_user_msgid("ScoreInfo"))
  742.         write_byte(victim)
  743.         write_short(get_user_frags(victim))
  744.         write_short(get_user_deaths(victim))
  745.         write_short(0)
  746.         write_short(get_user_team(victim))
  747.         message_end()
  748.     }
  749. }
  750.  
  751. stock get_percent(value, tvalue)
  752. {      
  753.     return floatround(floatmul(float(value) / float(tvalue) , 100.0))  
  754. }
  755.  
  756. stock get_distance_to_line(Float:pos_start[3], Float:pos_end[3], Float:pos_object[3])  
  757. {  
  758.     new Float:vec_start_end[3], Float:vec_start_object[3], Float:vec_end_object[3], Float:vec_end_start[3]
  759.     xs_vec_sub(pos_end, pos_start, vec_start_end)       // vector from start to end
  760.     xs_vec_sub(pos_object, pos_start, vec_start_object)     // vector from end to object
  761.     xs_vec_sub(pos_start, pos_end, vec_end_start)       // vector from end to start
  762.     xs_vec_sub(pos_end, pos_object, vec_end_object)         // vector object to end
  763.    
  764.     new Float:len_start_object = getVecLen(vec_start_object)
  765.     new Float:angle_start = floatacos(xs_vec_dot(vec_start_end, vec_start_object) / (getVecLen(vec_start_end) * len_start_object), degrees)  
  766.     new Float:angle_end = floatacos(xs_vec_dot(vec_end_start, vec_end_object) / (getVecLen(vec_end_start) * getVecLen(vec_end_object)), degrees)  
  767.  
  768.     if(angle_start <= 90.0 && angle_end <= 90.0)
  769.         return floatround(len_start_object * floatsin(angle_start, degrees))
  770.     return -1  
  771. }
  772.  
  773. stock Float:getVecLen(Float:Vec[3])
  774. {
  775.     new Float:VecNull[3] = {0.0, 0.0, 0.0}
  776.     new Float:len = get_distance_f(Vec, VecNull)
  777.     return len
  778. }
  779.  
  780. stock bool:fm_is_ent_visible(index, entity)
  781. {
  782.     new Float:origin[3], Float:view_ofs[3], Float:eyespos[3]
  783.     pev(index, pev_origin, origin)
  784.     pev(index, pev_view_ofs, view_ofs)
  785.     xs_vec_add(origin, view_ofs, eyespos)
  786.  
  787.     new Float:entpos[3]
  788.     pev(entity, pev_origin, entpos)
  789.     engfunc(EngFunc_TraceLine, eyespos, entpos, 0, index)
  790.  
  791.     switch(pev(entity, pev_solid)) {
  792.         case SOLID_BBOX..SOLID_BSP: return global_get(glb_trace_ent) == entity
  793.     }
  794.    
  795.     new Float:fraction
  796.     global_get(glb_trace_fraction, fraction)
  797.     if(fraction == 1.0)
  798.         return true
  799.        
  800.     return false
  801. }
  802.  
  803. stock bool:has_shield(id)
  804. {
  805.     new modelName[32]
  806.     entity_get_string(id, EV_SZ_viewmodel, modelName, 31)
  807.  
  808.     if(containi(modelName, "v_shield_") != -1)
  809.         return true
  810.        
  811.     return false
  812. }
  813.  
  814. stock fm_set_user_frags(index, frags)
  815. {
  816.     set_pev(index, pev_frags, float(frags));
  817.  
  818.     return 1;
  819. }
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