Guest User

gluaweapondrop

a guest
Apr 10th, 2021
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. local drop_weapons = true
  2. local function toggleDrops(ply)
  3. -- Note that this check won't work and will most likely error when executed from dedicated server console
  4. -- Read more here: https://wiki.facepunch.com/gmod/concommand.Add`
  5. if ply:IsAdmin() then
  6. drop_weapons = not drop_weapons
  7. ply:ChatPrint(string.format("You turned %s weapon dropping!", drop_weapons and "on" or "off"))
  8. end
  9. end
  10.  
  11. -------------------------------------------
  12.  
  13. local drop_dismiss = {
  14. weapon_physgun = true,
  15. weapon_physcannon = true,
  16. gmod_tool = true,
  17. -- and so on...
  18. }
  19.  
  20. local drop_jobs = {
  21. TEAM_POLICE = true,
  22. }
  23.  
  24. local function dropWeapons(ply)
  25.  
  26. -- Only proceed if player is in a team listed in `drop_jobs` and drops are enabled
  27. if drop_weapons and drop_jobs[ply:Team()] then
  28. local spawn_pos = ply:GetPos() + Vector(0, 0, 30)
  29.  
  30. for _, wep in ipairs(ply:GetWeapons()) do
  31. local class = wep:GetClass()
  32. if not drop_dismiss[class] then
  33. -- only spawn weapons that are not present in `drop_dismiss`
  34. local ent = ents.Create(class)
  35. ent:SetPos(spawn_pos)
  36. ent:Spawn()
  37. end
  38. end
  39.  
  40. end
  41.  
  42. end
  43.  
  44. -------------------------------------------
  45.  
  46. concommand.Add("toggleweapondrop", toggleDrops)
  47. hook.Add("DoPlayerDeath", "pldrophook", dropWeapons)
Advertisement
Add Comment
Please, Sign In to add comment