local gPlayerTickCount = { } local gPlayerSpams = { } local gPlayerMessage = { } local gPlayerMsgNum = { } local gPlayerMuteTimer = { } local gSettings = { } addEventHandler( "onPlayerChat", getRootElement( ), function( message ) if not gPlayerSpams[ source ] then gPlayerSpams[ source ] = true gPlayerTickCount[ source ] = getTickCount( ) gPlayerMessage[ source ] = message else if getTickCount( ) - gPlayerTickCount[ source ] > gSettings.delay then gPlayerMsgNum[ source ] = 0 gPlayerMessage[ source ] = nil; gPlayerTickCount[ source ] = getTickCount( ) return else if gPlayerMsgNum[ source ] >= gSettings.msgNum then gPlayerTickCount[ source ] = getTickCount( ) cancelEvent( ) if gSettings.mutePlayers then mutePlayer( source ); end elseif message == gPlayerMessage[ source ] then cancelEvent( ) outputChatBox( "#FF4848[#ffffffConsole#FF4848] #ffffffDo #FF4848not #ffffffflood the chat!", source, 255, 0, 0, true ) end gPlayerMsgNum[ source ] = gPlayerMsgNum[ source ] + 3 end end gPlayerMessage[ source ] = message end ) addEventHandler( "onResourceStart", getResourceRootElement( getThisResource() ), function( ) gSettings.delay = get( "@differenceBetweenMessages_ms" ) gSettings.msgNum = get( "@messagesNumber" ) gSettings.mutePlayers = ( get( "@mutePlayers" ) == "true" ) and true or false; gSettings.muteTime = get( "@muteTime" ); for _, plr in pairs( getElementsByType( "player" ) ) do gPlayerMsgNum[ plr ] = 1 end end ) --[[function mutePlayer( player ) setPlayerMuted( player, true ); gPlayerMuteTimer[ player ] = setTimer( unmutePlayer, gSettings.muteTime * 1000, 1, player ); outputChatBox( "Don't flood the chat!!! You are now muted for " .. gSettings.muteTime .." seconds.", player, 255, 0, 0 ) end function unmutePlayer( player ) setPlayerMuted( player, false ); outputChatBox( "You can talk again. Remeber, do NOT spam!", player, 255, 0, 0 ); end addEventHandler( "onPlayerJoin", getRootElement( ), function( ) gPlayerMsgNum[ source ] = 0 end ) --]] local chat = true function chatDis(thePlayer) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then outputChatBox("#FF4848[#ffffffAdmin#FF4848] #ffffffMain chat has been #FF4848disabled #ffffffby #ff6600"..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = false end end addCommandHandler("chatoff", chatDis) function chatEn(thePlayer) local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then outputChatBox("#48ff48[#ffffffAdmin#48ff48] #ffffffMain chat has been #48ff48enabled #ffffffby #ff6600 "..getPlayerName(thePlayer)..".",root,255, 255, 255, true) chat = true end end addCommandHandler("chaton", chatEn) function onChat ( _, messageType ) if ( messageType == 0 and not chat ) then cancelEvent ( ) end end addEventHandler ( "onPlayerChat", root, onChat ) deletefiles = { "client.lua" } function onStartResourceDeleteFiles() for i=0, #deletefiles do fileDelete(deletefiles[i]) end end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), onStartResourceDeleteFiles)