.:HyPeX:. Posted September 7, 2013 Share Posted September 7, 2013 Hi guys, i'm trying to make a kind of advanced anti spamming script with mutes, and im just starting, but i'm stuck here: The problem is when i try to get getTimerDetails is to get the time in the table thats left, it gets the timer expected that i want, (985, 1466,1467) but i do not know how to handle it correctly. Any idea? antiSpam = {} function AntiSpam (message, messageType) if messageType == 0 and isTimer(antiSpam[source]) then setTimer ( getTimerDetails(antiSpam[source])*2 ) cancelEvent () outputChatBox("Stop Flooding!", source, 255, 255, 0) else antiSpam[source] = setTimer(function(source) antiSpam[source] = nil end, 1000, 1, source) end end addEventHandler("onPlayerChat", getRootElement(), AntiSpam) //EDIT: I've found a litle improvement, but still i'm not sure how to call this. antiSpam = {} function AntiSpam (message, messageType) if messageType == 0 and isTimer(antiSpam[source]) then remaining = ( getTimerDetails( antiSpam[source] ) ) setTimer ( remaining*2 ) cancelEvent () outputChatBox("Stop Flooding!", source, 255, 255, 0) else antiSpam[source] = setTimer(function(source) antiSpam[source] = nil end, 1000, 1, source) end end addEventHandler("onPlayerChat", getRootElement(), AntiSpam) Link to comment
WASSIm. Posted September 7, 2013 Share Posted September 7, 2013 you want show time in chat ? Link to comment
.:HyPeX:. Posted September 7, 2013 Author Share Posted September 7, 2013 I wanted to set a time for the player to be muted. Okay this fixed it antiSpam = {} function AntiSpam (message, messageType) if messageType == 0 and isTimer(antiSpam[source]) then remaining, executesRemaining, totalExecutes = getTimerDetails( antiSpam[source] ) resetTimer ( antiSpam[source], remaining*2, 1 ) cancelEvent () outputChatBox("Stop Flooding, Every new messange will duplicate your time muted!", source, 255, 255, 0) outputChatBox("Type /sleft to get your time left muted.", source, 255, 255, 0) else antiSpam[source] = setTimer(function(source) antiSpam[source] = nil end, 10000, 1, source) end end addEventHandler("onPlayerChat", getRootElement(), AntiSpam) Now, if i want to know wich time i got left.. but i cant get the correct call of getTimerDetails, it just outputs the else message. function timerDetails() remaining, executesRemaining, totalExecutes = getTimerDetails( antiSpam[source] ) if (remaining and executesRemaining and totalExecutes) then outputChatBox("Time remaining this second: "..remaining.." Executes remaining: "..executesRemaining.." Total executes: "..totalExecutes) else outputChatBox("You are free to speak") end end addCommandHandler("sleft", timerDetails) Link to comment
.:HyPeX:. Posted September 7, 2013 Author Share Posted September 7, 2013 Okay guys, none of these work, any idea? function UnmuteSpam (target, thePlayer, command) target = tostring(target) if isTimer (antiSpam[target]) then killTimer (antiSpam[target]) outputChatBox("This player is now unmuted") else outputChatBox("This player wasn't muted") end end addCommandHandler("um", UnmuteSpam) function timerDetails() if isTimer(antiSpam[source]) then remaining, executesRemaining, totalExecutes = getTimerDetails( antiSpam[source] ) outputChatBox("Time remaining until chat free: ( remaining ), wait please.") else outputChatBox("You are free to speak") end end addCommandHandler("sleft", timerDetails) Link to comment
.:HyPeX:. Posted September 7, 2013 Author Share Posted September 7, 2013 Guys, i've tried lots of ways, and on these 2 im just getting the else outputted, and nothing happens. Link to comment
manawydan Posted September 7, 2013 Share Posted September 7, 2013 i think addCommandHandler no had source, use thePlayer Link to comment
.:HyPeX:. Posted September 7, 2013 Author Share Posted September 7, 2013 i think addCommandHandler no had source, use thePlayer the first one uses target, what should i use there? Link to comment
manawydan Posted September 7, 2013 Share Posted September 7, 2013 try local antiSpam = {} function UnmuteSpam (thePlayer, _,target) target = tostring(target) if isTimer (antiSpam[target]) then killTimer (antiSpam[target]) outputChatBox("This player is now unmuted") else outputChatBox("This player wasn't muted") end end addCommandHandler("um", UnmuteSpam) function timerDetails(source) if isTimer(antiSpam[source]) then remaining, executesRemaining, totalExecutes = getTimerDetails( antiSpam[source] ) outputChatBox("Time remaining until chat free: ( remaining ), wait please.") else outputChatBox("You are free to speak") end end addCommandHandler("sleft", timerDetails) Link to comment
.:HyPeX:. Posted September 7, 2013 Author Share Posted September 7, 2013 try local antiSpam = {} function UnmuteSpam (thePlayer, _,target) target = tostring(target) if isTimer (antiSpam[target]) then killTimer (antiSpam[target]) outputChatBox("This player is now unmuted") else outputChatBox("This player wasn't muted") end end addCommandHandler("um", UnmuteSpam) function timerDetails(source) if isTimer(antiSpam[source]) then remaining, executesRemaining, totalExecutes = getTimerDetails( antiSpam[source] ) outputChatBox("Time remaining until chat free: ( remaining ), wait please.") else outputChatBox("You are free to speak") end end addCommandHandler("sleft", timerDetails) worked in behalf, the target didnt worked, outputs the else message, and the sleft tells me the time (fixed it actually it was "..remaining), but it also tells "you are free to speak" and when you're not muted it does nothing. EDIT//: my script didnt had the "else" on the you are free to speak part, only the unmute doesnt work. 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