Poke Auto Responder Help

jeudi 17 septembre 2015

I found a LUA script on GitHub, and I can't get it to work. Here's a link, and the script itself:

Code:

count = {} --To keep track of poke count.
haspoked = {} --To index individual users.
poketime = {} --To save poke times.
maxpokes = 3 --Max number of pokes.
maxtime = 180 --Interval in seconds in which the pokes will be accounted for.
doreply = "y"
recmsg = "Received your poke! Please don't poke me again, I'll respond whenever I can." --Message to be sent on poke receival.
kickmsg = "Don't abuse pokes!" --Message to be sent with kick.
function onClientPokeEvent(serverConnectionHandlerID, pokerID, pokerName, message, ffIgnored)
        maxpokes-=1
        if (pokerID ~= haspoked[pokerID]) then --Checks if there's a "record" of the poker
                        haspoked[pokerID] = pokerID --Creates a record
                        count[pokerID] = 1 --Sets his poke count to one
                        poketime[pokerID] = os.time() --Records the time of first poke
                        if (doreply == "y") then
                                ts3.requestSendPrivateTextMsg(serverConnectionHandlerID, recmsg, pokerID) --Send message back.
                        end
        elseif(pokerID == haspoked[pokerID])then --If there is a record already
                  if (count[pokerID] >= maxpokes and os.difftime(poketime[pokerID],os.time()) <= maxtime) then --If the poker has poked over -maxpokes- times under maxtime interval.
                          ts3.requestClientKickFromServer(serverConnectionHandlerID,pokerID, kickmsg) --Kick poker with message.
                          poketime[pokerID] = os.time() --Reset timer.
                        else
                                if(os.difftime(poketime[pokerID],os.time()) > maxtime) then --If the interval between pokes is greater than maxtime.
                                        poketime[pokerID] = os.time --Reset timer.
                                end
                                if (doreply == "y")then
                                  ts3.requestSendPrivateTextMsg(serverConnectionHandlerID, recmsg, pokerID) --Sends message.
                                end
                                count[pokerID] = count[pokerID]+1 --Increments poke count for the user.
                  end
        end
end

The only things I changed were maxtime and recmsg. I've never done any coding before though, so I can't figure out if there's a flaw in the code or if I simply messed up somewhere (I checked that I did everything right a couple of times).

Thanks in advance if anyone is able to help me get this working. :)
Poke Auto Responder Help

0 commentaires:

Enregistrer un commentaire