Advertisement
KrYn0MoRe

Trust System/Algorithm v1.6 - anti bot/alt

Nov 12th, 2020 (edited)
1,916
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 14.80 KB | None | 0 0
  1. --[[
  2.  
  3. = TRUST ALGORITHM =
  4.  
  5. Made by KrYn0MoRe
  6. This is used to prevent bots and alts
  7. Very useful but sometimes it is not friendly to new Roblox players
  8. The board is not required, this can be used silently in the background and can be used to let players have a good time without trolls, bots, etc.
  9.  
  10. ]]
  11.  
  12. local base_trust = 0
  13. local board = nil
  14. local title = nil
  15. local plrs = {}
  16. local scrolls = {}
  17. local funcs = {}
  18. local kick = false -- kick if the player is not trusted
  19. local chat = true -- if you can use chat commands (disable if you don't know what you're doing)
  20. local list = true -- to see players trust (disable if using for game anti cheat)
  21. local tmin = -1 -- minimum trust factor (this really matters)
  22. local tmax = 3 -- max trust factor to be good boy (just visual i guess lol)
  23.  
  24. local HS = game:GetService("HttpService")
  25. local BS = game:GetService("BadgeService")
  26. local MPS = game:GetService("MarketplaceService")
  27.  
  28. function point(n,low,max) -- sets a max for points
  29.     return math.clamp(n,low,max)
  30. end
  31.  
  32. function afunc(f) -- adds functions that determine the players trust
  33.     table.insert(funcs,1,f)
  34. end
  35.  
  36. afunc(function(plr,remote)
  37.     local r
  38.     if remote and type(plr) == 'string' then
  39.         --r = HS:JSONDecode(HS:GetAsync("https://premiumfeatures.rprxy.xyz/v1/users/" .. tostring(plr.UserId) .. "/validate-membership"))
  40.         return
  41.     else
  42.         if plr.MembershipType ~= Enum.MembershipType.None then
  43.             r = true
  44.         end
  45.     end
  46.     if r then
  47.         return 1
  48.     else
  49.         return -1
  50.     end
  51. end)
  52.  
  53. afunc(function(plr,remote)
  54.     local verified
  55.     if remote then
  56.         verified = HS:JSONDecode(HS:GetAsync("https://api.rprxy.xyz/ownership/hasasset?userId=" .. tostring(plr.UserId) .. "&assetId=102611803"))
  57.     else
  58.         verified = MPS:PlayerOwnsAsset(plr,102611803)
  59.     end
  60.     local t = 0
  61.     if verified then
  62.         t = t + 1
  63.     else
  64.         t = t - 2
  65.     end
  66.     return t
  67. end)
  68.  
  69. afunc(function(plr)
  70.     local y = os.date('!*t').year-2006
  71.     local age = plr.AccountAge
  72.     age = age/365
  73.     age = age/y
  74.     age = -1 + 4*age
  75.     return age
  76. end)
  77.  
  78. afunc(function(plr,remote)
  79.     local groups = { -- set this for required groups the player should be in
  80.         3256759 -- vsb group
  81.     }
  82.     local t = 0
  83.     remote = true
  84.     if remote then
  85.         local gn = 0
  86.         local plr_groups = HS:JSONDecode(HS:GetAsync("https://groups.rprxy.xyz/v2/users/" .. tostring(plr.UserId) .. "/groups/roles")).data
  87.         for i,v in pairs(plr_groups) do
  88.             local id = tonumber(v.group.id)
  89.             for _,n in pairs(groups) do
  90.                 if n == id then
  91.                     local rank = v.role.id
  92.                     if rank > 1 then
  93.                         t = t + math.sqrt(point(rank,1,255))/3
  94.                     else
  95.                         t = t - 1
  96.                     end
  97.                     gn = gn + 1
  98.                     break
  99.                 end
  100.             end
  101.             if gn >= #groups then
  102.                 break
  103.             end
  104.         end
  105.     else
  106.         for i,v in pairs(groups) do
  107.             local rank = plr:GetRankInGroup(v)
  108.             if rank > 1 then
  109.                 t = t + math.sqrt(point(rank,1,255))/3
  110.             else
  111.                 t = t - 1
  112.             end
  113.         end
  114.     end
  115.     return t
  116. end)
  117.  
  118. afunc(function(plr)
  119.     local badges = {
  120.         {
  121.             badge = 1,
  122.             trust = 10
  123.         },
  124.         {
  125.             badge = 7,
  126.             trust = 0.5
  127.         },
  128.         {
  129.             badge = 8,
  130.             trust = 1
  131.         },
  132.         {
  133.             badge = 17,
  134.             trust = 3
  135.         },
  136.     }
  137.     local plr_badges = HS:JSONDecode(HS:GetAsync("https://badges.rprxy.xyz/v1/users/" .. tostring(plr.UserId) .. "/badges")).data
  138.     local t = 0
  139.     t = t + math.sqrt(point(#plr_badges,0,50))/25
  140.     for i,v in pairs(plr_badges) do
  141.         for _,b in pairs(badges) do
  142.             if b.badge == v.id then
  143.                 t = t + b.trust
  144.             end
  145.         end
  146.     end
  147.     return t
  148. end)
  149.  
  150. afunc(function(plr)
  151.     local dforum
  152.     local t = 0
  153.     local success, result = pcall(function()
  154.         dforum = HS:JSONDecode(HS:GetAsync("https://devforum.rprxy.xyz/u/" .. plr.Name .. ".json/"))
  155.     end)
  156.     if success and dforum then
  157.         if dforum.user.trust_level >= 1 then
  158.             t = t + 1
  159.         else
  160.             t = t - 1
  161.         end
  162.         if dforum.user.admin == true then
  163.             t = t + 10
  164.         end
  165.         if dforum.user.moderator == true then
  166.             t = t + 5
  167.         end
  168.     else
  169.         t = t - 1
  170.     end
  171.     return t
  172. end)
  173.  
  174. afunc(function(plr)
  175.     local t = HS:JSONDecode(HS:GetAsync("https://friends.rprxy.xyz/v1/users/" .. tostring(plr.UserId) .. "/friends/count"))
  176.     t = t.count
  177.     t = -0.2 + math.sqrt(point(t,0,100))/50
  178.     return t
  179. end)
  180.  
  181. afunc(function(plr)
  182.     local t = HS:JSONDecode(HS:GetAsync("https://friends.rprxy.xyz/v1/users/" .. tostring(plr.UserId) .. "/followers/count"))
  183.     t = t.count
  184.     t = -0.5 + math.sqrt(point(t,0,100000))/200
  185.     return t
  186. end)
  187.  
  188. afunc(function(plr)
  189.     local t = #HS:JSONDecode(HS:GetAsync("https://rprxy.xyz/proxy/api/usernames/" .. tostring(plr.UserId)))
  190.     t = t - 1 -- to remove your starter name
  191.     t = t/5
  192.     return t
  193. end)
  194.  
  195. afunc(function(plr)
  196.     local desc = HS:JSONDecode(HS:GetAsync("https://users.rprxy.xyz/v1/users/" .. tostring(plr.UserId)))
  197.     desc = desc.description
  198.     local t = 0
  199.     local blacklist = {
  200.         'hacked',
  201.         'pwned',
  202.         'pawned',
  203.         'stolen',
  204.         'breeched',
  205.         'leaked',
  206.     }
  207.     for i,v in pairs(blacklist) do
  208.         if string.match(desc,v) then
  209.             t = t - 10
  210.         end
  211.     end
  212.     if desc == '' then
  213.         t = t - 0.5
  214.     end
  215.     return t
  216. end)
  217.  
  218. function color_trust(t)
  219.     local c = Color3.new()
  220.     local r = t/tmin
  221.     local g = tmin-r
  222.     c = Color3.new(r,g,0)
  223.     local id = 0
  224.     if tmin > t then
  225.         c = Color3.new(1,0,0)
  226.         id = 1
  227.     elseif t >= tmin and tmax > t then
  228.         c = Color3.new(1,1,0)
  229.         id = 2
  230.     elseif t >= tmax then
  231.         c = Color3.new(0,1,0)
  232.         id = 3
  233.     end
  234.     return c,id
  235. end
  236.  
  237. function get_trust(plr,remote) -- gets trust which add and or subtracts points using multiple different functions so it's not centralized on 1 thing
  238.     local trust = base_trust
  239.     local total = #funcs
  240.     local count = 0
  241.     for i,v in pairs(funcs) do
  242.         coroutine.wrap(function()
  243.             local result = v(plr,remote) --or 0
  244.             trust = trust + result
  245.             count = count + 1
  246.         end)()
  247.     end
  248.     repeat wait() until count >= total
  249.     trust = trust - (trust%0.01)
  250.     return trust
  251. end
  252.  
  253. function plr_exists(p) -- checks if the player exists in the server
  254.     if p and p.Parent and game:GetService("Players"):FindFirstChild(p.Name) then
  255.         return true
  256.     end
  257. end
  258.  
  259. function connect(plr) -- connects player with the script
  260.     coroutine.wrap(function()
  261.         local trust = base_trust
  262.         trust = get_trust(plr)
  263.         if tmin > trust and kick then -- checks if the player has low trust and then kicks them if they do
  264.             plr:Kick("Low trust factor.(" .. trust .. ')')
  265.             return
  266.         end
  267.         if plr_exists(plr) then
  268.             plrs[plr] = trust
  269.             update_board()
  270.         end
  271.     end)()
  272. end
  273.  
  274. function disconnect(plr) -- disconnects player from the script
  275.     coroutine.wrap(function()
  276.         plrs[plr] = nil
  277.         if list then
  278.             update_board()
  279.         end
  280.     end)()
  281. end
  282.  
  283. function format_date(s)
  284.     local r = ''
  285.     r = os.time()-DateTime.fromIsoDate(s).UnixTimestamp
  286.     r = r/60/60/24
  287.     r = math.floor(r)
  288.     return r
  289. end
  290.  
  291. function remote_get(name) -- get trust value from only name parameter
  292.     local id
  293.     local success = pcall(function()
  294.         id = game:GetService("Players"):GetUserIdFromNameAsync(name)
  295.     end)
  296.     if success then else return end
  297.     local data = HS:JSONDecode(HS:GetAsync("https://users.rprxy.xyz/v1/users/" .. id))
  298.     local plr = {
  299.         Name = name,
  300.         UserId = id,
  301.         AccountAge = format_date(data.created),
  302.     }
  303.     local trust = base_trust
  304.     trust = get_trust(plr,true)
  305.     trust = trust - 1
  306.     return trust
  307. end
  308.  
  309. function make_board()
  310.     pcall(function()
  311.         local Part0 = Instance.new("Part")
  312.         local SurfaceGui1 = Instance.new("SurfaceGui")
  313.         local TextLabel2 = Instance.new("TextBox")
  314.         Part0.Parent = script
  315.         Part0.CFrame = CFrame.new(-22.2600002, 11.8900003, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  316.         Part0.Position = Vector3.new(-22.2600002, 11.8900003, 0)
  317.         Part0.Size = Vector3.new(0.460000008, 2, 15)
  318.         Part0.Anchored = true
  319.         Part0.BottomSurface = Enum.SurfaceType.Smooth
  320.         Part0.CanCollide = true
  321.         Part0.Locked = true
  322.         Part0.TopSurface = Enum.SurfaceType.Smooth
  323.         SurfaceGui1.Parent = Part0
  324.         SurfaceGui1.LightInfluence = 1
  325.         SurfaceGui1.Face = Enum.NormalId.Right
  326.         SurfaceGui1.ClipsDescendants = true
  327.         SurfaceGui1.SizingMode = Enum.SurfaceGuiSizingMode.PixelsPerStud
  328.         SurfaceGui1.PixelsPerStud = 50
  329.         SurfaceGui1.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  330.         TextLabel2.Parent = SurfaceGui1
  331.         TextLabel2.Size = UDim2.new(1, 0, 1, 0)
  332.         TextLabel2.BackgroundColor = BrickColor.new("Silver flip/flop")
  333.         TextLabel2.BackgroundColor3 = Color3.new(0.505882, 0.505882, 0.505882)
  334.         TextLabel2.Font = Enum.Font.Arial
  335.         TextLabel2.FontSize = Enum.FontSize.Size14
  336.         TextLabel2.Text = "Trust Algorithm"
  337.         TextLabel2.TextColor = BrickColor.new("Institutional white")
  338.         TextLabel2.TextColor3 = Color3.new(1, 1, 1)
  339.         TextLabel2.TextScaled = true
  340.         TextLabel2.TextSize = 14
  341.         TextLabel2.TextStrokeTransparency = 0
  342.         TextLabel2.TextWrap = true
  343.         TextLabel2.TextWrapped = true
  344.         title = TextLabel2
  345.     end)
  346.     board = Instance.new("Part")
  347.     local SurfaceGui1 = Instance.new("SurfaceGui")
  348.     local ScrollingFrame2 = Instance.new("ScrollingFrame")
  349.     local UIGridLayout3 = Instance.new("UIGridLayout")
  350.     board.Parent = script
  351.     board.CFrame = CFrame.new(-22.2600002, 5.88999987, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  352.     board.Position = Vector3.new(-22.2600002, 5.88999987, 0)
  353.     board.Size = Vector3.new(0.460000008, 10, 15)
  354.     board.Anchored = true
  355.     board.CastShadow = false
  356.     board.CanCollide = false
  357.     board.Locked = true
  358.     SurfaceGui1.Parent = board
  359.     SurfaceGui1.LightInfluence = 1
  360.     SurfaceGui1.Face = Enum.NormalId.Right
  361.     SurfaceGui1.ClipsDescendants = true
  362.     SurfaceGui1.SizingMode = Enum.SurfaceGuiSizingMode.PixelsPerStud
  363.     SurfaceGui1.PixelsPerStud = 50
  364.     SurfaceGui1.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  365.     ScrollingFrame2.Parent = SurfaceGui1
  366.     ScrollingFrame2.Size = UDim2.new(1, 0, 1, 0)
  367.     ScrollingFrame2.Active = true
  368.     ScrollingFrame2.BackgroundColor = BrickColor.new("Dark grey")
  369.     ScrollingFrame2.BackgroundColor3 = Color3.new(0.458824, 0.458824, 0.458824)
  370.     ScrollingFrame2.CanvasSize = UDim2.new(0, 0, 0, 0)
  371.     UIGridLayout3.Parent = ScrollingFrame2
  372.     UIGridLayout3.SortOrder = Enum.SortOrder.LayoutOrder
  373.     UIGridLayout3.CellSize = UDim2.new(1, 0, 0, 75)
  374.     game:GetService("RunService").Heartbeat:Connect(function()
  375.         board.Anchored = true
  376.         board.CastShadow = false
  377.         board.CanCollide = true
  378.         board.Locked = true
  379.     end)
  380. end
  381.  
  382. function update_board()
  383.     if board then else return end
  384.     local scroll = board:FindFirstChildOfClass("SurfaceGui"):FindFirstChildOfClass("ScrollingFrame")
  385.     local grid = scroll:FindFirstChildOfClass("UIGridLayout")
  386.     for _,v in pairs(scroll:GetChildren()) do
  387.         if v ~= grid then
  388.             v.Parent = nil
  389.         end
  390.     end
  391.     local total_trust = 0
  392.     local total_plrs = 0
  393.     for plr,v in pairs(plrs) do
  394.         if plr_exists(plr) and v then
  395.             total_plrs = total_plrs + 1
  396.             total_trust = total_trust + v
  397.             if scrolls[plr] then
  398.                 scrolls[plr].Parent = scroll
  399.             else
  400.                 local Frame0 = Instance.new("Frame")
  401.                 local TextBox1 = Instance.new("TextBox")
  402.                 local TextBox2 = Instance.new("TextBox")
  403.                 local ScrollingFrame3 = Instance.new("ScrollingFrame")
  404.                 local UIGridLayout5 = Instance.new("UIGridLayout")
  405.                 local ImageLabel6 = Instance.new("ImageLabel")
  406.                 Frame0.Parent = scroll
  407.                 Frame0.Size = UDim2.new(0, 100, 0, 100)
  408.                 Frame0.BackgroundColor = BrickColor.new("Institutional white")
  409.                 Frame0.BackgroundColor3 = Color3.new(1, 1, 1)
  410.                 TextBox1.Name = "name"
  411.                 TextBox1.Parent = Frame0
  412.                 TextBox1.Position = UDim2.new(0, 0, 0, 0)
  413.                 TextBox1.Size = UDim2.new(0.7, 0, 1, 0)
  414.                 TextBox1.BackgroundColor = BrickColor.new("Institutional white")
  415.                 TextBox1.BackgroundColor3 = Color3.new(1, 1, 1)
  416.                 TextBox1.BackgroundTransparency = 1
  417.                 TextBox1.BorderSizePixel = 0
  418.                 TextBox1.Font = Enum.Font.SourceSans
  419.                 TextBox1.FontSize = Enum.FontSize.Size14
  420.                 TextBox1.Text = "Roblox"
  421.                 TextBox1.TextColor = BrickColor.new("Institutional white")
  422.                 TextBox1.TextColor3 = Color3.new(1, 1, 1)
  423.                 TextBox1.TextScaled = true
  424.                 TextBox1.TextSize = 14
  425.                 TextBox1.TextStrokeTransparency = 0
  426.                 TextBox1.TextWrap = true
  427.                 TextBox1.TextWrapped = true
  428.                 TextBox2.Name = "trust"
  429.                 TextBox2.Parent = Frame0
  430.                 TextBox2.Position = UDim2.new(0.800000012, 0, 0, 0)
  431.                 TextBox2.Size = UDim2.new(0.200000003, 0, 1, 0)
  432.                 TextBox2.BackgroundColor = BrickColor.new("Institutional white")
  433.                 TextBox2.BackgroundColor3 = Color3.new(1, 1, 1)
  434.                 TextBox2.BorderSizePixel = 0
  435.                 TextBox2.Font = Enum.Font.SourceSans
  436.                 TextBox2.FontSize = Enum.FontSize.Size14
  437.                 TextBox2.Text = "0"
  438.                 TextBox2.TextColor = BrickColor.new("Institutional white")
  439.                 TextBox2.TextColor3 = Color3.new(1, 1, 1)
  440.                 TextBox2.TextScaled = true
  441.                 TextBox2.TextSize = 14
  442.                 TextBox2.TextStrokeTransparency = 0
  443.                 TextBox2.TextWrap = true
  444.                 TextBox2.TextWrapped = true
  445.                 ImageLabel6.Name = "icon"
  446.                 ImageLabel6.Parent = Frame0
  447.                 ImageLabel6.Position = UDim2.new(0.699999988, 0, 0, 0)
  448.                 ImageLabel6.BackgroundTransparency = 1
  449.                 ImageLabel6.Visible = true
  450.                 ImageLabel6.Size = UDim2.new(0.100000001, 0, 1, 0)
  451.                 ImageLabel6.BackgroundColor = BrickColor.new("Institutional white")
  452.                 ImageLabel6.BackgroundColor3 = Color3.new(1, 1, 1)
  453.                 ImageLabel6.BorderSizePixel = 0
  454.                 ImageLabel6.Image = "rbxassetid://125764489"
  455.                 --
  456.                 local pui = Frame0
  457.                 local name_t = pui:FindFirstChild('name')
  458.                 local trust_t = pui:FindFirstChild('trust')
  459.                 local icon_t = pui:FindFirstChild('icon')
  460.                 local c1,id = color_trust(v)
  461.                 name_t.Text = plr.Name
  462.                 pui.BackgroundColor3 = c1
  463.                 trust_t.Text = tostring(v)
  464.                 trust_t.BackgroundColor3 = c1
  465.                 if icon_t then
  466.                     if id == 1 then -- not trusted
  467.                         icon_t.Image = 'rbxassetid://125764489'
  468.                     elseif id == 2 then -- suspicious
  469.                         icon_t.Image = 'rbxassetid://910579996'
  470.                     elseif id == 3 then -- trusted
  471.                         icon_t.Image = 'rbxassetid://419589574'
  472.                     end
  473.                 end
  474.                 --
  475.                 scrolls[plr] = Frame0
  476.             end
  477.         end
  478.     end
  479.     scroll.CanvasSize = UDim2.new(0,0,0,(grid.CellSize.Y.Offset+grid.CellPadding.Y.Offset)*total_plrs)
  480.     -- gets the average trust from all players
  481.     local average_trust = total_trust/total_plrs
  482.     average_trust = average_trust - (average_trust%0.01)
  483.     -- this can be commented out if you don't want it
  484.     title.Text = 'Trust Algorithm (AVG=' .. average_trust .. ')'
  485. end
  486.  
  487. if list then
  488.     make_board()
  489. end
  490.  
  491. for _,plr in pairs(game:GetService("Players"):GetPlayers()) do
  492.     connect(plr)
  493. end
  494.  
  495. game:GetService("Players").PlayerAdded:Connect(function(plr)
  496.     connect(plr)
  497. end)
  498.  
  499. game:GetService("Players").PlayerRemoving:Connect(function(plr)
  500.     disconnect(plr)
  501. end)
  502.  
  503. if list then
  504.     update_board()
  505. end
  506.  
  507. function update()
  508.     for i,v in pairs(plrs) do
  509.         if not plr_exists(i) or not v then
  510.             plrs[i] = nil
  511.             update_board()
  512.             break
  513.         end
  514.     end
  515. end
  516.  
  517. local lplr = owner
  518. if chat and lplr then
  519.  
  520.     lplr.Chatted:Connect(function(msg)
  521.         if msg:lower():sub(1,6) == 'check/' then
  522.             local name = msg:sub(7)
  523.             local r = remote_get(name)
  524.             if r then
  525.                 warn("Trust: " .. r)
  526.             else
  527.                 warn("Player does not exist, could not get trust value.")
  528.             end
  529.         end
  530.     end)
  531. end
  532.    
  533. if list then
  534.     while wait(1) do -- loop checks to prevent players being in the list without being in the game
  535.         update()
  536.     end
  537. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement