Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- By Nicolasledu
- -- Initialisation des variables
- isAfk = {}
- afkTime = {}
- afkRaison = {}
- id = {}
- idnumber = 50000
- for joueur,player in pairs(tfm.get.room.playerList) do
- isAfk[joueur] = false
- idnumber = idnumber + 1
- id[joueur] = idnumber
- afkRaison[joueur] = ""
- for i = 0, 200 do
- tfm.exec.bindKeyboard(joueur, i, true, true) -- Active les touches.
- end
- afkTime[joueur] = 0
- end
- function eventNewPlayer(joueur)
- isAfk[joueur] = false
- idnumber = idnumber + 1
- id[joueur] = idnumber
- afkRaison[joueur] = ""
- for i = 0, 200 do
- tfm.exec.bindKeyboard(joueur, i, true, true) -- Active les touches.
- end
- end
- function eventPlayerLeft(joueur)
- notafk(joueur)
- end
- -- Commande
- function eventChatCommand(joueur,commande)
- if commande:sub(0,3)=="afk" then
- if isAfk[joueur] then
- notafk(joueur)
- else
- isAfk[joueur] = true
- afkRaison[joueur] = commande:sub(5)
- afk(joueur)
- end
- elseif commande == 'closeafk' then
- ui.removeTextArea(1, joueur)
- end
- end
- -- Afk
- function afk(joueur)
- ui.addTextArea(id[joueur],"<a href='event:"..joueur.." est afk pour la raison : "..afkRaison[joueur].."'>AFK",all,tfm.get.room.playerList[joueur].x-13,tfm.get.room.playerList[joueur].y-40,28,18)
- tfm.exec.setPlayerScore(joueur,-2000)
- end
- function notafk(joueur)
- ui.removeTextArea(id[joueur], all)
- isAfk[joueur] = false
- tfm.exec.setPlayerScore(joueur,0)
- afkTime[joueur] = 0
- end
- -- Detection si plus afk
- function eventKeyboard(playerName, keyCode)
- notafk(playerName)
- end
- -- Auto AFK
- function eventLoop(currentTime, timeRemaining)
- for joueur,player in pairs(tfm.get.room.playerList) do
- afkTime[joueur] = afkTime[joueur] + 0.5
- if isAfk[joueur] then
- afkRaison[joueur] = 'Auto AFK'
- else
- if afkTime[joueur] == 60 then afk(joueur) end
- end
- end
- end
- function eventTextAreaCallback(id,playerName,event)
- ui.addTextArea(1, "<p align='center'><j>Pour fermer , tape !closeafk !<br>"..event.."</p>", playerName, 10, 30, 770,50)
- end
Advertisement
Add Comment
Please, Sign In to add comment