Jump to content

mute problem


Guest

Recommended Posts

local serialMute = { }

	function doAction(thePlayer, cmd, actionId, playername, arg3)
	if getElementData(thePlayer, "player.key") == "Warlock" or getElementData(thePlayer, "player.key") == "Wind:Oer" or getElementData(thePlayer, "player.key") == "Ivan" or getElementData(thePlayer, "player.key") == "Scorpio1" or getElementData(thePlayer, "player.key") == "vievsonic" then
		if actionId then
			local actionId = tonumber(actionId) 
			local player = getPlayerFromNamePart(playername or "")
			local name = getPlayerName(thePlayer)
			if player then
				if actionId == 1 then
					local duration = (tonumber(arg3) or 0) * 60 * 1000
					setPlayerMuted(player, true)
					outputChatBox(getPlayerName(player).." #005A0Ehas been muted by #FFFFFF"..name.."#005A0E.#FFFFFF Reason: insulting #005A0EDuration #FFFFFF["..math.floor((duration *1.66666667 * 1/100000)).." mins].", root, 255, 255, 255, true)
					local timer = setTimer ( unmute, duration, 1, player )
					serialMute [ getPlayerSerial ( player ) ] = { duration, timer })
				end
			else
				outputChatBox("Could not find the player.",thePlayer, 255, 0, 0)
			end
		end
	end
end
addCommandHandler("action", doAction)

function unmutePlayer(player,command,victimName)
	if victimName then
		local victim = getPlayerFromNamePart(victimName or "")
		if victim then
			if ( isPlayerMuted(victim) ) then
				setPlayerMuted(victim, false)
			end
		end
	end
end
addCommandHandler("unmute",unmutePlayer)

function onJoin ()
    local serial = getPlayerSerial(source)
    local muted = serialMute [ serial ]
    if ( type ( muted ) == "table" ) then
        if ( muted [ 1 ] ) then
            setPlayerMuted ( source, true )
            local timer = setTimer ( unmute, muted [ 1 ], 1, source )
            serialMute [ serial ] [ 2 ] = timer
 
            return
        end
    end
    setPlayerMuted ( source, false )
end
addEventHandler ( "onPlayerJoin", getRootElement(), onJoin )
 
addEventHandler ( "onPlayerQuit", root,
    function ( )
        local serial = getPlayerSerial ( source )
        local muted = serialMute [ serial ]
        if ( type ( muted ) == "table" ) then
            if isTimer ( muted [ 2 ] ) then
                local timeLeft = getTimerDetails ( muted [ 2 ] )
                killTimer ( muted [ 2 ] )
                serialMute [ serial ] [ 1 ] = timeLeft
            end
        end
    end
)
 
function unmute ( thePlayer )
    if isElement ( thePlayer ) then
        setPlayerMuted ( thePlayer, false )
        serialMute [ getPlayerSerial ( thePlayer ) ] = nil
        outputChatBox ( "You have been unmuted by Console.", thePlayer, 0, 255, 100 )
    end
end

function getPlayerFromNamePart(name)
    if name then
        for i, player in ipairs(getElementsByType("player")) do
            if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then
                return player
            end
        end
    end
    return false
end

When i do /action [mute id ] [Player name] [Time] 

nothing happens

Link to comment

Line 4 is checking for data related to the player, It's there because the script is taken from another game mode, or considered connected to other scripts.

Replace line 4 with this line and post any errors you have

if (isElement( thePlayer )) then

Next time, please write your own code

Link to comment

i have more than 30 minutes searching

i founded this code

   local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 

But nothing happened

Edited by Guest
Link to comment

i used this

bool aclReload ()

local serialMute = { }

	function doAction(thePlayer, cmd, actionId, playername, arg3)
    if (isElement( thePlayer )) then
		if actionId then
			local actionId = tonumber(actionId) 
			local player = getPlayerFromNamePart(playername or "")
			local name = getPlayerName(thePlayer)
			if player then
				if actionId == 1 then
					local duration = (tonumber(arg3) or 0) * 60 * 1000
					setPlayerMuted(player, true)
					outputChatBox(getPlayerName(player).." #005A0Ehas been muted by #FFFFFF"..name.."#005A0E.#FFFFFF Reason: insulting #005A0EDuration #FFFFFF["..math.floor((duration *1.66666667 * 1/100000)).." mins].", root, 255, 255, 255, true)
					local timer = setTimer ( unmute, duration, 1, player )
					serialMute [ getPlayerSerial ( player ) ] = { duration, timer })
				end
			else
				outputChatBox("Could not find the player.",thePlayer, 255, 0, 0)
			end
		end
	end
end
addCommandHandler("action", doAction)

function unmutePlayer(player,command,victimName)
	if victimName then
		local victim = getPlayerFromNamePart(victimName or "")
		if victim then
			if ( isPlayerMuted(victim) ) then
				setPlayerMuted(victim, false)
			end
		end
	end
end
addCommandHandler("unmute",unmutePlayer)

function onJoin ()
    local serial = getPlayerSerial(source)
    local muted = serialMute [ serial ]
    if ( type ( muted ) == "table" ) then
        if ( muted [ 1 ] ) then
            setPlayerMuted ( source, true )
            local timer = setTimer ( unmute, muted [ 1 ], 1, source )
            serialMute [ serial ] [ 2 ] = timer
 
            return
        end
    end
    setPlayerMuted ( source, false )
end
addEventHandler ( "onPlayerJoin", getRootElement(), onJoin )
 
addEventHandler ( "onPlayerQuit", root,
    function ( )
        local serial = getPlayerSerial ( source )
        local muted = serialMute [ serial ]
        if ( type ( muted ) == "table" ) then
            if isTimer ( muted [ 2 ] ) then
                local timeLeft = getTimerDetails ( muted [ 2 ] )
                killTimer ( muted [ 2 ] )
                serialMute [ serial ] [ 1 ] = timeLeft
            end
        end
    end
)
 
function unmute ( thePlayer )
    if isElement ( thePlayer ) then
        setPlayerMuted ( thePlayer, false )
        serialMute [ getPlayerSerial ( thePlayer ) ] = nil
        outputChatBox ( "You have been unmuted by Console.", thePlayer, 0, 255, 100 )
    end
end
    local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
function getPlayerFromNamePart(name)
    if name then
        for i, player in ipairs(getElementsByType("player")) do
            if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then
                return player
            end
        end
    end
    return false
end

 

Edited by Guest
Link to comment

Help me to understand.. I'm still new in scripting

   function ( thePlayer )   
   local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
     if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 

What about this?

Link to comment
    local serialMute = { }

    	function doAction(thePlayer, cmd, actionId, playername, arg3)
        if (isElement( thePlayer )) then
    		if actionId then
    			local actionId = tonumber(actionId) 
    			local player = getPlayerFromNamePart(playername or "")
    			local name = getPlayerName(thePlayer)
    			if player then
    				if actionId == 1 then
						local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) 
         				if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then 
	    					local duration = (tonumber(arg3) or 0) * 60 * 1000
	    					setPlayerMuted(player, true)
	    					outputChatBox(getPlayerName(player).." #005A0Ehas been muted by #FFFFFF"..name.."#005A0E.#FFFFFF Reason: insulting #005A0EDuration #FFFFFF["..math.floor((duration *1.66666667 * 1/100000)).." mins].", root, 255, 255, 255, true)
	    					local timer = setTimer ( unmute, duration, 1, player )
	    					serialMute [ getPlayerSerial ( player ) ] = { duration, timer })
    					end
    				end
    			else
    				outputChatBox("Could not find the player.",thePlayer, 255, 0, 0)
    			end
    		end
    	end
    end
    addCommandHandler("action", doAction)

    function unmutePlayer(player,command,victimName)
    	if victimName then
    		local victim = getPlayerFromNamePart(victimName or "")
    		if victim then
    			if ( isPlayerMuted(victim) ) then
    				setPlayerMuted(victim, false)
    			end
    		end
    	end
    end
    addCommandHandler("unmute",unmutePlayer)

    function onJoin ()
        local serial = getPlayerSerial(source)
        local muted = serialMute [ serial ]
        if ( type ( muted ) == "table" ) then
            if ( muted [ 1 ] ) then
                setPlayerMuted ( source, true )
                local timer = setTimer ( unmute, muted [ 1 ], 1, source )
                serialMute [ serial ] [ 2 ] = timer
     
                return
            end
        end
        setPlayerMuted ( source, false )
    end
    addEventHandler ( "onPlayerJoin", getRootElement(), onJoin )
     
    addEventHandler ( "onPlayerQuit", root,
        function ( )
            local serial = getPlayerSerial ( source )
            local muted = serialMute [ serial ]
            if ( type ( muted ) == "table" ) then
                if isTimer ( muted [ 2 ] ) then
                    local timeLeft = getTimerDetails ( muted [ 2 ] )
                    killTimer ( muted [ 2 ] )
                    serialMute [ serial ] [ 1 ] = timeLeft
                end
            end
        end
    )
     
    function unmute ( thePlayer )
        if isElement ( thePlayer ) then
            setPlayerMuted ( thePlayer, false )
            serialMute [ getPlayerSerial ( thePlayer ) ] = nil
            outputChatBox ( "You have been unmuted by Console.", thePlayer, 0, 255, 100 )
        end
    end

    function getPlayerFromNamePart(name)
        if name then
            for i, player in ipairs(getElementsByType("player")) do
                if string.find(getPlayerName(player):lower(), tostring(name):lower(), 1, true) then
                    return player
                end
            end
        end
        return false
    end

Try this

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...