Postado Janeiro 15, 2015 10 anos Pessoal to tentando por no meu OTServ o MOD do Capture The Flag que peguei do Servidor DarksandOts Free Data 8.60 mas ele verifica uma tabela na TB, como faço para add essa tabela? segue o MOD do CTF: <?xml version='1.0' encoding='UTF-8'?> <mod name='Capture The Flag' version='2.0' author='Collocorpusek' contact='7284838' enabled='yes'> <config name='CTF_config'> ESTE EH O ORIGINAL <![CDATA[ ctfConfig = { bases = { [1] = { -- Positions -- fromPos = {x = 4781, y = 3245, z = 7}, toPos = {x = 4787, y = 3251, z = 7}, showInfoPos = {x = 4784, y = 3248, z = 7}, -- Storage -- points = 123661, controled = 123662, -- Flags -- flags = { [1] = {pos = {x=4783, y=3250, z=7}, id = {1878,1867,1870}}, [2] = {pos = {x=4784, y=3250, z=7}, id = {1878,1867,1870}}, [3] = {pos = {x=4785, y=3250, z=7}, id = {1878,1867,1870}}, [4] = {pos = {x=4786, y=3247, z=7}, id = {1879,1868,1871}}, [5] = {pos = {x=4786, y=3248, z=7}, id = {1879,1868,1871}}, [6] = {pos = {x=4786, y=3249, z=7}, id = {1879,1868,1871}}, -- NEXT FLOOR -- [7] = {pos = {x=4784, y=3250, z=6}, id = {1878,1867,1870}}, [8] = {pos = {x=4785, y=3250, z=6}, id = {1878,1867,1870}}, [9] = {pos = {x=4786, y=3249, z=6}, id = {1879,1868,1871}}, [10] = {pos = {x=4786, y=3248, z=6}, id = {1879,1868,1871}}, -- NEXT FLOOR -- [11] = {pos = {x=4785, y=3250, z=5}, id = {1878,1867,1870}}, [12] = {pos = {x=4786, y=3249, z=5}, id = {1879,1868,1871}} }, topFlagPos = {pos = {x=4786, y=3250, z=2}, id = {4990,11330,11326}} }, [2] = { -- Positions -- fromPos = {x = 4780, y = 3262, z = 7}, toPos = {x = 4786, y = 3268, z = 7}, showInfoPos = {x = 4783, y = 3265, z = 7}, -- Storage -- points = 123663, controled = 123664, -- Flags -- flags = { [1] = {pos = {x=4785, y=3264, z=7}, id = {1879,1868,1871}}, [2] = {pos = {x=4785, y=3265, z=7}, id = {1879,1868,1871}}, [3] = {pos = {x=4785, y=3266, z=7}, id = {1879,1868,1871}}, [4] = {pos = {x=4784, y=3267, z=7}, id = {1878,1867,1870}}, [5] = {pos = {x=4783, y=3267, z=7}, id = {1878,1867,1870}}, [6] = {pos = {x=4782, y=3267, z=7}, id = {1878,1867,1870}}, -- NEXT FLOOR -- [7] = {pos = {x=4785, y=3265, z=6}, id = {1879,1868,1871}}, [8] = {pos = {x=4785, y=3266, z=6}, id = {1879,1868,1871}}, [9] = {pos = {x=4784, y=3267, z=6}, id = {1878,1867,1870}}, [10] = {pos = {x=4783, y=3267, z=6}, id = {1878,1867,1870}}, -- NEXT FLOOR -- [11] = {pos = {x=4785, y=3266, z=5}, id = {1879,1868,1871}}, [12] = {pos = {x=4784, y=3267, z=5}, id = {1878,1867,1870}} }, topFlagPos = {pos = {x=4785, y=3267, z=2}, id = {4990,11330,11326}} }, [3] = { -- Positions -- fromPos = {x = 4806, y = 3245, z = 7}, toPos = {x = 4812, y = 3251, z = 7}, showInfoPos = {x = 4809, y = 3248, z = 7}, -- Storage -- points = 123665, controled = 123666, -- Flags -- flags = { [1] = {pos = {x=4811, y=3247, z=7}, id = {1879,1868,1871}}, [2] = {pos = {x=4811, y=3248, z=7}, id = {1879,1868,1871}}, [3] = {pos = {x=4811, y=3249, z=7}, id = {1879,1868,1871}}, [4] = {pos = {x=4810, y=3250, z=7}, id = {1878,1867,1870}}, [5] = {pos = {x=4809, y=3250, z=7}, id = {1878,1867,1870}}, [6] = {pos = {x=4808, y=3250, z=7}, id = {1878,1867,1870}}, -- NEXT FLOOR -- [7] = {pos = {x=4811, y=3248, z=6}, id = {1879,1868,1871}}, [8] = {pos = {x=4811, y=3249, z=6}, id = {1879,1868,1871}}, [9] = {pos = {x=4810, y=3250, z=6}, id = {1878,1867,1870}}, [10] = {pos = {x=4809, y=3250, z=6}, id = {1878,1867,1870}}, -- NEXT FLOOR -- [11] = {pos = {x=4811, y=3249, z=5}, id = {1879,1868,1871}}, [12] = {pos = {x=4810, y=3250, z=5}, id = {1878,1867,1870}} }, topFlagPos = {pos = {x=4811, y=3250, z=2}, id = {4990,11330,11326}} }, [4] = { -- Positions -- fromPos = {x = 4808, y = 3261, z = 7}, toPos = {x = 4814, y = 3267, z = 7}, showInfoPos = {x = 4811, y = 3264, z = 7}, -- Storage -- points = 123667, controled = 123668, -- Flags -- flags = { [1] = {pos = {x=4813, y=3263, z=7}, id = {1879,1868,1871}}, [2] = {pos = {x=4813, y=3264, z=7}, id = {1879,1868,1871}}, [3] = {pos = {x=4813, y=3265, z=7}, id = {1879,1868,1871}}, [4] = {pos = {x=4812, y=3266, z=7}, id = {1878,1867,1870}}, [5] = {pos = {x=4811, y=3266, z=7}, id = {1878,1867,1870}}, [6] = {pos = {x=4810, y=3266, z=7}, id = {1878,1867,1870}}, -- NEXT FLOOR -- [7] = {pos = {x=4813, y=3264, z=6}, id = {1879,1868,1871}}, [8] = {pos = {x=4813, y=3265, z=6}, id = {1879,1868,1871}}, [9] = {pos = {x=4812, y=3266, z=6}, id = {1878,1867,1870}}, [10] = {pos = {x=4811, y=3266, z=6}, id = {1878,1867,1870}}, -- NEXT FLOOR -- [11] = {pos = {x=4813, y=3265, z=5}, id = {1879,1868,1871}}, [12] = {pos = {x=4812, y=3266, z=5}, id = {1878,1867,1870}} }, topFlagPos = {pos = {x=4813, y=3266, z=2}, id = {4990,11330,11326}} } }, red = { teleportPos = {x = 4821, y = 3257, z = 6}, deathPos = {x = 4821, y = 3257, z = 7}, storage = 123669, scores = 1236610 }, blue = { teleportPos = {x = 4773, y = 3257, z = 6}, deathPos = {x = 4773, y = 3257, z = 7}, storage = 1236611, scores = 1236612 }, walls = { {pos = {x = 4776, y = 3257, z = 6}, id = 1049}, {pos = {x = 4818, y = 3257, z = 6}, id = 1049} }, days = { {['Monday'] = {'03:00:20'}, ['Sunday'] = {'03:00:20'}} }, -- Main flag -- flag = { storage = 1236617, pos = {x = 4798, y = 3257, z = 7}, id = 1436 }, -- Rewards -- rewards = {3954, 7957, 2542}, -- Requires -- minLevel = 200000, minOfParticipants = 1, -- minimum graczy z kazdej druzyny aby event sie rozpoczal maxOfParticipants = 15, -- ile moze byc maksymalnie uczestnikow w jeden druzynie -- Storage -- eventStorage = 100014, joinEventStorage = 100015, groupStorage = 100016, -- Times -- finishEvent = 15, -- minuty timeToStartJoiningToCTF = 3.0, timeToStartCTFEvent = 2.0, -- Points -- maxTeamPoints = 1000, pointsForFlag = 100, pointsForEachBase = 50, -- Base -- maxBasePoints = 12, basePointsToControl = 10, -- Death -- deathStorage = 100017, deathCountStorage = 100018, deathTime = 15, -- seconds text = '-PL-\nNa srodku pola walki znajduje sie flaga. \nTrzeba ja zabrac i zaniesc do przejetej bazy. \nAby przejac baze trzeba stac wokol niej w przewadze. \nPrzejeta baze pokazuja zawieszone na niej flagi. \nPo odniesieniu flagi do bazy otrzymuje sie punkty.\n\n-ENG-\nIn the middle the battle is located flag. \nYou have to take it and carry it to the acquired base. \nTo take over the base you have to stand around her in the superiority. \nA compromised base shows the suspended flags. \nAfter the flag for the database receives the points.' } ]]> </config> <lib name='CTF_lib'> <![CDATA[ domodlib('CTF_config') ------------------------------------- ---- dla blue teamu przypisuje sie wartosci ujemne (basa) ---- dla red teamu przypisuje sie wartosci dodatnie (basa) function checkDeathRoomCTF() if getStorage(ctfConfig.deathCountStorage) - ctfConfig.deathTime == 0 then for _, cid in ipairs(getPlayersOnline()) do if getCreatureStorage(cid, ctfConfig.deathStorage) > 0 then local conditionBlue = createConditionObject(CONDITION_OUTFIT) setConditionParam(conditionBlue, CONDITION_PARAM_TICKS, -1) addOutfitCondition(conditionBlue, {lookType = 130, lookHead = 87, lookBody = 87, lookLegs = 87, lookFeet = 87}) local conditionRed = createConditionObject(CONDITION_OUTFIT) setConditionParam(conditionRed, CONDITION_PARAM_TICKS, -1) addOutfitCondition(conditionRed, {lookType = 130, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94}) if getCreatureStorage(cid, ctfConfig.blue.storage) > 0 then doAddCondition(cid, conditionBlue) doTeleportThing(cid, ctfConfig.blue.teleportPos) elseif getCreatureStorage(cid, ctfConfig.red.storage) > 0 then doTeleportThing(cid, ctfConfig.red.teleportPos) doAddCondition(cid, conditionRed) end doCreatureSetStorage(cid, ctfConfig.deathStorage, -1) doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid)) doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid)) end end for i = 1, 2 do local team = i == 1 and ctfConfig.blue or ctfConfig.red doSendAnimatedText(team.deathPos, '0', TEXTCOLOR_BLACK) end doSetStorage(ctfConfig.deathCountStorage, 0) else for i = 1, 2 do local team = i == 1 and ctfConfig.blue or ctfConfig.red doSendAnimatedText(team.deathPos, math.abs(getStorage(ctfConfig.deathCountStorage) - ctfConfig.deathTime), TEXTCOLOR_BLACK) end end doSetStorage(ctfConfig.deathCountStorage, getStorage(ctfConfig.deathCountStorage) + 1) end function doAddScoreToBaseCTF() for k, v in pairs(ctfConfig.bases) do local blue, red = 0, 0 for x = v.fromPos.x, v.toPos.x do for y = v.fromPos.y, v.toPos.y do local n, i = getTileInfo({x=x, y=y, z=v.toPos.z}).creatures, 1 if n ~= 0 then local t = getThingfromPos({x=x, y=y, z=v.toPos.z, stackpos=i}).uid while t ~= 0 do if isPlayer(t) then if getCreatureStorage(t, ctfConfig.red.storage) > 0 then red = red + 1 elseif getCreatureStorage(t, ctfConfig.blue.storage) > 0 then blue = blue + 1 end end i = i + 1 t = getThingfromPos({x=x, y=y, z=v.toPos.z, stackpos=i}).uid end end end end -- ustawia storage basy local addPoints = getStorage(v.points) + (red - blue) if math.abs(addPoints) > ctfConfig.maxBasePoints then doSetStorage(v.points, (addPoints < 0 and - ctfConfig.maxBasePoints or ctfConfig.maxBasePoints)) doSendAnimatedText(v.showInfoPos, ctfConfig.maxBasePoints .. '/' .. ctfConfig.maxBasePoints, (addPoints < 0 and COLOR_BLUE or COLOR_RED)) else -- Add points -- if math.abs(addPoints) < ctfConfig.basePointsToControl then doSendAnimatedText(v.showInfoPos, math.abs(addPoints) .. '/' .. ctfConfig.maxBasePoints, COLOR_GREY) else local takeControl = addPoints < 0 and 'blue' or 'red' doSendAnimatedText(v.showInfoPos, math.abs(addPoints) .. '/' .. ctfConfig.maxBasePoints, (takeControl == 'blue' and COLOR_BLUE or COLOR_RED)) end doSetStorage(v.points, addPoints) end -- Top flag -- local topFlag for _, id in pairs(v.topFlagPos.id) do if getTileItemById(v.topFlagPos.pos, id).uid > 0 then topFlag = getTileItemById(v.topFlagPos.pos, id).uid break end end if topFlag ~= nil then if math.abs(addPoints) < ctfConfig.basePointsToControl then doTransformItem(topFlag, v.topFlagPos.id[1]) doSetStorage(v.controled, '') else local whoControl = addPoints < 0 and 3 or 2 doTransformItem(topFlag, v.topFlagPos.id[whoControl]) doSetStorage(v.controled, (addPoints < 0 and 'blue' or 'red')) end end -- Tapestry -- for i, flags in pairs(v.flags) do local flag for _, id in pairs(flags.id) do if getTileItemById(flags.pos, id).uid > 0 then flag = getTileItemById(flags.pos, id).uid break end end if flag ~= nil then if i > math.abs(addPoints) then doTransformItem(flag, flags.id[1]) else local whoControl = addPoints < 0 and 3 or 2 doTransformItem(flag, flags.id[whoControl]) end end end end end function getBasesControledByTeamCTF(team) local bases = 0 for k, v in pairs(ctfConfig.bases) do if getStorage(v.controled) == team then bases = bases + 1 end end return bases end function isControledByTeamCTF(pos, team) for k, v in pairs(ctfConfig.bases) do if isInRange(pos, v.fromPos, v.toPos) then if getStorage(v.controled) == team then return true end end end return false end function getAmountParticipantsCTF() local blue, red = {}, {} for _, pid in ipairs(getPlayersOnline()) do if getCreatureStorage(pid, ctfConfig.blue.storage) > 0 then table.insert(blue, pid) elseif getCreatureStorage(pid, ctfConfig.red.storage) > 0 then table.insert(red, pid) end end return blue, red end function openCtfEvent() doSetStorage(ctfConfig.joinEventStorage, 1) doBroadcastMessage('[CTF]\n\nPrzygotuj sie do bitwy! Jesli masz conajmniej ' .. ctfConfig.minLevel .. ' level mozesz dolaczyc do eventu piszac "!ctf join".', MESSAGE_EVENT_ADVANCE) addEvent(doStartCtfEvent, ctfConfig.timeToStartCTFEvent * 1000 * 60) for k, v in pairs(ctfConfig.walls) do doCreateItem(v.id, 1, v.pos) end end function doStartCtfEvent() for _, pid in ipairs(getPlayersOnline()) do if isInArray({getCreatureStorage(pid, ctfConfig.blue.storage), getCreatureStorage(pid, ctfConfig.red.storage)}, 1) then doCreatureSetNoMove(pid, false) doRemoveCondition(pid, CONDITION_INFIGHT) doPlayerSetGroupId(pid, math.max(1, getCreatureStorage(pid, ctfConfig.groupStorage))) end end local blue, red = getAmountParticipantsCTF() if #blue >= ctfConfig.minOfParticipants and #red >= ctfConfig.minOfParticipants then doBroadcastMessage('[CTF]\n\nLet\'s go! Bramy otworzone!', MESSAGE_EVENT_ADVANCE) addEvent( function() if getStorage(ctfConfig.red.scores) > getStorage(ctfConfig.blue.scores) then doCloseCtfEvent('red') elseif getStorage(ctfConfig.red.scores) < getStorage(ctfConfig.blue.scores) then doCloseCtfEvent('blue') else doCloseCtfEvent(math.random(2) == 1 and 'blue' or 'red') end end, ctfConfig.finishEvent * 1000 * 60 ) else doBroadcastMessage('[CTF]\n\nEvent failed, not enough players joined to event!', MESSAGE_EVENT_ADVANCE) for _, pid in ipairs(getPlayersOnline()) do -- Storages -- if getCreatureStorage(pid, ctfConfig.blue.storage) == 1 then doCreatureSetStorage(pid, ctfConfig.blue.storage, -1) -- TP -- doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), true) doRemoveCondition(pid, CONDITION_OUTFIT) elseif getCreatureStorage(pid, ctfConfig.red.storage) == 1 then doCreatureSetStorage(pid, ctfConfig.red.storage, -1) -- TP -- doTeleportThing(pid, getTownTemplePosition(getPlayerTown(pid)), true) doRemoveCondition(pid, CONDITION_OUTFIT) end if getCreatureStorage(pid, ctfConfig.flag.storage) > 0 then doCreatureSetStorage(pid, ctfConfig.flag.storage, -1) end if getCreatureStorage(pid, ctfConfig.deathStorage) > 0 then doCreatureSetStorage(pid, ctfConfig.deathStorage, -1) end end -- Clean tabeli i event storage -- doSetStorage(ctfConfig.eventStorage, -1) end for k, v in pairs(ctfConfig.walls) do doRemoveItem(getTileItemById(v.pos, v.id).uid) end doSetStorage(ctfConfig.joinEventStorage, -1) end function doCloseCtfEvent(winTeam) if getStorage(ctfConfig.eventStorage) ~= -1 then doBroadcastMessage('[CTF]\n\nEvent ended! Winner is: ' .. winTeam .. ' team . Congratulations!', MESSAGE_INFO_DESCR) for _, eventPlayers in ipairs(getPlayersOnline()) do if getCreatureStorage(eventPlayers, ctfConfig.blue.storage) == 1 then local reward = ctfConfig.rewards[math.random(#ctfConfig.rewards)] -- Clean storage -- doCreatureSetStorage(eventPlayers, ctfConfig.blue.storage, -1) if winTeam == 'blue' then -- Add item if winner -- doPlayerAddItem(eventPlayers, reward, 1) end -- TP -- doTeleportThing(eventPlayers, getTownTemplePosition(getPlayerTown(eventPlayers)), true) doRemoveCondition(eventPlayers, CONDITION_OUTFIT) elseif getCreatureStorage(eventPlayers, ctfConfig.red.storage) == 1 then -- Clean storage -- doCreatureSetStorage(eventPlayers, ctfConfig.red.storage, -1) if winTeam == 'red' then -- Add item if winner -- doPlayerAddItem(eventPlayers, reward, 1) end -- TP -- doTeleportThing(eventPlayers, getTownTemplePosition(getPlayerTown(eventPlayers)), true) doRemoveCondition(eventPlayers, CONDITION_OUTFIT) end if getCreatureStorage(eventPlayers, ctfConfig.flag.storage) > 0 then doCreatureSetStorage(eventPlayers, ctfConfig.flag.storage, -1) end if getCreatureStorage(eventPlayers, ctfConfig.deathStorage) > 0 then doCreatureSetStorage(eventPlayers, ctfConfig.deathStorage, -1) end end -- Clean all storages -- for k, v in pairs(ctfConfig.bases) do doSetStorage(v.controled, 0) doSetStorage(v.points, 0) end doSetStorage(ctfConfig.red.scores, 0) doSetStorage(ctfConfig.blue.scores, 0) doSetStorage(ctfConfig.eventStorage, -1) doSetStorage(ctfConfig.joinEventStorage, -1) doSetStorage(ctfConfig.deathCountStorage, 0) end end function doStartCountingCtfEvent(x) if ctfConfig.timeToStartJoiningToCTF-x > 0 then doBroadcastMessage('[CTF]\n\nCapture The Flag Event zaczyna sie za '..ctfConfig.timeToStartJoiningToCTF+ctfConfig.timeToStartCTFEvent-x..' minuty.') addEvent(doStartCountingCtfEvent, 60*1000, x+1) else openCtfEvent() end end ]]> </lib> <talkaction words='!startctf' access='5' event='script'> <![CDATA[ domodlib('CTF_config') domodlib('CTF_lib') function onSay(cid, words, param) if getStorage(ctfConfig.eventStorage) ~= 1 then doStartCountingCtfEvent(0) doSetStorage(ctfConfig.eventStorage, 1) else doPlayerSendCancel(cid, 'You can not do it if "CTF event" is enabled yet.') end return true end ]]> </talkaction> <talkaction words='!ctf' log="yes" event='script'> <![CDATA[ domodlib('CTF_config') domodlib('CTF_lib') local conditionBlue = createConditionObject(CONDITION_OUTFIT) setConditionParam(conditionBlue, CONDITION_PARAM_TICKS, -1) addOutfitCondition(conditionBlue, {lookType = 130, lookHead = 87, lookBody = 87, lookLegs = 87, lookFeet = 87}) local conditionRed = createConditionObject(CONDITION_OUTFIT) setConditionParam(conditionRed, CONDITION_PARAM_TICKS, -1) addOutfitCondition(conditionRed, {lookType = 130, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94}) function onSay(cid, words, param) if getStorage(ctfConfig.joinEventStorage) == 1 then if getPlayerLevel(cid) < ctfConfig.minLevel then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You can not sing up to CTF event if you do not have a require level. [' .. ctfConfig.minLevel .. ']') end if getTileInfo(getThingPos(cid)).protection ~= true then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You can not sing up to CTF event if are not in protection zone.') end if getCreatureStorage(cid, ctfConfig.blue.storage) == 1 or getCreatureStorage(cid, ctfConfig.red.storage) == 1 then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_SMALL, 'You are arleady joined to CTF event.') end local blue, red = getAmountParticipantsCTF() if #blue == ctfConfig.maxOfParticipants and #red == ctfConfig.maxOfParticipants then return doPlayerSendCancel(cid, 'Max players in the event has been reached!') end for _, v in ipairs(red) do if getPlayerIp(cid) == getPlayerIp(v) then return doPlayerSendCancel(cid, 'In CTF event there is arleady player who have same ip like you.') end end for _, v in ipairs(blue) do if getPlayerIp(cid) == getPlayerIp(v) then return doPlayerSendCancel(cid, 'In CTF event there is arleady player who have same ip like you.') end end if #blue > 0 or #red > 0 then if #blue > #red then -- TP, noMove -- doTeleportThing(cid, ctfConfig.red.teleportPos) -- Storages -- doCreatureSetStorage(cid, ctfConfig.red.storage, 1) -- Conditions -- doAddCondition(cid, conditionRed) elseif #blue < #red then -- TP, noMove -- doTeleportThing(cid, ctfConfig.blue.teleportPos) -- Storages -- doCreatureSetStorage(cid, ctfConfig.blue.storage, 1) -- Conditions -- doAddCondition(cid, conditionBlue) elseif #blue == #red then local team = math.random(2) == 1 and ctfConfig.blue or ctfConfig.red -- TP, noMove -- doTeleportThing(cid, team.teleportPos) -- Storages -- doCreatureSetStorage(cid, team.storage, 1) -- Conditions -- doAddCondition(cid, getCreatureStorage(cid, ctfConfig.blue.storage) > 0 and conditionBlue or conditionRed) end else local team = math.random(2) == 1 and ctfConfig.blue or ctfConfig.red -- TP -- doTeleportThing(cid, team.teleportPos) -- Storages -- doCreatureSetStorage(cid, team.storage, 1) -- Condition -- doAddCondition(cid, getCreatureStorage(cid, ctfConfig.blue.storage) > 0 and conditionBlue or conditionRed) end doPlayerPopupFYI(cid, ctfConfig.text) doCreatureSetNoMove(cid, true) -- Group -- doCreatureSetStorage(cid, ctfConfig.groupStorage, getPlayerGroupId(cid)) doPlayerSetGroupId(cid, 7) -- Condition -- doAddCondition(cid, createConditionObject(CONDITION_INFIGHT, -1)) else doPlayerSendCancel(cid, 'It is not time yet!') end return true end ]]> </talkaction> <!-- Flaga --> <action itemid='1436' event='script'> <![CDATA[ domodlib('CTF_config') domodlib('CTF_lib') function onUse(cid, item, fromPosition, itemEx, toPosition) doRemoveItem(itemEx.uid) doCreatureSetStorage(cid, ctfConfig.flag.storage, 1) doRemoveCondition(cid, CONDITION_OUTFIT) local conditionFlagRed = createConditionObject(CONDITION_OUTFIT) setConditionParam(conditionFlagRed, CONDITION_PARAM_TICKS, -1) addOutfitCondition(conditionFlagRed, {lookType = 335, lookHead = 94, lookBody = 94, lookLegs = 79, lookFeet = 79, lookAddons = 3}) local conditionFlagBlue = createConditionObject(CONDITION_OUTFIT) setConditionParam(conditionFlagBlue, CONDITION_PARAM_TICKS, -1) addOutfitCondition(conditionFlagBlue, {lookType = 335, lookHead = 87, lookBody = 87, lookLegs = 79, lookFeet = 79, lookAddons = 3}) doAddCondition(cid, (getCreatureStorage(cid, ctfConfig.blue.storage) == 1 and conditionFlagBlue or conditionFlagRed)) doChangeSpeed(cid, -(math.floor(getCreatureBaseSpeed(cid) / 2))) doBroadcastMessage('[CTF]\n\n' .. getCreatureName(cid) .. ' from [' .. (getCreatureStorage(cid, ctfConfig.blue.storage) == 1 and 'blue' or 'red') .. ' team] zabral flage! Let\'s capture this flag!!', MESSAGE_STATUS_WARNING) return true end ]]> </action> <!-- Events --> <event type='login' name='CTF_event_login' event='script'> <![CDATA[ domodlib('CTF_config') domodlib('CTF_lib') function onLogin(cid) if getCreatureStorage(cid, ctfConfig.blue.storage) == 1 then -- Clean storage -- doCreatureSetStorage(cid, ctfConfig.blue.storage, -1) doPlayerSetGroupId(cid, math.max(1, getCreatureStorage(cid, ctfConfig.groupStorage))) doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), true) doRemoveCondition(cid, CONDITION_OUTFIT) elseif getCreatureStorage(cid, ctfConfig.red.storage) == 1 then -- Clean storage -- doCreatureSetStorage(cid, ctfConfig.red.storage, -1) doPlayerSetGroupId(cid, math.max(1, getCreatureStorage(cid, ctfConfig.groupStorage))) -- TP -- doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)), true) doRemoveCondition(cid, CONDITION_OUTFIT) end if getCreatureStorage(cid, ctfConfig.flag.storage) > 0 then doCreatureSetStorage(cid, ctfConfig.flag.storage, -1) end if getCreatureStorage(cid, ctfConfig.deathStorage) > 0 then doCreatureSetStorage(cid, ctfConfig.deathStorage, -1) end registerCreatureEvent(cid, 'CTF_statsChange') registerCreatureEvent(cid, 'CTF_target') return true end ]]> </event> <event type='statschange' name='CTF_statsChange' event='script'> <![CDATA[ domodlib('CTF_config') domodlib('CTF_lib') function onStatsChange(cid, attacker, type, combat, value) if type == 1 and getCreatureHealth(cid) <= value then if isPlayer(cid) then if getCreatureStorage(cid, ctfConfig.red.storage) > 0 then addEvent(doTeleportThing, 0, cid, ctfConfig.red.deathPos) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You dead and you have been teleported to dead room. After few seconds you will be teleported again to the battle.') local deadOutfit = createConditionObject(CONDITION_OUTFIT) setConditionParam(deadOutfit, CONDITION_PARAM_TICKS, -1) addOutfitCondition(deadOutfit, {lookType = 313, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94}) doAddCondition(cid, deadOutfit) doRemoveConditions(cid) doCreatureAddHealth(cid, -(getCreatureHealth(cid) - 1)) doCreatureAddMana(cid, -(getCreatureMana(cid) - 1)) doCreatureSetStorage(cid, ctfConfig.deathStorage, 1) if getCreatureStorage(cid, ctfConfig.flag.storage) == 1 then if getTileItemById(getThingPos(cid), 2019).uid > 0 then doRemoveItem(getTileItemById(getThingPos(cid), 2019).uid) end doCreateItem(ctfConfig.flag.id, 1, getThingPos(cid)) doCreatureSetStorage(cid, ctfConfig.flag.storage, -1) doBroadcastMessage('[CTF]\n\n' .. getCreatureName(cid) .. ' from [red team] stracil flage!', MESSAGE_STATUS_WARNING) doChangeSpeed(cid, math.floor(getCreatureBaseSpeed(cid) / 2)) end return false elseif getCreatureStorage(cid, ctfConfig.blue.storage) > 0 then addEvent(doTeleportThing, 0, cid, ctfConfig.blue.deathPos) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You dead and you have been teleported to dead room. After few seconds you will be teleported again to the battle.') local deadOutfit = createConditionObject(CONDITION_OUTFIT) setConditionParam(deadOutfit, CONDITION_PARAM_TICKS, -1) addOutfitCondition(deadOutfit, {lookType = 313, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94}) doAddCondition(cid, deadOutfit) doRemoveConditions(cid) doCreatureAddHealth(cid, -(getCreatureHealth(cid) - 1)) doCreatureAddMana(cid, -(getCreatureMana(cid) - 1)) doCreatureSetStorage(cid, ctfConfig.deathStorage, 1) if getCreatureStorage(cid, ctfConfig.flag.storage) > 0 then if getTileItemById(getThingPos(cid), 2019).uid > 0 then doRemoveItem(getTileItemById(getThingPos(cid), 2019).uid) end doCreateItem(ctfConfig.flag.id, 1, getThingPos(cid)) doCreatureSetStorage(cid, ctfConfig.flag.storage, -1) doBroadcastMessage('[CTF]\n\n' .. getCreatureName(cid) .. ' from [blue team] stracil flage!', MESSAGE_STATUS_WARNING) doChangeSpeed(cid, math.floor(getCreatureBaseSpeed(cid) / 2)) end return false end end end return true end ]]> </event> <event type='combat' name='CTF_target' event='script'> <![CDATA[ domodlib('CTF_config') domodlib('CTF_lib') function onCombat(cid, target) if isPlayer(cid) and isPlayer(target) then if getCreatureStorage(cid, ctfConfig.red.storage) == 1 and getCreatureStorage(target, ctfConfig.red.storage) == 1 then return doPlayerSendCancel(cid, 'You may not attack your team mates.') and false elseif getCreatureStorage(cid, ctfConfig.blue.storage) == 1 and getCreatureStorage(target, ctfConfig.blue.storage) == 1 then return doPlayerSendCancel(cid, 'You may not attack your team mates.') and false end end return true end ]]> </event> <movement type='StepIn' actionid='58834' event='script'> <![CDATA[ domodlib('CTF_config') domodlib('CTF_lib') function onStepIn(cid, item, position, fromPosition, toPosition, lastPosition, actor) if isPlayer(cid) then if getCreatureStorage(cid, ctfConfig.flag.storage) > 0 then if getCreatureStorage(cid, ctfConfig.red.storage) > 0 then if isControledByTeamCTF(getThingPos(cid), 'red') then local points = ctfConfig.pointsForFlag + (ctfConfig.pointsForEachBase * getBasesControledByTeamCTF('red')) if getStorage(ctfConfig.red.scores) + points >= ctfConfig.maxTeamPoints then -- Close event -- doCloseCtfEvent('red') doChangeSpeed(cid, math.floor(getCreatureBaseSpeed(cid) / 2)) else doChangeSpeed(cid, math.floor(getCreatureBaseSpeed(cid) / 2)) doRemoveCondition(cid, CONDITION_OUTFIT) local conditionRed = createConditionObject(CONDITION_OUTFIT) setConditionParam(conditionRed, CONDITION_PARAM_TICKS, -1) addOutfitCondition(conditionRed, {lookType = 130, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94}) doAddCondition(cid, conditionRed) doSetStorage(ctfConfig.red.scores, getStorage(ctfConfig.red.scores) + points) doBroadcastMessage('[CTF]\n\n' .. getCreatureName(cid) .. ' from [red team] przekazal flage do bazy. Aktualny wynik:\nRed team: ' .. getStorage(ctfConfig.red.scores) .. '/' .. ctfConfig.maxTeamPoints .. '\nBlue team: ' .. getStorage(ctfConfig.blue.scores) .. '/' .. ctfConfig.maxTeamPoints .. '', MESSAGE_STATUS_WARNING) end addEvent(doCreateItem, 15000, ctfConfig.flag.id, 1, ctfConfig.flag.pos) doCreatureSetStorage(cid, ctfConfig.flag.storage, -1) else doPlayerSendCancel(cid, 'This base isn\'t controlled by your team.') end elseif getCreatureStorage(cid, ctfConfig.blue.storage) > 0 then if isControledByTeamCTF(getThingPos(cid), 'blue') then local points = ctfConfig.pointsForFlag + ctfConfig.pointsForEachBase * getBasesControledByTeamCTF('blue') if getStorage(ctfConfig.blue.scores) + points >= ctfConfig.maxTeamPoints then -- Close event -- doCloseCtfEvent('blue') doChangeSpeed(cid, math.floor(getCreatureBaseSpeed(cid) / 2)) else doChangeSpeed(cid, math.floor(getCreatureBaseSpeed(cid) / 2)) doRemoveCondition(cid, CONDITION_OUTFIT) local conditionBlue = createConditionObject(CONDITION_OUTFIT) setConditionParam(conditionBlue, CONDITION_PARAM_TICKS, -1) addOutfitCondition(conditionBlue, {lookType = 130, lookHead = 87, lookBody = 87, lookLegs = 87, lookFeet = 87}) doAddCondition(cid, conditionBlue) doSetStorage(ctfConfig.blue.scores, getStorage(ctfConfig.blue.scores) + points) doBroadcastMessage('[CTF]\n\n' .. getCreatureName(cid) .. ' from [blue team] has supplied flag to the base. Actual results:\nRed team: ' .. getStorage(ctfConfig.red.scores) .. '/' .. ctfConfig.maxTeamPoints .. '\nBlue team: ' .. getStorage(ctfConfig.blue.scores) .. '/' .. ctfConfig.maxTeamPoints .. '', MESSAGE_STATUS_WARNING) end addEvent(doCreateItem, 15000, ctfConfig.flag.id, 1, ctfConfig.flag.pos) doCreatureSetStorage(cid, ctfConfig.flag.storage, -1) else doPlayerSendCancel(cid, 'This base isn\'t controlled by your team.') end end end end return true end ]]> </movement> <globalevent name='CTF_startEvent' interval='10000' event='script'> <![CDATA[ domodlib('CTF_config') domodlib('CTF_lib') local daysOpen = {} for k, v in pairs(ctfConfig.days) do table.insert(daysOpen, k) end function onThink(interval) if isInArray(daysOpen, os.date('%A')) then if isInArray(ctfConfig.days[os.date('%A')], os.date('%X', os.time())) then if getStorage(ctfConfig.eventStorage) ~= 1 then doStartCountingCtfEvent(0) doSetStorage(ctfConfig.eventStorage, 1) end end end if getStorage(ctfConfig.eventStorage) == 1 then checkDeathRoomCTF() for _, playerWithFlag in ipairs(getPlayersOnline()) do if getCreatureStorage(playerWithFlag, ctfConfig.flag.storage) == 1 then doSendAnimatedText(getThingPos(playerWithFlag), 'FLAG', COLOR_DARKYELLOW) break end end end return true end ]]> </globalevent> <globalevent name='CTF_bases' interval='5000' event='script'> <![CDATA[ domodlib('CTF_config') domodlib('CTF_lib') function onThink(interval) if getStorage(ctfConfig.eventStorage) == 1 then doAddScoreToBaseCTF() end return true end ]]> </globalevent> <globalevent name='CTF_outfits' interval='10000' event='script'> <![CDATA[ domodlib('CTF_config') local conditionBlue = createConditionObject(CONDITION_OUTFIT) setConditionParam(conditionBlue, CONDITION_PARAM_TICKS, -1) addOutfitCondition(conditionBlue, {lookType = 130, lookHead = 87, lookBody = 87, lookLegs = 87, lookFeet = 87}) local conditionRed = createConditionObject(CONDITION_OUTFIT) setConditionParam(conditionRed, CONDITION_PARAM_TICKS, -1) addOutfitCondition(conditionRed, {lookType = 130, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94}) local conditionFlagRed = createConditionObject(CONDITION_OUTFIT) setConditionParam(conditionFlagRed, CONDITION_PARAM_TICKS, -1) addOutfitCondition(conditionFlagRed, {lookType = 335, lookHead = 94, lookBody = 94, lookLegs = 79, lookFeet = 79, lookAddons = 3}) local conditionFlagBlue = createConditionObject(CONDITION_OUTFIT) setConditionParam(conditionFlagBlue, CONDITION_PARAM_TICKS, -1) addOutfitCondition(conditionFlagBlue, {lookType = 335, lookHead = 87, lookBody = 87, lookLegs = 79, lookFeet = 79, lookAddons = 3}) local conditionDead = createConditionObject(CONDITION_OUTFIT) setConditionParam(conditionDead, CONDITION_PARAM_TICKS, -1) addOutfitCondition(conditionDead, {lookType = 313, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94}) function onThink(interval) if getStorage(ctfConfig.eventStorage) == 1 then for _, cid in ipairs(getPlayersOnline()) do if getCreatureStorage(cid, ctfConfig.blue.storage) > 0 then doRemoveCondition(cid, CONDITION_OUTFIT) if getCreatureStorage(cid, ctfConfig.flag.storage) > 0 then doAddCondition(cid, conditionFlagBlue) elseif getCreatureStorage(cid, ctfConfig.deathStorage) > 0 then doAddCondition(cid, conditionDead) else doAddCondition(cid, conditionBlue) end elseif getCreatureStorage(cid, ctfConfig.red.storage) > 0 then doRemoveCondition(cid, CONDITION_OUTFIT) if getCreatureStorage(cid, ctfConfig.flag.storage) > 0 then doAddCondition(cid, conditionFlagRed) elseif getCreatureStorage(cid, ctfConfig.deathStorage) > 0 then doAddCondition(cid, conditionDead) else doAddCondition(cid, conditionRed) end end end end return true end ]]> </globalevent> <globalevent name='CTF_start' type='startup' event='script'> <![CDATA[ domodlib('CTF_config') function onStartup() for k, v in pairs(ctfConfig.bases) do doSetStorage(v.controled, 0) doSetStorage(v.points, 0) end doSetStorage(ctfConfig.red.scores, 0) doSetStorage(ctfConfig.blue.scores, 0) doSetStorage(ctfConfig.eventStorage, -1) doSetStorage(ctfConfig.joinEventStorage, -1) doSetStorage(ctfConfig.deathCountStorage, 0) return true end ]]> </globalevent> </mod>
Postado Janeiro 15, 2015 10 anos tenta usar esse: http://www.tibiaking.com/forum/topic/10952-mod-capture-the-flagctf/ Att,Dieguiin XP »»http://baiakfull.com/««
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.