· 6 years ago · Mar 12, 2020, 12:32 AM
1tfm.exec.disableAutoShaman(boolean)
2
3
4local killer = "Brandondito#0000"
5local killerData = {}
6
7local EVERYONE = false -- Set "EVERYONE = true" if you want everyone to be able to kill
8local SPACE_KEY = 32
9local MINIMUM_KILL_RANGE = 50
10local KILL_ATTEMPT_COOLDOWN = 10000 -- 10s * 1000ms
11
12-- Checking if a certain coordinate is within the range of another coordinate
13function withinRange(x1, y1, x2, y2, range)
14 local xDist = math.abs(x1 - x2)
15 local yDist = math.abs(y1 - y2)
16
17 if xDist < range and yDist < range then
18 return true
19 end
20
21 return false
22end
23
24-- If a player joins, bind their spacebar keyboard-key based on the configured settings.
25function eventNewPlayer(name)
26
27 if EVERYONE or killer == name then
28 -- Storing last kill attempt's timestamp to implement cooldown
29 killerData[name] = 0
30
31 tfm.exec.bindKeyboard(name, SPACE_KEY, true, true)
32 end
33end
34
35-- Function provided by TFM's API. Occurs whenever someone presses a binded key.
36function eventKeyboard(name, key, down, x, y)
37
38 local now = os.time()
39
40 if key == SPACE_KEY and killerData[name] < now then
41 killerData[name] = now + KILL_ATTEMPT_COOLDOWN
42
43 for _name, player in next, tfm.get.room.playerList do
44 if _name ~= name and withinRange(x, y, player.x, player.y, MINIMUM_KILL_RANGE) then
45 tfm.exec.killPlayer(_name)
46 tfm.exec.setNameColor(killer, 2664641556)
47 end
48 end
49 end
50end
51
52-- For every player in the room, run eventNewPlayer on them.
53-- tfm.get.room.playerList gives us a list of players in the room.
54for name in next, tfm.get.room.playerList do
55 eventNewPlayer(name)
56end
57tfm.exec.newGame(7681727)
58
59monedas=10
60
61ui.addTextArea(0,"<br><a href='event:cosa1'>cerar puertas",killer,0,450,50,nil)
62
63 function eventTextAreaCallback(id,name,cb)
64 if cb=='cosa1' then
65 monedas=monedas-1
66 bloque = {type = 1, width = 22, height = 650,fricction=0}
67 tfm.exec.addPhysicObject(15,430,480,bloque)
68 bloque = {type = 1, width = 22, height = 650, friction = 0}
69 tfm.exec.addPhysicObject(14,535,480,bloque)
70 if monedas==0 then
71print("Okay!")
72ui.removeTextArea(0)
73
74 end
75end
76end