Advertisement
Guest User

AFK Version 2.0

a guest
Jan 29th, 2014
851
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.39 KB | None | 0 0
  1. print('<j>Lancement de la fonction afk.')
  2. function afk(option1,option2,option3,option4)
  3. -- Préparation pour un joueur.
  4.     if option1 == 'set' then
  5.         isAfk[option2] = false
  6.         idnumber = idnumber + 1
  7.         id[option2] = idnumber
  8.         afkRaison[option2] = ""
  9.         afkTime[option2] = 0
  10.         for i = 0, 200 do
  11.             tfm.exec.bindKeyboard(option2, i, true, true) -- Active les touches.
  12.         end
  13. -- Lancement de la fonction afk.
  14.     elseif option1 == 'start' then
  15.         print('<j>Le fonction afk marche !')
  16.         isAfk = {}
  17.         afkTime = {}
  18.         afkRaison = {}
  19.         id = {}
  20.         idnumber = 50000
  21.         for joueur,player in pairs(tfm.get.room.playerList) do
  22.             afk('set',joueur)
  23.         end
  24. -- Le joueur est afk.
  25.     elseif option1 == 'afk' then
  26.         ui.addTextArea(id[option2],"<a href='event:|AFK|"..option2.." est afk pour la raison : "..afkRaison[option2].."'>AFK</a>",all,tfm.get.room.playerList[option2].x-13,tfm.get.room.playerList[option2].y-40,28,18)
  27.         tfm.exec.setPlayerScore(option2,-2000)
  28. -- Le joueur n'est plus afk.
  29.     elseif option1 == 'noafk' then
  30.         ui.removeTextArea(id[option2], all)
  31.         isAfk[option2] = false
  32.         tfm.exec.setPlayerScore(option2,0)
  33.         afkTime[option2] = 0
  34.     elseif option1 == 'afktime' then
  35.         for joueur,player in pairs(tfm.get.room.playerList) do
  36.             afkTime[joueur] = afkTime[joueur] + 0.5
  37.                 if isAfk[joueur] then
  38.                     afkRaison[joueur] = 'Auto AFK'
  39.                 else
  40.                     if afkTime[joueur] == 60 then afk('afk',joueur) end
  41.             end
  42.         end
  43. -- eventTextAreaCallback
  44.     elseif option1 == 'callback' then
  45.         if option3:sub(0,5) == "|AFK|" then
  46.             ui.addTextArea(10000, "<p align='center'><j><a href='event:closepopup'>Pour fermer , clique ici !</a><br>"..option3.."</p>", option2, 10, 30, 770,50)
  47.         elseif option3 == "closepopup" then
  48.             ui.removeTextArea(10000, option2)
  49.         end
  50. -- Quand le joueur tape la commande !afk.
  51.     elseif option1 == 'command' then
  52.         if isAfk[option2] then
  53.             afk('noafk',option2)
  54.         else
  55.             isAfk[option2] = true
  56.             afkRaison[option2] = option3
  57.             afk('afk',option2)
  58.         end
  59.     end
  60. end
  61.  
  62. function eventNewPlayer(playerName)
  63.     afk('set',playerName)
  64. end
  65. function eventPlayerLeft(playerName)
  66.     afk('noafk',playerName)
  67. end
  68. function eventKeyboard(playerName, keyCode)
  69.     afk('noafk',playerName)
  70. end
  71. function eventChatCommand(playerName,command)
  72.     if command:sub(0,3)=="afk" then afk('command',playerName,command) end
  73. end
  74. function eventTextAreaCallback(id,playerName,event)
  75.     afk('callback',playerName,event)
  76. end
  77. function eventLoop(currentTime, timeRemaining)
  78.     afk('afktime')
  79. end
  80. afk('start')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement