Advertisement
Guest User

Fixed

a guest
Apr 28th, 2014
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.75 KB | None | 0 0
  1. PLAYERS, LEFT_KEYS, RIGHT_KEYS = { }, { 68, 69  },  { 81, 37 }
  2. function changeSpeedChanger()
  3.     for key, value in pairs(tfm.get.room.playerList) do
  4.         PLAYERS[#PLAYERS + 1] = key
  5.     end
  6.     SPEED_CHANGER = PLAYERS[math.random(1, table.getn(PLAYERS))]
  7.     tfm.exec.setUIMapName("<N>Speed changer :<V> "..SPEED_CHANGER)
  8. end
  9. function eventChatCommand(playerName, command)
  10.     local args = { }
  11.     for split in string.gmatch(command, "[^%s]+") do
  12.         table.insert(args, split)
  13.     end
  14.     if args[1] == "speed" and args[2] and args[3] then
  15.         if playerName ~= SPEED_CHANGER and (tonumber(args[2]) <= 50 and tonumber(args[2]) >= -50) and (tonumber(args[3]) <= 50 and tonumber(args[3]) >= -50) then
  16.             PLAYERS[playerName].LEFT_SPEED, PLAYERS[playerName].RIGHT_SPEED = args[2], args[3]
  17.             print("Set"..name.." speed to "..args[3].." and "..args[4])
  18.         else
  19.             if tfm.get.room.playerList[args[2]] and playerName == SPEED_CHANGER and tonumber(args[3]) and tonumber(args[4]) then
  20.                 PLAYERS[args[2]].LEFT_SPEED, PLAYERS[playerName].RIGHT_SPEED = args[3], args[4]
  21.                 print("Set"..args[2].." speed to "..args[3].." and "..args[4])
  22.             end
  23.         end
  24.     end
  25. end
  26. function eventKeyboard(playerName, keyId, down)
  27.     if keyId == 68 or keyId == 69 and down then tfm.exec.movePlayer(playerName, 0, 0, true, PLAYERS[playerName].LEFT_SPEED, 0, true)
  28.     elseif keyId == 81 or keyId == 37 and down then tfm.exec.movePlayer(playerName, 0, 0, true, PLAYERS[playerName].RIGHT_SPEED, 0, true)
  29.     end
  30. end
  31. function eventNewPlayer(playerName)
  32.     PLAYERS[playerName] = { LEFT_SPEED = 45, RIGHT_SPEED = -45 }
  33.     for i = 1, 100 do tfm.exec.bindKeyboard(playerName, i, true, true) end
  34. end
  35. function eventNewGame() changeSpeedChanger() end
  36. for key, value in pairs(tfm.get.room.playerList) do eventNewPlayer(key) end
  37. changeSpeedChanger()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement