00fjg

Untitled

Jun 18th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.04 KB | None | 0 0
  1. --rbxsig%Jl1magpG8HDueelFdv0f65hWuwxRy+UB2PTJXROQcS/jkrCeRCEwXcRtMTmXlA6+KznENfbm8DKgvDGLoJI8SWRvMTVYF1uY2qz5wgF1wJ0ZSPoEim3NpGQh592n2cQefYyP9VDqVIkLDSpFwXfS/N3Tp9liHbaipOH1uk1dcyw=%
  2. --rbxassetid%1311981%
  3. print("Vote Kicker 1.0 Loaded")
  4. ---------------------------------------------------
  5. -- This script adds the "kick" command to your game.
  6. -- Players can type "kick [player name]" to vote to kick an abusive player.
  7. -- If enough people vote to kick the same person, that person contracts a deadly case of NoTorsoItis
  8. -- There is no cure for NoTorsoItis, even rejoining the game doesn't stop it.
  9. -- The number of votes required to kick a player depends on the number of people in the game.
  10. --
  11. -- One cool thing - you don't need to type the player's full name, just enough letters to be sure of who you
  12. -- want to kick.
  13. --
  14. -- For example: if Builderman and Builderdude are in-game, "kick builderm" is enough
  15. -- if Builderman and Telamon are the only people in the game, you can vote to kick both
  16. -- by typing "kick b t"
  17. --
  18. -- Multiple votes from the same person are ignored. As are ambigious votes:
  19. -- Example: Builderman and Builderdude are in-game. "kick bu" is ambigious.
  20. ---------------------------------------------------
  21.  
  22.  
  23. -- This hack brought to you by Telamon.
  24.  
  25. -- If you find bugs in this script, post them to the scripting forum.
  26. -- If you find a bug and change the script to fix it, post your solution in the scripting forum. There is a 500 R$ bonus for each fix.
  27.  
  28. kickedlist = {}
  29.  
  30. voteMatrix = {}
  31.  
  32.  
  33. function onPlayerEntered(newPlayer)
  34.  
  35.  
  36. local stats = Instance.new("IntValue")
  37. stats.Name = "punkstats"
  38.  
  39. local votes = Instance.new("IntValue")
  40. votes.Name = "votes"
  41. votes.Value = 0
  42.  
  43.  
  44.  
  45.  
  46. votes.Parent = stats
  47.  
  48.  
  49. -- VERY UGLY HACK
  50. -- Will this leak threads?
  51. -- Is the problem even what I think it is (player arrived before character)?
  52. while true do
  53. if newPlayer.Character ~= nil then break end
  54. wait(5)
  55. end
  56.  
  57. -- start to listen for new humanoid
  58. newPlayer.Changed:connect(function(property) onPlayerRespawn(property, newPlayer) end )
  59.  
  60. stats.Parent = newPlayer
  61.  
  62. newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end)
  63.  
  64. -- make sure this isn't a previously banned player re-entering the game
  65.  
  66. for i = 1, #kickedlist do
  67. if (string.lower(newPlayer.Name) == kickedlist[i]) then
  68. banish(newPlayer)
  69. end
  70. end
  71.  
  72. end
  73.  
  74. function getVotesNeeded()
  75. local np = game.Players.NumPlayers
  76.  
  77. if np > 10 then return 4 end
  78. if np > 4 then return 3 end
  79. return 2
  80.  
  81. end
  82.  
  83. function onPlayerRespawn(property, player)
  84. if property == "Character" and player.Character ~= nil then
  85. local stats = player:findFirstChild("punkstats")
  86. if (stats ~= nil) then
  87. if (stats:findFirstChild("banned") ~= nil) then
  88. punish(player)
  89. end
  90. end
  91. end
  92. end
  93.  
  94. function banish(player)
  95.  
  96. local stats = player:findFirstChild("punkstats")
  97. local votes = stats:findFirstChild("votes")
  98.  
  99. if (stats ~= nil and votes ~= nil) then
  100.  
  101. votes.Value = votes.Value + 1
  102. if (votes.Value >= getVotesNeeded()) then
  103. local banned = Instance.new("IntValue")
  104. banned.Name = "banned"
  105. banned.Parent = stats
  106. local message = Instance.new("Message")
  107. message.Text = "You caught NoTorsoItis!"
  108. message.Parent = player
  109. table.insert(kickedlist, string.lower(player.Name))
  110. punish(player)
  111. end
  112. end
  113.  
  114.  
  115. end
  116.  
  117. function punish(player)
  118. -- called when we think the player has respawned
  119. while true do
  120. if player.Character ~= nil then break end
  121. wait(5)
  122. end
  123.  
  124. player.Character.Torso.Parent = nil
  125. end
  126.  
  127. function matchPlayer(str)
  128. -- find all players that start with the str
  129. -- if there is only one, match it
  130. -- 0 or 2+, don't match it
  131. local result = nil
  132.  
  133. local players = game.Players:GetPlayers()
  134.  
  135. for i = 1,#players do
  136. if (string.find(string.lower(players[i].Name), str) == 1) then
  137. if (result ~= nil) then return nil end
  138. result = players[i]
  139. end
  140. end
  141.  
  142. return result
  143. end
  144.  
  145. function voteAgainst(voter, victim)
  146. -- consult the voteMatrix to see if this guy has voted against that guy before
  147.  
  148. -- voter is a string - all lowers
  149. -- victim is a player
  150.  
  151. local votesList = voteMatrix[voter]
  152.  
  153. if (votesList ~= nil) then
  154. local prior = votesList[string.lower(victim.Name)]
  155. if (prior ~= nil) then
  156. -- this dude voted against that dude before
  157. return
  158. end
  159. else
  160. voteMatrix[voter] = {}
  161. end
  162.  
  163. -- insert the record
  164. voteMatrix[voter][string.lower(victim.Name)] = 1
  165.  
  166. banish(victim)
  167.  
  168. end
  169.  
  170. function onChatted(msg, recipient, speaker)
  171.  
  172. -- convert to all lower case
  173.  
  174. local source = string.lower(speaker.Name)
  175. msg = string.lower(msg)
  176.  
  177.  
  178. -- vote to kick the following players
  179. -- "kick telamon buildman wookong"
  180. if (string.find(msg, "kick") == 1) then --- msg starts with "kick"
  181. -- words and numbers
  182. for word in msg:gmatch("%w+") do
  183. if word ~= "kick" then
  184. local p = matchPlayer(word)
  185. if p ~= nil then
  186. voteAgainst(source, p)
  187. end
  188. end
  189. end
  190. end
  191.  
  192.  
  193. end
  194.  
  195.  
  196. game.Players.ChildAdded:connect(onPlayerEntered)
Add Comment
Please, Sign In to add comment