Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local delay = 3000
- local dataPlayer={}
- function eventNewPlayer(name)
- tfm.exec.bindKeyboard(name,32,true,true)
- dataPlayer[name]={
- time=os.time(),
- }
- end
- for name,players in pairs(tfm.get.room.playerList) do
- eventNewPlayer(name)
- end
- function eventKeyboard(name,key,down,x,y)
- if key == 32 then
- if dataPlayer[name].time < os.time()-delay then
- tfm.exec.displayParticle(20,x,y)
- local p1X = x
- local p1Y = y
- for jogador,player in pairs(tfm.get.room.playerList) do
- local p2X = tfm.get.room.playerList[jogador].x
- local p2Y = tfm.get.room.playerList[jogador].y
- local distanceX=(p1X-p2X)-50
- if distanceX <= 0 then
- distanceX=-distanceX
- end
- local distanceY=(p1Y-p2Y)-50
- if distanceY <= 0 then
- distanceY=-distanceY
- end
- if p2X < p1X and p2X > p1X-100 and jogador ~= name then
- tfm.exec.movePlayer(jogador, 0, 0, false, -distanceX, 0, true)
- end
- if p2X > p1X and p2X < p1X+100 and jogador ~= name then
- tfm.exec.movePlayer(jogador, 0, 0, false, distanceX, 0, true)
- end
- if p2Y <= p1Y and p2Y >= p1Y-100 and jogador ~= name and p2X > p1X-100 and p2X < p1X+100 then
- tfm.exec.movePlayer(jogador, 0, 0, false, 0, -distanceY, true)
- end
- if p2Y > p1Y and p2Y <= p1Y+100 and jogador ~= name and p2X > p1X-100 and p2X < p1X+100 then
- tfm.exec.movePlayer(jogador, 0, 0, false, 0, distanceY, true)
- end
- end
- dataPlayer[name].time = os.time()
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement