
Tudo que Wise postou
-
Duvida básica sobre return
Certo. Porém, não deixa de ser incorreto em Lua.
-
Duvida básica sobre return
Calma. nil significa nulo, é um valor nulo. Em outras linguagens de programação, 0 e 1 representam false e true (respectivamente), como você disse. Porém, em Lua, o correto é fazer uso dos valores booleanos true e false. O que acontece, é que provavelmente, alguns (ou a maioria) dos servidores de open tibia devem ter algo declarando que true = 1 e false = 0. Na linguagem Lua (em si), se você retornar 1, irá simplesmente resultar no número 1 (sem alterações provenientes disso).
-
(Resolvido)TP monster
Não tem necessidade de criar uma função pra remover o item. Caso prefira, já corrigi: local tps = { ["Bazir"] = {pos = {x=1851, y=642, z=8}, toPos = {x=1866, y=642, z=8}, time = 30} } function onDeath(cid) local tpId = 1387 local tp = tps[getCreatureName(cid)] if tp then doCreateTeleport(tpId, tp.toPos, tp.pos) doCreatureSay(cid, "O teleport irá sumir em "..tp.time.." segundos.", TALKTYPE_ORANGE_1) local t = getTileItemById(tp.pos, tpId) if t.uid > 0 then addEvent(doRemoveItem, tp.time*1000, t.uid, 1) end end return true end
-
pedido script simples valendo rep +
Certo, tente: local s = {} local cspeed = createConditionObject(CONDITION_HASTE) setConditionParam(cspeed, CONDITION_PARAM_TICKS, -1) setConditionParam(cspeed, CONDITION_PARAM_SPEED, #s) local o = {} local outfit = createConditionObject(CONDITION_OUTFIT) setConditionParam(outfit, CONDITION_PARAM_TICKS, -1) setConditionParam(outfit, CONDITION_PARAM_OUTFIT, {lookType = #o}) function onSay(cid) speed = 30 -- % level = 120 outfit = { [0] = 123, -- female [1] = 234 -- male } if getPlayerLevel(cid) >= level then if getCreatureOutfit(cid).lookType ~= outfit[getPlayerSex(cid)] then table.insert(s, speed * (getCreatureSpeed(cid) / 100)) table.insert(o, outfit[getPlayerSex(cid)]) doAddCondition(cid, cspeed) doAddCondition(cid, outfit) doSendMagicEffect(getThingPos(cid), CONST_ME_STUN) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You\'re now '..speed..'% faster.') else doRemoveCondition(cid, CONDITION_HASTE) doRemoveCondition(cid, CONDITION_OUTFIT) end else doPlayerSendCancel(cid, 'You need at least level '..level..' to use this command.') end return true end
-
Pedido comando !reset
Fiz para que o player só possa resetar dentro de uma protection zone e para que ele fique imóvel até que seja removido do jogo. reset.lua (data\talkactions\scripts): function onSay(cid) local lvl = {1000, 100} -- {minLevel, newLevel} local time = 5 -- time to logout if getTileInfo(getThingPos(cid)).protection then if getPlayerLevel(cid) >= lvl[1] then db.executeQuery("UPDATE `players` SET `level`="..lvl[2]..",`experience`= "..getExperienceForLevel(lvl[2]).." WHERE `players`.`id`= "..getPlayerGUID(cid).."") doCreatureSetNoMove(cid, true) addEvent(doRemoveCreature, time * 1000, cid, true) doPlayerSendTextMessage(last, MESSAGE_INFO_DESCR, 'You will be logged out within '..time..' seconds.') else doPlayerSendCancel(cid, 'You need at least level '..lvl[1]..' to reset.') end else doPlayerSendCancel(cid, 'You can only reset within a protected zone.') end return true end Tag - talkactions.xml (data\talkactions): <talkaction words="!reset" event="script" value="reset.lua"/>
-
(Resolvido)TP monster
local tps = { ["Bazir"] = {pos = {x=1851, y=642, z=8}, toPos = {x=1866, y=642, z=8}, time = 30} } function onDeath(cid) local tpId = 1387 local tp = tps[getCreatureName(cid)] if tp then doCreateTeleport(tpId, tp.toPos, tp.pos) doCreatureSay(cid, "O teleport irá sumir em "..tp.time.." segundos.", TALKTYPE_ORANGE_1) local t = getTileItemById(tp.pos, tpId) if t.uid > 0 then addEvent(doRemoveItem, tp.time*1000, t.uid, 1) end end return true end
- Item para o last hit / mais dano
-
Item para o last hit / mais dano
Ambos (lasthitkiller / mostdamagekiller) recebem um item? Se for: bossreward.lua (data\creaturescripts\scripts): local lasthit = {5432, 1} -- lasthitkiller = {itemid, amount} local mostdmg = {5432, 1} -- mostdamagekiller = {itemid, amount} function doPlayerAddDepotItems(pid, item, count) -- function by magus - modified by vodkart local item, count = {item}, {(count or 1)} for k, v in ipairs(item) do local ls = db.getResult("SELECT `sid` FROM `player_depotitems` WHERE `player_id` = "..pid.." ORDER BY `sid` DESC LIMIT 1") return db.executeQuery("INSERT INTO `player_depotitems` (`player_id`, `sid`, `pid`, `itemtype`, `count`, `attributes`) VALUES ("..pid..", "..(ls:getDataInt("sid")+1)..", 101, "..v..", "..count[k]..", '')") or false end end function onDeath(cid, corpse, deathList) local last, most = deathList[1], deathList[2] if isPlayer(last) then if getPlayerFreeCap(last) > getItemWeightById(lasthit[1], lasthit[2]) then doPlayerAddItem(last, lasthit[1], lasthit[2]) doPlayerSendTextMessage(last, MESSAGE_INFO_DESCR, 'You have received a reward for being the player that gave the last hit on the BOSS.') else doPlayerAddDepotItems(last, lasthit[1], lasthit[2]) doPlayerSendTextMessage(last, MESSAGE_STATUS_CONSOLE_BLUE, 'You have received a reward for being the player that gave the last hit on the BOSS. But you don\'t have enought cap, so it was sent to your depot.') end end if isPlayer(most) then if getPlayerFreeCap(most) > getItemWeightById(mostdmg[1], mostdmg[2]) then doPlayerAddItem(most, mostdmg[1], mostdmg[2]) doPlayerSendTextMessage(most, MESSAGE_INFO_DESCR, 'You have received a reward for being the player that gave the most damage on the BOSS.') else doPlayerAddDepotItems(most, mostdmg[1], mostdmg[2]) doPlayerSendTextMessage(most, MESSAGE_STATUS_CONSOLE_BLUE, 'You have received a reward for being the player that gave the most damage on the BOSS. But you don\'t have enought cap, so it was sent to your depot.') end end return true end Tag - creaturescripts.xml (data\creaturescripts): <event type="death" name="BOSSReward" event="script" value="bossreward.lua"/> Registre o creature event no XML do monster: <script> <event name="BOSSReward"/> </script>
-
Duvida básica sobre return
Return é um comando (uma função "disfarçada"). Ele é usado para retornar valores de uma função ou trecho, sempre sendo escrito no fim de um bloco. Em Lua, se você retornar 0, 1 ou qualquer valor, irá retornar 0, 1 ou esse valor. Para determinar o resultado de um callback, de modo que o mesmo possa ou não ser executado, o correto é fazer uso dos valores booleanos true / false (a menos que a função em questão seja para retornar um valor específico, como uma string/algarismo/tabela/variável/função/qualquer coisa).
-
(Resolvido)Ao equipar um item X no meu slot serta vocartion mudara a outfit
@Tuka Pronto, tente.
-
Estágio
É perceptível que a sua vontade de ajudar é imensa. Espero que consiga realizar tais feitos. Parabéns e seja bem vindo ;]
- [TUTORIAL] (GOD) Ambient Light
-
(Resolvido)Ao equipar um item X no meu slot serta vocartion mudara a outfit
local tab = { [1] = {outfit = 123}, -- [vocID] = {outfit = lookTypeNumber} [300] = {outfit = 456} } local h, m = {50, 3}, {25, 3} -- {amount, seconds to regenerate} local regain = createConditionObject(CONDITION_REGENERATION) setConditionParam(regain, CONDITION_PARAM_TICKS, -1) setConditionParam(regain, CONDITION_PARAM_HEALTHGAIN, h[1]) setConditionParam(regain, CONDITION_PARAM_HEALTHTICKS, h[2] * 1000) setConditionParam(regain, CONDITION_PARAM_MANAGAIN, m[1]) setConditionParam(regain, CONDITION_PARAM_MANATICKS, m[2] * 1000) function onEquip(cid, item, slot) doSetCreatureOutfit(cid, {lookType = tab[getPlayerVocation(cid)].outfit}, -1) doChangeSpeed(cid, getCreatureSpeed(cid) + 50) doAddCondition(cid, regain) return true end function onDeEquip(cid, item, slot) doChangeSpeed(cid, getCreatureSpeed(cid) - 50) doRemoveCondition(cid, CONDITION_REGENERATION) doRemoveCondition(cid, CONDITION_OUTFIT) return true end Nesse caso, vai regenerar 50 de hp e 25 de mana a cada 3 segundos.
-
(Resolvido)[PEDIDO] - Alavanca System
Quando ela for utilizada (se for utilizada) em outro script, provavelmente vai ter o valor redefinido. Então, não.
- Quest e Comando de Loop Effect
-
(Resolvido)[PEDIDO] - Alavanca System
Relaxa, não precisa e não tem de quê. Disponha.
-
(Resolvido)[PEDIDO] - Alavanca System
Não precisa. Do modo como fiz, só são verificadas as posições x e y. Se não houver um outro item com o mesmo actionid/uniqueid em outros andares nas mesmas posições x e y, não precisa verificar a posição z.
- BUFF JUNTO A OUTRO BUFF
-
[PEDIDO] Alavanca
lever.lua (data\actions\scripts): function onUse(cid) itemid = 1234 pos = {x=123, y=456, z=7} -- item position item = getTileItemById(pos, itemid) if item.uid > 0 then doRemoveItem(item.uid) doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'The '..getItemNameById(itemid)..' was removed.') else doCreateItem(itemid, 1, pos) doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, 'The '..getItemNameById(itemid)..' was created.') end return true end Tag - actions.xml (data\actions): <action actionid="54321" script="lever.lua"/>
-
Script sumon com bug (doconvincecreature not found)
Caso prefira: function onCastSpell(cid, var) max = 3 name = 'Demon' summons = getCreatureSummons(cid) if #summons < max then if getClosestFreeTile(cid, getCreaturePosition(cid)) then doSummonMonster(cid, name) else doPlayerSendCancel(cid, 'Não há espaço para criar o summon.') end else doPlayerSendCancel(cid, 'Você só pode criar '..max..' '..name..'\'s.') end return true end
-
(Resolvido)[PEDIDO] - Alavanca System
function onUse(cid, fromPos, toPos) pos = {x=123, y=456} -- de onde newpos = {x=1369, y=1026, z=8} -- para onde cpos = getCreaturePosition(cid) if cpos.x == pos.x and cpos.y == pos.y then doTeleportThing(cid, newpos) doSendMagicEffect(toPos, CONST_ME_TELEPORT) doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have been teleported.') else doPlayerSendCancel(cid, 'You need to stay in the correct floor to be teleported.') end return true end
-
Ajuda Mount
Informe o script referente aos items das mounts, se possível. E também, verifique se as tags das mounts existem e/ou se estão corretamente estipuladas em seu mounts.xml (data/XML). O tópico foi movido para a área correta, preste mais atenção da próxima vez! Leia as regras do fórum: http://tibiaking.com/forum/topic/1281-regras-gerais/?p=7680 Este tópico foi movido: De: "OTServ → Suporte OTServ → Suporte de Clients" Para: "OTServ → Suporte OTServ → Suporte de Scripts"
-
Cassino Script HELP
O tópico foi movido para a área correta, preste mais atenção da próxima vez! Leia as regras do fórum: http://tibiaking.com/forum/topic/1281-regras-gerais/?p=7680 Este tópico foi movido: De: "OTServ → Suporte OTServ → Suporte de Scripts" Para: "Bots para Tibia → Suporte Bots"
-
Tirar Battle ao entrar em PZ
@kabesudao Tente: function onThink(cid) if isPlayer(cid) and getTileInfo(getThingPos(cid)).protection and getCreatureCondition(cid, CONDITION_INFIGHT) then doRemoveCondition(cid, CONDITION_INFIGHT) end return true end
-
(Resolvido)Pedido, script de Quest
Eu havia feito um script semelhante para outro membro há alguns dias. uchests.lua (data\actions\scripts): local t = { -- [uniqueID] = {vocs = {vocationIDs}, items = {itemIDs}} [55001] = {vocs = {4, 8}, items = {1234}}, -- club ~ knights [55002] = {vocs = {4, 8}, items = {1234}}, -- axe ~ knights [55003] = {vocs = {4, 8}, items = {1234}}, -- sword ~ knights [55004] = {vocs = {1, 2, 5, 6}, items = {1234}}, -- mages [55005] = {vocs = {3, 7}, items = {1234, 5678}} -- paladins } function onUse(cid, item, fromPos, toPos) storage = 54321 u = t[item.uid] if not u then return false end if isInArray(u.vocs, getPlayerVocation(cid)) then if getPlayerStorageValue(cid, storage) < 1 then setPlayerStorageValue(cid, storage, 1) for i = 1, #u.items do doPlayerAddItem(cid, u.items[i], 1) end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You got your reward for completing the quest.') else doPlayerSendCancel(cid, 'You already have done this quest.') end else doPlayerSendCancel(cid, 'Your vocation is not allowed to do this quest.') end return true end Tag - actions.xml (data\actions): <action uniqueid="55001-55005" event="script" value="uchests.lua"/> Basta adicionar aos baús, os uniqueids compatíveis com a configuração da tabela, sendo no exemplo acima: 55001 - Club (Knight, Elite Knight) 55002 - Axe (Knight, Elite Knight) 55003 - Sword (Knight, Elite Knight) 55004 - Staff (Sorcerer, Druid, Master Sorcerer, Elder Druid) 55005 - Bow / Arrow (Paladin, Royal Paladin)