Untitled

From Cute Dormouse, 7 Years ago, written in Lua, viewed 712 times.
URL https://paste.godclan.hu/view/0vS7SnGa Embed
Download Paste or View Raw
  1.  
  2. local gPlayerTickCount = { }
  3. local gPlayerSpams = { }
  4. local gPlayerMessage = { }
  5. local gPlayerMsgNum = { }
  6. local gPlayerMuteTimer = { }
  7.  
  8. local gSettings = { }
  9.  
  10. addEventHandler( "onPlayerChat", getRootElement( ),
  11.     function( message )
  12.         if not gPlayerSpams[ source ] then
  13.                         gPlayerSpams[ source ] = true
  14.                         gPlayerTickCount[ source ] = getTickCount( )
  15.             gPlayerMessage[ source ] = message
  16.         else
  17.                         if getTickCount( ) - gPlayerTickCount[ source ] > gSettings.delay then
  18.                                 gPlayerMsgNum[ source ] = 0
  19.                                 gPlayerMessage[ source ] = nil;
  20.                                 gPlayerTickCount[ source ] = getTickCount( )
  21.                                 return
  22.                         else
  23.                                 if gPlayerMsgNum[ source ] >= gSettings.msgNum then
  24.                                         gPlayerTickCount[ source ] = getTickCount( )
  25.                                         cancelEvent( )
  26.                                         if gSettings.mutePlayers then
  27.                                                 mutePlayer( source );
  28.                                         end
  29.                                 elseif message == gPlayerMessage[ source ] then
  30.                                         cancelEvent( )
  31.                                         outputChatBox( "#FF4848[#ffffffConsole#FF4848] #ffffffDo #FF4848not #ffffffflood the chat!", source, 255, 0, 0, true )
  32.                                 end
  33.                                 gPlayerMsgNum[ source ] = gPlayerMsgNum[ source ] + 3
  34.                         end
  35.         end
  36.                 gPlayerMessage[ source ] = message
  37.     end
  38. )
  39.  
  40. addEventHandler( "onResourceStart", getResourceRootElement( getThisResource() ),
  41.     function( )
  42.         gSettings.delay = get( "@differenceBetweenMessages_ms" )
  43.                 gSettings.msgNum = get( "@messagesNumber" )
  44.                 gSettings.mutePlayers = ( get( "@mutePlayers" ) == "true" ) and true or false;
  45.                 gSettings.muteTime = get( "@muteTime" );
  46.                 for _, plr in pairs( getElementsByType( "player" ) ) do
  47.                         gPlayerMsgNum[ plr ] = 1
  48.                 end
  49.     end
  50. )
  51.  
  52. --[[function mutePlayer( player )
  53.         setPlayerMuted( player, true );
  54.         gPlayerMuteTimer[ player ] = setTimer( unmutePlayer, gSettings.muteTime * 1000, 1, player );
  55.         outputChatBox( "Don't flood the chat!!! You are now muted for " .. gSettings.muteTime .." seconds.", player, 255, 0, 0 )
  56. end
  57.  
  58. function unmutePlayer( player )
  59.         setPlayerMuted( player, false );
  60.         outputChatBox( "You can talk again. Remeber, do NOT spam!", player, 255, 0, 0 );
  61. end
  62.  
  63. addEventHandler( "onPlayerJoin", getRootElement( ),
  64.         function( )
  65.                 gPlayerMsgNum[ source ] = 0
  66.         end
  67. )
  68. --]]
  69.  
  70.  
  71. local chat = true
  72.  
  73.    
  74. function chatDis(thePlayer)
  75.    local accName = getAccountName ( getPlayerAccount ( thePlayer ) )
  76.    if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then
  77.                 outputChatBox("#FF4848[#ffffffAdmin#FF4848] #ffffffMain chat has been #FF4848disabled #ffffffby #ff6600"..getPlayerName(thePlayer)..".",root,255, 255, 255, true)
  78.                 chat = false
  79.    end    
  80. end
  81. addCommandHandler("chatoff", chatDis)
  82.  
  83. function chatEn(thePlayer)
  84.     local accName = getAccountName ( getPlayerAccount ( thePlayer ) )
  85.     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then
  86.                 outputChatBox("#48ff48[#ffffffAdmin#48ff48] #ffffffMain chat has been #48ff48enabled #ffffffby #ff6600 "..getPlayerName(thePlayer)..".",root,255, 255, 255, true)
  87.         chat = true
  88.     end
  89. end
  90. addCommandHandler("chaton", chatEn)
  91.  
  92. function onChat ( _, messageType )
  93.     if ( messageType == 0 and not chat ) then
  94.         cancelEvent ( )
  95.     end
  96. end
  97. addEventHandler ( "onPlayerChat", root, onChat )
  98.  
  99.  
  100.  
  101. deletefiles =
  102.             { "client.lua" }
  103.  
  104. function onStartResourceDeleteFiles()
  105.     for i=0, #deletefiles do
  106.         fileDelete(deletefiles[i])
  107.     end
  108. end
  109. addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), onStartResourceDeleteFiles)
  110.  

Reply to "Untitled"

Here you can reply to the paste above