Python1320

Untitled

Dec 15th, 2010
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.82 KB | None | 0 0
  1. --prototype ugly ass code
  2.  
  3.  
  4. module("ms",package.seeall)
  5.  
  6. local hook_name = _NAME.."_DM"
  7.  
  8. DMSpawns = {
  9.     Vector(-3905.9990, 6010.6992, 0.0312),
  10.     Vector(-3771.9688, 4875.0801, 0.0312),
  11.     Vector(-3882.6646, 4488.7695, 0.0312),
  12.     Vector(-3113.3406, 4629.9834, 0.0312),
  13.     Vector(-2883.4004, 5658.2051, 0.0312),
  14.     Vector(-3766.5190, 4399.9688, 128.0298),
  15.     Vector(-2732.1672, 4434.4546, 128.0298),
  16.     Vector(-2780.7112, 1403.7767, 128.0312),
  17.     Vector(-3843.4331, 3179.2180, -1.6159),
  18. }
  19.  
  20. DMEntsSpawn = {
  21.             {
  22.                 class   =   "weapon_357",
  23.                 pos =   Vector(-3397.3427734375,5422.3452148438,0.03125),
  24.             },
  25.             {
  26.                 class   =   "weapon_rpg",
  27.                 pos =   Vector(-3362.1352539062,5821.173828125,2.03125),
  28.             },
  29.             {
  30.                 class   =   "item_ammo_ar2_altfire",
  31.                 pos =   Vector(-4015.9907226562,4065.4929199219,39.576751708984),
  32.             },
  33.             {
  34.                 class   =   "item_ammo_ar2_altfire",
  35.                 pos =   Vector(-4015.9907226562,4051.2570800781,39.576751708984),
  36.             },
  37.             {
  38.                 class   =   "item_healthkit_full",
  39.                 pos =   Vector(-4062.9973144531,4650.4072265625,39.025939941406),
  40.             },
  41.             {
  42.                 class   =   "weapon_crossbow",
  43.                 pos =   Vector(-3763.2543945312,4399.96875,128.03125),
  44.             },
  45.             {
  46.                 class   =   "item_ammo_crossbow",
  47.                 pos =   Vector(-3807.96875,4399.96875,128.03125),
  48.             },
  49.             {
  50.                 class   =   "item_box_buckshot",
  51.                 pos =   Vector(-3384.03125,5104.048828125,128.03125),
  52.             },
  53.             {
  54.                 class   =   "item_box_buckshot",
  55.                 pos =   Vector(-3474.96875,4624.03125,128.03125),
  56.             },
  57.             {
  58.                 class   =   "weapon_shotgun",
  59.                 pos =   Vector(-3474.9924316406,4660.4018554688,128.03125),
  60.             },
  61.             {
  62.                 class   =   "weapon_ar2",
  63.                 pos =   Vector(-3583.96875,4083.9326171875,162.40794372559),
  64.             },
  65.             {
  66.                 class   =   "weapon_357",
  67.                 pos =   Vector(-3050.720703125,5040.03125,0.03125),
  68.             },
  69.             {
  70.                 class   =   "item_rpg_round",
  71.                 pos =   Vector(-3384.03125,5104.048828125,128.03125),
  72.             },
  73.             {
  74.                 class   =   "medkit_item_sent",
  75.                 pos =   Vector(-3886.6223144531,4864.62890625,0.03125),
  76.             },
  77.             {
  78.                 class   =   "medkit_item_sent",
  79.                 pos =   Vector(-3887.6865234375,4898.2202148438,0.03125),
  80.             },
  81.             {
  82.                 class   =   "item_ammo_ar2_altfire",
  83.                 pos =   Vector(-3887.5505371094,4945.7680664062,0.13342741131783),
  84.             },
  85.             {
  86.                 class   =   "item_ammo_ar2",
  87.                 pos =   Vector(-3824.3823242188,4943.3256835938,0.34368500113487),
  88.             },
  89.             {
  90.                 class   =   "item_ammo_ar2",
  91.                 pos =   Vector(-3809.05078125,4943.4741210938,0.46465215086937),
  92.             },
  93.             {
  94.                 class   =   "item_ammo_357_large",
  95.                 pos =   Vector(-3695.96875,3628.3986816406,0.03125),
  96.             },
  97.             {
  98.                 class   =   "item_ammo_357_large",
  99.                 pos =   Vector(-3695.4526367188,3593.4619140625,0.03125),
  100.             },
  101.             {
  102.                 class   =   "weapon_357",
  103.                 pos =   Vector(-3679.8686523438,3621.12109375,0.03125),
  104.             },
  105.             {
  106.                 class   =   "weapon_ar2",
  107.                 pos =   Vector(-3183.96875,2161.6213378906,0.023487091064453),
  108.             },
  109.             {
  110.                 class   =   "medkit_item_sent",
  111.                 pos =   Vector(-3183.6437988281,2205.1896972656,0.023487091064453),
  112.             },
  113.             {
  114.                 class   =   "item_ammo_ar2_altfire",
  115.                 pos =   Vector(-4125.9418945312,2747.3562011719,-5.6235980987549),
  116.             },
  117.             {
  118.                 class   =   "weapon_smg1",
  119.                 pos =   Vector(-4036.1276855469,4735.96875,0.03125),
  120.             },
  121.             {
  122.                 class   =   "item_ammo_smg1_grenade",
  123.                 pos =   Vector(-4075.67578125,4735.96875,0.03125),
  124.             },
  125.             {
  126.                 class   =   "item_ammo_smg1_grenade",
  127.                 pos =   Vector(-4101.0629882812,4735.96875,0.03125),
  128.             },
  129.             {
  130.                 class   =   "item_ammo_smg1_large",
  131.                 pos =   Vector(-3292.4165039062,5616.03125,0.03125),
  132.             },
  133.             {
  134.                 class   =   "item_ammo_smg1_large",
  135.                 pos =   Vector(-3578.2238769531,3631.96875,0.03125),
  136.             },
  137.             {
  138.                 class   =   "item_ammo_crossbow",
  139.                 pos =   Vector(-3518.8071289062,3631.96875,0.03125),
  140.             },
  141.             {
  142.                 class   =   "item_ammo_crossbow",
  143.                 pos =   Vector(-3520.6262207031,3616.189453125,0.03125),
  144.             },
  145. }
  146.  
  147.  
  148. function PlayerEnteredDM(ent)
  149.     ent:SetAllowBuild(false)
  150.     ent:SetAllowNoclip(false)
  151.     ent.ms_in_dm = true
  152.    
  153.     if ent.IsScanner and ent:IsScanner() then ent:Kill() end
  154.    
  155.     ent:SetNotSolid(false)
  156.     ent:SetHealth(100)
  157.     ent:StripWeapons()
  158.     ent:Give("fists")
  159.     ent:Give("none")
  160.     ent:Give("weapon_pistol")
  161.     ent:SelectWeapon("weapon_pistol")
  162.    
  163.     ent:SetPACConfig{}
  164.    
  165.     if ent:GetCoins() < 200 then
  166.         ent.ms_dm = nil
  167.         ent.ms_in_dm = nil
  168.         ent:Spawn()
  169.     end
  170. end
  171.  
  172. function PlayerLeftDM(ent)
  173.     ent.ms_in_dm = nil
  174.     ent:SetAllowBuild(true)
  175.     ent:SetAllowNoclip(true)
  176. end
  177.  
  178. timer.Create("dmarea", 1, 0, function()
  179.     for key, ply in pairs(player.GetAll()) do
  180.         if ply:GetPos():Distance(Vector(-3600.03125,3350.3227539062,216.99838256836)) > 3000 then
  181.             if ply.ms_in_dm or ply.ms_dm then
  182.                 PlayerLeftDM(ply)
  183.             end
  184.         else
  185.             if not ply.ms_in_dm or not ply.ms_dm then
  186.                 PlayerEnteredDM(ply)
  187.             end
  188.         end
  189.     end
  190. end)
  191.  
  192. function DMRemoval(ent)
  193.     if not ent:GetOwner():IsPlayer() and not ent:GetParent():IsPlayer() and not ent:IsPlayer() and not ent:IsWeapon() then
  194.         ent:Remove()
  195.         print("removing ent in dm ", ent)
  196.     end
  197. end
  198.  
  199. hook.Add('PlayerShouldTakeDamage', hook_name,function( ply, attacker )
  200.  
  201.     if ply.ms_in_dm then
  202.         ply:SetAllowBuild(false) -- temporary fix until I can figure out why this resets
  203.         ply:SetAllowNoclip(false)
  204.     end
  205.  
  206.     if not attacker.ms_dm then
  207.         attacker.ms_dm = true
  208.     end
  209.     if ply and ply.ms_in_dm then return true end
  210. end)
  211.  
  212. hook.Add("NeroCommand", hook_name, function(ply, command, var)
  213.  
  214.     if command == "tp" and IsValid(ply) and ply.ms_in_dm then return false end
  215.    
  216.    
  217.     if command == "goto" then
  218.         local target = nero.GetPlayer(var)
  219.         if IsValid(target) and target.ms_in_dm then
  220.             ply:SetPos(table.Random(DMSpawns))
  221.             return false
  222.         end
  223.        
  224.         if ply.ms_dm then
  225.             return false
  226.         end
  227.     end
  228. end)
  229.  
  230. hook.Add("PlayerSpawn", hook_name, function(ply)
  231.     if ply.ms_dm then
  232.         ply:SetPos(table.Random(DMSpawns))
  233.     end
  234. end)
  235.  
  236. hook.Add("PlayerDeath", hook_name, function(ply, weapon, killer)
  237.     if ply.ms_dm and ply:PayCoins(200) then
  238.         local coin = coins.Create(ply:GetShootPos(), 200)
  239.         coin:GetPhysicsObject():SetVelocity((killer:GetShootPos() - ply:GetShootPos()):Normalize() * 300)
  240.         coin:SetOwner(ply)
  241.         killer:Cexec("saysoundrandom")
  242.         ply:Cexec("saysoundrandom")
  243.     end
  244. end)
  245.  
  246. local function ScaleDamage(dmginfo, attacker)
  247.     dmginfo:ScaleDamage(math.max(attacker:GetVelocity():Length() / 100, 1))
  248. end
  249.  
  250. hook.Add("ScalePlayerDamage", hook_name, function(ply, hitgroup, dmginfo)
  251.     if ply.ms_dm then
  252.         local attacker = dmginfo:GetAttacker()
  253.         if attacker.ms_dm and attacker:IsPlayer() and not attacker:IsOnGround() then
  254.             --ScaleDamage(dmginfo, ply)
  255.             ScaleDamage(dmginfo, attacker)
  256.         end
  257.     end
  258. end)
  259.  
  260. timer.Create("ms_dm_spawn_weapons", 1, 0, function()
  261.    
  262.  
  263.     local random = table.Random(DMEntsSpawn)
  264.        
  265.     if IsValid(random.ent) and not random.ent:GetOwner():IsPlayer() then return end
  266.    
  267.     local ent = ents.Create(random.class)
  268.     if not IsValid(ent) then print(random.class) return end
  269.     ent:SetPos(random.pos)
  270.     ent:Spawn()
  271.    
  272.     random.ent = ent
  273. end)
Advertisement
Add Comment
Please, Sign In to add comment