Advertisement
KrYn0MoRe

Trust System v2.1

Jan 10th, 2022 (edited)
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 15.82 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 proxy = 'roproxy.com' -- api proxy to replace roblox
  13. local base_trust = 0
  14. local board = nil
  15. local title = nil
  16. local plrs = {}
  17. local scrolls = {}
  18. local funcs = {}
  19. local kick = false -- kick if the player is not trusted
  20. local list = true -- to see players trust (disable if using for game anti cheat)
  21. local tmin = 0 -- minimum trust factor (this really matters)
  22. local tmax = 5 -- max trust for warning icon (just visual)
  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. function wrap(f)
  37.     return coroutine.wrap(f)()
  38. end
  39.  
  40. function http(l)
  41.     local r
  42.     local pass = true
  43.     wrap(function()
  44.         local success,ret = pcall(function()
  45.             return HS:GetAsync(l)
  46.         end)
  47.         if success then
  48.             r = ret
  49.         else
  50.             pass = false
  51.         end
  52.         if r then
  53.             r = HS:JSONDecode(r)
  54.         end
  55.     end)
  56.     local st = os.clock()
  57.     repeat
  58.         task.wait()
  59.         if not pass then return end
  60.         if r then
  61.             return r
  62.         end
  63.     until os.clock()-st >= 5
  64.     --if success and success2 then else return end
  65.     return r
  66. end
  67.  
  68. --[[]
  69. afunc(function(plr)
  70.     local t = 0
  71.     local bypass = { -- most trusted
  72.         279462171,
  73.         1282751190,
  74.         189503,
  75.         280238,
  76.     }
  77.     for i,v in pairs(bypass) do
  78.         if plr.UserId == v then
  79.             t = 20
  80.             break
  81.         end
  82.     end
  83.     return t
  84. end)
  85. ]]
  86.  
  87. afunc(function(plr)
  88.     local r
  89.     if plr.MembershipType ~= Enum.MembershipType.None then
  90.         r = true
  91.     end
  92.     if r then
  93.         return 2
  94.     else
  95.         return 0
  96.     end
  97. end)
  98.  
  99. --[[ I can find this out with users api (hasVerifiedBadge)
  100. afunc(function(plr)
  101.     local verified
  102.     verified = MPS:PlayerOwnsAsset(plr,102611803)
  103.     local t = 0
  104.     if verified then
  105.         t = t + 1
  106.     else
  107.         t = t - 2
  108.     end
  109.     return t
  110. end)
  111. ]]
  112.  
  113. afunc(function(plr)
  114.     local y = os.date('!*t').year-2006
  115.     local age = plr.AccountAge
  116.     age = age/365
  117.     age = age/y
  118.     age = -1 + 4*age
  119.     return age
  120. end)
  121.  
  122. afunc(function(plr)
  123.     local t = 0
  124.     local bypass = { -- most trusted
  125.         279462171,
  126.         1282751190,
  127.         189503,
  128.         280238,
  129.     }
  130.     for i,v in pairs(bypass) do
  131.         if plr.UserId == v then
  132.             t = 50
  133.             break
  134.         end
  135.     end
  136.     return t
  137. end)
  138.  
  139. afunc(function(plr)
  140.     local groups = { -- set this for required groups the player should be in
  141.         {
  142.             id = 3256759, -- vsb
  143.             ranks = {
  144.                 ['Owner'] = 30,
  145.                 ['Co-Owner'] = 30,
  146.                 ['Admin'] = 20,
  147.                 ['Group Mod'] = 10,
  148.                 ['Sb Mod'] = 10,
  149.                 ['Advance Scripter'] = 5,
  150.                 ['Scripter'] = 5,
  151.                 ['Builder'] = 5,
  152.             },
  153.         },
  154.         {
  155.             id = 16281178, -- lua sandbox
  156.             min_rank = 50,
  157.             ranks = {
  158.                 ['Owner'] = 30,
  159.                 ['Admin'] = 30,
  160.                 ['Developer'] = 20,
  161.                 ['Mod'] = 10,
  162.                 ['Scripter + Place 1 require permissions'] = 10,
  163.                 ['Builder + Place 1 require permissions'] = 10,
  164.                 ['Builder'] = 5,
  165.                 ['Scripter'] = 5,
  166.                 ['Member'] = 1,
  167.             },
  168.         },
  169.         {
  170.             id = 2574296, -- bleu pigs
  171.             ranks = {
  172.                 ['Group Holder'] = 30,
  173.                 ['Bot'] = 30,
  174.                 ['Arbitrator'] = 30,
  175.                 ['Elite Pig'] = 10,
  176.                 ['Bleu Pig'] = 10,
  177.                 ['New Member'] = 5,
  178.             },
  179.         },
  180.     }
  181.     local t = 0
  182.     for i,v in pairs(groups) do
  183.         local rank = plr:GetRoleInGroup(v.id)
  184.         for name,point in pairs(v.ranks) do
  185.             if rank == name then
  186.                 t = t + point
  187.                 break
  188.             end
  189.         end
  190.         if v.min_rank then
  191.             local id = plr:GetRankInGroup(v.id)
  192.             if id >= v.min_rank then
  193.                 t = t + 5
  194.             end
  195.         end
  196.     end
  197.     return t
  198. end)
  199.  
  200. afunc(function(plr)
  201.     local badges = {
  202.         {
  203.             badge = 1,
  204.             trust = 10
  205.         },
  206.         {
  207.             badge = 7,
  208.             trust = 0.5
  209.         },
  210.         {
  211.             badge = 8,
  212.             trust = 1
  213.         },
  214.         {
  215.             badge = 17,
  216.             trust = 3
  217.         },
  218.     }
  219.     local result = http("https://badges." .. proxy .. "/v1/users/" .. tostring(plr.UserId) .. "/badges")
  220.     if result then else return end
  221.     result = result.data
  222.     local t = 0
  223.     t = t + math.sqrt(point(#result,0,50))/25
  224.     for i,v in pairs(result) do
  225.         for _,b in pairs(badges) do
  226.             if b.badge == v.id then
  227.                 t = t + b.trust
  228.             end
  229.         end
  230.     end
  231.     return t
  232. end)
  233.  
  234. afunc(function(plr)
  235.     local result
  236.     local t = 0
  237.     result = http("https://devforum." .. proxy .. "/u/" .. plr.Name .. ".json")
  238.     if result then
  239.         if result.user.trust_level >= 1 then
  240.             t = t + 1
  241.         else
  242.             t = t - 1
  243.         end
  244.         if result.user.admin == true then
  245.             t = t + 10
  246.         end
  247.         if result.user.moderator == true then
  248.             t = t + 5
  249.         end
  250.     else
  251.         t = t - 1
  252.     end
  253.     return t
  254. end)
  255.  
  256. afunc(function(plr)
  257.     local result = http("https://friends." .. proxy .. "/v1/users/" .. tostring(plr.UserId) .. "/friends/count")
  258.     if result then
  259.         result = result.count
  260.         result = -0.2 + math.sqrt(point(result,0,100))/50
  261.     else
  262.         result = -0.2
  263.     end
  264.     return result
  265. end)
  266.  
  267. afunc(function(plr)
  268.     local result = http("https://friends." .. proxy .. "/v1/users/" .. tostring(plr.UserId) .. "/followers/count")
  269.     if result then
  270.         result = result.count
  271.         result = -0.5 + math.sqrt(point(result,0,100000))/200
  272.     else
  273.         result = -0.5
  274.     end
  275.     return result
  276. end)
  277.  
  278. afunc(function(plr)
  279.     local result = http("https://inventory." .. proxy .. "/v1/users/" .. tostring(plr.UserId) .. "/assets/collectibles?limit=100")
  280.     if result then else return end
  281.     local rap = 0
  282.     for i,v in pairs(result.data) do
  283.         rap += v.recentAveragePrice
  284.     end
  285.     local min = 1000
  286.     if rap >= min then
  287.         rap = math.sqrt(rap)/25
  288.     else
  289.         return 0
  290.     end
  291.     return rap
  292. end)
  293.  
  294.  
  295. afunc(function(plr)
  296.     local result = http("https://games." .. proxy .. "/v2/users/" .. tostring(plr.UserId) .. "/games")
  297.     if result then else return end
  298.     local visits = 0
  299.     for i,v in pairs(result.data) do
  300.         visits += v.placeVisits
  301.     end
  302.     visits = math.sqrt(visits)/50
  303.     visits = math.clamp(visits,0,200)
  304.     return visits
  305. end)
  306.  
  307. afunc(function(plr)
  308.     local result = http("https://users." .. proxy .. "/v1/users/" .. tostring(plr.UserId) .. "/username-history?limit=100")
  309.     if result then else return end
  310.     result = #result.data
  311.     result = result - 1 -- to remove your starter name
  312.     result = result/5
  313.     return result
  314. end)
  315.  
  316. afunc(function(plr)
  317.     local result = http("https://users." .. proxy .. "/v1/users/" .. tostring(plr.UserId))
  318.     if result then else return end
  319.     local desc = result.description
  320.     local t = 0
  321.     local blacklist = {
  322.         'hacked',
  323.         'pwned',
  324.         'pawned',
  325.         'stolen',
  326.         'breeched',
  327.         'leaked',
  328.         'acc taken',
  329.         'account taken',
  330.     }
  331.     for i,v in pairs(blacklist) do
  332.         if string.match(desc,v) then
  333.             t = t - 50
  334.         end
  335.     end
  336.     if desc == '' then
  337.         t = t - 0.5
  338.     end
  339.     if result.hasVerifiedBadge then
  340.         t = t + 1
  341.     else
  342.         t = t - 2
  343.     end
  344.     return t
  345. end)
  346.  
  347. function color_trust(t)
  348.     local c = Color3.new()
  349.     local r = t/tmin
  350.     local g = tmin-r
  351.     c = Color3.new(r,g,0)
  352.     local id = 0
  353.     if tmin > t then
  354.         c = Color3.new(1,0,0)
  355.         id = 1
  356.     elseif t >= tmin and tmax > t then
  357.         c = Color3.new(1,1,0)
  358.         id = 2
  359.     elseif t >= tmax then
  360.         c = Color3.new(0,1,0)
  361.         id = 3
  362.     end
  363.     return c,id
  364. end
  365.  
  366. function plr_exists(p) -- checks if the player exists in the server
  367.     if p and p.Parent and game:GetService("Players"):FindFirstChild(p.Name) then
  368.         return true
  369.     end
  370. end
  371.  
  372. function get_trust(plr)
  373.     local trust = base_trust
  374.     local total = 0
  375.     local count = 0
  376.     for i,v in pairs(funcs) do
  377.         total += 1
  378.     end
  379.     for i,v in pairs(funcs) do
  380.         if plr_exists(plr) then else break end
  381.         local result = v(plr) or 0
  382.         if result then
  383.             trust = trust + result
  384.         end
  385.         count = count + 1
  386.     end
  387.     repeat task.wait() until count >= total
  388.     return trust
  389. end
  390.  
  391. local connect_tag = {}
  392.  
  393. function connect(plr) -- connects player with the script
  394.     if not connect_tag[plr.UserId] then
  395.         connect_tag[plr.UserId] = 0
  396.     else
  397.         connect_tag[plr.UserId] += 1
  398.     end
  399.     local ctid = connect_tag[plr.UserId]
  400.     local trust = base_trust
  401.     trust = get_trust(plr)
  402.     if (tmin > trust) and plr_exists(plr) and kick then -- checks if the player has low trust and then kicks them if they do
  403.         plr:Kick("Low trust factor.(" .. tmin .. " > " .. trust .. ')')
  404.         return
  405.     end
  406.     if plr_exists(plr) and ctid == connect_tag[plr.UserId] then
  407.         plrs[plr] = trust
  408.         update_board()
  409.     end
  410. end
  411.  
  412. function disconnect(plr) -- disconnects player from the script
  413.     if plr and plrs[plr] then
  414.         plrs[plr] = nil
  415.         if list then
  416.             update_board()
  417.         end
  418.     end
  419. end
  420.  
  421. function make_board()
  422.     pcall(function()
  423.         local Part0 = Instance.new("Part")
  424.         local SurfaceGui1 = Instance.new("SurfaceGui")
  425.         local TextLabel2 = Instance.new("TextBox")
  426.         Part0.Parent = script
  427.         Part0.CFrame = CFrame.new(-22.2600002, 11.8900003, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  428.         Part0.Position = Vector3.new(-22.2600002, 11.8900003, 0)
  429.         Part0.Size = Vector3.new(0.460000008, 2, 15)
  430.         Part0.Anchored = true
  431.         Part0.BottomSurface = Enum.SurfaceType.Smooth
  432.         Part0.CanCollide = true
  433.         Part0.Locked = true
  434.         Part0.TopSurface = Enum.SurfaceType.Smooth
  435.         SurfaceGui1.Parent = Part0
  436.         SurfaceGui1.LightInfluence = 1
  437.         SurfaceGui1.Face = Enum.NormalId.Right
  438.         SurfaceGui1.ClipsDescendants = true
  439.         SurfaceGui1.SizingMode = Enum.SurfaceGuiSizingMode.PixelsPerStud
  440.         SurfaceGui1.PixelsPerStud = 50
  441.         SurfaceGui1.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  442.         TextLabel2.Parent = SurfaceGui1
  443.         TextLabel2.Size = UDim2.new(1, 0, 1, 0)
  444.         TextLabel2.BackgroundColor = BrickColor.new("Silver flip/flop")
  445.         TextLabel2.BackgroundColor3 = Color3.new(0.505882, 0.505882, 0.505882)
  446.         TextLabel2.Font = Enum.Font.Arial
  447.         TextLabel2.FontSize = Enum.FontSize.Size14
  448.         TextLabel2.Text = "Trust Algorithm"
  449.         TextLabel2.TextColor = BrickColor.new("Institutional white")
  450.         TextLabel2.TextColor3 = Color3.new(1, 1, 1)
  451.         TextLabel2.TextScaled = true
  452.         TextLabel2.TextSize = 14
  453.         TextLabel2.TextStrokeTransparency = 0
  454.         TextLabel2.TextWrap = true
  455.         TextLabel2.TextWrapped = true
  456.         title = TextLabel2
  457.     end)
  458.     board = Instance.new("Part")
  459.     local SurfaceGui1 = Instance.new("SurfaceGui")
  460.     local ScrollingFrame2 = Instance.new("ScrollingFrame")
  461.     local UIGridLayout3 = Instance.new("UIGridLayout")
  462.     board.Parent = script
  463.     board.CFrame = CFrame.new(-22.2600002, 5.88999987, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1)
  464.     board.Position = Vector3.new(-22.2600002, 5.88999987, 0)
  465.     board.Size = Vector3.new(0.460000008, 10, 15)
  466.     board.Anchored = true
  467.     board.CastShadow = false
  468.     board.CanCollide = false
  469.     board.Locked = true
  470.     SurfaceGui1.Parent = board
  471.     SurfaceGui1.LightInfluence = 1
  472.     SurfaceGui1.Face = Enum.NormalId.Right
  473.     SurfaceGui1.ClipsDescendants = true
  474.     SurfaceGui1.SizingMode = Enum.SurfaceGuiSizingMode.PixelsPerStud
  475.     SurfaceGui1.PixelsPerStud = 50
  476.     SurfaceGui1.ZIndexBehavior = Enum.ZIndexBehavior.Sibling
  477.     ScrollingFrame2.Parent = SurfaceGui1
  478.     ScrollingFrame2.Size = UDim2.new(1, 0, 1, 0)
  479.     ScrollingFrame2.Active = true
  480.     ScrollingFrame2.BackgroundColor = BrickColor.new("Dark grey")
  481.     ScrollingFrame2.BackgroundColor3 = Color3.new(0.458824, 0.458824, 0.458824)
  482.     ScrollingFrame2.CanvasSize = UDim2.new(0, 0, 0, 0)
  483.     UIGridLayout3.Parent = ScrollingFrame2
  484.     UIGridLayout3.SortOrder = Enum.SortOrder.LayoutOrder
  485.     UIGridLayout3.CellSize = UDim2.new(1, 0, 0, 75)
  486.     game:GetService("RunService").Heartbeat:Connect(function()
  487.         board.Anchored = true
  488.         board.CastShadow = false
  489.         board.CanCollide = true
  490.         board.Locked = true
  491.     end)
  492. end
  493.  
  494. function update_board()
  495.     if board then else return end
  496.     local scroll = board:FindFirstChildOfClass("SurfaceGui"):FindFirstChildOfClass("ScrollingFrame")
  497.     local grid = scroll:FindFirstChildOfClass("UIGridLayout")
  498.     for _,v in pairs(scroll:GetChildren()) do
  499.         if v ~= grid then
  500.             v.Parent = nil
  501.         end
  502.     end
  503.     local total_trust = 0
  504.     local total_plrs = 0
  505.     for plr,v in pairs(plrs) do
  506.         if plr_exists(plr) and v then
  507.             total_plrs = total_plrs + 1
  508.             total_trust = total_trust + v
  509.             if scrolls[plr] then
  510.                 scrolls[plr].Parent = scroll
  511.             else
  512.                 local Frame0 = Instance.new("Frame")
  513.                 local TextBox1 = Instance.new("TextBox")
  514.                 local TextBox2 = Instance.new("TextBox")
  515.                 local ScrollingFrame3 = Instance.new("ScrollingFrame")
  516.                 local UIGridLayout5 = Instance.new("UIGridLayout")
  517.                 local ImageLabel6 = Instance.new("ImageLabel")
  518.                 Frame0.Parent = scroll
  519.                 Frame0.Size = UDim2.new(0, 100, 0, 100)
  520.                 Frame0.BackgroundColor = BrickColor.new("Institutional white")
  521.                 Frame0.BackgroundColor3 = Color3.new(1, 1, 1)
  522.                 TextBox1.Name = "name"
  523.                 TextBox1.Parent = Frame0
  524.                 TextBox1.Position = UDim2.new(0, 0, 0, 0)
  525.                 TextBox1.Size = UDim2.new(0.7, 0, 1, 0)
  526.                 TextBox1.BackgroundColor = BrickColor.new("Institutional white")
  527.                 TextBox1.BackgroundColor3 = Color3.new(1, 1, 1)
  528.                 TextBox1.BackgroundTransparency = 1
  529.                 TextBox1.BorderSizePixel = 0
  530.                 TextBox1.Font = Enum.Font.SourceSans
  531.                 TextBox1.FontSize = Enum.FontSize.Size14
  532.                 TextBox1.Text = "Roblox"
  533.                 TextBox1.TextColor = BrickColor.new("Institutional white")
  534.                 TextBox1.TextColor3 = Color3.new(1, 1, 1)
  535.                 TextBox1.TextScaled = true
  536.                 TextBox1.TextSize = 14
  537.                 TextBox1.TextStrokeTransparency = 0
  538.                 TextBox1.TextWrap = true
  539.                 TextBox1.TextWrapped = true
  540.                 TextBox2.Name = "trust"
  541.                 TextBox2.Parent = Frame0
  542.                 TextBox2.Position = UDim2.new(0.800000012, 0, 0, 0)
  543.                 TextBox2.Size = UDim2.new(0.200000003, 0, 1, 0)
  544.                 TextBox2.BackgroundColor = BrickColor.new("Institutional white")
  545.                 TextBox2.BackgroundColor3 = Color3.new(1, 1, 1)
  546.                 TextBox2.BorderSizePixel = 0
  547.                 TextBox2.Font = Enum.Font.SourceSans
  548.                 TextBox2.FontSize = Enum.FontSize.Size14
  549.                 TextBox2.Text = "0"
  550.                 TextBox2.TextColor = BrickColor.new("Institutional white")
  551.                 TextBox2.TextColor3 = Color3.new(1, 1, 1)
  552.                 TextBox2.TextScaled = true
  553.                 TextBox2.TextSize = 14
  554.                 TextBox2.TextStrokeTransparency = 0
  555.                 TextBox2.TextWrap = true
  556.                 TextBox2.TextWrapped = true
  557.                 ImageLabel6.Name = "icon"
  558.                 ImageLabel6.Parent = Frame0
  559.                 ImageLabel6.Position = UDim2.new(0.699999988, 0, 0, 0)
  560.                 ImageLabel6.BackgroundTransparency = 1
  561.                 ImageLabel6.Visible = true
  562.                 ImageLabel6.Size = UDim2.new(0.100000001, 0, 1, 0)
  563.                 ImageLabel6.BackgroundColor = BrickColor.new("Institutional white")
  564.                 ImageLabel6.BackgroundColor3 = Color3.new(1, 1, 1)
  565.                 ImageLabel6.BorderSizePixel = 0
  566.                 ImageLabel6.Image = "rbxassetid://125764489"
  567.                 --
  568.                 local pui = Frame0
  569.                 local name_t = pui:FindFirstChild('name')
  570.                 local trust_t = pui:FindFirstChild('trust')
  571.                 local icon_t = pui:FindFirstChild('icon')
  572.                 local c1,id = color_trust(v)
  573.                 name_t.Text = plr.Name
  574.                 pui.BackgroundColor3 = c1
  575.                 trust_t.Text = math.floor(v*100)/100
  576.                 trust_t.BackgroundColor3 = c1
  577.                 if icon_t then
  578.                     if id == 1 then -- not trusted
  579.                         icon_t.Image = 'rbxassetid://125764489'
  580.                     elseif id == 2 then -- suspicious
  581.                         icon_t.Image = 'rbxassetid://910579996'
  582.                     elseif id == 3 then -- trusted
  583.                         icon_t.Image = 'rbxassetid://419589574'
  584.                     end
  585.                 end
  586.                 --
  587.                 scrolls[plr] = Frame0
  588.             end
  589.         end
  590.     end
  591.     scroll.CanvasSize = UDim2.new(0,0,0,(grid.CellSize.Y.Offset+grid.CellPadding.Y.Offset)*total_plrs)
  592.     -- gets the average trust from all players
  593.     local average_trust = total_trust/total_plrs
  594.     average_trust = math.floor(average_trust*100)/100
  595.     -- this can be commented out if you don't want it
  596.     title.Text = 'Trust Algorithm (AVG=' .. average_trust .. ')'
  597. end
  598.  
  599. if list then
  600.     make_board()
  601. end
  602.  
  603. game:GetService("Players").PlayerAdded:Connect(function(plr)
  604.     connect(plr)
  605.     update()
  606. end)
  607.  
  608. game:GetService("Players").PlayerRemoving:Connect(function(plr)
  609.     disconnect(plr)
  610.     update()
  611. end)
  612.  
  613. for _,plr in pairs(game:GetService("Players"):GetPlayers()) do
  614.     wrap(function()
  615.         connect(plr)
  616.         update()
  617.     end)
  618. end
  619.  
  620. if list then
  621.     update_board()
  622. end
  623.  
  624. function update()
  625.     for i,v in pairs(plrs) do
  626.         if not plr_exists(i) or not v then
  627.             plrs[i] = nil
  628.             update_board()
  629.             break
  630.         end
  631.     end
  632. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement