Gravestone Posted May 24, 2016 Share Posted May 24, 2016 This code mutes the player with a reason for a specific time when defined. For example you type '/p grav 1 6' this will punish a guy name grav for Rule #1 and for 6 minutes. I want my code to select the timer in an ascending order. I mean, the first mute for that serial goes for 1 min then the second goes for 2 mins and then 5 mins later 10 mins and so on. The timer maximum time stays at 6 hours. Any help would be highly appreciated. function punish(thePlayer, cmd, playername, rule, arg3, arg4) if hasObjectPermissionTo(thePlayer, "function.setPlayerMuted", false) then if rule then local rule = tonumber(rule) local player = getPlayerFromNamePart(playername or "") if player then if rule == 1 then local duration = (tonumber(arg3) or 0) * 60 * 3600000 setPlayerMuted(player, true, true, true, thePlayer, reason, duration) outputChatBox("#008AB8 • #ffffff"..getPlayerName(thePlayer).." #008AB8has muted #ffffff"..getPlayerName(player).." #008AB8for RULE #1 ( #ffffffNon-English#008AB8 ) #008AB8(#ffffff "..tonumber(arg3).." minutes #008AB8) ", root, 255, 255, 255, true) else outputChatBox("Error: Invalid rule ID",thePlayer, 255, 0, 0) end else outputChatBox("Error: Invalid player",thePlayer, 255, 0, 0) end else outputChatBox("Error: /p [Player's name] [Rule ID] [Duration]",thePlayer, 255, 0, 0) end end end addCommandHandler("p", punish) 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 Link to comment
ViRuZGamiing Posted May 25, 2016 Share Posted May 25, 2016 How I'd go about it is make an array and a index variable. muteTimeIndex = 0 muteTimes = {1, 2, 5, 10, 15, 30, 60, 120, 180, 240, 300, 360} --in minutes needs conversion to ms --onMute muteTimeIndex = muteTimeIndex + 1 muteTimes[muteTimeIndex] there might be a better way but this would be mine Link to comment
Gravestone Posted May 25, 2016 Author Share Posted May 25, 2016 This table is created. Now what do I add in my script? Link to comment
ViRuZGamiing Posted May 28, 2016 Share Posted May 28, 2016 You might wanna start looking into learning how to script first. Link to comment
Gravestone Posted May 28, 2016 Author Share Posted May 28, 2016 You might wanna learn how to help first. This forum is to help, and I'm here to learn. Stop being rude. Link to comment
ViRuZGamiing Posted May 28, 2016 Share Posted May 28, 2016 I did help, and I helped many others. After I gave you all you needed you kept bumping the post with question marks. Also don't tell me what this forum's about I've been around long enough to know this. If you are really here to learn, start learning, cause you said I was being rude but I really ment that you should start learning it. You can keep making forum posts with code that has to be fixed for you. 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