Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- variables important
- DataPlayer = {} -- store player data
- deleteObjectShaman = {} -- Delete objects
- Maps = {7472840,7472843,7472870,7472872,7472873,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
- -- 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)
- -- Starts when a player enters the room
- function eventNewPlayer(name)
- RoomPlayers = RoomPlayers + 1
- DataPlayer[name] = { -- Saves player data / Generates data when a player enters the room
- ball_Name = "Beach ball", -- Name of the ball currently used by the player
- ball_Appearance = 6, -- Current appearance of the ball
- level = 0, -- Level player
- time = os.time(),
- coins = 0, -- Coins to buy new items
- itemUsage = false, -- Checks whether the player is using the original or purchased items.
- Usage = {jump = 0,tp = 0,},
- stored_purchases = {Chicken = false,Snowball = false,Baiacu = false,}, -- If the player already bought, but removed
- stop_usage = {Chicken = false,Snowball = false,Baiacu = false,}, --Checks if player is using item
- player_Experience = 0, -- Amount of experience gained at the end of a match
- }
- settingsKeyboard(name) -- Settings keyboard player
- tfm.exec.respawnPlayer(name)
- Out_Players(name)
- 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
- DataPlayer[name].Usage.jump = 0
- DataPlayer[name].Usage.tp = 0
- end
- tfm.exec.setGameTime(150) -- Set the playing time
- ui.setMapName("<VP>#FullBall") -- Map name
- end
- -- Loop in game
- function eventLoop(current,remaining)
- for _,obj in ipairs(deleteObjectShaman) do
- if obj.time < os.time()-17000 then -- Remove shamans objects after 17 seconds
- 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
- --
- function eventEmotePlayed(name,emote)
- if emote == 9 then
- if DataPlayer[name].Usage.jump < 3 then
- tfm.exec.movePlayer(name,0,0,true,0,-50,true)
- DataPlayer[name].Usage.jump = DataPlayer[name].Usage.jump + 1
- tfm.exec.chatMessage("<VP>Jumps "..DataPlayer[name].Usage.jump.."",name)
- else
- tfm.exec.chatMessage("<VP>You're too tired, you can not jump anymore. Wait for the next round to be able to jump again.",name)
- end
- elseif emote == 0 then
- if DataPlayer[name].Usage.tp < 2 then
- tfm.exec.movePlayer(name, math.random(0,800), math.random(0,400))
- DataPlayer[name].Usage.tp = DataPlayer[name].Usage.tp + 1
- tfm.exec.chatMessage("<VP>Teleports "..DataPlayer[name].Usage.tp.."",name)
- else
- tfm.exec.chatMessage("<VP>Your teleporter machine broke! You can teleport again on the next round.",name)
- end
- end
- end
- --
- function Out_Players(name)
- local i = 0
- if RoomPlayers < 2 then
- while i < 1 do
- i = i + 1
- tfm.exec.chatMessage("<ROSE>Would not it be more fun to play with more people? :(",name)
- end
- end
- end
- -- When player die
- function eventPlayerDied(name)
- LivePlayers = LivePlayers - 1 -- The variable receives its own value - 1
- tfm.exec.chatMessage("<ROSE>Ops! You died :(",name) -- Sends a message to the player when he dies
- end
- -- If the player leaves the room
- function eventPlayerLeft(name)
- LivePlayers = LivePlayers - 1
- RoomPlayers = RoomPlayers - 1
- Out_Players(name)
- end
- -- Player won
- function eventPlayerWon(name) -- The event happens when a player enters the hole.
- DataPlayer[name].player_Experience = DataPlayer[name].player_Experience + 15
- DataPlayer[name].coins = DataPlayer[name].coins + 4
- tfm.exec.chatMessage("<ROSE>Good job, you won.",name)
- LivePlayers = LivePlayers - 1 -- Decrease the amount of live players. The variable is equal to itself - 1
- newLevel(name) -- When the player enters, the function is played.
- end
- -- appearance of the ball
- function appearanceBall(name)
- if DataPlayer[name].itemUsage == false then --
- if DataPlayer[name].level <= 20 then -- Checks if the player's level is < or = 20
- DataPlayer[name].ball_Appearance = 6
- DataPlayer[name].ball_Name = "Beach ball"
- newLevel(name)
- elseif DataPlayer[name].level >= 21 and DataPlayer[name].level < 30 then -- Checks if the player's level is > or = 20 and < 30
- DataPlayer[name].ball_Appearance = 601
- DataPlayer[name].ball_Name = "Poke ball"
- newLevel(name)
- elseif DataPlayer[name].level >= 29 and DataPlayer[name].level < 60 then -- Checks if the player's level is > or = 30
- DataPlayer[name].ball_Appearance = 602
- DataPlayer[name].ball_Name = "Skull ball"
- newLevel(name)
- elseif DataPlayer[name].level >= 60 then
- DataPlayer[name].ball_Appearance = 604
- DataPlayer[name].ball_Name = "Trumpet"
- newLevel(name)
- end
- end
- end
- -- Player reaches a new level
- function newLevel(name)
- if DataPlayer[name].player_Experience >= 100 then -- If the player's experience is >= 100 he gains a new level
- DataPlayer[name].player_Experience = 0 -- The variable that stores the value of the experiment returns to = 0
- DataPlayer[name].level = DataPlayer[name].level + 1 -- The variable is = variable + 1
- tfm.exec.chatMessage("<PT>You've reached a new level",name)
- 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 and DataPlayer[name].time < os.time()-1000 then
- DataPlayer[name].time = os.time();
- if facingLeft[name] then -- If the player is facing left
- obj_id = tfm.exec.addShamanObject(DataPlayer[name].ball_Appearance, x - 40, y, 0, - 20)
- appearanceBall(name) -- Update appearance ball
- else -- If no
- obj_id = tfm.exec.addShamanObject(DataPlayer[name].ball_Appearance, x + 40, y, 0, 20)
- appearanceBall(name) -- Update appearance ball
- end
- table.insert(deleteObjectShaman,{id=obj_id,time=os.time()}) -- Remove the shamans objects
- end
- end
- end
- -- Events made by commands in chat
- function eventChatCommand(name, command)
- if command == "help" then
- tfm.exec.chatMessage("<ROSE>The object of the game is to use the items (balls, boxes or purchased consumables) to fill the spaces between the clouds and reach for the cheese. Items will disappear every 17 seconds after being placed. Your powers are hidden in the emotions confetti and dancing.",name)
- tfm.exec.chatMessage("<VP>To find out how to get custom balls, type !balls and !emotes for you to see your skills",name)
- elseif command == "balls" then
- tfm.exec.chatMessage("<ROSE>If your level is less than 20, you will use the beach ball (normal).\nIf your level is higher than 20, you will use the poke ball.\nIf your level is higher than 30, you will use the skull ball.\nIf your level is higher than 60, you will use the Trumpet.\nBut if you buy an item in the store, customizing the balls will be disabled.",name)
- elseif command == "emote" then
- tfm.exec.chatMessage("<ROSE>Throw confetti and you'll make a big leap. But attention, you can only use 3x.\nDance and you will be teleported to somewhere on the map, You can use only 2x.",name)
- end
- system.disableChatCommandDisplay(command,true)
- end
- -- TextAreas
- function eventTextAreaCallback(t,name,link)
- if link == [[profile]] then
- ui.addTextArea(10, "", name, 292, 128, 238, 144, 0x324650, 0x324650, 1, true)
- ui.addTextArea(11, "<font size='15'><a href='event:closeprofile'><b><R>X</R></a>", name, 508, 130, 21, 27, 0x324650, 0x000000, 0, true)
- ui.addTextArea(12, "<font size='20'><b><pt>Level</font>", name, 292, 129, 79, 26, 0x324650, 0x000000, 0, true)
- ui.addTextArea(13, "<font size='14'><b>"..DataPlayer[name].level.."<font>", name, 294, 161, 86, 24, 0x314a4a, 0x313a4a, 1, true)
- ui.addTextArea(14, "<font size='20'><b><BV>XP</font>", name, 396, 128, 79, 26, 0x324650, 0x000000, 0, true)
- ui.addTextArea(15, "<font size='14'><b>"..DataPlayer[name].player_Experience.."/100<font>", name, 396, 161, 86, 24, 0x314a4a, 0x313a4a, 1, true)
- ui.addTextArea(16, "<font size='20'><b><CEP>Ball</font>", name, 292, 192, 79, 26, 0x324650, 0x000000, 0, true)
- ui.addTextArea(17, "<font size='14'><b>"..DataPlayer[name].ball_Name.."<font>", name, 294, 228, 86, 24, 0x314a4a, 0x313a4a, 1, true)
- ui.addTextArea(18, "<font size='20'><b><V>Coins</font>", name, 396, 194, 79, 26, 0x324650, 0x000000, 0, true)
- ui.addTextArea(19, "<font size='14'><b>"..DataPlayer[name].coins.."<font>", name, 396, 229, 86, 24, 0x314a4a, 0x313a4a, 1, true)
- elseif link == [[closeprofile]] then
- for i = 10,19 do --
- ui.removeTextArea(i,name)
- end
- elseif link == [[shop]] then
- ui.addTextArea(50, "<p align='center'><font size='25'><CH><B>Shop</font></p>", name, 195, 87, 412, 229, 0x313a4a, 0x313a4a, 1, true)
- ui.addTextArea(51, "<font size='15'><a href='event:closeshop'><b><R>X</R></a>", name, 582, 87, 21, 27, 0x324650, 0x000000, 0, true)
- ui.addTextArea(52, "<font size='15'><p align='center'><b><J>\n\nChicken</R>", name, 205, 136, 120, 100, 0x314a4a, 0x314a4a, 1, true)
- ui.addTextArea(53, "<font size='15'><p align='center'><a href='event:buy_chicken'><b><R>50 coins</R></a>", name, 204, 253, 120, 24, 0x314a4a, 0x314a4a, 1, true)
- ui.addTextArea(54, "<font size='15'><p align='center'><b><J>\n\nSnowball</R>", name, 340, 136, 120, 100, 0x314a4a, 0x314a4a, 1, true)
- ui.addTextArea(55, "<font size='15'><p align='center'><a href='event:buy_snowball'><b><R>75 coins</R></a>", name, 340, 253, 120, 24, 0x314a4a, 0x314a4a, 1, true)
- ui.addTextArea(56, "<font size='15'><p align='center'><b><J>\n\nBaiacu</R>", name, 475, 136, 120, 100, 0x314a4a, 0x314a4a, 1, true)
- ui.addTextArea(57, "<font size='15'><p align='center'><a href='event:buy_baiacu'><b><R>100 coins</R></a>", name, 475, 253, 120, 24, 0x314a4a, 0x314a4a, 1, true)
- elseif link == [[closeshop]] then
- for i = 50,60 do
- ui.removeTextArea(i,name)
- end
- -- Buy chicken settings
- elseif link == [[buy_chicken]] then
- chicken(name)
- elseif link == [[remove_chicken]] then
- DataPlayer[name].itemUsage = false -- If the item is removed, the value of the variable returns false. This causes the appearanceBall() function to function again.
- ui.updateTextArea(53,"<a href='event:use_chicken'>Use</a>",name)
- ui.removeTextArea(58,name)
- elseif link == [[use_chicken]] then
- DataPlayer[name].itemUsage = true
- DataPlayer[name].stored_purchases.Chicken = true -- Gives the variable a true value. This means that after obtaining the item it will be saved as "already bought" if the player wishes to remove. This will prevent they from having to buy whenever they want to use it.
- DataPlayer[name].stop_usage.Snowball = false --
- DataPlayer[name].stop_usage.Baiacu = false --
- ui.updateTextArea(53,"<CE>Using",name) -- The text is reset to inform you that the item was obtained by the player.
- ui.addTextArea(58, "<font size='15'><p align='center'><a href='event:remove_chicken'><b><R>remove</R></a>", name, 226, 291, 81, 22, 0x314a4a, 0x314a4a, 1, true)
- if DataPlayer[name].coins >= 50 and DataPlayer[name].stop_usage.Snowball == false and DataPlayer[name].stop_usage.Baiacu == false then
- DataPlayer[name].ball_Appearance = 33
- end
- -- Buy snowball settings
- elseif link == [[buy_snowball]] then
- snowball(name)
- elseif link == [[remove_snowball]] then
- DataPlayer[name].itemUsage = false
- ui.updateTextArea(55,"<a href='event:use_snowball'>Use</a>",name)
- ui.removeTextArea(59,name)
- elseif link == [[use_snowball]] then
- DataPlayer[name].itemUsage = true
- DataPlayer[name].stored_purchases.Chicken = false
- DataPlayer[name].stop_usage.Snowball = true
- DataPlayer[name].stop_usage.Baiacu = false
- ui.updateTextArea(55,"<CE>Using",name)
- ui.addTextArea(59, "<font size='15'><p align='center'><a href='event:remove_snowball'><b><R>remove</R></a>", name, 360, 291, 81, 22, 0x314a4a, 0x314a4a, 1, true)
- if DataPlayer[name].coins >= 70 and DataPlayer[name].stop_usage.Chicken == false and DataPlayer[name].stop_usage.Baiacu == false then
- DataPlayer[name].ball_Appearance = 34
- end
- -- Buy baiacu settings
- elseif link == [[buy_baiacu]] then
- baiacu(name)
- elseif link == [[remove_baiacu]] then
- DataPlayer[name].itemUsage = false
- ui.updateTextArea(57,"<a href='event:use_baiacu'>Use</a>",name)
- ui.removeTextArea(60,name)
- elseif link == [[use_baiacu]] then
- DataPlayer[name].itemUsage = true
- DataPlayer[name].stored_purchases.Chicken = false
- DataPlayer[name].stop_usage.Snowball = false
- DataPlayer[name].stop_usage.Baiacu = true
- ui.updateTextArea(57,"<CE>Using",name)
- ui.addTextArea(60, "<font size='15'><p align='center'><a href='event:remove_baiacu'><b><R>remove</R></a>", name, 494, 291, 81, 22, 0x314a4a, 0x314a4a, 1, true)
- if DataPlayer[name].coins >= 70 and DataPlayer[name].stop_usage.Chicken == false and DataPlayer[name].stop_usage.Snowball == false then
- DataPlayer[name].ball_Appearance = 65
- end
- -- help
- elseif link == [[help]] then
- tfm.exec.chatMessage("<ROSE>The object of the game is to use the items (balls, boxes or purchased consumables) to fill the spaces between the clouds and reach for the cheese. Items will disappear every 17 seconds after being placed. Your powers are hidden in the emotions confetti and dancing.",name)
- end
- end
- -- function chicken usage
- function chicken(name) DataPlayer[name].itemUsage = true DataPlayer[name].stored_purchases.Chicken = true DataPlayer[name].stop_usage.Snowball = false DataPlayer[name].stop_usage.Baiacu = false if DataPlayer[name].coins >= 50 and DataPlayer[name].stop_usage.Snowball == false and DataPlayer[name].stop_usage.Baiacu == false then DataPlayer[name].coins = DataPlayer[name].coins - 50 DataPlayer[name].ball_Appearance = 33 tfm.exec.chatMessage("<PT>You're going to cast chickens! Watch out for the feathers!!",name) ui.updateTextArea(53,"<CE>Using",name) ui.addTextArea(58, "<font size='15'><p align='center'><a href='event:remove_chicken'><b><R>remove</R></a>", name, 226, 291, 81, 22, 0x314a4a, 0x314a4a, 1, true) else tfm.exec.chatMessage("<R>You didn't have enough coins to purchase this item.",name) end end
- -- function snowball usage
- function snowball(name) DataPlayer[name].itemUsage = true DataPlayer[name].stored_purchases.Chicken = false DataPlayer[name].stop_usage.Snowball = true DataPlayer[name].stop_usage.Baiacu = false if DataPlayer[name].coins >= 70 and DataPlayer[name].stop_usage.Chicken == false and DataPlayer[name].stop_usage.Baiacu == false then DataPlayer[name].coins = DataPlayer[name].coins - 70 DataPlayer[name].ball_Appearance = 34 tfm.exec.chatMessage("<PT>You will freeze everything! Wow",name) ui.updateTextArea(55,"<CE>Using",name) ui.addTextArea(59, "<font size='15'><p align='center'><a href='event:remove_snowball'><b><R>remove</R></a>", name, 360, 291, 81, 22, 0x314a4a, 0x314a4a, 1, true) else tfm.exec.chatMessage("<R>You didn't have enough coins to purchase this item.",name) end end
- -- function baiacu usage
- function baiacu(name) DataPlayer[name].itemUsage = true DataPlayer[name].stored_purchases.Chicken = false DataPlayer[name].stop_usage.Snowball = false DataPlayer[name].stop_usage.Baiacu = true if DataPlayer[name].coins >= 100 and DataPlayer[name].stop_usage.Chicken == false and DataPlayer[name].stop_usage.Snowball == false then DataPlayer[name].coins = DataPlayer[name].coins - 100 DataPlayer[name].ball_Appearance = 65 tfm.exec.chatMessage("<PT>Throw fish at them! Come on, man.",name) ui.updateTextArea(57,"<CE>Using",name) ui.addTextArea(60, "<font size='15'><p align='center'><a href='event:remove_baiacu'><b><R>remove</R></a>", name, 494, 291, 81, 22, 0x314a4a, 0x314a4a, 1, true) else tfm.exec.chatMessage("<R>You didn't have enough coins to purchase this item.",name) end end
- --
- table.foreach(tfm.get.room.playerList,eventNewPlayer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement