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