Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if not SERVER then return end
- local function PlaceWeapon(swep, pos, ang)
- local cls = swep and WEPS.GetClass(swep)
- if not cls then return end
- -- Create the weapon, somewhat in the air in case the spot hugs the ground.
- local ent = ents.Create(cls)
- pos.z = pos.z + 3
- ent:SetPos(pos)
- ent:SetAngles(VectorRand():Angle())
- ent:Spawn()
- -- Create some associated ammo (if any)
- if ent.AmmoEnt then
- for i=1, math.random(0,3) do
- local ammo = ents.Create(ent.AmmoEnt)
- if IsValid(ammo) then
- pos.z = pos.z + 2
- ammo:SetPos(pos)
- ammo:SetAngles(VectorRand():Angle())
- ammo:Spawn()
- ammo:PhysWake()
- end
- end
- end
- return ent
- end
- local function SpawnWeps()
- if #player.GetAll() == 0 then return end
- for k,v in pairs(ents.GetAll()) do
- if IsValid(v) and v.AutoSpawnable and not IsValid(v:GetOwner()) then
- v:Remove()
- end
- end
- local spot_classes = {
- ["info_player_teamspawn"] = true,
- ["team_control_point"] = true,
- ["team_control_point_master"] = true,
- ["team_control_point_round"] = true,
- ["item_ammopack_full"] = true,
- ["item_ammopack_medium"] = true,
- ["item_ammopack_small"] = true,
- ["item_healthkit_full"] = true,
- ["item_healthkit_medium"] = true,
- ["item_healthkit_small"] = true,
- ["item_teamflag"] = true,
- ["game_intro_viewpoint"] = true,
- ["info_observer_point"] = true,
- ["info_player_terrorist"] = true,
- ["info_player_counterterrorist"] = true,
- ["hostage_entity"] = true,
- ["info_player_deathmatch"] = true,
- }
- local spots = {}
- for _, e in pairs(ents.GetAll()) do
- if( spot_classes[e:GetClass()] ) then
- table.insert(spots, e)
- end
- end
- local spawnables = ents.TTT.GetSpawnableSWEPs()
- local max = #spots*3
- local num = 0
- local w = nil
- for k, v in RandomPairs(spots) do
- w = table.Random(spawnables)
- if w and IsValid(v) and util.IsInWorld(v:GetPos()) then
- local spawned = PlaceWeapon(w, v:GetPos(), v:GetAngles())
- num = num + 1
- if spawned and spawned.IsGrenade then
- w = table.Random(spawnables)
- if w then
- PlaceWeapon(w, v:GetPos(), v:GetAngles())
- end
- end
- end
- if num > max then
- return
- end
- end
- end
- local function SpawnPlayer( ply )
- ply:SetTeam( TEAM_TERROR )
- ply:Spawn()
- end
- timer.Simple(60, function()
- timer.Create( "FG_Wait", 60, 0, function()
- if GAMEMODE.round_state ~= ROUND_WAIT then return end
- SpawnWeps()
- end)
- hook.Add("Think", "FG_Wait", function()
- if GAMEMODE.round_state ~= ROUND_WAIT then return end
- for k, ply in pairs(player.GetAll()) do
- if not ply:Alive() or ply:Team() == TEAM_SPEC then
- SpawnPlayer( ply )
- end
- end
- end)
- hook.Add("PlayerInitialSpawn", "FG_Wait", function(ply)
- if GAMEMODE.round_state ~= ROUND_WAIT then return end
- timer.Simple(1, SpawnWeps)
- end)
- hook.Add("PlayerDeath", "FG_Wait", function( ply, inflictor, attacker )
- if GAMEMODE.round_state ~= ROUND_WAIT then return end
- for k,ent in pairs(ents.GetAll()) do
- if ent:GetClass() == "prop_ragdoll" then
- if ent.sid == ply:SteamID() and CurTime() - ent.time > 0.1 then
- ent:Remove()
- end
- end
- end
- end)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement