Jump to content

Anti vote spam


Memory

Recommended Posts

Hi,

Can you are help with anti vote spam? How activated "function mutePlayer" on started vote for change map, and "function UnmutePlayer" on stop vote?

function mutePlayer() 
        for _, player in ipairs ( getElementsByType ( "player" ) ) do 
        setPlayerMuted(player, true) 
            outputChatBox("#FF0000All has been muted.", getRootElement(), 255, 255, 255, true ) 
    end 
  
        for i,v in ipairs(getAccounts()) do 
        setPlayerMuted(v, true) 
        end 
addCommandHandler("mute",mutePlayer) 
  
function UnmutePlayer() 
        for _, player in ipairs ( getElementsByType ( "player" ) ) do 
        setPlayerMuted(player, false) 
            outputChatBox("#FF0000All has been unmuted.", getRootElement(), 255, 255, 255, true ) 
    end 
  
        for i,v in ipairs(getAccounts()) do 
        setPlayerMuted(v, false) 
        end 
addCommandHandler("unmute",UnmutePlayer) 

Link to comment

try this:

function mutePlayers() 
    for _, player in ipairs ( getElementsByType ( "player" ) ) do 
        setPlayerMuted(player, true) 
        outputChatBox("#FF0000All has been muted.",player, 255, 255, 255, true ) 
    end 
end --forgot end 
addCommandHandler("mute",mutePlayers) 
  
function unmutePlayers() 
    for _, player in ipairs ( getElementsByType ( "player" ) ) do 
        setPlayerMuted(player, false) 
        outputChatBox("#FF0000All has been unmuted.",player, 255, 255, 255, true ) 
    end 
end --forgot end 
addCommandHandler("unmute",unmutePlayers) 
  
addEventHandler("onPollStarting",root,function() 
    mutePlayers() 
end) 
addEventHandler("onRaceStateChanging",root,function(state) 
    if state=="LoadingMap" then 
        unmutePlayers() 
    end 
end) 

oh, and there was no need for the accounts loop, you could only set players muted.

Link to comment

Can be this? But don't work

function mutePlayers() 
    for _, player in ipairs ( getElementsByType ( "player" ) ) do 
        setPlayerMuted(player, true) 
        outputChatBox("#FF0000All has been muted.",player, 255, 255, 255, true ) 
    end 
end  
addEventHandler("onPollStarting",root, mutePlayers) 
  
function unmutePlayers(state) 
    for _, player in ipairs ( getElementsByType ( "player" ) ) do 
      if state=="LoadingMap" then 
        setPlayerMuted(player, false) 
        outputChatBox("#FF0000All has been unmuted.",player, 255, 255, 255, true ) 
    end 
end  
addEventHandler("onRaceStateChanging",root, unmutePlayers) 
  

Link to comment

It doesn't have any errors now, but I'm not sure if it works.

function mutePlayers() 
    for _, player in ipairs ( getElementsByType ( "player" ) ) do 
        setPlayerMuted(player, true) 
        outputChatBox("#FF0000All has been muted.",player, 255, 255, 255, true ) 
    end 
end 
addEventHandler("onPollStarting",root, mutePlayers) 
  
function unmutePlayers(state) 
    for _, player in ipairs ( getElementsByType ( "player" ) ) do 
        if state=="LoadingMap" then 
            setPlayerMuted(player, false) 
            outputChatBox("#FF0000All has been unmuted.",player, 255, 255, 255, true ) 
        end 
    end 
end 
addEventHandler("onRaceStateChanging",root, unmutePlayers) 

Link to comment

Thanks, work :) I still added "addEvent("onRaceStateChanging",true)" for all unmuted.

Full code, add resource name to acl "Admin",

function mutePlayers() 
    for _, player in ipairs ( getElementsByType ( "player" ) ) do 
        setPlayerMuted(player, true) 
        outputChatBox("#FF0000All has been muted.",player, 255, 255, 255, true ) 
    end 
end 
addEvent("onPollStarting",true) 
addEventHandler("onPollStarting",root, mutePlayers) 
  
function unmutePlayers(state) 
    for _, player in ipairs ( getElementsByType ( "player" ) ) do 
        if state=="LoadingMap" then 
            setPlayerMuted(player, false) 
            outputChatBox("#FF0000All has been unmuted.",player, 255, 255, 255, true ) 
        end 
    end 
end 
addEvent("onRaceStateChanging",true) 
addEventHandler("onRaceStateChanging",root, unmutePlayers) 

Edited by Guest
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...