Advertisement
swagergod

Untitled

Jun 23rd, 2015
342
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. speakers = {“mlg″, “DevDane″, “T0tallyN0tATr0ll”} — Those who can say the command. change this into the names you want.
  2.  
  3. banned = {“EvilPerson”, “BadUsername”, “MrEnemy”} — Those who are banned
  4.  
  5.  
  6.  
  7. function checkSpeakers(name)
  8.  
  9.  
  10.  
  11. — check if name matches a speaker
  12.  
  13. for i,v in pairs(speakers) do
  14.  
  15. — convert names to all upper case, otherwise we will allow
  16.  
  17. — “Telamon” but not “telamon” or “tELAMON”
  18.  
  19. if (string.upper(name) == string.upper(v)) then return true end
  20.  
  21. end
  22.  
  23. return false
  24.  
  25. end
  26.  
  27.  
  28.  
  29. function banPlayer(banner, victim)
  30.  
  31.  
  32.  
  33. — remove if the victim is not also the speaker
  34.  
  35. if (victim ~= banner) then
  36.  
  37. victim:kick("shrektbyadmin")
  38.  
  39. banned[victim.Name] = victim.Name
  40. end
  41.  
  42. end
  43.  
  44.  
  45.  
  46. function matchPlayer(str)
  47.  
  48.  
  49.  
  50. — find all players that start with the str
  51.  
  52. — if there is only one, match it
  53.  
  54. — 0 or 2+, don’t match it
  55.  
  56. local result = nil
  57.  
  58.  
  59.  
  60. local players = game.Players:GetPlayers()
  61.  
  62.  
  63.  
  64. for i,v in pairs(game.Players:GetPlayers()) do
  65.  
  66. if (string.find(string.lower(v.Name), str) == 1) then
  67.  
  68. if (result ~= nil) then return nil end
  69.  
  70. result = v
  71.  
  72. end
  73.  
  74. end
  75.  
  76.  
  77.  
  78. return result
  79.  
  80. end
  81.  
  82.  
  83.  
  84. function onChatted(msg, recipient, speaker)
  85.  
  86.  
  87.  
  88. — convert to all lower case
  89.  
  90. local source = string.lower(speaker.Name)
  91.  
  92. msg = string.lower(msg)
  93.  
  94.  
  95.  
  96. — ban the following players
  97.  
  98. — “ban telamon buildman wookong”
  99.  
  100. if (string.find(msg, “ban”) == 1) then — msg starts with “ban”
  101.  
  102. — words and numbers
  103.  
  104. for word in msg:gmatch(“%w+”) do
  105.  
  106. local p = matchPlayer(word)
  107.  
  108. if (p ~= nil) then
  109.  
  110. banPlayer(speaker, p)
  111.  
  112. end
  113.  
  114. end
  115.  
  116. end
  117.  
  118. end
  119.  
  120.  
  121.  
  122. function onPlayerEntered(newPlayer)
  123.  
  124.  
  125.  
  126. — remove banned player if they try to come back in
  127.  
  128. for i,v in pairs(banned) do
  129.  
  130. if (v:lower() == newPlayer.Name:lower()) then
  131.  
  132. newPlayer:kick("BannedFromServer)
  133.  
  134. end
  135.  
  136. end
  137.  
  138. if checkSpeakers(newPlayer.Name) then
  139.  
  140. newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end)
  141.  
  142. end
  143.  
  144. end
  145.  
  146.  
  147.  
  148. game.Players.PlayerAdded:connect(onPlayerEntered)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement