Advertisement
Guest User

Untitled

a guest
May 27th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. if CLIENT then return end; if not SERVER then return end
  2.  
  3. hook.Remove( "PhysgunDrop", "ulxPlayerDrop")
  4. local function isPlayer(ent) return (IsValid(ent) && ent.GetClass && ent:GetClass() == "player") end
  5.  
  6. hook.Add("PhysgunPickup", "_ply_physgungrab", function(ply, targ)
  7. if IsValid(ply) and isPlayer(targ) then
  8. if ply:query("ulx physgunplayer") then
  9. local allowed, _ = ULib.getUser( "@", true, ply )
  10. if isPlayer(allowed) then
  11. if allowed.frozen && ply:query( "ulx unfreeze" ) then
  12. allowed.phrozen = true;
  13. allowed.frozen = false;
  14. end
  15. allowed._ulx_physgun = {p=targ:GetPos(), b=true}
  16. end
  17. end
  18. end
  19. end, HOOK_HIGH)
  20.  
  21. hook.Add("PlayerSpawn", "_ply_physgungrab", function(ply)
  22. if ply._ulx_physgun then
  23. if ply._ulx_physgun.b and ply._ulx_physgun.p then
  24. timer.Simple(0.001, function()
  25. ply:SetPos(ply._ulx_physgun.p);
  26. ply:SetMoveType(MOVETYPE_NONE);
  27. end);
  28. end
  29. end
  30. end)
  31.  
  32. local function physgun_freeze( calling_ply, target_ply, should_unfreeze)
  33. local v = target_ply
  34. if v:InVehicle() then
  35. v:ExitVehicle()
  36. end
  37.  
  38. if not should_unfreeze then
  39. v:Lock()
  40. v.frozen = true
  41. v.phrozen = true
  42. ulx.setExclusive( v, "frozen" )
  43. else
  44. v:UnLock()
  45. v.frozen = nil
  46. v.phrozen = nil
  47. ulx.clearExclusive( v )
  48. end
  49.  
  50. v:DisallowSpawning( not should_unfreeze )
  51. ulx.setNoDie( v, not should_unfreeze )
  52.  
  53. if v.whipped then
  54. v.whipcount = v.whipamt
  55. end
  56. end
  57.  
  58. hook.Add("PhysgunDrop", "_ulx_physgunfreeze", function(pl, ent)
  59. if isPlayer(ent) then
  60. ent:SetMoveType( MOVETYPE_WALK )
  61. ent._ulx_physgun = {p=ent:GetPos(), b=false}
  62. end
  63.  
  64. if IsValid(pl) and isPlayer(ent) then
  65. if pl:query("ulx physgunplayer") then
  66. local isFrozen = ( ent:IsFrozen() or ent.frozen or ent.phrozen );
  67. ent:SetVelocity(ent:GetVelocity()*-1);
  68. ent:SetMoveType(pl:KeyDown(IN_ATTACK2) and MOVETYPE_NOCLIP or MOVETYPE_WALK);
  69. timer.Simple(0.001, function()
  70. if pl:KeyDown(IN_ATTACK2) and not isFrozen then
  71. if pl:query( "ulx freeze" ) then
  72. ulx.freeze( pl, {ent}, false );
  73. if ent.frozen then ent.phrozen = true end;
  74. end
  75. elseif pl:query( "ulx unfreeze" ) and isFrozen then
  76. if pl:KeyDown(IN_ATTACK2) and pl:query( "ulx freeze" ) then
  77. physgun_freeze(pl, ent, true)
  78. timer.Simple(0.001, function() physgun_freeze(pl, ent, false) end);
  79. else
  80. ulx.freeze( pl, {ent}, true );
  81. if not ent.frozen then ent.phrozen = nil end;
  82. end
  83. end
  84. end);
  85. else
  86. ent:SetMoveType( MOVETYPE_WALK )
  87. end
  88. end
  89. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement