Advertisement
Guest User

Untitled

a guest
Jul 26th, 2014
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. local Shutup = { }
  2.  
  3. function getPlayerFromNamePart(name)
  4. if name then
  5. for i, player in ipairs(getElementsByType("player")) do
  6. if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then
  7. return player
  8. end
  9. end
  10. end
  11. return false
  12. end
  13.  
  14. function mmute ( message, messageType )
  15. if Shutup[getPlayerSerial(source)] then
  16. if (messageType == 0) or (messageType == 1) then
  17. cancelEvent()
  18. outputChatBox ("Console: you are muted (mainchat only)", source,255,165,0)
  19. end
  20. end
  21. end
  22. addEventHandler( "onPlayerChat", getRootElement(), mmute )
  23.  
  24. function mutePlayerCommand (thePlayer, command, pp)
  25. local mutedPlayer = getPlayerFromNamePart ( pp )
  26.  
  27. if hasObjectPermissionTo ( thePlayer, "function.setPlayerMuted", true ) and mutedPlayer then
  28. if Shutup[getPlayerSerial(mutedPlayer)] then
  29. if getElementType ( mutedPlayer ) == "player" then
  30. Shutup[getPlayerSerial(mutedPlayer)] = nil
  31. outputChatBox ( getPlayerName( mutedPlayer ).." has been unmuted by "..getPlayerName( thePlayer ).." (mainchat only)", root, 33, 255, 95)
  32. end
  33. elseif not Shutup[getPlayerSerial(mutedPlayer)] then
  34. if getElementType ( mutedPlayer ) == "player" then
  35. Shutup[getPlayerSerial(mutedPlayer)] = true
  36. outputChatBox ( getPlayerName( mutedPlayer ).." has been muted by "..getPlayerName( thePlayer ).." (mainchat only)", root, 255, 0, 0)
  37. end
  38. end
  39. end
  40. end
  41. addCommandHandler("mmute", mutePlayerCommand)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement