Python1320

CapsAdmin

Feb 18th, 2011
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.94 KB | None | 0 0
  1. chatcommands.RegisterArg("boolean", function(s)
  2.     if self.Alias[s] then return self.Alias[s] end
  3.  
  4.     if s == "1" or s == "true" or s == "yes" or "s" == "on" then return true end
  5.     if s == "0" or s == "false" or s == "no" or "s" == "off" then return true end
  6.    
  7.     -- lmao
  8.     if s == "not likely" then return math.random() > 0.25 end
  9.     if s == "maybe" then return math.random() > 0.5 end
  10.     if s == "likely" then return math.random() > 0.85 end
  11.     if s == "very likely" then return math.random() > 0.95 end
  12. end)
  13.  
  14. chatcommands.RegisterArg("vector", function(s)
  15.     if self.Alias[s] then return self.Alias[s] end
  16.     Vector(s)
  17. end) -- since Vector("0 0 0") works now
  18.  
  19. chatcommands.RegisterArg("angle",  function(s)
  20.     if self.Alias[s] then return self.Alias[s] end
  21.     Angle(s)
  22. end)
  23.  
  24. local CHTCMD = chatcommands.New()
  25.     CHTCMD.Prefix = nil -- or "/"
  26.     CHTCMD.Command = {"goto"}
  27.     CHTCMD.Description = "teleports you to a position"
  28.  
  29.     CHTCMD.ArgList = {
  30.         "position", -- input: Entity (GetPos), Vector
  31.         "boolean", -- input: true false, 1 0, yes no
  32.     }
  33.  
  34.  
  35.     CHTCMD.Verbosity = "all" -- "executor" or "silent" or nil
  36.  
  37.  
  38.     function CHTCMD:OnExecute(executor, object, playsound)
  39.         local var = object:GetVar()
  40.        
  41.         if object:IsVector() then
  42.             executor:SetPos(var)
  43.            
  44.         end
  45.        
  46.         if object:IsEntity() then
  47.             executor:SetPos(var:GetPos() + Vector(0, 0, var:OBBMaxs().z * 1.1))
  48.         end
  49.  
  50.        
  51.         if playsound:GetVar() then
  52.             executor:EmitSound("beep.wav")
  53.         end
  54.  
  55.         self:Notify(executor, "went to", var)
  56.     end
  57.  
  58.     function CHTCMD:CheckExecutor(ply)
  59.         if ply:IsUserGroup("idiot") then
  60.             return "cannot run this command because he's an idiot"
  61.         end
  62.     end
  63.  
  64.     function CHTCMD:CheckObject(var)
  65.         if var:IsEntity() and var:GetVar():IsAdmin() then
  66.             return "You cannot go to", var:GetVar(), "because he is an admin"
  67.         end
  68.        
  69.         if var:IsVector() and not util.IsInWorld(var:GetVar()) then
  70.             return "You cannot go outside the world"
  71.         end
  72.     end
  73.  
  74. chatcommands.Register(CHTCMD)
Advertisement
Add Comment
Please, Sign In to add comment