Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --prototype ugly ass code
- module("ms",package.seeall)
- local hook_name = _NAME.."_DM"
- DMSpawns = {
- Vector(-3905.9990, 6010.6992, 0.0312),
- Vector(-3771.9688, 4875.0801, 0.0312),
- Vector(-3882.6646, 4488.7695, 0.0312),
- Vector(-3113.3406, 4629.9834, 0.0312),
- Vector(-2883.4004, 5658.2051, 0.0312),
- Vector(-3766.5190, 4399.9688, 128.0298),
- Vector(-2732.1672, 4434.4546, 128.0298),
- Vector(-2780.7112, 1403.7767, 128.0312),
- Vector(-3843.4331, 3179.2180, -1.6159),
- }
- DMEntsSpawn = {
- {
- class = "weapon_357",
- pos = Vector(-3397.3427734375,5422.3452148438,0.03125),
- },
- {
- class = "weapon_rpg",
- pos = Vector(-3362.1352539062,5821.173828125,2.03125),
- },
- {
- class = "item_ammo_ar2_altfire",
- pos = Vector(-4015.9907226562,4065.4929199219,39.576751708984),
- },
- {
- class = "item_ammo_ar2_altfire",
- pos = Vector(-4015.9907226562,4051.2570800781,39.576751708984),
- },
- {
- class = "item_healthkit_full",
- pos = Vector(-4062.9973144531,4650.4072265625,39.025939941406),
- },
- {
- class = "weapon_crossbow",
- pos = Vector(-3763.2543945312,4399.96875,128.03125),
- },
- {
- class = "item_ammo_crossbow",
- pos = Vector(-3807.96875,4399.96875,128.03125),
- },
- {
- class = "item_box_buckshot",
- pos = Vector(-3384.03125,5104.048828125,128.03125),
- },
- {
- class = "item_box_buckshot",
- pos = Vector(-3474.96875,4624.03125,128.03125),
- },
- {
- class = "weapon_shotgun",
- pos = Vector(-3474.9924316406,4660.4018554688,128.03125),
- },
- {
- class = "weapon_ar2",
- pos = Vector(-3583.96875,4083.9326171875,162.40794372559),
- },
- {
- class = "weapon_357",
- pos = Vector(-3050.720703125,5040.03125,0.03125),
- },
- {
- class = "item_rpg_round",
- pos = Vector(-3384.03125,5104.048828125,128.03125),
- },
- {
- class = "medkit_item_sent",
- pos = Vector(-3886.6223144531,4864.62890625,0.03125),
- },
- {
- class = "medkit_item_sent",
- pos = Vector(-3887.6865234375,4898.2202148438,0.03125),
- },
- {
- class = "item_ammo_ar2_altfire",
- pos = Vector(-3887.5505371094,4945.7680664062,0.13342741131783),
- },
- {
- class = "item_ammo_ar2",
- pos = Vector(-3824.3823242188,4943.3256835938,0.34368500113487),
- },
- {
- class = "item_ammo_ar2",
- pos = Vector(-3809.05078125,4943.4741210938,0.46465215086937),
- },
- {
- class = "item_ammo_357_large",
- pos = Vector(-3695.96875,3628.3986816406,0.03125),
- },
- {
- class = "item_ammo_357_large",
- pos = Vector(-3695.4526367188,3593.4619140625,0.03125),
- },
- {
- class = "weapon_357",
- pos = Vector(-3679.8686523438,3621.12109375,0.03125),
- },
- {
- class = "weapon_ar2",
- pos = Vector(-3183.96875,2161.6213378906,0.023487091064453),
- },
- {
- class = "medkit_item_sent",
- pos = Vector(-3183.6437988281,2205.1896972656,0.023487091064453),
- },
- {
- class = "item_ammo_ar2_altfire",
- pos = Vector(-4125.9418945312,2747.3562011719,-5.6235980987549),
- },
- {
- class = "weapon_smg1",
- pos = Vector(-4036.1276855469,4735.96875,0.03125),
- },
- {
- class = "item_ammo_smg1_grenade",
- pos = Vector(-4075.67578125,4735.96875,0.03125),
- },
- {
- class = "item_ammo_smg1_grenade",
- pos = Vector(-4101.0629882812,4735.96875,0.03125),
- },
- {
- class = "item_ammo_smg1_large",
- pos = Vector(-3292.4165039062,5616.03125,0.03125),
- },
- {
- class = "item_ammo_smg1_large",
- pos = Vector(-3578.2238769531,3631.96875,0.03125),
- },
- {
- class = "item_ammo_crossbow",
- pos = Vector(-3518.8071289062,3631.96875,0.03125),
- },
- {
- class = "item_ammo_crossbow",
- pos = Vector(-3520.6262207031,3616.189453125,0.03125),
- },
- }
- function PlayerEnteredDM(ent)
- ent:SetAllowBuild(false)
- ent:SetAllowNoclip(false)
- ent.ms_in_dm = true
- if ent.IsScanner and ent:IsScanner() then ent:Kill() end
- ent:SetNotSolid(false)
- ent:SetHealth(100)
- ent:StripWeapons()
- ent:Give("fists")
- ent:Give("none")
- ent:Give("weapon_pistol")
- ent:SelectWeapon("weapon_pistol")
- ent:SetPACConfig{}
- if ent:GetCoins() < 200 then
- ent.ms_dm = nil
- ent.ms_in_dm = nil
- ent:Spawn()
- end
- end
- function PlayerLeftDM(ent)
- ent.ms_in_dm = nil
- ent:SetAllowBuild(true)
- ent:SetAllowNoclip(true)
- end
- timer.Create("dmarea", 1, 0, function()
- for key, ply in pairs(player.GetAll()) do
- if ply:GetPos():Distance(Vector(-3600.03125,3350.3227539062,216.99838256836)) > 3000 then
- if ply.ms_in_dm or ply.ms_dm then
- PlayerLeftDM(ply)
- end
- else
- if not ply.ms_in_dm or not ply.ms_dm then
- PlayerEnteredDM(ply)
- end
- end
- end
- end)
- function DMRemoval(ent)
- if not ent:GetOwner():IsPlayer() and not ent:GetParent():IsPlayer() and not ent:IsPlayer() and not ent:IsWeapon() then
- ent:Remove()
- print("removing ent in dm ", ent)
- end
- end
- hook.Add('PlayerShouldTakeDamage', hook_name,function( ply, attacker )
- if ply.ms_in_dm then
- ply:SetAllowBuild(false) -- temporary fix until I can figure out why this resets
- ply:SetAllowNoclip(false)
- end
- if not attacker.ms_dm then
- attacker.ms_dm = true
- end
- if ply and ply.ms_in_dm then return true end
- end)
- hook.Add("NeroCommand", hook_name, function(ply, command, var)
- if command == "tp" and IsValid(ply) and ply.ms_in_dm then return false end
- if command == "goto" then
- local target = nero.GetPlayer(var)
- if IsValid(target) and target.ms_in_dm then
- ply:SetPos(table.Random(DMSpawns))
- return false
- end
- if ply.ms_dm then
- return false
- end
- end
- end)
- hook.Add("PlayerSpawn", hook_name, function(ply)
- if ply.ms_dm then
- ply:SetPos(table.Random(DMSpawns))
- end
- end)
- hook.Add("PlayerDeath", hook_name, function(ply, weapon, killer)
- if ply.ms_dm and ply:PayCoins(200) then
- local coin = coins.Create(ply:GetShootPos(), 200)
- coin:GetPhysicsObject():SetVelocity((killer:GetShootPos() - ply:GetShootPos()):Normalize() * 300)
- coin:SetOwner(ply)
- killer:Cexec("saysoundrandom")
- ply:Cexec("saysoundrandom")
- end
- end)
- local function ScaleDamage(dmginfo, attacker)
- dmginfo:ScaleDamage(math.max(attacker:GetVelocity():Length() / 100, 1))
- end
- hook.Add("ScalePlayerDamage", hook_name, function(ply, hitgroup, dmginfo)
- if ply.ms_dm then
- local attacker = dmginfo:GetAttacker()
- if attacker.ms_dm and attacker:IsPlayer() and not attacker:IsOnGround() then
- --ScaleDamage(dmginfo, ply)
- ScaleDamage(dmginfo, attacker)
- end
- end
- end)
- timer.Create("ms_dm_spawn_weapons", 1, 0, function()
- local random = table.Random(DMEntsSpawn)
- if IsValid(random.ent) and not random.ent:GetOwner():IsPlayer() then return end
- local ent = ents.Create(random.class)
- if not IsValid(ent) then print(random.class) return end
- ent:SetPos(random.pos)
- ent:Spawn()
- random.ent = ent
- end)
Advertisement
Add Comment
Please, Sign In to add comment