Jump to content

Mute&Ban&kick Reason


-Doc-

Recommended Posts

Posted

not working nothing player not getting mute no chatbox not ban nothing and im asking for help

My scripting skills

 


76561198189590622.pngAddFriend.png

Posted

Replcae player with thePlayer

if hasObjectPermissionTo(player, "function.setPlayerMuted", false) then 

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

Posted

Lel, why don't you use the getPlayerFromNamePart function ?

function doAction(thePlayer, cmd, actionId, playername) 
    if actionId then 
        local actionId = tonumber(actionId) --forgot this line 
        local player = getPlayerFromNamePart(playername) 
        if hasObjectPermissionTo(thePlayer, "function.setPlayerMuted", false) then 
            if actionId == 1 then 
                local duration = (1000 * 1800) 
                setPlayerMuted(player, true) 
                outputChatBox(getPlayerName(player).." #FF0000has been muted by #FFFFFF"..name.."#FF0000.#FFFFFF [RULE #1:Only English  in Main Chat(mute)] #FF0000Length #FFFFFF[30 mins].", root, 255, 255, 255, true) 
                local timer = setTimer ( unmute, duration, 1, player ) 
            elseif actionId == 2 then 
                local duration = (1000 * 1800) 
                setPlayerMuted(player, true) 
                outputChatBox(getPlayerName(player).." #FF0000has been muted by #FFFFFF"..name.."#FF0000.#FFFFFF [RULE #2:No insulting people (mute)] #FF0000Length #FFFFFF[30 mins].", root, 255, 255, 255, true) 
                local timer = setTimer ( unmute, duration, 1, player ) 
            elseif actionId == 3 then 
                local duration = (1000 * 1800) 
                setPlayerMuted(player, true) 
                outputChatBox(getPlayerName(player).." #FF0000has been muted by #FFFFFF"..name.."#FF0000.#FFFFFF [RULE #3:No annoying people (mute)] #FF0000Length #FFFFFF[30 mins].", root, 255, 255, 255, true) 
                local timer = setTimer ( unmute, duration, 1, player ) 
            elseif actionId == 4 then 
                local duration = (1000 * 1800) 
                setPlayerMuted(player, true) 
                outputChatBox(getPlayerName(player).." #FF0000has been muted by #FFFFFF"..name.."#FF0000.#FFFFFF [RULE #4:No advertising other servers (mute)] #FF0000Length #FFFFFF[30 mins].", root, 255, 255, 255, true) 
                local timer = setTimer ( unmute, duration, 1, player ) 
            elseif actionId == 5 then 
                local duration = (1000 * 1800) 
                setPlayerMuted(player, true) 
                outputChatBox(getPlayerName(player).." #FF0000has been muted by #FFFFFF"..name.."#FF0000.#FFFFFF [RULE #5:No spamming (mute)] #FF0000Length #FFFFFF[30 mins].", root, 255, 255, 255, true) 
                local timer = setTimer ( unmute, duration, 1, player ) 
            elseif actionId == 6 then 
                local duration = (1000 * 1800) 
                setPlayerMuted(player, true) 
                outputChatBox(getPlayerName(player).." #FF0000has been muted by #FFFFFF"..name.."#FF0000.#FFFFFF [RULE #6:No asking for staff (mute)] #FF0000Length #FFFFFF[30 mins]", root, 255, 255, 255, true) 
                local timer = setTimer ( unmute, duration, 1, player ) 
            elseif actionId == 7 then 
                local reason = "[RULE #7:No killing/annoying working or busy staff (kick)]" 
                outputChatBox(getPlayerName(player).." #FF0000has been kicked by #FFFFFF"..name.."#FF0000.#FFFFFF [RULE #7:No killing/annoying working or busy staff (kick)]", root, 255, 255, 255, true) 
                kickPlayer(player, thePlayer, reason) 
            elseif actionId == 8 then 
                local duration = (24 * 3600) 
                local reason = "[RULE #8:No impersonating (ban)]" 
                outputChatBox(getPlayerName(player).." #FF0000has been banned by #FFFFFF"..name.."#FF0000.#FFFFFF [RULE #8:No impersonating (ban)]", root, 255, 255, 255, true) 
                banPlayer(player, true, true, true, thePlayer, reason, duration) 
            elseif actionId == 9 then 
                local duration = (24 * 3600) 
                local reason = "[RULE #9:No hacking/abusing the bugs (ban)]" 
                outputChatBox(getPlayerName(player).." #FF0000has been banned by #FFFFFF"..name.."#FF0000.#FFFFFF [RULE #9:No hacking/abusing the bugs (ban)]", root, 255, 255, 255, true) 
                banPlayer(player, true, true, true, thePlayer, reason, duration) 
                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.", thePlayer, 0, 100, 0 ) 
    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 

This should work.

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