Guest User

AFK Version 1.0

a guest
Jan 16th, 2014
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.89 KB | None | 0 0
  1. -- By Nicolasledu
  2. -- Initialisation des variables
  3. isAfk = {}
  4. afkTime = {}
  5. afkRaison = {}
  6. id = {}
  7. idnumber = 50000
  8. for joueur,player in pairs(tfm.get.room.playerList) do
  9.     isAfk[joueur] = false
  10.     idnumber = idnumber + 1
  11.     id[joueur] = idnumber
  12.     afkRaison[joueur] = ""
  13.     for i = 0, 200 do
  14.         tfm.exec.bindKeyboard(joueur, i, true, true) -- Active les touches.
  15.     end
  16.     afkTime[joueur] = 0
  17. end
  18. function eventNewPlayer(joueur)
  19.     isAfk[joueur] = false
  20.     idnumber = idnumber + 1
  21.     id[joueur] = idnumber
  22.     afkRaison[joueur] = ""
  23.     for i = 0, 200 do
  24.         tfm.exec.bindKeyboard(joueur, i, true, true) -- Active les touches.
  25.     end
  26. end
  27. function eventPlayerLeft(joueur)
  28.     notafk(joueur)
  29. end
  30. -- Commande
  31. function eventChatCommand(joueur,commande)
  32.     if commande:sub(0,3)=="afk" then
  33.         if isAfk[joueur] then
  34.             notafk(joueur)
  35.         else
  36.             isAfk[joueur] = true
  37.             afkRaison[joueur] = commande:sub(5)
  38.             afk(joueur)
  39.         end
  40.     elseif commande == 'closeafk' then
  41.         ui.removeTextArea(1, joueur)
  42.     end
  43. end
  44. -- Afk
  45. function afk(joueur)
  46.     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)
  47.     tfm.exec.setPlayerScore(joueur,-2000)
  48. end
  49. function notafk(joueur)
  50.     ui.removeTextArea(id[joueur], all)
  51.     isAfk[joueur] = false
  52.     tfm.exec.setPlayerScore(joueur,0)
  53.     afkTime[joueur] = 0
  54. end
  55. -- Detection si plus afk
  56. function eventKeyboard(playerName, keyCode)
  57.     notafk(playerName)
  58. end
  59. -- Auto AFK
  60. function eventLoop(currentTime, timeRemaining)
  61.     for joueur,player in pairs(tfm.get.room.playerList) do
  62.         afkTime[joueur] = afkTime[joueur] + 0.5
  63.             if isAfk[joueur] then
  64.             afkRaison[joueur] = 'Auto AFK'
  65.             else
  66.             if afkTime[joueur] == 60 then afk(joueur) end
  67.             end
  68.     end
  69. end
  70. function eventTextAreaCallback(id,playerName,event)
  71.     ui.addTextArea(1, "<p align='center'><j>Pour fermer , tape !closeafk !<br>"..event.."</p>", playerName, 10, 30, 770,50)
  72. end
Advertisement
Add Comment
Please, Sign In to add comment