Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local drop_weapons = true
- local function toggleDrops(ply)
- -- Note that this check won't work and will most likely error when executed from dedicated server console
- -- Read more here: https://wiki.facepunch.com/gmod/concommand.Add`
- if ply:IsAdmin() then
- drop_weapons = not drop_weapons
- ply:ChatPrint(string.format("You turned %s weapon dropping!", drop_weapons and "on" or "off"))
- end
- end
- -------------------------------------------
- local drop_dismiss = {
- weapon_physgun = true,
- weapon_physcannon = true,
- gmod_tool = true,
- -- and so on...
- }
- local drop_jobs = {
- TEAM_POLICE = true,
- }
- local function dropWeapons(ply)
- -- Only proceed if player is in a team listed in `drop_jobs` and drops are enabled
- if drop_weapons and drop_jobs[ply:Team()] then
- local spawn_pos = ply:GetPos() + Vector(0, 0, 30)
- for _, wep in ipairs(ply:GetWeapons()) do
- local class = wep:GetClass()
- if not drop_dismiss[class] then
- -- only spawn weapons that are not present in `drop_dismiss`
- local ent = ents.Create(class)
- ent:SetPos(spawn_pos)
- ent:Spawn()
- end
- end
- end
- end
- -------------------------------------------
- concommand.Add("toggleweapondrop", toggleDrops)
- hook.Add("DoPlayerDeath", "pldrophook", dropWeapons)
Advertisement
Add Comment
Please, Sign In to add comment