Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- variables important
- DataPlayer = {} -- store player data
- deleteObjectShaman = {} -- Delete objects
- Maps = {7472843,7472873,7472870,7472895} -- Map list
- LivePlayers = 0 -- Store live players
- RoomPlayers = 0 -- Store players in room
- --Disable some automatic things.
- for _, s in next, {'AutoTimeLeft', 'PhysicalConsumables', 'AfkDeath', 'AutoShaman', 'AutoNewGame'} do
- tfm.exec['disable' .. s]()
- end
- -- Starts when a player enters the room
- -- Help, Profile and shop
- ui.addTextArea(201, "<p align='center'><a href='event:profile'><B><R>P</B></a></p>", name, 680, 375, 29, 19, 0x313a4a, 0x313a4a, 1, true)
- ui.addTextArea(202, "<p align='center'><a href='event:shop'><B><T>S</B></a></p>", name, 722, 375, 29, 19, 0x313a4a, 0x313a4a, 1, true)
- ui.addTextArea(203, "<p align='center'><a href='event:help'><B><J>H</B></a></p>", name, 764, 375, 29, 19, 0x313a4a, 0x313a4a, 1, true)
- function eventNewPlayer(name)
- RoomPlayers = RoomPlayers + 1
- DataPlayer[name] = { -- Saves player data / Generates data when a player enters the room
- ball_Name = "", -- Name of the ball currently used by the player
- ball_Appearance = 6, -- Current appearance of the ball
- level = 0, -- Level player
- player_Experience = 0, -- Amount of experience gained at the end of a match
- }
- settingsKeyboard(name) -- Settings keyboard player
- end
- -- Loop in game
- function eventLoop(current,remaining)
- for _,obj in ipairs(deleteObjectShaman) do
- if obj.time < os.time()-15000 then
- tfm.exec.removeObject(obj.id)
- table.remove(deleteObjectShaman,_)
- end
- end
- if LivePlayers == 0 or remaining <= 0 then -- If the number of live players = 0 or time = 0
- tfm.exec.newGame(Maps[math.random(#Maps)]) -- Execute a new game
- end
- end
- -- When player die
- function eventPlayerDied(name)
- LivePlayers = LivePlayers - 1 -- The variable receives its own value - 1
- tfm.exec.chatMessage("Ops! You died :(",name) -- Sends a message to the player when he dies
- end
- -- Player won
- function eventPlayerWon(name) -- The event happens when a player enters the hole.
- DataPlayer[name].player_Experience = DataPlayer[name].player_Experience + 15
- tfm.exec.chatMessage("Good job, you won.",name)
- LivePlayers = LivePlayers - 1
- end
- -- Starts event new game
- function eventNewGame()
- LivePlayers = 0 -- The variable returns to 0
- for name in pairs(tfm.get.room.playerList) do -- All players
- LivePlayers = LivePlayers + 1 -- Adds one more to the variable
- end
- tfm.exec.setGameTime(150) -- Set the playing time
- ui.setMapName("<VP>#FullBall")
- end
- -- appearance of the ball
- function appearanceBall(name)
- if DataPlayer[name].level <= 20 then
- DataPlayer[name].ball_Appearance = 6
- DataPlayer[name].ball_Name = "Beach ball"
- elseif DataPlayer[name].level >= 21 and DataPlayer[name].level < 30 then
- DataPlayer[name].ball_Appearance = 601
- DataPlayer[name].ball_Name = "Poke ball"
- elseif DataPlayer[name].level >= 29 then
- DataPlayer[name].ball_Appearance = 602
- DataPlayer[name].ball_Name = "Skull ball"
- end
- end
- -- Keyboard settings
- function settingsKeyboard(name)
- if k == 32 and tfm.get.room.playerList[name].isFacingRight == true and info[name].time < os.time()-1500 then
- info[name].time = os.time()
- tfm.exec.movePlayer(name,0,0,true,100,0,false)
- elseif k == 32 and tfm.get.room.playerList[name].isFacingRight == false and info[name].time < os.time()-1500 then
- info[name].time = os.time()
- tfm.exec.movePlayer(name,0,0,true,-100,0,false)
- end
- local facingLeft = {} -- Create a table facing left
- for name in pairs(tfm.get.room.playerList) do
- for _,key in pairs{0,2,3} do system.bindKeyboard(name, key, true)
- end
- end
- function eventKeyboard(name, key, down, x, y)
- if key == 0 or key == 2 then
- facingLeft[name] = key == 0
- elseif key == 3 then
- if facingLeft[name] then -- If the player is facing left
- obj_id = tfm.exec.addShamanObject(DataPlayer[name].ball_Appearance, x - 8, y - 5, 0, 20)
- appearanceBall(name) -- Update appearance ball
- else -- If no
- obj_id = tfm.exec.addShamanObject(DataPlayer[name].ball_Appearance, x + 8, y - 5, 0, 20)
- appearanceBall(name) -- Update appearance ball
- end
- table.insert(deleteObjectShaman,{id=obj_id,time=os.time()}) -- Remove the shamans objects
- end
- end
- end
- -- TextAreas
- function eventTextAreaCallback(t,name,link)
- if link == [[profile]] then
- ui.addTextArea(10, "", name, 266, 116, 267, 143, 0x313a4a, 0x314a4a, 1, true)
- ui.addTextArea(11, "<font size='20'><b><BV>XP</font>", name, 266, 117, 79, 26, 0x324650, 0x000000, 0, true)
- ui.addTextArea(12, "<font size='14'><b>"..DataPlayer[name].player_Experience.."/100<font>", name, 268, 148, 86, 24, 0x314a4a, 0x313a4a, 1, true)
- ui.addTextArea(13, "<font size='20'><b><pt>Level</font>", name, 364, 117, 79, 26, 0x324650, 0x000000, 0, true)
- ui.addTextArea(14, "<font size='14'><b>"..DataPlayer[name].level.."<font>", name, 367, 148, 86, 24, 0x314a4a, 0x313a4a, 1, true)
- ui.addTextArea(15, "<font size='20'><b><CEP>Ball</font>", name, 269, 185, 79, 26, 0x324650, 0x000000, 0, true)
- ui.addTextArea(16, "<font size='14'><b>"..DataPlayer[name].ball_Name.."<font>", name, 268, 216, 86, 24, 0x314a4a, 0x313a4a, 1, true)
- ui.addTextArea(17, "<font size='15'><a href='event:closeprofile'><b><R>X</R></a>", name, 512, 117, 21, 27, 0x324650, 0x000000, 0, true)
- elseif link == [[closeprofile]] then
- for i = 10,17 do --
- ui.removeTextArea(i,name)
- end
- elseif link == [[shop]] then
- ui.addTextArea(50, "<font size='20'></font>", name, 244, 113, 311, 173, 0x313a4a, 0x313a4a, 1, true)
- ui.addTextArea(51, "<font size='15'><a href='event:closeshop'><b><R>X</R></a>", name, 532, 115, 21, 27, 0x324650, 0x000000, 0, true)
- elseif link == [[closeshop]] then
- for i = 50,51 do --
- ui.removeTextArea(i,name)
- end
- elseif link == [[help]] then
- tfm.exec.chatMessage("<ROSE>Fill the room with as many balls as you can.\n• Level 0-20 Beach Ball\n• Level 21-30 Pokeball\n• Level +30 Skull Ball",name)
- end
- end
- table.foreach(tfm.get.room.playerList,eventNewPlayer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement