Guest Posted June 11, 2018 Share Posted June 11, 2018 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
AJXB Posted June 12, 2018 Share Posted June 12, 2018 Did you verify all that getElementData() you're doing on line 4 ? Link to comment
Guest Posted June 12, 2018 Share Posted June 12, 2018 Oh , no If i remove line 4 it works but with some bugs can you tell me what is it mean ( Line 4) because my friend gave me the code Link to comment
AJXB Posted June 12, 2018 Share Posted June 12, 2018 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
Guest Posted June 12, 2018 Share Posted June 12, 2018 Working, Thanks you very very much bro But player can mute/ban/kick how to make this function works only with staffs? Link to comment
AJXB Posted June 12, 2018 Share Posted June 12, 2018 Many ways to do that, but you can just go on the wiki and look for an ACL function that checks that. I can tell you what function that is but you should spend some time Link to comment
Guest Posted June 12, 2018 Share Posted June 12, 2018 (edited) 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 June 12, 2018 by Guest Link to comment
AJXB Posted June 12, 2018 Share Posted June 12, 2018 Did you add yourself in the ACL file? Link to comment
AJXB Posted June 12, 2018 Share Posted June 12, 2018 Did you restart the server after you added yourself? If so, repost your code. Link to comment
Guest Posted June 12, 2018 Share Posted June 12, 2018 (edited) 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 June 12, 2018 by Guest Link to comment
AJXB Posted June 13, 2018 Share Posted June 13, 2018 What the hell is that? line 74 and 75 are not in a function.. What.. Link to comment
Guest Posted June 13, 2018 Share Posted June 13, 2018 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
AJXB Posted June 13, 2018 Share Posted June 13, 2018 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
Guest Posted June 13, 2018 Share Posted June 13, 2018 (edited) What did you added other than you puted this code local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "Admin" ) ) then Because i added the same code at the same place you putted and nothing happened Edited June 13, 2018 by Guest Link to comment
AJXB Posted June 13, 2018 Share Posted June 13, 2018 I just added it in the right place and added an "end" for the if. Just copy my code, you need to learn more from the wiki how Lua works Link to comment
Guest Posted June 13, 2018 Share Posted June 13, 2018 You are right bro thank you very mch Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now