boxxer321 67 Postado Abril 12, 2017 Share Postado Abril 12, 2017 Fala galera, eu tenho um script aqui porém, ele está em TFS 1.2, alguém converter ele para 0.3.6? O script é esse: globalevents/globalevents.xml <globalevent type="startup" name="hunger" script="hunger.lua"/> globalevents/scripts/hunger.lua Spoiler currentgameid = 201 killstreak = 60013 depotbox= {x=700,y=760,z=5} --location of a depot box, recommended to be accessible by players incase of bugs or crashes game = {{name="Hunger Games Arena 1", cheststartid=60100, minplayers=8, maxplayers=16, chests=299, startpos={ {x = 814, y = 760, z = 7}, {x = 809, y = 758, z = 7}, {x = 807, y = 753, z = 7}, {x = 809, y = 748, z = 7}, {x = 814, y = 746, z = 7}, {x = 819, y = 748, z = 7}, {x = 821, y = 753, z = 7}, {x = 819, y = 758, z = 7}, {x = 811, y = 759, z = 7}, {x = 808, y = 756, z = 7}, {x = 808, y = 750, z = 7}, {x = 811, y = 747, z = 7}, {x = 817, y = 747, z = 7}, {x = 820, y = 750, z = 7}, {x = 820, y = 756, z = 7}, {x = 817, y = 759, z = 7} } }, { name="Hunger Games Arena 2", cheststartid=61100, minplayers=2, maxplayers=4, chests=299, startpos={ {x = 1036, y = 910, z = 6}, {x = 1032, y = 906, z = 6}, {x = 1036, y = 902, z = 6}, {x = 1040, y = 906, z = 6} } }, { name="Hunger Games Arena 3", cheststartid=62100, minplayers=4, maxplayers=8, chests=299, startpos={ {x = 1047, y = 1158, z = 7}, {x = 1048, y = 1158, z = 7}, {x = 1052, y = 1158, z = 7}, {x = 1053, y = 1158, z = 7}, {x = 1047, y = 1167, z = 7}, {x = 1048, y = 1167, z = 7}, {x = 1052, y = 1167, z = 7}, {x = 1053, y = 1167, z = 7} } } } availablearenas = {1,2,3} -- script starts with all arenas as "available" gameplayers = {} prize = {{2160,1},{5097,10},{2128,1}} function Player:removeAllItems() -- function to clear the player's inventory local depotpos = Tile(Position(depotbox.x, depotbox.y, depotbox.z)):getItemByType(ITEM_TYPE_DEPOT) local depotid = getDepotId(depotpos:getUniqueId()) local depot = self:getDepotChest(depotid,true) local box = depot:addItem(1988) box:setAttribute(ITEM_ATTRIBUTE_NAME,"player gear box") for i=1,10 do local item = self:getSlotItem(i) if item then item:moveTo(box) end end end function Player:getBackItems() -- function to clear the player's inventory local depotpos = Tile(Position(depotbox.x, depotbox.y, depotbox.z)):getItemByType(ITEM_TYPE_DEPOT) local depotid = getDepotId(depotpos:getUniqueId()) local depot = self:getDepotChest(depotid,true) local box = depot:getItem(0) for i= box:getSize()-1, 0, -1 do local item = box:getItem(i) if item then item:clone():moveTo(self) end end box:remove() end local function teleportThing(seconds) if seconds <= 0 and #queue >= 1 then local looparenas = availablearenas -- preventing possible conflicts with looping for a,b in pairs(looparenas) do if #queue >= game[looparenas[a]].minplayers then local p = 1 while p < game[looparenas[a]].maxplayers do for i, pname in pairs(queue) do local player = Player(pname) if player then player:setStorageValue(currentgameid, looparenas[a]) local pos = Position(game[looparenas[a]].startpos[p].x, game[looparenas[a]].startpos[p].y, game[looparenas[a]].startpos[p].z) player:teleportTo(pos) player:removeAllItems() player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Welcome to The Hunger Games, Your objective is to loot, kill and be the last man standing, Good luck!") if gameplayers[looparenas[a]] == nil then gameplayers[looparenas[a]] = {} end table.insert(gameplayers[looparenas[a]], player:getName()) table.remove(queue,i) end end p = p+1 end for i = game[looparenas[a]].cheststartid, game[looparenas[a]].cheststartid+game[looparenas[a]].chests do Game.setStorageValue(i, -1) end Game.broadcastMessage(MESSAGE_EVENT_ADVANCE,"Hunger Games started in " ..game[looparenas[a]].name.."!") for k,v in pairs(availablearenas) do if v == r then table.remove(availablearenas,i) end end else for _, player in pairs(queue) do Player(player):sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, There is not enough players to start "..game[availablearenas[a]].name) end end end return teleportThing(3600) end if seconds == 60 then for _, player in pairs(queue) do Player(player):sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "The Hunger Games will begin in " .. seconds/60 .. " minute, Get Ready!") end elseif seconds % 60 == 0 and seconds ~= 60 and seconds ~= 300 and seconds < 300 then for _, player in pairs(queue) do Player(player):sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "The Hunger Games will begin in " .. seconds/60 .. " minutes!") end elseif seconds == 300 then Game.broadcastMessage(MESSAGE_EVENT_ADVANCE,"The Hunger Games will begin in " .. seconds/60 .. " minutes! To join say /join hunger games") end if seconds ~= 0 then addEvent(teleportThing, 60000, seconds - 60) end return true end function onStartup() teleportThing(600) return true end creaturescripts/creaturescripts.xml Spoiler <event type="logout" name="eventlogout" script="eventlogout.lua"/> <event type="death" name="hunger" script="hunger.lua"/> creaturescripts/scripts/login.lua add this before "return true" player:registerEvent("hunger") creaturescripts/scripts/eventlogout.lua Spoiler function onLogout(player) local gameid = player:getStorageValue(currentgameid) if(gameid > 0 ) then player:getBackItems() player:setStorageValue(currentgameid, -1) if gameplayers[gameid] then for i=1,#gameplayers[gameid] do Player(gameplayers[gameid]):sendTextMessage(MESSAGE_STATUS_CONSOLE_RED, player:getName() .. " has left the hunger games with "..player:getStorageValue(killstreak).." kills | Tributes still alive: " .. #gameplayers[gameid]) end for k,v in pairs(gameplayers[gameid]) do if v == player:getName() then table.remove(gameplayers[gameid],k) end end end player:setStorageValue(killstreak, 0) player:teleportTo((player:getTown()):getTemplePosition()) if gameplayers[gameid] and #gameplayers[gameid] == 1 then Player(gameplayers[gameid][1]):getBackItems() Player(gameplayers[gameid][1]):setStorageValue(gameid, -1) Game.broadcastMessage(MESSAGE_EVENT_ADVANCE,gameplayers[gameid][1] .." Has won The Hunger Games in ".. game[gameid].name .." with "..Player(gameplayers[gameid][1]):getStorageValue(killstreak).." Kill Streaks! Congratulations!") Player(gameplayers[gameid][1]):teleportTo((Player(gameplayers[gameid][1]):getTown()):getTemplePosition()) Player(gameplayers[gameid][1]):setStorageValue(killstreak, 0) for _, item in pairs(prize) do Player(gameplayers[gameid][1]):addItem(item[1],item[2]) end for k,v in pairs(gameplayers[gameid]) do if v == gameplayers[gameid][1] then table.remove(gameplayers[gameid],i) end end table.insert(availablearenas, gameid) elseif gameplayers[gameid] and #gameplayers[gameid] < 1 then Game.broadcastMessage(MESSAGE_EVENT_ADVANCE,game[gameid].name .." Has Ended without winners because all players have left the game!") table.insert(availablearenas, gameid) end end for k,v in pairs(queue) do if v == player:getName() then table.remove(queue,i) end end return true end creaturescripts/scripts/hunger.lua Spoiler function onDeath(player, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified) local gameid = player:getStorageValue(currentgameid) if gameid > 0 then if killer and killer:isPlayer() then for _, gamer in pairs(gameplayers[gameid]) do Player(gamer):sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, player:getName() .. " has been killed by " .. killer:getName() .. " with "..player:getStorageValue(killstreak).." kills | Tributes still alive: " .. #gameplayers[gameid]) end killer:setStorageValue(killstreak, killer:getStorageValue(killstreak)+1) else for _, gamer in pairs(gameplayers[gameid]) do Player(gamer):sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, player:getName() .. " has died with "..player:getStorageValue(killstreak).." kills | Tributes still alive: " .. #gameplayers[gameid]) end end player:setStorageValue(killstreak, 0) player:setStorageValue(currentgameid, -1) player:getBackItems() for k,v in pairs(gameplayers[gameid]) do if v == player:getName() then table.remove(gameplayers[gameid],k) end end if #gameplayers[gameid] == 1 then Game.broadcastMessage(MESSAGE_EVENT_ADVANCE,Player(gameplayers[gameid][1]):getName() .." Has won The Hunger Games in ".. game[gameid].name .." with ".. Player(gameplayers[gameid][1]):getStorageValue(killstreak) .." Kill Streaks! Congratulations!") Player(gameplayers[gameid][1]):teleportTo((Player(gameplayers[gameid][1]):getTown()):getTemplePosition()) Player(gameplayers[gameid][1]):setStorageValue(killstreak, 0) Player(gameplayers[gameid][1]):setStorageValue(currentgameid, -1) Player(gameplayers[gameid][1]):getBackItems() for _, item in pairs(prize) do Player(gameplayers[gameid][1]):addItem(item[1],item[2]) end for k,v in pairs(gameplayers[gameid]) do if v == gameplayers[gameid][1] then table.remove(gameplayers[gameid],i) end end table.insert(availablearenas, gameid) end end return true end talkactions/talkactions.xml Code (Text): <talkaction words="!join" separator=" " script="join.lua"/><talkaction words="!ragequit" separator=" " script="leave.lua"/> talkactions/scripts/join.lua Code (Text): Spoiler local gamename = { "hunger games" } queue = {} function onSay(player, words, param) local id = 0 for i=1, #gamename do if param == gamename then id = i end end local currentgame = player:getStorageValue(currentgameid) if (id ~= 0) then if currentgame <= 0 then for _, playerid in pairs(queue) do if player:getName() == playerid then player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You are already queue for this game.") return player:getPosition():sendMagicEffect(CONST_ME_POFF) end end table.insert(queue, player:getName()) player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have queued up for "..gamename[id].." with "..#queue.." total players") return player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) else player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You are already in a game.") return player:getPosition():sendMagicEffect(CONST_ME_POFF) end else player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "!join hunger games") return player:getPosition():sendMagicEffect(CONST_ME_POFF) end end talkactions/scripts/leave.lua Code (Text): Spoiler function onSay(player, words, param) local currentgame = player:getStorageValue(currentgameid) if currentgame > 0 then return player:addHealth(-player:getMaxHealth()) else player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You can only do that in an event game.") return player:getPosition():sendMagicEffect(CONST_ME_POFF) end end actions/actions.xml Code (Text): <!-- Hunger Games Chests --> <action fromaid="60101" toaid="60499" script="games/hunger.lua"/> <action fromaid="61101" toaid="61499" script="games/hunger.lua"/> <action fromaid="62101" toaid="62499" script="games/hunger.lua"/> actions/scripts/hunger.lua Code (Text): Spoiler local tier = { { --tier1 {id =2120 , chance = 10, count = 1}, --rope {id =2554 , chance = 5, count = 1}, --shovel {id =1991 , chance = 10, count = 1}, --bag {id =1998 , chance = 5, count = 1}, --backpack {id =2376 , chance = 10, count = 1}, --sword1 {id =2409 , chance = 5, count = 1}, --sword2 {id =2461 , chance = 10, count = 1}, --helmet1 {id =2458 , chance = 5, count = 1}, --helmet2 {id =2467 , chance = 10, count = 1}, --armor1 {id =2464 , chance = 5, count = 1}, --armor2 {id =2649 , chance = 10, count = 1}, --legs1 {id =2648 , chance = 5, count = 1}, --legs2 {id =2643 , chance = 10, count = 1}, --feet1 {id =2642 , chance = 5, count = 1}, --feet2 {id =2684 , chance = 20, count = 10}, --food1 {id =2689 , chance = 20, count = 10}, --food2 {id =2691 , chance = 20, count = 10}, --food3 {id =2677 , chance = 20, count = 20}, --food4 {id =2674 , chance = 20, count = 10}, --food5 {id =2386 , chance = 10, count = 1}, --axe1 {id =2441 , chance = 5, count = 1}, --axe2 {id =2437 , chance = 10, count = 1}, --club1 {id =2398 , chance = 5, count = 1}, --club2 {id =2190 , chance = 5, count = 1}, --wand1 {id =2191 , chance = 5, count = 1}, --wand2 {id =2456 , chance = 5, count = 1}, --bow1 {id =7438 , chance = 5, count = 1}, --bow2 {id =2512 , chance = 10, count = 1}, --shield1 {id =2529 , chance = 5, count = 1}, --shield2 {id =2331 , chance = 10, count = 10}, --rune1 {id =2313 , chance = 5, count = 10}, --rune2 {id =2544 , chance = 10, count = 10}, --ammo1 {id =2545 , chance = 5, count = 10}, --ammo2 {id =8704 , chance = 10, count = 1}, --potion1 {id =7618 , chance = 5, count = 1} --potion2 }, { --tier2 {id =2392 , chance = 10, count = 1}, --sword1 {id =7385 , chance = 5, count = 1}, --sword2 {id =2460 , chance = 10, count = 1}, --helmet1 {id =2480 , chance = 5, count = 1}, --helmet2 {id =2465 , chance = 10, count = 1}, --armor1 {id =2463 , chance = 5, count = 1}, --armor2 {id =2478 , chance = 10, count = 1}, --legs1 {id =2647 , chance = 5, count = 1}, --legs2 {id =11303 , chance = 10, count = 1}, --feet1 {id =7453 , chance = 5, count = 1}, --feet2 {id =2428 , chance = 10, count = 1}, --axe1 {id =2429 , chance = 5, count = 1}, --axe2 {id =2439 , chance = 10, count = 1}, --club1 {id =2423 , chance = 5, count = 1}, --club2 {id =2188 , chance = 5, count = 1}, --wand1 {id =8921 , chance = 5, count = 1}, --wand2 {id =8857 , chance = 5, count = 1}, --bow1 {id =8855 , chance = 5, count = 1}, --bow2 {id =2524 , chance = 10, count = 1}, --shield1 {id =2525 , chance = 5, count = 1}, --shield2 {id =2288 , chance = 10, count = 10}, --rune1 {id =2274 , chance = 5, count = 10}, --rune2 {id =7364 , chance = 10, count = 10}, --ammo1 {id =15648 , chance = 5, count = 10} --ammo2 } } function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey) chesttier = math.floor(((item.actionid % 1000) + 100 ) / 200) if Game.getStorageValue(item:getActionId()) ~= 1 then for a=item:getSize()-1 , 0, -1 do item:getItem(i):remove() -- cleaning any old remaining items from previous games. end for i=1,20 do percentage = math.random(1,100) randomitem = math.random(1,#tier[chesttier]) if percentage <= tier[chesttier][randomitem].chance then item:addItem(tier[chesttier][randomitem].id, math.random(1,tier[chesttier][randomitem].count)) --adding random item end end Game.setStorageValue(item:getActionId(), 1) end end Se poderem me ajudar... Irei agradecer! Link para o comentário Compartilhar em outros sites More sharing options...
America 2 Postado Abril 12, 2017 Share Postado Abril 12, 2017 Vish vai ser algo difícil pois muitas das funções usando ae não tem no tfs 0.3.6 Link para o comentário Compartilhar em outros sites More sharing options...
Stigal 584 Postado Novembro 29, 2017 Share Postado Novembro 29, 2017 A questão neste tópico de suporte foi encerrada por falta de resposta. Este tópico está fechado e foi movido para Suporte - Tópicos Sem Resposta. Link para o comentário Compartilhar em outros sites More sharing options...
Posts Recomendados