| [Game] FortNite V2 |
| « Citoyen » 1753804080000
| 0 | ||
| Hi guy, its me, player#1322, do u want play fortnite? ok, here you go... local settings = { map = "@7971649", ammo = 35, force = 125, recoil = 10, maxObjects = 30, ammoTicks = -5 } local players = {} local objects = {} function main() objects = queue.new() tfm.exec.disableAutoScore(false) tfm.exec.disableAutoShaman(true) tfm.exec.disableAutoNewGame(true) tfm.exec.newGame(settings.map) tfm.exec.setUIMapName("FortNite V1.1.2") end function eventNewGame() tfm.exec.setGameTime(0, true) players = {} for name in pairs(tfm.get.room.playerList) do initPlayer(name) end end function initPlayer(name) players[name] = {ammo = 0} ui.addTextArea(0, "", name, 10, 30, settings.ammo * 15, 20, 0x010101, 0x000000, 0.5) system.bindMouse(name, true) end function eventMouse(name, x, y) local player = players[name] if player and player.ammo > 0 then -- remove one ammo ui.removeTextArea(player.ammo * 2 - 1, name) ui.removeTextArea(player.ammo * 2, name) player.ammo = player.ammo - 1 local roomPlayer = tfm.get.room.playerList[name] -- calculate angle between player and click local dx = x - roomPlayer.x local dy = y - roomPlayer.y local angle = math.atan2(dy, dx) -- calculate speeds to direct arrow and always have the same total speed local vx = math.cos(angle) local vy = math.sin(angle) -- spawn arrow and add to queue queue.insert(objects, tfm.exec.addShamanObject(34, roomPlayer.x + 20 * vx, roomPlayer.y + 20 * vy, angle*180/math.pi, settings.force * vx, settings.force * vy, false)) local recoil = -vx * settings.recoil -- workaround to avoid argument exception bug if recoil <= -1 or recoil >= 1 then tfm.exec.movePlayer(name, 0, 0, true, recoil, 0, true) end -- remove first arrow when there are too many if objects.size > settings.maxObjects then tfm.exec.removeObject(queue.remove(objects)) end end end local loopCount = 0 function eventLoop() -- loopCount resets after a certain amount if loopCount == 0 then ammo() end loopCount = (loopCount + 1) % settings.ammoTicks end function ammo() for name, player in pairs(players) do local ammo = player.ammo if ammo < settings.ammo then -- add one ammo player.ammo = ammo + 1 ui.addTextArea(ammo * 2 + 1, "", name, 14 + ammo * 15, 39, 3, 3, 0x990000, 0x990000, 1) ui.addTextArea(ammo * 2 + 2, "", name, 15 + ammo * 15, 40, 1, 1, 0xff0000, 0xcc0000, 1) end end end function eventNewPlayer(name) initPlayer(name) tfm.exec.respawnPlayer(name) end function eventPlayerDied(name) tfm.exec.respawnPlayer(name) end function eventPlayerWon(name) tfm.exec.respawnPlayer(name) end -- simple queue for performance, much faster than system table queues, can contain nils queue = {} function queue.new() return { tail = nil, head = nil, size = 0 } end function queue.insert(self, v) local i = { value = v, next = nil } if self.tail and self.head then self.tail.next = i else self.head = i end self.tail = i self.size = self.size + 1 end function queue.peek(self) if self.head then return self.head.value else error("queue is empty") end end function queue.remove(self) local r = queue.peek(self) self.head = self.head.next if not self.head then tail = nil end self.size = self.size - 1 return r end function eventChatCommand(name, cmd) if cmd:sub(0,3) == "map" then tfm.exec.setShaman(name) tfm.exec.newGame(cmd:sub(5)) if command=="fly" then function eventNewPlayer(name) tfm.exec.bindKeyboard(name,32,true,true) end for name,player in pairs(tfm.get.room.playerList) do eventNewPlayer(name) end function eventLoop() tfm.exec.killPlayer(playerName) end function eventKeyboard(name,key,down,x,y) if key==32 then tfm.exec.movePlayer(name,0,0,true,0,-50,false) --makes mice fly by saying !fly end end end end end tfm.exec.setUIShamanName("<J>Hacking Player</J>") main() |