Jump to content

[AJUDA] Script


Recommended Posts

Olá, alguém pode me ajudar? Eu estou tentando fazer um script de mutar / desmutar players, porém o mesmo não funciona.

Script:

addEventHandler("onPlayerChat", getRootElement(),
function(msg, msgType)
    if msgType == 0 then
        for k, v in ipairs (BadWords) do
            if string.find( string.lower ( msg ), v) then
				for i, m in ipairs( GoodWords ) do
					if string.find( string.lower ( msg ), m) then
						if string.find( string.lower ( msg ), v) == "puta" then
							return
						elseif string.find( string.lower ( msg ), v) == "cu" then
							return
						else
							cancelEvent(true)
							mtp(source)
							break
						end
					else
						cancelEvent(true)
						mtp(source)
						break
					end
				end
            end
        end
    end
end)

function mtp (source)
	if not isPlayerMuted(source) then
		local Nome = getPlayerName(source)
		setPlayerMuted(source, true)
		outputChatBox("#ff0000[INSULTO] #000000- #ffffff ".. Nome .."  #fffffffoi mutado por falar palavrão! #000000[#ffff0060s#000000] #ff0000[CONSOLE]", getRootElement(), 255, 0, 0, true)
		setTimer( dmtp, 60000, 1 )
	end
end

function dmtp (source)
	if isPlayerMuted(source) then
		local Nome = getPlayerName(source)
		setPlayerMuted(source, false)
		outputChatBox("#ff0000[INSULTO] - #ffffff ".. Nome .." #fffffffoi desmutado. #ff0000[CONSOLE]", getRootElement(), 255, 0, 0, true)
	end
end

 

Erro:  WARNING: [all]\insulto\insulto.lua:94 Bad argument @ 'isPlayerMuted'' [Expected player at argument 1, got nil]

Link to comment
  • Other Languages Moderators

O seu setTimer da linha 33 está faltando o argumento do source. Faça assim:

badWords = {
	"fdp",
	"puta",
	"cu",
	"caralho"
}

addEventHandler ("onPlayerChat", getRootElement(), function (msg, msgType)
	if msgType == 0 then
		for k, v in ipairs (badWords) do
			if string.find (string.lower (msg), v) then
				cancelEvent()
				mtp(source)
				break
			end
		end
	end
end)

function mtp (source)
	if not isPlayerMuted (source) then
		local nome = getPlayerName (source)
		setPlayerMuted (source, true)
		outputChatBox("[INSULTO] #ffffff- "..nome.."  #fffffffoi mutado por falar palavrão! [#ffff0060s#ffffff] [CONSOLE]", getRootElement(), 255, 0, 0, true)
		setTimer (dmtp, 60000, 1, source)
	end
end

function dmtp (source)
	if isPlayerMuted (source) then
		local nome = getPlayerName (source)
		setPlayerMuted (source, false)
		outputChatBox ("[INSULTO] #ffffff- "..nome.." #fffffffoi desmutado. [CONSOLE]", getRootElement(), 255, 0, 0, true)
	end
end

Testei aqui e funcionou.

Edited by Lord Henry
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...