Aek177

ulx stuff

Jun 1st, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.84 KB | None | 0 0
  1. --=======================================--
  2. -- I claim no credit for this code most of it is
  3. -- base ULX code that has my punishment logging
  4. -- injected into it. What I do however have is
  5. -- permission from the ULX creators to sell and
  6. -- redistribute this code in my addon. Should you
  7. -- question the validity of this statement you are more
  8. -- then welcome to contact me on steam or contact the ULX
  9. -- creators and I will provide prof that this statement is
  10. -- true.
  11. --=======================================--
  12. if not RapSheet.Settings.OverWriteULX or not ulx then return end
  13. if RapSheet.Log then RapSheet.Log("Loading ULX commands!") end
  14. -- Fun.lua
  15.  
  16. ------------------------------ Slay ------------------------------
  17. function ulx.slay( calling_ply, target_plys, reason )
  18. local affected_plys = {}
  19.  
  20. for i=1, #target_plys do
  21. local v = target_plys[ i ]
  22.  
  23. if ulx.getExclusive( v, calling_ply ) then
  24. ULib.tsayError( calling_ply, ulx.getExclusive( v, calling_ply ), true )
  25. elseif not v:Alive() then
  26. ULib.tsayError( calling_ply, v:Nick() .. " is already dead!", true )
  27. elseif v:IsFrozen() then
  28. ULib.tsayError( calling_ply, v:Nick() .. " is frozen!", true )
  29. else
  30. v:Kill()
  31. table.insert( affected_plys, v )
  32. if RapSheet then RapSheet.SavePlayerPunishment(v, "Slayed", reason and reason != "" and reason or "No Reason", IsValid(calling_ply) and string.format("%s (%s)",calling_ply:Nick(),calling_ply:SteamID()) or "(CONSOLE)") end
  33. end
  34. end
  35. if reason and reason != "" then
  36. ulx.fancyLogAdmin( calling_ply, "#A slayed #T for #s", affected_plys, reason )
  37. else
  38. ulx.fancyLogAdmin( calling_ply, "#A slayed #T", affected_plys )
  39. end
  40. end
  41. local slay = ulx.command( "Fun", "ulx slay", ulx.slay, "!slay" )
  42. slay:addParam{ type=ULib.cmds.PlayersArg }
  43. slay:addParam{ type=ULib.cmds.StringArg, hint="reason", ULib.cmds.optional, ULib.cmds.takeRestOfLine, completes=ulx.common_kick_reasons }
  44. slay:defaultAccess( ULib.ACCESS_ADMIN )
  45. slay:help( "Slays target(s)." )
  46.  
  47. ------------------------------ Sslay ------------------------------
  48. function ulx.sslay( calling_ply, target_plys )
  49. local affected_plys = {}
  50.  
  51. for i=1, #target_plys do
  52. local v = target_plys[ i ]
  53.  
  54. if ulx.getExclusive( v, calling_ply ) then
  55. ULib.tsayError( calling_ply, ulx.getExclusive( v, calling_ply ), true )
  56. elseif not v:Alive() then
  57. ULib.tsayError( calling_ply, v:Nick() .. " is already dead!", true )
  58. elseif v:IsFrozen() then
  59. ULib.tsayError( calling_ply, v:Nick() .. " is frozen!", true )
  60. else
  61. if v:InVehicle() then
  62. v:ExitVehicle()
  63. end
  64.  
  65. v:KillSilent()
  66. table.insert( affected_plys, v )
  67. if RapSheet then RapSheet.SavePlayerPunishment(v, "Silent Slayed", "", IsValid(calling_ply) and string.format("%s (%s)",calling_ply:Nick(),calling_ply:SteamID()) or "(CONSOLE)") end
  68. end
  69. end
  70.  
  71. ulx.fancyLogAdmin( calling_ply, "#A silently slayed #T", affected_plys )
  72. end
  73. local sslay = ulx.command( "Fun", "ulx sslay", ulx.sslay, "!sslay" )
  74. sslay:addParam{ type=ULib.cmds.PlayersArg }
  75. sslay:defaultAccess( ULib.ACCESS_ADMIN )
  76. sslay:help( "Silently slays target(s)." )
  77.  
  78. ------------------------------ Freeze ------------------------------
  79. function ulx.freeze( calling_ply, target_plys, should_unfreeze )
  80. local affected_plys = {}
  81. for i=1, #target_plys do
  82. if not should_unfreeze and ulx.getExclusive( target_plys[ i ], calling_ply ) then
  83. ULib.tsayError( calling_ply, ulx.getExclusive( target_plys[ i ], calling_ply ), true )
  84. else
  85. local v = target_plys[ i ]
  86. if v:InVehicle() then
  87. v:ExitVehicle()
  88. end
  89.  
  90. if not should_unfreeze then
  91. v:Lock()
  92. v.frozen = true
  93. ulx.setExclusive( v, "frozen" )
  94. if RapSheet and not should_unfreeze then RapSheet.SavePlayerPunishment(v, "Frozen", "", IsValid(calling_ply) and string.format("%s (%s)",calling_ply:Nick(),calling_ply:SteamID()) or "(CONSOLE)") end
  95. else
  96. v:UnLock()
  97. v.frozen = nil
  98. ulx.clearExclusive( v )
  99. end
  100.  
  101. v:DisallowSpawning( not should_unfreeze )
  102. ulx.setNoDie( v, not should_unfreeze )
  103. table.insert( affected_plys, v )
  104.  
  105. if v.whipped then
  106. v.whipcount = v.whipamt -- Will make it remove
  107. end
  108. end
  109. end
  110.  
  111. if not should_unfreeze then
  112. ulx.fancyLogAdmin( calling_ply, "#A froze #T", affected_plys )
  113. else
  114. ulx.fancyLogAdmin( calling_ply, "#A unfroze #T", affected_plys )
  115. end
  116. end
  117. local freeze = ulx.command( "Fun", "ulx freeze", ulx.freeze, "!freeze" )
  118. freeze:addParam{ type=ULib.cmds.PlayersArg }
  119. freeze:addParam{ type=ULib.cmds.BoolArg, invisible=true }
  120. freeze:defaultAccess( ULib.ACCESS_ADMIN )
  121. freeze:help( "Freezes target(s)." )
  122. freeze:setOpposite( "ulx unfreeze", {_, _, true}, "!unfreeze" )
  123.  
  124. ------------------------------ Blind ------------------------------
  125. function ulx.blind( calling_ply, target_plys, amount, should_unblind )
  126. for i=1, #target_plys do
  127. local v = target_plys[ i ]
  128. umsg.Start( "ulx_blind", v )
  129. umsg.Bool( not should_unblind )
  130. umsg.Short( amount )
  131. umsg.End()
  132.  
  133. if should_unblind then
  134. if v.HadCamera then
  135. v:Give( "gmod_camera" )
  136. end
  137. v.HadCamera = nil
  138. if RapSheet then RapSheet.SavePlayerPunishment(v, "Blinded", "", IsValid(calling_ply) and string.format("%s (%s)",calling_ply:Nick(),calling_ply:SteamID()) or "(CONSOLE)") end
  139. else
  140. if v.HadCamera == nil then -- In case blind is run twice
  141. v.HadCamera = v:HasWeapon( "gmod_camera" )
  142. end
  143. v:StripWeapon( "gmod_camera" )
  144. end
  145. end
  146.  
  147. if not should_unblind then
  148. ulx.fancyLogAdmin( calling_ply, "#A blinded #T by amount #i", target_plys, amount )
  149. else
  150. ulx.fancyLogAdmin( calling_ply, "#A unblinded #T", target_plys )
  151. end
  152. end
  153. local blind = ulx.command( "Fun", "ulx blind", ulx.blind, "!blind" )
  154. blind:addParam{ type=ULib.cmds.PlayersArg }
  155. blind:addParam{ type=ULib.cmds.NumArg, min=0, max=255, default=255, hint="amount", ULib.cmds.round, ULib.cmds.optional }
  156. blind:addParam{ type=ULib.cmds.BoolArg, invisible=true }
  157. blind:defaultAccess( ULib.ACCESS_ADMIN )
  158. blind:help( "Blinds target(s)." )
  159. blind:setOpposite( "ulx unblind", {_, _, _, true}, "!unblind" )
  160.  
  161. ------------------------------ Jail ------------------------------
  162. local doJail
  163. local jailableArea
  164. function ulx.jail( calling_ply, target_plys, seconds, should_unjail )
  165. local affected_plys = {}
  166. for i=1, #target_plys do
  167. local v = target_plys[ i ]
  168.  
  169. if not should_unjail then
  170. if ulx.getExclusive( v, calling_ply ) then
  171. ULib.tsayError( calling_ply, ulx.getExclusive( v, calling_ply ), true )
  172. elseif not jailableArea( v:GetPos() ) then
  173. ULib.tsayError( calling_ply, v:Nick() .. " is not in an area where a jail can be placed!", true )
  174. else
  175. doJail( v, seconds )
  176. if RapSheet then RapSheet.SavePlayerPunishment(v, "Jailed", "for "..seconds, IsValid(calling_ply) and string.format("%s (%s)",calling_ply:Nick(),calling_ply:SteamID()) or "(CONSOLE)") end
  177. table.insert( affected_plys, v )
  178. end
  179. elseif v.jail then
  180. v.jail.unjail()
  181. v.jail = nil
  182. table.insert( affected_plys, v )
  183. end
  184. end
  185.  
  186. if not should_unjail then
  187. local str = "#A jailed #T"
  188. if seconds > 0 then
  189. str = str .. " for #i seconds"
  190. end
  191. ulx.fancyLogAdmin( calling_ply, str, affected_plys, seconds )
  192. else
  193. ulx.fancyLogAdmin( calling_ply, "#A unjailed #T", affected_plys )
  194. end
  195. end
  196. local jail = ulx.command( "Fun", "ulx jail", ulx.jail, "!jail" )
  197. jail:addParam{ type=ULib.cmds.PlayersArg }
  198. jail:addParam{ type=ULib.cmds.NumArg, min=0, default=0, hint="seconds, 0 is forever", ULib.cmds.round, ULib.cmds.optional }
  199. jail:addParam{ type=ULib.cmds.BoolArg, invisible=true }
  200. jail:defaultAccess( ULib.ACCESS_ADMIN )
  201. jail:help( "Jails target(s)." )
  202. jail:setOpposite( "ulx unjail", {_, _, _, true}, "!unjail" )
  203.  
  204. ------------------------------ Jail TP ------------------------------
  205. function ulx.jailtp( calling_ply, target_ply, seconds )
  206. local t = {}
  207. t.start = calling_ply:GetPos() + Vector( 0, 0, 32 ) -- Move them up a bit so they can travel across the ground
  208. t.endpos = calling_ply:GetPos() + calling_ply:EyeAngles():Forward() * 16384
  209. t.filter = target_ply
  210. if target_ply ~= calling_ply then
  211. t.filter = { target_ply, calling_ply }
  212. end
  213. local tr = util.TraceEntity( t, target_ply )
  214.  
  215. local pos = tr.HitPos
  216.  
  217. if ulx.getExclusive( target_ply, calling_ply ) then
  218. ULib.tsayError( calling_ply, ulx.getExclusive( target_ply, calling_ply ), true )
  219. return
  220. elseif not target_ply:Alive() then
  221. ULib.tsayError( calling_ply, target_ply:Nick() .. " is dead!", true )
  222. return
  223. elseif not jailableArea( pos ) then
  224. ULib.tsayError( calling_ply, "That is not an area where a jail can be placed!", true )
  225. return
  226. else
  227. target_ply.ulx_prevpos = target_ply:GetPos()
  228. target_ply.ulx_prevang = target_ply:EyeAngles()
  229.  
  230. if target_ply:InVehicle() then
  231. target_ply:ExitVehicle()
  232. end
  233. if RapSheet then RapSheet.SavePlayerPunishment(target_ply, "Jailed", "for "..seconds, IsValid(calling_ply) and string.format("%s (%s)",calling_ply:Nick(),calling_ply:SteamID()) or "(CONSOLE)") end
  234. target_ply:SetPos( pos )
  235. target_ply:SetLocalVelocity( Vector( 0, 0, 0 ) ) -- Stop!
  236.  
  237. doJail( target_ply, seconds )
  238. end
  239.  
  240. local str = "#A teleported and jailed #T"
  241. if seconds > 0 then
  242. str = str .. " for #i seconds"
  243. end
  244. ulx.fancyLogAdmin( calling_ply, str, target_ply, seconds )
  245. end
  246. local jailtp = ulx.command( "Fun", "ulx jailtp", ulx.jailtp, "!jailtp" )
  247. jailtp:addParam{ type=ULib.cmds.PlayerArg }
  248. jailtp:addParam{ type=ULib.cmds.NumArg, min=0, default=0, hint="seconds, 0 is forever", ULib.cmds.round, ULib.cmds.optional }
  249. jailtp:defaultAccess( ULib.ACCESS_ADMIN )
  250. jailtp:help( "Teleports, then jails target(s)." )
  251.  
  252.  
  253. local function jailCheck()
  254. local remove_timer = true
  255. local players = player.GetAll()
  256. for i=1, #players do
  257. local ply = players[ i ]
  258. if ply.jail then
  259. remove_timer = false
  260. end
  261. if ply.jail and (ply.jail.pos-ply:GetPos()):LengthSqr() >= 6500 then
  262. ply:SetPos( ply.jail.pos )
  263. if ply.jail.jail_until then
  264. doJail( ply, ply.jail.jail_until - CurTime() )
  265. else
  266. doJail( ply, 0 )
  267. end
  268. end
  269. end
  270.  
  271. if remove_timer then
  272. timer.Remove( "ULXJail" )
  273. end
  274. end
  275.  
  276. jailableArea = function( pos )
  277. entList = ents.FindInBox( pos - Vector( 35, 35, 5 ), pos + Vector( 35, 35, 110 ) )
  278. for i=1, #entList do
  279. if entList[ i ]:GetClass() == "trigger_remove" then
  280. return false
  281. end
  282. end
  283.  
  284. return true
  285. end
  286.  
  287. local mdl1 = Model( "models/props_building_details/Storefront_Template001a_Bars.mdl" )
  288. local jail = {
  289. { pos = Vector( 0, 0, -5 ), ang = Angle( 90, 0, 0 ), mdl=mdl1 },
  290. { pos = Vector( 0, 0, 97 ), ang = Angle( 90, 0, 0 ), mdl=mdl1 },
  291. { pos = Vector( 21, 31, 46 ), ang = Angle( 0, 90, 0 ), mdl=mdl1 },
  292. { pos = Vector( 21, -31, 46 ), ang = Angle( 0, 90, 0 ), mdl=mdl1 },
  293. { pos = Vector( -21, 31, 46 ), ang = Angle( 0, 90, 0 ), mdl=mdl1 },
  294. { pos = Vector( -21, -31, 46), ang = Angle( 0, 90, 0 ), mdl=mdl1 },
  295. { pos = Vector( -52, 0, 46 ), ang = Angle( 0, 0, 0 ), mdl=mdl1 },
  296. { pos = Vector( 52, 0, 46 ), ang = Angle( 0, 0, 0 ), mdl=mdl1 },
  297. }
  298. doJail = function( v, seconds )
  299. if v.jail then -- They're already jailed
  300. v.jail.unjail()
  301. end
  302.  
  303. if v:InVehicle() then
  304. local vehicle = v:GetParent()
  305. v:ExitVehicle()
  306. vehicle:Remove()
  307. end
  308.  
  309. -- Force other players to let go of this player
  310. if v.physgunned_by then
  311. for ply, v in pairs( v.physgunned_by ) do
  312. if ply:IsValid() and ply:GetActiveWeapon():IsValid() and ply:GetActiveWeapon():GetClass() == "weapon_physgun" then
  313. ply:ConCommand( "-attack" )
  314. end
  315. end
  316. end
  317.  
  318. if v:GetMoveType() == MOVETYPE_NOCLIP then -- Take them out of noclip
  319. v:SetMoveType( MOVETYPE_WALK )
  320. end
  321.  
  322. local pos = v:GetPos()
  323.  
  324. local walls = {}
  325. for _, info in ipairs( jail ) do
  326. local ent = ents.Create( "prop_physics" )
  327. ent:SetModel( info.mdl )
  328. ent:SetPos( pos + info.pos )
  329. ent:SetAngles( info.ang )
  330. ent:Spawn()
  331. ent:GetPhysicsObject():EnableMotion( false )
  332. ent:SetMoveType( MOVETYPE_NONE )
  333. ent.jailWall = true
  334. table.insert( walls, ent )
  335. end
  336.  
  337. local key = {}
  338. local function unjail()
  339. if not v:IsValid() or not v.jail or v.jail.key ~= key then -- Nope
  340. return
  341. end
  342.  
  343. for _, ent in ipairs( walls ) do
  344. if ent:IsValid() then
  345. ent:DisallowDeleting( false )
  346. ent:Remove()
  347. end
  348. end
  349. if not v:IsValid() then return end -- Make sure they're still connected
  350.  
  351. v:DisallowNoclip( false )
  352. v:DisallowMoving( false )
  353. v:DisallowSpawning( false )
  354. v:DisallowVehicles( false )
  355.  
  356. ulx.clearExclusive( v )
  357. ulx.setNoDie( v, false )
  358.  
  359. v.jail = nil
  360. end
  361. if seconds > 0 then
  362. timer.Simple( seconds, unjail )
  363. end
  364.  
  365. local function newWall( old, new )
  366. table.insert( walls, new )
  367. end
  368.  
  369. for _, ent in ipairs( walls ) do
  370. ent:DisallowDeleting( true, newWall )
  371. ent:DisallowMoving( true )
  372. end
  373. v:DisallowNoclip( true )
  374. v:DisallowMoving( true )
  375. v:DisallowSpawning( true )
  376. v:DisallowVehicles( true )
  377. v.jail = { pos=pos, unjail=unjail, key=key }
  378. if seconds > 0 then
  379. v.jail.jail_until = CurTime() + seconds
  380. end
  381. ulx.setExclusive( v, "in jail" )
  382. ulx.setNoDie( v, true )
  383.  
  384. timer.Create( "ULXJail", 1, 0, jailCheck )
  385. end
  386.  
  387. ------------------------------ Ragdoll ------------------------------
  388. function ulx.ragdoll( calling_ply, target_plys, should_unragdoll )
  389. local affected_plys = {}
  390. for i=1, #target_plys do
  391. local v = target_plys[ i ]
  392.  
  393. if not should_unragdoll then
  394. if ulx.getExclusive( v, calling_ply ) then
  395. ULib.tsayError( calling_ply, ulx.getExclusive( v, calling_ply ), true )
  396. elseif not v:Alive() then
  397. ULib.tsayError( calling_ply, v:Nick() .. " is dead and cannot be ragdolled!", true )
  398. else
  399. if v:InVehicle() then
  400. local vehicle = v:GetParent()
  401. v:ExitVehicle()
  402. end
  403.  
  404. ULib.getSpawnInfo( v ) -- Collect information so we can respawn them in the same state.
  405.  
  406. local ragdoll = ents.Create( "prop_ragdoll" )
  407. ragdoll.ragdolledPly = v
  408.  
  409. ragdoll:SetPos( v:GetPos() )
  410. local velocity = v:GetVelocity()
  411. ragdoll:SetAngles( v:GetAngles() )
  412. ragdoll:SetModel( v:GetModel() )
  413. ragdoll:Spawn()
  414. ragdoll:Activate()
  415. v:SetParent( ragdoll ) -- So their player ent will match up (position-wise) with where their ragdoll is.
  416. -- Set velocity for each peice of the ragdoll
  417. local j = 1
  418. while true do -- Break inside
  419. local phys_obj = ragdoll:GetPhysicsObjectNum( j )
  420. if phys_obj then
  421. phys_obj:SetVelocity( velocity )
  422. j = j + 1
  423. else
  424. break
  425. end
  426. end
  427.  
  428. v:Spectate( OBS_MODE_CHASE )
  429. v:SpectateEntity( ragdoll )
  430. v:StripWeapons() -- Otherwise they can still use the weapons.
  431.  
  432. ragdoll:DisallowDeleting( true, function( old, new )
  433. v.ragdoll = new
  434. end )
  435. v:DisallowSpawning( true )
  436.  
  437. v.ragdoll = ragdoll
  438. ulx.setExclusive( v, "ragdolled" )
  439. if RapSheet then RapSheet.SavePlayerPunishment(v, "Ragdolled", "", IsValid(calling_ply) and string.format("%s (%s)",calling_ply:Nick(),calling_ply:SteamID()) or "(CONSOLE)") end
  440. table.insert( affected_plys, v )
  441. end
  442. elseif v.ragdoll then -- Only if they're ragdolled...
  443. v:DisallowSpawning( false )
  444. v:SetParent()
  445.  
  446. v:UnSpectate() -- Need this for DarkRP for some reason, works fine without it in sbox
  447.  
  448. local ragdoll = v.ragdoll
  449. v.ragdoll = nil -- Gotta do this before spawn or our hook catches it
  450.  
  451. if not ragdoll:IsValid() then -- Something must have removed it, just spawn
  452. ULib.spawn( v, true )
  453.  
  454. else
  455. local pos = ragdoll:GetPos()
  456. pos.z = pos.z + 10 -- So they don't end up in the ground
  457.  
  458. ULib.spawn( v, true )
  459. v:SetPos( pos )
  460. v:SetVelocity( ragdoll:GetVelocity() )
  461. local yaw = ragdoll:GetAngles().yaw
  462. v:SetAngles( Angle( 0, yaw, 0 ) )
  463. ragdoll:DisallowDeleting( false )
  464. ragdoll:Remove()
  465. end
  466.  
  467. ulx.clearExclusive( v )
  468.  
  469. table.insert( affected_plys, v )
  470. end
  471. end
  472.  
  473. if not should_unragdoll then
  474. ulx.fancyLogAdmin( calling_ply, "#A ragdolled #T", affected_plys )
  475. else
  476. ulx.fancyLogAdmin( calling_ply, "#A unragdolled #T", affected_plys )
  477. end
  478. end
  479. local ragdoll = ulx.command( "Fun", "ulx ragdoll", ulx.ragdoll, "!ragdoll" )
  480. ragdoll:addParam{ type=ULib.cmds.PlayersArg }
  481. ragdoll:addParam{ type=ULib.cmds.BoolArg, invisible=true }
  482. ragdoll:defaultAccess( ULib.ACCESS_ADMIN )
  483. ragdoll:help( "ragdolls target(s)." )
  484. ragdoll:setOpposite( "ulx unragdoll", {_, _, true}, "!unragdoll" )
  485.  
  486.  
  487. function ulx.maul( calling_ply, target_plys )
  488. local affected_plys = {}
  489. for i=1, #target_plys do
  490. local v = target_plys[ i ]
  491.  
  492. if ulx.getExclusive( v, calling_ply ) then
  493. ULib.tsayError( calling_ply, ulx.getExclusive( v, calling_ply ), true )
  494.  
  495. elseif not v:Alive() then
  496. ULib.tsayError( calling_ply, v:Nick() .. " is dead!", true )
  497.  
  498. else
  499. local pos = {}
  500. local testent = newZombie( Vector( 0, 0, 0 ), Angle( 0, 0, 0 ), v, true ) -- Test ent for traces
  501.  
  502. local yawForward = v:EyeAngles().yaw
  503. local directions = { -- Directions to try
  504. math.NormalizeAngle( yawForward - 180 ), -- Behind first
  505. math.NormalizeAngle( yawForward + 90 ), -- Right
  506. math.NormalizeAngle( yawForward - 90 ), -- Left
  507. yawForward,
  508. }
  509.  
  510. local t = {}
  511. t.start = v:GetPos() + Vector( 0, 0, 32 ) -- Move them up a bit so they can travel across the ground
  512. t.filter = { v, testent }
  513.  
  514. for i=1, #directions do -- Check all directions
  515. t.endpos = v:GetPos() + Angle( 0, directions[ i ], 0 ):Forward() * 47 -- (33 is player width, this is sqrt( 33^2 * 2 ))
  516. local tr = util.TraceEntity( t, testent )
  517.  
  518. if not tr.Hit then
  519. table.insert( pos, v:GetPos() + Angle( 0, directions[ i ], 0 ):Forward() * 47 )
  520. end
  521. end
  522.  
  523. testent:DisallowDeleting( false )
  524. testent:Remove() -- Don't forget to remove our friend now!
  525.  
  526. if #pos > 0 then
  527. v.maul_npcs = {}
  528. for _, newpos in ipairs( pos ) do
  529. local newang = (v:GetPos() - newpos):Angle()
  530.  
  531. local ent = newZombie( newpos, newang, v )
  532. table.insert( v.maul_npcs, ent )
  533. end
  534.  
  535. v:SetMoveType( MOVETYPE_WALK )
  536. v:DisallowNoclip( true )
  537. v:DisallowSpawning( true )
  538. v:DisallowVehicles( true )
  539. v:GodDisable()
  540. v:SetArmor( 0 ) -- Armor takes waaaay too long for them to take down
  541. v.maulOrigWalk = v:GetWalkSpeed()
  542. v.maulOrigSprint = v:GetRunSpeed()
  543. v:SetWalkSpeed(1)
  544. v:SetRunSpeed(1)
  545.  
  546. v.maulStart = CurTime()
  547. v.maulStartHP = v:Health()
  548. hook.Add( "Think", "MaulMoreDamageThink", maulMoreDamage )
  549.  
  550. ulx.setExclusive( v, "being mauled" )
  551. if RapSheet then RapSheet.SavePlayerPunishment(v, "Mauled", "", IsValid(calling_ply) and string.format("%s (%s)",calling_ply:Nick(),calling_ply:SteamID()) or "(CONSOLE)") end
  552. table.insert( affected_plys, v )
  553. else
  554. ULib.tsayError( calling_ply, "Can't find a place to put the npcs for " .. v:Nick(), true )
  555. end
  556. end
  557. end
  558.  
  559. ulx.fancyLogAdmin( calling_ply, "#A mauled #T", affected_plys )
  560. end
  561. local maul = ulx.command( "Fun", "ulx maul", ulx.maul, "!maul" )
  562. maul:addParam{ type=ULib.cmds.PlayersArg }
  563. maul:defaultAccess( ULib.ACCESS_SUPERADMIN )
  564. maul:help( "Maul target(s)." )
  565.  
  566. local ID_GIMP = 1
  567. local ID_MUTE = 2
  568.  
  569. -- Chat.lua
  570. function ulx.gimp( calling_ply, target_plys, should_ungimp )
  571. for i=1, #target_plys do
  572. local v = target_plys[ i ]
  573. if should_ungimp then
  574. v.gimp = nil
  575. else
  576. v.gimp = ID_GIMP
  577. end
  578. v:SetNWBool("ulx_gimped", not should_ungimp)
  579. if RapSheet and not should_ungimp then RapSheet.SavePlayerPunishment(v, "Gimped", "", IsValid(calling_ply) and string.format("%s (%s)",calling_ply:Nick(),calling_ply:SteamID()) or "(CONSOLE)") end
  580. end
  581.  
  582. if not should_ungimp then
  583. ulx.fancyLogAdmin( calling_ply, "#A gimped #T", target_plys )
  584. else
  585. ulx.fancyLogAdmin( calling_ply, "#A ungimped #T", target_plys )
  586. end
  587. end
  588. local gimp = ulx.command( "Chat", "ulx gimp", ulx.gimp, "!gimp" )
  589. gimp:addParam{ type=ULib.cmds.PlayersArg }
  590. gimp:addParam{ type=ULib.cmds.BoolArg, invisible=true }
  591. gimp:defaultAccess( ULib.ACCESS_ADMIN )
  592. gimp:help( "Gimps target(s) so they are unable to chat normally." )
  593. gimp:setOpposite( "ulx ungimp", {_, _, true}, "!ungimp" )
  594.  
  595. ------------------------------ Mute ------------------------------
  596. function ulx.mute( calling_ply, target_plys, should_unmute, reason )
  597. for i=1, #target_plys do
  598. local v = target_plys[ i ]
  599. if should_unmute then
  600. v.gimp = nil
  601. else
  602. v.gimp = ID_MUTE
  603. end
  604. v:SetNWBool("ulx_muted", not should_unmute)
  605. if RapSheet and not should_unmute then RapSheet.SavePlayerPunishment(v, "Muted", reason != "reason" and reason or "", calling_ply and IsValid(calling_ply) and string.format("%s (%s)",calling_ply:Nick(),calling_ply:SteamID()) or "(CONSOLE)") end
  606. end
  607.  
  608. if not should_unmute then
  609. if reason and reason ~= "" then
  610. ulx.fancyLogAdmin( calling_ply, "#A muted #T for #s", target_plys, reason)
  611. else
  612. ulx.fancyLogAdmin( calling_ply, "#A muted #T", target_plys )
  613. end
  614. else
  615. ulx.fancyLogAdmin( calling_ply, "#A unmuted #T", target_plys )
  616. end
  617. end
  618. local mute = ulx.command( "Chat", "ulx mute", ulx.mute, "!mute" )
  619. mute:addParam{ type=ULib.cmds.PlayersArg }
  620. mute:addParam{ type=ULib.cmds.BoolArg, invisible=true }
  621. mute:addParam{ type=ULib.cmds.StringArg, hint="reason", ULib.cmds.optional, ULib.cmds.takeRestOfLine, completes=ulx.common_kick_reasons }
  622. mute:defaultAccess( ULib.ACCESS_ADMIN )
  623. mute:help( "Mutes target(s) so they are unable to chat." )
  624. mute:setOpposite( "ulx unmute", {_, _, true}, "!unmute" )
  625.  
  626. ------------------------------ Gag ------------------------------
  627. function ulx.gag( calling_ply, target_plys, should_ungag, reason )
  628. local players = player.GetAll()
  629. for i=1, #target_plys do
  630. local v = target_plys[ i ]
  631. v.ulx_gagged = not should_ungag
  632. v:SetNWBool("ulx_gagged", v.ulx_gagged)
  633. if RapSheet and not should_ungag then RapSheet.SavePlayerPunishment(v, "Gagged", reason != "reason" and reason or "", IsValid(calling_ply) and string.format("%s (%s)",calling_ply:Nick(),calling_ply:SteamID()) or "(CONSOLE)") end
  634. end
  635.  
  636. if not should_ungag then
  637. if reason and reason ~= "" then
  638. ulx.fancyLogAdmin( calling_ply, "#A gagged #T for #s", target_plys, reason )
  639. else
  640. ulx.fancyLogAdmin( calling_ply, "#A gagged #T", target_plys )
  641. end
  642. else
  643. ulx.fancyLogAdmin( calling_ply, "#A ungagged #T", target_plys )
  644. end
  645. end
  646. local gag = ulx.command( "Chat", "ulx gag", ulx.gag, "!gag" )
  647. gag:addParam{ type=ULib.cmds.PlayersArg }
  648. gag:addParam{ type=ULib.cmds.BoolArg, invisible=true }
  649. gag:addParam{ type=ULib.cmds.StringArg, hint="reason", ULib.cmds.optional, ULib.cmds.takeRestOfLine, completes=ulx.common_kick_reasons }
  650. gag:defaultAccess( ULib.ACCESS_ADMIN )
  651. gag:help( "Gag target(s), disables microphone." )
  652. gag:setOpposite( "ulx ungag", {_, _, true}, "!ungag" )
  653.  
  654. ------------------------------ Kick ------------------------------
  655.  
  656. function ulx.kick( calling_ply, target_ply, reason )
  657. if reason and reason ~= "" then
  658. ulx.fancyLogAdmin( calling_ply, "#A kicked #T (#s)", target_ply, reason )
  659. else
  660. reason = nil
  661. ulx.fancyLogAdmin( calling_ply, "#A kicked #T", target_ply )
  662. end
  663. -- Delay by 1 frame to ensure the chat hook finishes with player intact. Prevents a crash.
  664. if RapSheet then RapSheet.SavePlayerPunishment(target_ply, "Kicked", string.format("%s",reason), IsValid(calling_ply) and string.format("%s (%s)", calling_ply:Nick(), calling_ply:SteamID()) or "(CONSOLE)") end
  665. ULib.queueFunctionCall( ULib.kick, target_ply, reason, calling_ply )
  666. end
  667. local kick = ulx.command( "Utility", "ulx kick", ulx.kick, "!kick" )
  668. kick:addParam{ type=ULib.cmds.PlayerArg }
  669. kick:addParam{ type=ULib.cmds.StringArg, hint="reason", ULib.cmds.optional, ULib.cmds.takeRestOfLine, completes=ulx.common_kick_reasons }
  670. kick:defaultAccess( ULib.ACCESS_ADMIN )
  671. kick:help( "Kicks target." )
  672.  
  673. ------------------------------ Ban ------------------------------
  674.  
  675. function ulx.ban( calling_ply, target_ply, minutes, reason )
  676. if target_ply:IsBot() then
  677. ULib.tsayError( calling_ply, "Cannot ban a bot", true )
  678. return
  679. end
  680.  
  681. local time = "for #i minute(s)"
  682. if minutes == 0 then time = "permanently" end
  683. local str = "#A banned #T " .. time
  684. if reason and reason ~= "" then str = str .. " (#s)" end
  685. ulx.fancyLogAdmin( calling_ply, str, target_ply, minutes ~= 0 and minutes or reason, reason )
  686. -- Delay by 1 frame to ensure any chat hook finishes with player intact. Prevents a crash.
  687. if RapSheet then RapSheet.SavePlayerPunishment(target_ply, "Banned", string.format("Banned %s with reason %s", tonumber(minutes) == 0 and "permanently" or "for "..tostring(minutes).." minute(s)",reason), IsValid(calling_ply) and string.format("%s (%s)", calling_ply:Nick(), calling_ply:SteamID()) or "(CONSOLE)") end
  688. ULib.queueFunctionCall( ULib.kickban, target_ply, minutes, reason, calling_ply )
  689. end
  690. local ban = ulx.command( "Utility", "ulx ban", ulx.ban, "!ban" )
  691. ban:addParam{ type=ULib.cmds.PlayerArg }
  692. ban:addParam{ type=ULib.cmds.NumArg, hint="minutes, 0 for perma", ULib.cmds.optional, ULib.cmds.allowTimeString, min=0 }
  693. ban:addParam{ type=ULib.cmds.StringArg, hint="reason", ULib.cmds.optional, ULib.cmds.takeRestOfLine, completes=ulx.common_kick_reasons }
  694. ban:defaultAccess( ULib.ACCESS_ADMIN )
  695. ban:help( "Bans target." )
  696.  
  697. ------------------------------ BanID ------------------------------
  698.  
  699. function ulx.banid( calling_ply, steamid, minutes, reason )
  700. steamid = steamid:upper()
  701. if not ULib.isValidSteamID( steamid ) then
  702. ULib.tsayError( calling_ply, "Invalid steamid." )
  703. return
  704. end
  705.  
  706. local name
  707. local plys = player.GetAll()
  708. for i=1, #plys do
  709. if plys[ i ]:SteamID() == steamid then
  710. name = plys[ i ]:Nick()
  711. break
  712. end
  713. end
  714.  
  715. local time = "for #i minute(s)"
  716. if minutes == 0 then time = "permanently" end
  717. local str = "#A banned steamid #s "
  718. displayid = steamid
  719. if name then
  720. displayid = displayid .. "(" .. name .. ") "
  721. end
  722. str = str .. time
  723. if reason and reason ~= "" then str = str .. " (#4s)" end
  724. ulx.fancyLogAdmin( calling_ply, str, displayid, minutes ~= 0 and minutes or reason, reason )
  725. -- Delay by 1 frame to ensure any chat hook finishes with player intact. Prevents a crash.
  726. if RapSheet then RapSheet.SavePlayerPunishment(steamid, "Banned", string.format("Banned %s with reason %s", tonumber(minutes) == 0 and "permanently" or "for "..tostring(minutes).." minute(s)",reason), IsValid(calling_ply) and string.format("%s (%s)", calling_ply:Nick(), calling_ply:SteamID()) or "(CONSOLE)") end
  727. ULib.queueFunctionCall( ULib.addBan, steamid, minutes, reason, name, calling_ply )
  728. end
  729. local banid = ulx.command( "Utility", "ulx banid", ulx.banid )
  730. banid:addParam{ type=ULib.cmds.StringArg, hint="steamid" }
  731. banid:addParam{ type=ULib.cmds.NumArg, hint="minutes, 0 for perma", ULib.cmds.optional, ULib.cmds.allowTimeString, min=0 }
  732. banid:addParam{ type=ULib.cmds.StringArg, hint="reason", ULib.cmds.optional, ULib.cmds.takeRestOfLine, completes=ulx.common_kick_reasons }
  733. banid:defaultAccess( ULib.ACCESS_SUPERADMIN )
  734. banid:help( "Bans steamid." )
  735.  
  736.  
  737. ------------------------------ UnBan ------------------------------
  738.  
  739. function ulx.unban( calling_ply, steamid, reason)
  740. steamid = steamid:upper()
  741. if not ULib.isValidSteamID( steamid ) then
  742. ULib.tsayError( calling_ply, "Invalid steamid." )
  743. return
  744. end
  745.  
  746. name = ULib.bans[ steamid ] and ULib.bans[ steamid ].name
  747. reason = reason or "No reason given."
  748. ULib.unban( steamid, calling_ply )
  749. if name then
  750. ulx.fancyLogAdmin( calling_ply, "#A unbanned steamid #s", steamid .. " (" .. name .. ") for #s", reason )
  751. else
  752. ulx.fancyLogAdmin( calling_ply, "#A unbanned steamid #s for #s", steamid, reason )
  753. end
  754. if RapSheet then
  755. RapSheet.SavePlayerPunishment(steamid, "UnBanned", string.format("Unbanned %s with reason %s",steamid, reason), IsValid(calling_ply) and string.format("%s (%s)", calling_ply:Nick(), calling_ply:SteamID()) or "(CONSOLE)")
  756. end
  757. end
  758. local unban = ulx.command( CATEGORY_NAME, "ulx unban", ulx.unban )
  759. unban:addParam{ type=ULib.cmds.StringArg, hint="steamid" }
  760. unban:addParam{ type=ULib.cmds.StringArg, hint="unban reason", ULib.cmds.optional, ULib.cmds.takeRestOfLine, completes=ulx.common_kick_reasons }
  761. unban:defaultAccess( ULib.ACCESS_ADMIN )
  762. unban:help( "Unbans steamid." )
Advertisement
Add Comment
Please, Sign In to add comment