Tudo que MatteusDeli postou
-
[AULA] Entendendo a diferença entre ItemID, ActionID e UniqueID
Nesse tópico você irá aprender a diferença entre ItemID, ActionID e UniqueID na criação de scripts. Primeiramente vamos começar com o ItemID, imagine que você está criando um simples script que o player pode ter acesso a uma área VIP, só que para ele entrar, primeiro precisará passar por um tile especial que possui o ID 471, até aqui tudo bem, só que qualquer player do servidor irá ter acesso também, já que não possui nenhuma restrição. Como poderíamos resolver isso? É aqui que entra a função da ActionID, com ela podemos dizer que os tiles que tiverem o valor 1000 no atributo ActionID, serão os tiles referentes a área VIP. Agora temos uma maneira de diferenciar os tiles comuns dos que são VIPs, veja como ficaria: (tiles sem as ActionIDs no valor de 1000) Repare que os 3 tiles tem apenas o atributo ItemID: [471]. Todos os players poderiam passar sem problemas… Caso você use apenas esse tipo de tile para as suas áreas VIPs então não tem problema, agora se você usa esses mesmos tiles para outras finalidades, então você precisará recorrer a ActionID, para que assim consiga diferenciá-los. Vamos adicionar as ActionIDs então: (tiles com as ActionIDs adicionados no valor de 1000) Pronto, agora apenas esse tiles terão a função de controlar a entrada para a área VIP! Bom, então você deve estar se perguntando, aonde que o UniqueID entra nessa história? O UniqueID é parecido com a ActionID com apenas uma diferença. O valor que você define para ele deve ser único para o servidor inteiro, caso ele se repita aparecerá um aviso na sua distro, mais ou menos como este… Repare quantos UniqueIDs duplicados existem, isso é ruim porque quanto mais tiver mais tempo demorará para o servidor iniciar, entre outras coisas como conflitos de scripts. Concluindo… O ItemID é usado quando você quer que todos os itens com esse ID façam uma ação, por exemplo a fishing rod, qualquer player pode comprar uma no NPC e começar a pescar. A ActionID é usado geralmente quando você quer diferenciar os mesmos itens um dos outros. Eu tenho 2 crystal rings só que apenas um deles vai me curar 500 de vida quando usá-lo. O UniqueID é quando você quer definir um ID único para um determinado item e só terá apenas um dele no servidor, um exemplo seria uma estátua que vai dar ao player um determinado item e só existirá somente uma dela no jogo. Tentei ser o mais breve e direto sobre esse assunto, espero que tenha ficado claro… Agora é só praticar!
-
AJUDA NPC 8.60
@Strikerzerh Tem que criar o arquivo Traveler.xml na pasta data/npc e adicionar esse código nele. <?xml version="1.0" encoding="UTF-8"?> <npc name="Traveller" script="data/npc/scripts/traveler.lua" walkinterval="1000" floorchange="0"> <health now="100" max="100"/> <look type="128" head="96" body="99" legs="76" feet="115" addons="1"/> </npc>
-
AJUDA NPC 8.60
@Strikerzerh Boa noite XML do Npc <?xml version="1.0" encoding="UTF-8"?> <npc name="Traveller" script="data/npc/scripts/traveler.lua" walkinterval="1000" floorchange="0"> <health now="100" max="100"/> <look type="128" head="96" body="99" legs="76" feet="115" addons="1"/> </npc> Na pasta data/npc/scripts crie um arquivo chamado traveler.lua e adicione isso dentro: local TELEPORT_EFFECT = 10 local config = { ['Demonland'] = { position = { x=160, y=54, z=7 }, items = { [2160] = { count = 1 }, [2124] = { count = 1 } } }, ['Orc Hall'] = { position = { x=160, y=54, z=7 }, items = { [8299] = { count = 1 }, } }, -- [DESTINO] = { -- position = { x=160, y=54, z=7 }, -- items = { -- [ITEM_ID] = { count = QUANTIDADE_DO_ITEM }, -- } -- }, } local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end if (not checkDestinyExists(msg)) then selfSay('Este lugar nao existe. Por favor diga outro.', cid) return false end local destinyData = getDestinyData(msg) if msgcontains(string.lower(msg), string.lower(destinyData.destiny)) then local items = {} for item, data in pairs(destinyData.data.items) do if (getPlayerItemCount(cid, item) < data.count) then table.insert(items, { item = item }) end end if (#items <= 0) then removePlayerItems(cid, destinyData.data.items) doTeleportThing(cid, destinyData.data.position) doSendMagicEffect(getThingPos(cid), TELEPORT_EFFECT) selfSay('Ate mais.', cid) return true end selfSay('Voce nao possui todos os itens necessarios para viajar.', cid) end return TRUE end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) function checkDestinyExists(destiny) for dest, _ in pairs(config) do if (string.lower(dest) == string.lower(destiny)) then return true end end return false end function getDestinyData(destiny) for dest, data in pairs(config) do if (string.lower(dest) == string.lower(destiny)) then return { destiny = dest, data = data } end end end function removePlayerItems(cid, items) for item, data in pairs(items) do doPlayerRemoveItem(cid, item, data.count) end end
-
ERROR no script CRITICAL
@deza Tem que ver se essa funcao onStatsChange existe no tfs 3996, pode ser que ela esteja com outro nome
-
Alguem ajuda? [ 8.60 ]
Tem varias maneiras, da para adicionar pelo RME, usar o comando /attr actionid Numero_da_action ou criar um script que já adicione para o player essa chave ja com a actionid setada.
-
Alguem ajuda? [ 8.60 ]
@Strikerzerh Boa tarde local config = { item = 8988, -- ID ou ACTIONID que o item do player será usado, exemplo seria uma porta teleport = { position = { x=160, y=54, z=7 }, -- Posição para onde o player será teleportado effect = 10 -- Efeito do teleporte } } function onUse(cid, item, fromPos, itemEx, toPos) if (itemEx.itemid == config.item or itemEx.actionid == config.item) then doTeleportThing(cid, config.teleport.position) doSendMagicEffect(getThingPos(cid), config.teleport.effect) end return true end <action itemid="ID_ITEM" script="ARQUIVO.lua" /> ID_ITEM = É o item que o player usara para realizar a ação, exemplo de uma key Obs: Recomendo usar o item com action_id para diferencia-lo. <action actionid="ACTIONID_ITEM" script="ARQUIVO.lua" />
-
(Resolvido)onStepOut Movements
@Fiapets Vê se é isso, não testei -- Stamine Trainer -- <movevent type="StepIn" actionid="22120" event="script" value="stamine_trainer.lua"/> -- <movevent type="StepOut" actionid="22120" event="script" value="stamine_trainer.lua"/> STAMINA_MESSAGE = "Você ganhou 1 minutos de Stamina." STAMINA_TIME = 60 * 2000 STAMINA_EFFECT = 12 STAMINA_ADD = 1 ACCESS_AREA_STORAGE = 154578 ACCESS_AREA_TIME = 1 -- Tempo definido em minutos ACCESS_AREA_DENIED_MESSAGE = "Você tem que esperar " ..ACCESS_AREA_TIME.. " minuto(s) para começar acessar a area de treino novamente." function event(cid) if isPlayer(cid) then doPlayerAddStamina(cid, STAMINA_ADD) doPlayerSendTextMessage(cid, 27, STAMINA_MESSAGE) eventCheck = addEvent(event, STAMINA_TIME, cid) end end function onStepIn(cid, item, position, fromPosition, pos) if isPlayer(cid) then if (getPlayerStorageValue(cid, ACCESS_AREA_STORAGE) > os.time()) then doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, ACCESS_AREA_DENIED_MESSAGE) doTeleportThing(cid, fromPosition) return false; end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Bem-vindo a área de treino, você receberá 1 de stamina a cada 2 minutos.") eventCheck = addEvent(event, STAMINA_TIME, cid) end return true end function onStepOut(cid, item, position, fromPosition) if isPlayer(cid) then doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Você parou de treinar, agora não está mais regenerando Stamina.") stopEvent(eventCheck) setPlayerStorageValue(cid, ACCESS_AREA_STORAGE, os.time() + (ACCESS_AREA_TIME * 60)) end return true end
-
(Resolvido)Usar um item em outro e ganhar stg
@lolksky Tenta assim local config = { itemY = 2160, -- Id do item Y message = 'A mensagem que ira aparecer quando usar o item X no item Y.', storage = 412311 } function onUse(cid, item, fromPosition, itemEx, toPosition) if (itemEx.itemid == config.itemY) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, config.message) doRemoveItem(item.uid, 1) doCreatureSetStorage(cid, config.storage, 1) end return true end Na hora de checar nos outros scripts tente assim: if getCreatureStorage(cid, 412311) >= 1 then
-
Bug script action item de summon
@Gatinha Pirada Creio que seja um bug em outro script no caso auto_loot.lua que fica na pasta data/lib e no auto_loot da pasta creaturescripts/scripts/auto_loot.lua, tente trocar o valor da storage para outro.
-
Bug script action item de summon
@Gatinha Pirada Boa tarde, tente assim: local monsters = {"Druid familiar"} -- todos os monsters que podem ser summonados. local time = 30 -- tempo em minutos para usar o item novamente. local storage = 10923 -- storage qualquer, que não esteja em uso. function onUse(cid, Item, fromPosition, itemEx, toPosition) if isInArray({2,4}, getPlayerVocation(cid)) then -----> vocaciones 4 8 puede aumentar mas local summon = getCreatureSummons(cid) if (table.maxn(summon) < 1) then if getPlayerStorageValue(cid, storage) - os.time() <= 0 then local summonRandom = monsters[math.random(#monsters)] doSummonMonster(cid, summonRandom) doPlayerSendTextMessage(cid, 22, "Você summonou uma Criatura!") setPlayerStorageValue(cid, storage, os.time() + time*60) for _, pid in ipairs (getCreatureSummons(cid)) do doSendMagicEffect(getCreaturePosition(pid), 15) doCreatureSay(pid, "Vou Te Ajudar", TALKTYPE_ORANGE_1) end else doPlayerSendCancel(cid, "Voce so pode usar esse item a cada "..time.." Minuto(s).") end elseif (table.maxn(summon) > 0) then for _, pid in ipairs(getCreatureSummons(cid)) do doCreatureSay(pid, "Tchau", TALKTYPE_ORANGE_1) doSendMagicEffect(getCreaturePosition(pid), 2) doRemoveCreature(pid) end doPlayerSendTextMessage(cid, 22, "Voce Removeu A Criatura.") end else doPlayerSendTextMessage(cid, 22, "voce nao e druid.") end return true end
-
(Resolvido)Usar um item em outro e ganhar stg
@lolksky Boa noite, seria isso? local config = { itemY = 2160, -- Id do item Y message = 'A mensagem que ira aparecer quando usar o item X no item Y.', storage = 412311 } function onUse(cid, item, fromPosition, itemEx, toPosition) if (itemEx.itemid == config.itemY) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, config.message) doRemoveItem(item.uid, 1) setPlayerStorageValue(cid, config.storage, 1) end return true end <action itemid="3114" script="nomedoarquivo.lua"/>
-
(Resolvido)[TALK] -=[TFS]=- 0.4 v8.60 Queria que vendesse tudo de uma vez no comando !sellall e 1 de cada no comando !sell
@Muvuka Boa noite. local items = {} local sellTable = { [2498] = 40000, [2475] = 6000, [2497] = 9000, [2491] = 5000, [2462] = 4000, [2663] = 500, [2458] = 35, [2459] = 30, [2645] = 400000, [2195] = 40000, [2646] = 100000, [2472] = 100000, [2492] = 60000, [2494] = 90000, [2466] = 30000, [2487] = 20000, [2476] = 5000, [2656] = 15000, [2500] = 2500, [2463] = 400, [2465] = 200, [2464] = 100, [2470] = 80000, [2488] = 15000, [2477] = 6000, [2647] = 500, [2487] = 100, [2514] = 80000, [2520] = 40000, [2523] = 150000, [2522] = 100000, [2534] = 25000, [2536] = 8000, [2537] = 4000, [2519] = 5000, [2528] = 4000, [2515] = 200, [2518] = 1500, [2525] = 100, [2390] = 150000, [2408] = 100000, [2400] = 90000, [2393] = 10000, [2407] = 6000, [2396] = 4000, [2392] = 3000, [2409] = 1500, [2383] = 800, [2377] = 400, [2413] = 70, [2406] = 30, [2376] = 25, [2414] = 10000, [2431] = 90000, [2427] = 7500, [2432] = 10000, [2430] = 2000, [2387] = 200, [2381] = 200, [2378] = 100, [2388] = 20, [2391] = 6000, [2421] = 90000, [2436] = 1000, [2434] = 2000, [2423] = 200, [2417] = 60, [2398] = 30, } function get_items_container(cid, uid) local size = getContainerCap(uid) for slot = (size - 1), 0, -1 do local item = getContainerItem(uid, slot) if item.uid > 0 then if sellTable[item.itemid] then table.insert(items, item.itemid) elseif isContainer(item.uid) then get_items_container(cid, item.uid) end end end return items end function onSay(cid, words, param, channel) items = {} local backpack = getPlayerSlotItem(cid, CONST_SLOT_BACKPACK).uid if (words == "!sellall") then sellAllItems(cid, backpack) return true end if (words == "!sell") then if (param == nil) then return false end sellItem(cid, param, backpack) return true end return true end function sellItem(cid, item, backpack) local items = get_items_container(cid, backpack) if #items <= 0 then return false end local itemId = items[1] local money = sellTable[itemId] local itemName = getItemNameById(itemId) if string.lower(itemName) ~= string.lower(item) then return false end sell(cid, itemId, money) return true end function sellAllItems(cid, backpack) local items = get_items_container(cid, backpack) if #items <= 0 then return false end for i = 1, #items do local item = items[i] local money = sellTable[item] sell(cid, item, money) end return true end function sell(cid, item, money) doPlayerAddMoney(cid, money) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sold ".. getItemNameById(item) .." for ".. money .." gold.") doPlayerRemoveItem(cid, item, 1) end
-
SCRIPTS ANTIGOS
@ricardo3 Boa tarde, o script do outfit: local config = { exhaustionInSeconds = 30, storage = 34534 } function onSay(cid, words, param) if(exhaustion.check(cid, config.storage) == TRUE) then doPlayerSendCancel(cid, "You can change outfit only 1 time per " .. config.exhaustionInSeconds .. " seconds.") return TRUE end local playerGuild = getPlayerGuildId(cid) if(playerGuild == FALSE) then doPlayerSendCancel(cid, "Sorry, you're not in a guild.") return TRUE end local playerGuildLevel = getPlayerGuildLevel(cid) if(playerGuildLevel < GUILDLEVEL_LEADER) then doPlayerSendCancel(cid, "You have to be Leader of your guild to change outfits!") return TRUE end local players = getPlayersOnline() local outfit = getCreatureOutfit(cid) local message = "*Guild* Your outfit has been changed by leader. (" .. getCreatureName(cid) .. ")" local members = 0 local tmp = {} for i, tid in ipairs(players) do if(getPlayerGuildId(tid) == playerGuild and cid ~= tid) then tmp = outfit if(canPlayerWearOutfit(tid, outfit.lookType, outfit.lookAddons) ~= TRUE) then local tidOutfit = getCreatureOutfit(tid) tmp.lookType = tidOutfit.lookType tmp.lookAddons = tidOutfit.lookAddons end doSendMagicEffect(getCreaturePosition(tid), 66) doCreatureChangeOutfit(tid, tmp) doPlayerSendTextMessage(tid, MESSAGE_INFO_DESCR, message) members = members + 1 end end exhaustion.set(cid, config.storage, config.exhaustionInSeconds) doPlayerSendCancel(cid, "Guild members outfit has been changed. (Total: " .. members .. ")") return TRUE end <talkaction words="!go" event="script" value="guildOutfit.lua"/>
-
SCRIPT SLOT MACHINE "ROLETA" SIMPLES DE CASSINO PEDIDO DE SCRIPT
@Glacial08 Boa tarde, seria isso? O script não está limitado a apenas 3 slots, pode ser quantos quiser, lembrando que quanto mais slots mais difícil. Crie um arquivo chamado slotsMachine.lua em data/actions/scripts e adicione isso nele: local createdItems = {} local config = { startPos = { x = 165, y = 47, z = 7}, -- Posicao aonde o player estara para poder usar a alavanca leverIds = { from = 9825, to = 9826, }, slotsPos = { -- As posicoes dos slots { x = 164, y = 45, z = 7}, { x = 165, y = 45, z = 7}, { x = 166, y = 45, z = 7}, }, amount = 1, -- Quantidade de item que sera adicionado ao player quando ganhar items = { -- Lista de ids dos itens que irão aparecer nos slots 2160, 2148, 2471 } } function onUse(cid, item, fromPosition, itemEx, toPosition) if (playerInStartPosition(cid)) then transformLever(item) removeItemsSlots() createRandomItemsInSlots() local item = getMostRepeatedItem() if (item.count == #createdItems) then doPlayerAddItem(cid, item.id, config.amount) doBroadcastMessage("Parabens o player ".. getPlayerNameDescription(cid) .." conseguiu o item " .. getItemNameById(item.id) .. " na roleta do templo...") removeItemsSlots() end end return true end function playerInStartPosition(cid) local playerPos = getThingPos(cid) local startPos = config.startPos if (playerPos.x == startPos.x and playerPos.y == startPos.y and playerPos.z == startPos.z) then return true end return false end function transformLever(item) if (item.itemid == config.leverIds.from) then doTransformItem(item.uid, config.leverIds.to) end if (item.itemid == config.leverIds.to) then doTransformItem(item.uid, config.leverIds.from) end end function createRandomItemsInSlots() for _, pos in pairs(config.slotsPos) do local item = config.items[math.random(1, #config.items)] doCreateItem(item, pos) table.insert(createdItems, item) end end function removeItemsSlots() createdItems = {} for _, pos in pairs(config.slotsPos) do for _, itemId in ipairs(config.items) do local item = getTileItemById(pos, itemId) if (item.uid > 0) then doRemoveItem(item.uid, 1) end end end end function getMostRepeatedItem() local repeatedItems = {} for i = 1, #createdItems do local item = createdItems[i] local count = 0 for j = 1, #createdItems do if (item == createdItems[j]) then count = count + 1 end end table.insert(repeatedItems, { item = { id = item, count = count } }) end table.sort(repeatedItems, function (a, b) return a.item.count < b.item.count end) return repeatedItems[#repeatedItems].item end Actions.xml <action actionid="13001" script="slotsMachine.lua"/>
-
editar sistema de lavanca
@Carlinhous1996 Boa noite, seria isso? local config = { pos = {x=7508, y=12624, z=11}, stoneOne = 7522, stoneTwo = 7524, time = 20 -- time in seconds to remove the stone } function onUse(cid, item, fromPosition, itemEx, toPosition) local posItemOne = getTileItemById(config.pos, config.stoneOne).uid if (posItemOne > 0) then doRemoveItem(posItemOne, 1) doCreateItem(config.stoneTwo, config.pos) doPlayerSendTextMessage(cid,22,"a parede falsa foi removida.") doSendMagicEffect(config.pos, CONST_ME_MAGIC_RED) addEvent(function() local posItemTwo = getTileItemById(config.pos, config.stoneTwo).uid doRemoveItem(posItemTwo, 1) doCreateItem(config.stoneOne, config.pos) doSendMagicEffect(config.pos, CONST_ME_MAGIC_RED) end, config.time * 1000) doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945) end return true end
-
[TFS 0.4 860] {Pedido} NPC de quest de 3 etapas
@underpunk Boa tarde, seria isso? npc.xml <?xml version="1.0" encoding="UTF-8"?> <npc name="Stages" script="data/npc/scripts/stages.lua" walkinterval="2000" floorchange="0"> <health now="100" max="100"/> <look type="134" head="78" body="88" legs="0" feet="88" addons="3"/> </npc> data/npcs/scripts loadmodlib('npc_stages_config') local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} local stage = nil function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if (getPlayerStorageValue(cid, storage) == (#stages + 1)) then selfSay('Voce ja completou todos os estagios', cid) return end for storage, data in pairs(stages) do if (msg == data.msg) then data.storage = storage stage = data selfSay('Voce deseja ir para o ' ..data.msg.. ' ?', cid) talkState[talkUser] = 1 return end end if(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if (getPlayerStorageValue(cid, storage) <= 0) then setPlayerStorageValue(cid, storage, 1) end if (getPlayerStorageValue(cid, storage) == stage.storage) then doTeleportThing(cid, stage.teleport) else selfSay('Voce nao tem permissao para ir no ' ..stage.msg, cid) end stage = nil talkState[talkUser] = 0 end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) criar um arquivo chamado npc_stages_config.lua na pasta LIB e adicionar isso nele, aqui ficará toda a configuração dos estágios caso você queira adicionar mais de 3 storage = 12000 bossName = "Demon" -- Seguir na sequencia entre cochetes 1, 2, 3, 4 ... stages = { [1] = { msg = 'training 1', teleport = { x=156,y=49,z=8 } }, [2] = { msg = 'training 2', teleport = { x=156,y=54,z=9 } }, [3] = { msg = 'training 3', teleport = { x=141,y=61,z=6 } } --[4] = { msg = 'training 4', teleport = { x=0,y=0,z=0 } } } data/actions/scripts loadmodlib('npc_stages_config') function onUse(cid, item, fromPosition, itemEx, toPosition) setPlayerStorageValue(cid, storage, getPlayerStorageValue(cid, storage) + 1) return true end actions.xml <action actionid="13000" script="stages.lua"/> data/creaturescripts/scripts loadmodlib('npc_stages_config') function onKill(cid, target) local monsterName = getCreatureName(target) if (string.lower(monsterName) == string.lower(bossName)) then setPlayerStorageValue(cid, storage, (#stages + 1)) end return true end creaturescripts.xml <event type="kill" name="BossStages" event="script" value="stages.lua"/> data/creaturescripts/scripts/login.lua registerCreatureEvent(cid, "BossStages")
-
Quest diaria por IP
@Breniinx talkactions/scripts dailyQuestIpTime.lua: local storage = 18000 -- Manter essa storage igual a que esta no bau local ip = getPlayerIp(cid) function onSay(cid, words, param) if getIpStorageValue(ip, storage) - os.time() > 0 then return false end doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT,"Espere " .. timeString(getIpStorageValue(ip, storage) - os.time()) .. " para pegar um novo item!") return true end talkactions.xml: <talkaction words="/dailyTime" event="script" value="dailyQuestIpTime.lua"/> Créditos: @Vodkart
-
Help NPC que teleporta a cada 24 horas
@Gustavo0098 Boa tarde local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} local config = { position = { x = 151, y = 57, z = 7 }, -- posicao para onde o player irá timeInHours = 24, -- tempo em horas para o teleport storage = 78186 } function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid if(msgcontains(msg, 'teleport') or msgcontains(msg, 'Teleport')) then selfSay('Do you really want to teleport?', cid) talkState[talkUser] = 1 end if(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then if (getPlayerStorageValue(cid, config.storage) >= os.time()) then selfSay("Voce precisa aguardar ".. config.timeInHours .."hr(s) para se teleportar novamente", cid) talkState[talkUser] = 0 return end if (getPlayerStorageValue(cid, config.storage) <= os.time()) then addTimeTeleportAgain(cid) doTeleportThing(cid, config.position) doSendMagicEffect(getThingPos(cid), 10) selfSay('Ok', cid) talkState[talkUser] = 0 end end function addTimeTeleportAgain(cid) local time = (1 * 60 * 60) * config.timeInHours setPlayerStorageValue(cid, config.storage, os.time() + time) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new())
-
[AJUDA] ESTATUA VOCATION
@DeathRocks Tenta agora local storage = 62669 local message = "Voce nao pode treinar essa skill, escolha a estatua de sua vocacao." local config = { [1444] = { -- ID statue vocations = {4, 8}, -- Knight and Elite Knight skill = SKILL_SWORD }, [8836] = { vocations = {4, 8}, -- Knight, Elite Knight skill = SKILL_AXE }, [8834] = { vocations = {1, 2, 5, 6}, -- Sorcerer, Druid, Master Sorcerer, Elder Druid skill = SKILL__MAGLEVEL }, [8626] = { vocations = {4, 8}, -- Knight, Elite Knight skill = SKILL_CLUB }, [10353] = { vocations = {3, 7}, -- Paladin, Royal Paladin skill = SKILL_DISTANCE }, } function onUse(cid, item, fromPosition, itemEx, toPosition) for i = 1, #config[item.itemid].vocations, 1 do local vocation = config[item.itemid].vocations[i] local skill = config[item.itemid].skill if (getPlayerVocation(cid) == vocation and item.actionid == 6341) then doCreatureSetStorage(cid, storage, skill) doRemoveCreature(cid) break else doPlayerSendCancel(cid, message) end end return true end
-
[AJUDA] ESTATUA VOCATION
@DeathRocks Boa noite, tenta assim: local storage = 62669 local message = "Voce nao pode treinar essa skill, escolha a estatua de sua vocacao." local config = { [1444] = { -- ID statue vocations = {4, 8}, -- Knight and Elite Knight skill = SKILL_SWORD }, [8836] = { vocations = {4, 8}, -- Knight, Elite Knight skill = SKILL_AXE }, [8834] = { vocations = {1, 2, 5, 6}, -- Sorcerer, Druid, Master Sorcerer, Elder Druid skill = SKILL__MAGLEVEL }, [8626] = { vocations = {4, 8}, -- Knight, Elite Knight skill = SKILL_CLUB }, [10353] = { vocations = {3, 7}, -- Paladin, Royal Paladin skill = SKILL_DISTANCE }, } function onUse(cid, item, fromPosition, itemEx, toPosition) for i = 1, #config[item.itemid].vocations, 1 do local vocation = config[item.itemid].vocations[i] local skill = config[item.itemid].skill if (getPlayerVocation(cid) == vocation) then doCreatureSetStorage(cid, storage, skill) break else doPlayerSendCancel(cid, message) end end if item.actionid == 6341 then doRemoveCreature(cid) end return true end
-
(Resolvido)Como arrumar o npc que da vocation apos level 200?
@juvelino Opa, não testei mais creio que é isso: local config = { storage = 457771, cost = 1000000, -- Quantidade em gold (1000000 = 1kk) minimumLevel = 200, -- Level minimo necessario vocation = { sorcerer = { id = 1, name = "Sorcerer"}, druid = { id = 2, name = "Druid"}, paladin = { id = 3, name = "Paladin"}, knight = { id = 4, name = "Knight"}, } } local keywordHandler = KeywordHandler:new() local npcHandler = NpcHandler:new(keywordHandler) NpcSystem.parseParameters(npcHandler) local talkState = {} function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end function onThink() npcHandler:onThink() end local choose = {} local cancel = {} local available = {} function creatureSayCallback(cid, type, msg) if(not npcHandler:isFocused(cid)) then return false end local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_PRIVATE and 0 or cid if(msgcontains(msg, "info")) then selfSay("Olá "..getCreatureName(cid)..", Você quer trocar de vocação, digite o nome da sua proxima vocação. Temos Sorcerer, Druid, Knight e Paladin.", cid) talkState[talkUser] = 1 if canChangeVocation(cid) == false then selfSay("Desculpe, mais voce so pode trocar de vocacao apenas uma vez", cid) talkState[talkUser] = 0 return false end if haveEnoughLevel(cid) == false then selfSay("Desculpe, voce nao possui level suficiente", cid) talkState[talkUser] = 0 return false end removeMoney(cid) elseif msgcontains(msg, "sorcerer") or msgcontains(msg, "SORCERER") and talkState[talkUser] == 1 then addVocation(cid, config.vocation.sorcerer.id, config.vocation.sorcerer.name) elseif msgcontains(msg, "druid") or msgcontains(msg, "DRUID") and talkState[talkUser] == 1 then addVocation(cid, config.vocation.druid.id, config.vocation.druid.name) elseif msgcontains(msg, "paladin") or msgcontains(msg, "PALADIN") and talkState[talkUser] == 1 then addVocation(cid, config.vocation.paladin.id, config.vocation.paladin.name) elseif msgcontains(msg, "KNIGHT") or msgcontains(msg, "KNIGHT") and talkState[talkUser] == 1 then addVocation(cid, config.vocation.knight.id, config.vocation.knight.name) elseif(msgcontains(msg, "bye") or msgcontains(msg, "goodbye") or msgcontains(msg, "cya")) then selfSay("cya!", cid, TRUE) closeShopWindow(cid) removeFocus(cid) end end function canChangeVocation(cid) if getPlayerStorageValue(cid, config.storage) <= 0 then return true end return false end function haveEnoughLevel(cid) if getPlayerLevel(cid) >= config.minimumLevel then return true end return false end function removeMoney(cid) if getPlayerMoney(cid) < config.cost then selfSay("Voce nao possui dinheiro suficiente.", cid) return false end doPlayerRemoveMoney(cid, config.cost) end function addVocation(cid, id, name) doPlayerSetVocation(cid, id) selfSay("Parabéns, você virou um "..name, cid) broadcastMessage("O jogador "..getCreatureName(cid).." virou um "..name) setPlayerStorageValue(cid, config.storage, 1) end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Na parte que o npc não estar adicionando a vocação, voce pode checar em data/XML o arquivo de vocations.xml acho que bug pode estar lá, vou deixar um exemplo do script padrão dele: (Tente alterar para o script abaixo e faça o teste se irá funcionar) <?xml version="1.0" encoding="UTF-8"?> <vocations> <vocation id="0" name="None" description="none" needpremium="0" gaincap="5" gainhp="5" gainmana="5" gainhpticks="6" gainhpamount="1" gainmanaticks="6" gainmanaamount="2" manamultiplier="4.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="0" attackable="no"> <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/> <skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/> </vocation> <vocation id="1" name="Sorcerer" description="a sorcerer" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="12" gainhpamount="1" gainmanaticks="3" gainmanaamount="2" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="1"> <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/> <skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/> </vocation> <vocation id="2" name="Druid" description="a druid" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="12" gainhpamount="1" gainmanaticks="3" gainmanaamount="2" manamultiplier="1.1" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="2"> <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/> <skill fist="1.5" club="1.8" sword="1.8" axe="1.8" distance="1.8" shielding="1.5" fishing="1.1" experience="1.0"/> </vocation> <vocation id="3" name="Paladin" description="a paladin" needpremium="0" gaincap="20" gainhp="10" gainmana="15" gainhpticks="8" gainhpamount="1" gainmanaticks="4" gainmanaamount="2" manamultiplier="1.4" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="3"> <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/> <skill fist="1.2" club="1.2" sword="1.2" axe="1.2" distance="1.1" shielding="1.1" fishing="1.1" experience="1.0"/> </vocation> <vocation id="4" name="Knight" description="a knight" needpremium="0" gaincap="25" gainhp="15" gainmana="5" gainhpticks="6" gainhpamount="1" gainmanaticks="6" gainmanaamount="2" manamultiplier="3.0" attackspeed="2000" soulmax="100" gainsoulticks="120" fromvoc="4"> <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/> <skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/> </vocation> <vocation id="5" name="Master Sorcerer" description="a master sorcerer" needpremium="1" gaincap="10" gainhp="5" gainmana="30" gainhpticks="12" gainhpamount="1" gainmanaticks="2" gainmanaamount="2" manamultiplier="1.1" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="1" lessloss="30"> <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/> <skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/> </vocation> <vocation id="6" name="Elder Druid" description="an elder druid" needpremium="1" gaincap="10" gainhp="5" gainmana="30" gainhpticks="12" gainhpamount="1" gainmanaticks="2" gainmanaamount="2" manamultiplier="1.1" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="2" lessloss="30"> <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/> <skill fist="1.5" club="1.8" sword="1.8" axe="1.8" distance="1.8" shielding="1.5" fishing="1.1" experience="1.0"/> </vocation> <vocation id="7" name="Royal Paladin" description="a royal paladin" needpremium="1" gaincap="20" gainhp="10" gainmana="15" gainhpticks="6" gainhpamount="1" gainmanaticks="3" gainmanaamount="2" manamultiplier="1.4" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="3" lessloss="30"> <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/> <skill fist="1.2" club="1.2" sword="1.2" axe="1.2" distance="1.1" shielding="1.1" fishing="1.1" experience="1.0"/> </vocation> <vocation id="8" name="Elite Knight" description="an elite knight" needpremium="1" gaincap="25" gainhp="15" gainmana="5" gainhpticks="4" gainhpamount="1" gainmanaticks="6" gainmanaamount="2" manamultiplier="3.0" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="4" lessloss="30"> <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/> <skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/> </vocation> <!-- <vocation id="9" name="Epic Master Sorcerer" description="an epic master sorcerer" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="12" gainhpamount="1" gainmanaticks="1" gainmanaamount="2" manamultiplier="1.1" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="5" lessloss="50"> <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/> <skill fist="1.5" club="2.0" sword="2.0" axe="2.0" distance="2.0" shielding="1.5" fishing="1.1" experience="1.0"/> </vocation> <vocation id="10" name="Epic Elder Druid" description="an epic elder druid" needpremium="0" gaincap="10" gainhp="5" gainmana="30" gainhpticks="12" gainhpamount="1" gainmanaticks="1" gainmanaamount="2" manamultiplier="1.1" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="6" lessloss="50"> <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/> <skill fist="1.5" club="1.8" sword="1.8" axe="1.8" distance="1.8" shielding="1.5" fishing="1.1" experience="1.0"/> </vocation> <vocation id="11" name="Epic Royal Paladin" description="an epic royal paladin" needpremium="0" gaincap="20" gainhp="10" gainmana="15" gainhpticks="3" gainhpamount="1" gainmanaticks="2" gainmanaamount="2" manamultiplier="1.4" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="7" lessloss="50"> <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/> <skill fist="1.2" club="1.2" sword="1.2" axe="1.2" distance="1.1" shielding="1.1" fishing="1.1" experience="1.0"/> </vocation> <vocation id="12" name="Epic Elite Knight" description="an epic elite knight" needpremium="0" gaincap="25" gainhp="15" gainmana="5" gainhpticks="2" gainhpamount="1" gainmanaticks="6" gainmanaamount="2" manamultiplier="3.0" attackspeed="2000" soulmax="200" gainsoulticks="15" fromvoc="8" lessloss="50"> <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/> <skill fist="1.1" club="1.1" sword="1.1" axe="1.1" distance="1.4" shielding="1.1" fishing="1.1" experience="1.0"/> </vocation> --> </vocations>
-
(Resolvido)Tile que gasta soul ao entrar
@deza Boa noite, não testei o script mais acho que seria isso em data/movements crie um arquivo chamado soul.lua e cole isso nele local config = { soul = 10, -- Quantidade de soul que será removida message = { text = "Voce nao possui soul suficiente para passar aqui", color = MESSAGE_STATUS_CONSOLE_BLUE } } function onStepIn(cid, item, position, fromPosition) local playerSoul = getPlayerSoul(cid) if not isPlayer(cid) then return false end if playerSoul < config.soul then doPlayerSendTextMessage(cid, config.message.color, config.message.text) doTeleportThing(cid, fromPosition) return false end doPlayerAddSoul(cid, -config.soul) return true end em movements.xml adicione esta linha nele: <movevent event="StepIn" actionid="XXXX" script="soul.lua" /> Aonde esta XXXX você coloca o actionId do tile que ativará o script
-
Complementar Script
Só alterar a ultima função por essa aqui: Lembre-se que a variável "z" na configuração tem que ser do menor para o maior, caso contrario pode dar erro. Exemplo: { { x = 10, y = 12, z = 4 }, { x = 11, y = 12, z = 7 } }. function teleportarJogadoresEmArea() for x = config.area[1].x, config.area[2].x do for y = config.area[1].y, config.area[2].y do for z = config.area[1].z, config.area[2].z do local pos = {x=x, y=y, z=z} local player = getTopCreature(pos).uid if isPlayer(player) then doTeleportThing(player, config.togo) end end end end end
-
Complementar Script
@Doidodepeda Boa tarde, tenta assim: Altere a variável "area" na config, para a área aonde você quer que os players estejam para serem teleportados. local config = { tempo = 1*60, pos = {x=405, y=155, z=7, stackpos = 253}, area = { { x=100, y=100, z=7 }, { x=100, y=100, z=7 } }, tp = {x=167, y=43, z=7}, togo = {x=395, y=147, z=7}, premio = 12681, count = 5, effect = 27 } function onSay(cid, words, param, channel) doBroadcastMessage("The fight for the throne has begun, the last man standing there after "..config.tempo/60 .." minute(s) will be the winner.", 21) doCreateTeleport(1387, config.togo, config.tp) for j = 0, (config.tempo -1) do addEvent(function() doBroadcastMessage("Time left: ".. config.tempo - j .." second(s)", 25) end, (50+(j*1000))) end addEvent(function() if isPlayer(getThingFromPos(config.pos).uid) then local cid = getThingFromPos(config.pos).uid doBroadcastMessage("The winner is "..getCreatureName(cid)..".", 21) doPlayerAddItem(cid, config.premio, config.count) doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid))) doSendMagicEffect(config.pos, config.effect) else doBroadcastMessage("We didn't had a winner.. so sad!", 21) end doRemoveItem(getTileItemById(config.tp, 1387).uid, 1) teleportarJogadoresEmArea() end, 1000*config.tempo) end function teleportarJogadoresEmArea() for x = config.area[1].x, config.area[2].x do for y = config.area[1].y, config.area[2].y do local pos = {x=x, y=y, z=config.area[1].z} local player = getTopCreature(pos).uid if isPlayer(player) then doTeleportThing(player, config.togo) end end end end Créditos: @WooX
-
Reflect stones (storage)
@FearWar data\creaturescripts\scripts crie um arquivo chamado reflectStone.lua e adicione isso nele: local lvldodge = 48903 local percent = 0.5 function onStatsChange(cid, attacker, type, combat, value) if type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS and isCreature(attacker) then if (getPlayerStorageValue(cid, lvldodge)*3) >= math.random (0,1000) then value = math.ceil(value*(percent)) doCreatureAddHealth(attacker, -value) doSendAnimatedText(getCreaturePos(cid), "Reflected!", 6) return false end end return true end creaturescripts.xml: <event type="statschange" name="ReflectStone" event="script" value="reflectStone.lua"/> login.lua: registerCreatureEvent(cid, "ReflectStone")