· 6 years ago · Mar 10, 2020, 10:02 PM
1local killer = "Brandondito#0000"
2
3--Establezca "EVERYONE = true" si desea que todos puedan matar
4
5local EVERYONE = false
6
7local SPACE_KEY = 32
8local MINIMUM_KILL_RANGE = 50
9
10-- Checking if a certain coordinate is within the range of another coordinate
11function withinRange(x1, y1, x2, y2, range)
12 local xDist = math.abs(x1 - x2)
13 local yDist = math.abs(y1 - y2)
14
15 if xDist < range and yDist < range then
16 return true
17 end
18
19 return false
20end
21
22-- If a player joins, bind their spacebar keyboard-key based on the configured settings.
23function eventNewPlayer(name)
24
25 if EVERYONE or killer == name then
26 tfm.exec.bindKeyboard(name, SPACE_KEY, true, true)
27 end
28end
29
30-- Function provided by TFM's API. Occurs whenever someone presses a binded key.
31function eventKeyboard(name, key, down, x, y)
32
33 if key == SPACE_KEY then
34 for _name, player in next, tfm.get.room.playerList do
35 if _name ~= name and withinRange(x, y, player.x, player.y, MINIMUM_KILL_RANGE) then
36 tfm.exec.killPlayer(_name)
37 tfm.exec.setNameColor(killer, 2664641556)
38 end
39 end
40 end
41end
42
43-- For every player in the room, run eventNewPlayer on them.
44-- tfm.get.room.playerList gives us a list of players in the room.
45for name in next, tfm.get.room.playerList do
46 eventNewPlayer(name)
47end