thatonepuggo

someAdmin

Feb 1st, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.31 KB | None | 0 0
  1. -- before you use this script please note :                                                       --
  2. -- arguments are caps sensitive (yes even player arguments)                                       --
  3. -- do not edit this script unless you know what you're doing.                                     --
  4. -- commands with [DISABLED] next to them are commands that are not done or not completed.         --
  5. -- you cannot use this with exploits because it is FE                                             --
  6.  
  7.  
  8.  
  9. if game:GetService("RunService"):IsClient() then error("Script must be server-side in order to work; use h/ and not hl/") end
  10. local Player,Mouse,mouse,UserInputService,ContextActionService = owner
  11. do
  12.     print("FE Compatibility by timlikekezenit")
  13.     script.Parent = Player.Character
  14.  
  15.     --RemoteEvent for communicating
  16.     local Event = Instance.new("RemoteEvent")
  17.     Event.Name = "UserInput_Event"
  18.  
  19.     --Fake event to make stuff like Mouse.KeyDown work
  20.     local function fakeEvent()
  21.         local t = {_fakeEvent=true,Connect=function(self,f)self.Function=f end}
  22.         t.connect = t.Connect
  23.         return t
  24.     end
  25.  
  26.     --Creating fake input objects with fake variables
  27.     local m = {Target=nil,Hit=CFrame.new(),KeyUp=fakeEvent(),KeyDown=fakeEvent(),Button1Up=fakeEvent(),Button1Down=fakeEvent()}
  28.     local UIS = {InputBegan=fakeEvent(),InputEnded=fakeEvent()}
  29.     local CAS = {Actions={},BindAction=function(self,name,fun,touch,...)
  30.         CAS.Actions[name] = fun and {Name=name,Function=fun,Keys={...}} or nil
  31.     end}
  32.     --Merged 2 functions into one by checking amount of arguments
  33.     CAS.UnbindAction = CAS.BindAction
  34.  
  35.     --This function will trigger the events that have been :Connect()'ed
  36.     local function te(self,ev,...)
  37.         local t = m[ev]
  38.         if t and t._fakeEvent and t.Function then
  39.             t.Function(...)
  40.         end
  41.     end
  42.     m.TrigEvent = te
  43.     UIS.TrigEvent = te
  44.  
  45.     Event.OnServerEvent:Connect(function(plr,io)
  46.         if plr~=Player then return end
  47.         if io.isMouse then
  48.             m.Target = io.Target
  49.             m.Hit = io.Hit
  50.         else
  51.             local b = io.UserInputState == Enum.UserInputState.Begin
  52.             if io.UserInputType == Enum.UserInputType.MouseButton1 then
  53.                 return m:TrigEvent(b and "Button1Down" or "Button1Up")
  54.             end
  55.             for _,t in pairs(CAS.Actions) do
  56.                 for _,k in pairs(t.Keys) do
  57.                     if k==io.KeyCode then
  58.                         t.Function(t.Name,io.UserInputState,io)
  59.                     end
  60.                 end
  61.             end
  62.             m:TrigEvent(b and "KeyDown" or "KeyUp",io.KeyCode.Name:lower())
  63.             UIS:TrigEvent(b and "InputBegan" or "InputEnded",io,false)
  64.         end
  65.     end)
  66.     Event.Parent = NLS([==[
  67.     local Player = game:GetService("Players").LocalPlayer
  68.     local Event = script:WaitForChild("UserInput_Event")
  69.  
  70.     local UIS = game:GetService("UserInputService")
  71.     local input = function(io,a)
  72.         if a then return end
  73.         --Since InputObject is a client-side instance, we create and pass table instead
  74.         Event:FireServer({KeyCode=io.KeyCode,UserInputType=io.UserInputType,UserInputState=io.UserInputState})
  75.     end
  76.     UIS.InputBegan:Connect(input)
  77.     UIS.InputEnded:Connect(input)
  78.  
  79.     local Mouse = Player:GetMouse()
  80.     local h,t
  81.     --Give the server mouse data 30 times every second, but only if the values changed
  82.     --If player is not moving their mouse, client won't fire events
  83.     while wait(1/30) do
  84.         if h~=Mouse.Hit or t~=Mouse.Target then
  85.             h,t=Mouse.Hit,Mouse.Target
  86.             Event:FireServer({isMouse=true,Target=t,Hit=h})
  87.         end
  88.     end]==],Player.Character)
  89.     Mouse,mouse,UserInputService,ContextActionService = m,m,UIS,CAS
  90. end
  91.  
  92.  
  93. local plr = owner
  94. local char = plr.Character
  95. local someAdmin = Instance.new("Hint",workspace)
  96. someAdmin.Text = "someAdmin has loaded. type :cmds for a message containing commands."
  97. wait(3)
  98. someAdmin:Destroy()
  99. -- functions and how to use --
  100. --[[ eg. Function=function(args)
  101. player_arg(args,)
  102.  
  103. ]]
  104. local function player_arg(argument,code) -- turns argument into player (still caps sensitive)
  105. for _, player in pairs(game.Players:GetPlayers()) do
  106. if player.Name:sub(1,string.len(argument)) then
  107. code()
  108. end
  109. end
  110. end
  111. -- pass in a command dictionary (shown in cX variables). will convert the dictionary into a command.
  112. local function create_command(var_cmd)
  113. plr.Chatted:Connect(function(chat)
  114. if chat == prefix..""..var_cmd.name then
  115.  
  116. end
  117. end)
  118. end
  119. -- commands --
  120. plr.Chatted:Connect(function(chat)
  121. local prefix = ":"
  122. local cmds = {name="cmds",args="",desc="shows a list of cmds",disabled={is=false,res=""},Function=function(args)
  123. local cmdslist = Instance.new("Message",plr.PlayerGui)
  124. end)}
  125. local c1 = {name="kick",args="plr",desc="kicks a player from the server.",disabled={is=false,res=""}}
  126. local c2 = {name="btools",args="plr",desc="gives a player F3X building tools.",disabled={is=true,res="insertservice trash sometimes."}}
  127. local c3 = {name="admin",args="plr",desc="gives a player admin",disabled={is=true,res="not sure how tables work."}}
  128. local c4 = {name="m",args="text",desc="sends a message to the workspace (can't execute while commands open)",disabled={is=false,res=""},Function=function(args)
  129. local m = Instance.new("Message",workspace)
  130. m.Text = args
  131. end)
  132. }
  133. -- ehh kinda lazy to add more cmds --
  134. -- create_commands   --
  135. end)
Add Comment
Please, Sign In to add comment