-
-
-
-
-
-
Spraiinedweb reagiu a uma resposta no tópico: [AULA] Entendendo a diferença entre ItemID, ActionID e UniqueID
-
-
Vodkart reagiu a uma resposta no tópico: [AULA] Entendendo a diferença entre ItemID, ActionID e UniqueID
-
So volto tarde reagiu a uma resposta no tópico: [AULA] Entendendo a diferença entre ItemID, ActionID e UniqueID
-
FeeTads reagiu a uma resposta no tópico: [AULA] Entendendo a diferença entre ItemID, ActionID e UniqueID
-
-
[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