Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.81 KB | None | 0 0
  1. - Last Updated On JUN 21ST, 2015 --
  2. -- I need to recode allot of my old stuff, maybe I'll release a pack someday (#valvetime). --
  3.  
  4. if CLIENT then return end; if not SERVER then return end
  5.  
  6. hook.Remove( "PhysgunDrop", "ulxPlayerDrop") -- We don't need this hook since we have a better hook here.
  7. local function isPlayer(ent) return (IsValid(ent) && ent.GetClass && ent:GetClass() == "player") end
  8.  
  9. local function playerPickup( ply, ent )
  10. local access, tag = ULib.ucl.query( ply, "ulx physgunplayer" )
  11. if isPlayer(ent) and access then
  12. local restrictions = {}
  13. ULib.cmds.PlayerArg.processRestrictions( restrictions, ply, {}, tag and ULib.splitArgs( tag )[ 1 ] )
  14. if restrictions.restrictedTargets == false or (restrictions.restrictedTargets and not table.HasValue( restrictions.restrictedTargets, ent )) then
  15. return false
  16. end
  17. return true
  18. end
  19. end
  20.  
  21. timer.Simple(0.01, function()
  22. hook.Add("PhysgunPickup", "_ply_physgungrab", function(ply, targ)
  23. if IsValid(ply) and isPlayer(targ) then
  24. if ply:query("ulx physgunplayer") and playerPickup( ply, targ ) then
  25. local allowed = ULib.getUser( "@", true, ply )
  26. if isPlayer(allowed) then
  27. if allowed.frozen && ply:query( "ulx unfreeze" ) then
  28. allowed.phrozen = true;
  29. allowed.frozen = false;
  30. end
  31.  
  32. allowed._ulx_physgun = {p=targ:GetPos(), b=true, a=ply}
  33. end
  34. end
  35. end
  36. end, tonumber(HOOK_HIGH)-2); MsgAll('LOADED! 1')
  37. end)
  38.  
  39. hook.Add("PlayerSpawn", "_ply_physgungrab", function(ply)
  40. timer.Simple(0.001, function()
  41. if IsValid(ply) and ply._ulx_physgun then
  42. local admin = ply._ulx_physgun.a
  43. if ply._ulx_physgun.b and ply._ulx_physgun.p and IsValid(admin) then
  44. ply:SetPos(ply._ulx_physgun.p);
  45. ply:SetMoveType(MOVETYPE_NONE);
  46. timer.Simple(0.001, function()
  47. if not (IsValid(admin) and admin:KeyDown(IN_ATTACK)) then
  48. ply:SetMoveType( MOVETYPE_WALK )
  49. ply._ulx_physgun = nil
  50. ply:Spawn()
  51. end
  52. end)
  53. end
  54. end
  55. end)
  56. end)
  57.  
  58. local function physgun_freeze( calling_ply, target_ply, should_unfreeze )
  59. local v = target_ply
  60. if v:InVehicle() then
  61. v:ExitVehicle()
  62. end
  63.  
  64. if not should_unfreeze then
  65. v:Lock()
  66. v.frozen = true
  67. v.phrozen = true
  68. ulx.setExclusive( v, "frozen" )
  69. else
  70. v:UnLock()
  71. v.frozen = nil
  72. v.phrozen = nil
  73. ulx.clearExclusive( v )
  74. end
  75.  
  76. v:DisallowSpawning( not should_unfreeze )
  77. ulx.setNoDie( v, not should_unfreeze )
  78.  
  79. if v.whipped then
  80. v.whipcount = v.whipamt -- Will make it remove
  81. end
  82. end
  83.  
  84. timer.Simple(0.01, function()
  85. hook.Add("OnPhysgunFreeze", "_ulx_physgunfreeze", function(pl, ent)
  86. if isPlayer(ent) then
  87. ent:SetMoveType( MOVETYPE_WALK )
  88. ent._ulx_physgun = nil
  89. end
  90. end)
  91. hook.Add("PhysgunDrop", "_ulx_physgunfreeze", function(pl, ent)
  92. if isPlayer(ent) then
  93. ent:SetMoveType( MOVETYPE_WALK )
  94. ent._ulx_physgun = nil
  95. end
  96.  
  97. if IsValid(pl) and isPlayer(ent) then
  98. if pl:query("ulx freeze") then
  99. local isFrozen = ( ent:IsFrozen() or ent.frozen or ent.phrozen );
  100. ent:SetMoveType(pl:KeyDown(IN_ATTACK2) and MOVETYPE_NONE or MOVETYPE_WALK);
  101. timer.Simple(0.001, function()
  102. if pl:KeyDown(IN_ATTACK2) and not isFrozen then
  103. if pl:query( "ulx freeze" ) then
  104. ent:SetVelocity(ent:GetVelocity()*-1);
  105. ulx.freeze( pl, {ent}, false );
  106. if ent.frozen then ent.phrozen = true end;
  107. end
  108. elseif pl:query( "ulx unfreeze" ) and isFrozen then
  109. if pl:KeyDown(IN_ATTACK2) and pl:query( "ulx freeze" ) then
  110. physgun_freeze(pl, ent, true)
  111. timer.Simple(0.001, function() physgun_freeze(pl, ent, false) end);
  112. else
  113. ulx.freeze( pl, {ent}, true );
  114. if not ent.frozen then ent.phrozen = nil end;
  115. end
  116. end
  117. end);
  118. else
  119. ent:SetMoveType( MOVETYPE_WALK )
  120. end
  121. end
  122. end); MsgAll('LOADED! 2')
  123. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement