View difference between Paste ID: 6xXvfatM and KWSvPRxf
SHOW: | | - or go back to the newest paste.
1-
-- By Nicolasledu
1+
-- By Nicolasledu
2-
-- Initialisation des variables
2+
-- Initialisation des variables
3-
isAfk = {}
3+
isAfk = {}
4-
afkTime = {}
4+
afkTime = {}
5-
afkRaison = {}
5+
afkRaison = {}
6-
id = {}
6+
id = {}
7-
idnumber = 50000
7+
idnumber = 50000
8-
for joueur,player in pairs(tfm.get.room.playerList) do
8+
for joueur,player in pairs(tfm.get.room.playerList) do
9-
	isAfk[joueur] = false
9+
	isAfk[joueur] = false
10-
	idnumber = idnumber + 1
10+
	idnumber = idnumber + 1
11-
	id[joueur] = idnumber
11+
	id[joueur] = idnumber
12-
	afkRaison[joueur] = ""
12+
	afkRaison[joueur] = ""
13-
	for i = 0, 200 do
13+
	for i = 0, 200 do
14-
		tfm.exec.bindKeyboard(joueur, i, true, true) -- Active les touches.
14+
		tfm.exec.bindKeyboard(joueur, i, true, true) -- Active les touches.
15-
    end
15+
    end
16-
	afkTime[joueur] = 0
16+
	afkTime[joueur] = 0
17
end
18-
function eventNewPlayer(joueur)
18+
function eventNewPlayer(joueur)
19-
	isAfk[joueur] = false
19+
	isAfk[joueur] = false
20-
	idnumber = idnumber + 1
20+
	idnumber = idnumber + 1
21-
	id[joueur] = idnumber
21+
	id[joueur] = idnumber
22-
	afkRaison[joueur] = ""
22+
	afkRaison[joueur] = ""
23-
	for i = 0, 200 do
23+
	for i = 0, 200 do
24-
		tfm.exec.bindKeyboard(joueur, i, true, true) -- Active les touches.
24+
		tfm.exec.bindKeyboard(joueur, i, true, true) -- Active les touches.
25-
    end
25+
    end
26
end
27-
function eventPlayerLeft(joueur)
27+
function eventPlayerLeft(joueur)
28-
	notafk(joueur)
28+
	notafk(joueur)
29
end
30-
-- Commande
30+
-- Commande
31-
function eventChatCommand(joueur,commande)
31+
function eventChatCommand(joueur,commande)
32-
	if commande:sub(0,3)=="afk" then
32+
	if commande:sub(0,3)=="afk" then
33-
		if isAfk[joueur] then
33+
		if isAfk[joueur] then
34-
			notafk(joueur)
34+
			notafk(joueur)
35-
		else
35+
		else
36-
			isAfk[joueur] = true
36+
			isAfk[joueur] = true
37-
			afkRaison[joueur] = commande:sub(5)
37+
			afkRaison[joueur] = commande:sub(5)
38-
			afk(joueur)
38+
			afk(joueur)
39-
		end
39+
		end
40-
	elseif commande == 'closeafk' then
40+
	elseif commande == 'closeafk' then
41-
		ui.removeTextArea(1, joueur)
41+
		ui.removeTextArea(1, joueur)
42-
	end
42+
	end
43
end
44-
-- Afk
44+
-- Afk
45-
function afk(joueur)
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)
46+
	ui.addTextArea(id[joueur],"<a href='event:"..joueur.." est afk pour la raison : "..afkRaison[joueur].."'>AFK</a>",all,tfm.get.room.playerList[joueur].x-13,tfm.get.room.playerList[joueur].y-40,28,18)
47-
	tfm.exec.setPlayerScore(joueur,-2000)
47+
	tfm.exec.setPlayerScore(joueur,-2000)
48
end
49-
function notafk(joueur)
49+
function notafk(joueur)
50-
	ui.removeTextArea(id[joueur], all)
50+
	ui.removeTextArea(id[joueur], all)
51-
	isAfk[joueur] = false
51+
	isAfk[joueur] = false
52-
	tfm.exec.setPlayerScore(joueur,0)
52+
	tfm.exec.setPlayerScore(joueur,0)
53-
	afkTime[joueur] = 0
53+
	afkTime[joueur] = 0
54
end
55-
-- Detection si plus afk
55+
-- Detection si plus afk
56-
function eventKeyboard(playerName, keyCode)
56+
function eventKeyboard(playerName, keyCode)
57-
	notafk(playerName)
57+
	notafk(playerName)
58
end
59-
-- Auto AFK
59+
-- Auto AFK
60-
function eventLoop(currentTime, timeRemaining)
60+
function eventLoop(currentTime, timeRemaining)
61-
	for joueur,player in pairs(tfm.get.room.playerList) do
61+
	for joueur,player in pairs(tfm.get.room.playerList) do
62-
		afkTime[joueur] = afkTime[joueur] + 0.5
62+
		afkTime[joueur] = afkTime[joueur] + 0.5
63-
			if isAfk[joueur] then
63+
			if isAfk[joueur] then
64-
			afkRaison[joueur] = 'Auto AFK'
64+
			afkRaison[joueur] = 'Auto AFK'
65-
			else
65+
			else
66-
			if afkTime[joueur] == 60 then afk(joueur) end
66+
			if afkTime[joueur] == 60 then afk(joueur) end
67-
			end
67+
			end
68-
	end
68+
	end
69
end
70-
function eventTextAreaCallback(id,playerName,event)
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)
71+
	ui.addTextArea(1, "<p align='center'><j>Pour fermer , tape !closeafk !<br>"..event.."</p>", playerName, 10, 30, 770,50)
72
end