Advertisement
Guest User

Challenge 1

a guest
Apr 28th, 2014
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.54 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.setUIShamanName(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.         else
  18.             if tfm.get.room.playerList[args[2]] and playerName == SPEED_CHANGER then
  19.                 PLAYERS[args[2]].LEFT_SPEED, PLAYERS[playerName].RIGHT_SPEED = args[3], args[4]
  20.             end
  21.         end
  22.     end
  23. end
  24. function eventKeyboard(playerName, keyId)
  25.     if keyId == 68 or keyId == 69 then tfm.exec.movePlayer(playerName, 0, 0, true, PLAYERS[playerName].LEFT_SPEED, 0, false)
  26.     elseif keyId == 81 or keyId == 37 then tfm.exec.movePlayer(playerName, 0, 0, true, PLAYERS[playerName].RIGHT_SPEED, 0, false)
  27.     end
  28. end
  29. function eventNewPlayer(playerName)
  30.     PLAYERS[playerName] = { LEFT_SPEED = 30, RIGHT_SPEED = -30 }
  31.     for i = 1, 100 do tfm.exec.bindKeyboard(playerName, i, false, true) end
  32. end
  33. function eventNewGame() changeSpeedChanger() end
  34. for key, value in pairs(tfm.get.room.playerList) do eventNewPlayer(key) end
  35. changeSpeedChanger()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement