Ir para conteúdo

shanden4502

Membro
  • Registro em

  • Última visita

Tudo que shanden4502 postou

  1. eu uso tfs 1.2 estou a dias quebrando cabeça com o opcodes, queria enviar uma função no cliente executar ela, já vi diversos topicos, mas ainda sim não rola, eu não quero que façam nada somente me ajudem a entender eu percebi que na lib /data/lib/core/player.lua há isso.. function Player.sendExtendedOpcode(self, opcode, buffer) if not self:isUsingOtClient() then return false end local networkMessage = NetworkMessage() networkMessage:addByte(0x32) networkMessage:addByte(opcode) networkMessage:addString(buffer) networkMessage:sendToPlayer(self) networkMessage:delete() retu eu tenho q usar a função Player.sendExtendedOpcode, para enviar um opcode pro cliente correto? mas como eu posso fazer isso? ela precisa estar dentro do creaturescripts junto com a onExtendedOpcode? ou não necessariamente ? eu estou tentando algo como: Player.sendExtendedOpcode(115, getWorldLight()) esta errado? eu quero enviar a função getWorldLight para o cliente pra receber eu uso ProtocolGame.registerExtendedOpcode(115, (TESTE) e coloco em init, até ai ok e em terminate ProtocolGame.unregisterExtendedOpcode(115) e também na module eu coloco: function TESTE(getWorldLight()) local protocolGame = g_game.getProtocolGame() if protocolGame then if getWorldLight <= 160 then Image:setVisible(true) else Image:hide() end end eu simplesmente quero utilizar a função getWorldLight para ele ativar ou desativar uma imagem no cliente, estou a dias tentando, minha ultima opção pra tentar entender como usar esse opcodes foi recorrer aqui ;//
  2. Boa noite, então eu tenho esse codigo: local STORAGE_SKILL_LEVEL = 10009 local STORAGE_SKILL_TRY = 10007 local config = { levels = { {level = {0,9}, quant = {1,1}, percent = 5}, {level = {10,19}, quant = {1,1}, percent = 10}, {level = {20,29}, quant = {1,1}, percent = 15}, {level = {30,39}, quant = {1,1}, percent = 20}, {level = {40,49}, quant = {1,1}, percent = 25}, {level = {50,59}, quant = {1,1}, percent = 30}, {level = {60,69}, quant = {1,1}, percent = 30}, {level = {70,79}, quant = {1,1}, percent = 35}, {level = {80,89}, quant = {1,1}, percent = 35}, {level = {90,99}, quant = {1,1}, percent = 40}, {level = {100}, quant = {1,1}, percent = 50} }, rocks = {5092}, -- Id das rochas que podem ser quebradas rocks2 = {5093}, rocks3 = {5094}, rocks4 = {5095}, stones = {5097}, -- Modelo = {rock_id, rock_id} stones2 = {5099}, stones3 = {5100}, stones4 = {5098}, rock_delay = 60, -- Tempo de volta da rocha (Em segundos) bonus_chance = 3, -- Chance (em porcentagem) de se conseguir um bonus de exp bonus_exp = 1 -- Bonus extra } ------------------------------------ -- END Configurations --- ------------------------------------ function getCuttingLevel(cid) return getPlayerStorageValue(cid, STORAGE_SKILL_LEVEL) end function setPlayerCuttingLevel(cid, n) setPlayerStorageValue(cid, STORAGE_SKILL_LEVEL, n) end function addCuttingLevel(cid, n) setPlayerCuttingLevel(cid, getCuttingLevel(cid) + (isNumber(n) and n or 1)) setCuttingTry(cid, 0) end function getCuttingInfo(cid) for i = 1, #config.levels do min = config.levels[i].level[1]; max = config.levels[i].level[2] if (getCuttingLevel(cid) >= min and getCuttingLevel(cid) <= max) then return {quantity = {min = config.levels[i].quant[1], max = config.levels[i].quant[2]}, chance = config.levels[i].percent} end end end function getStoneByRock(rockid) for i = 1, #config.stones do if (config.stones[2] == rockid) then return config.stones[1] elseif (config.stones2[3] == rockid2) then return config.stones2[4] end end end function getCuttingTries(cid) return getPlayerStorageValue(cid, STORAGE_SKILL_TRY) end function setCuttingTry(cid, n) setPlayerStorageValue(cid, STORAGE_SKILL_TRY, n) end function addCuttingTry(cid, bonus) setCuttingTry(cid, getCuttingTries(cid) + 1 + (bonus and config.bonus_exp or 0)) if (getCuttingTries(cid) >= getCuttingExpTo(getCuttingLevel(cid))) then -- Up doPlayerSendTextMessage(cid, 22, "You advanced from level " .. getCuttingLevel(cid) .. " to level ".. (getCuttingLevel(cid) + 1) .." in miner.") if ((getCuttingLevel(cid)+1) == getCuttingMaxLevel()) then doPlayerSendTextMessage(cid, 22, "Max level reached in miner.") end addCuttingLevel(cid) doSendMagicEffect(getCreaturePosition(cid), math.random(28,30)) setCuttingTry(cid, 0) end end function getCuttingExpTo(level) return ((level*1.5)+((level+1)*7)) end function getCuttingMaxLevel() return config.levels[#config.levels].level[#config.levels[#config.levels].level] end --------------------------- function onUse(cid, item, fromPosition, itemEx, toPosition) rock = { id = itemEx.itemid, uid = itemEx.uid, position = toPosition } player = { position = getCreaturePosition(cid) } if (getCuttingLevel(cid) < 0) then setPlayerCuttingLevel(cid, 0) end if (isInArray(config.rocks, rocks2, rocks3, rocks4, rock.id, rock.id2, rock.id3, rock.id4)) then addCuttingTry(cid) if (math.random(1,100) <= getCuttingInfo(cid).chance) then local collected = math.random(getCuttingInfo(cid).quantity.min, getCuttingInfo(cid).quantity.max) doPlayerAddItem(cid, getStoneByRock(rock.id), collected) doPlayerSendTextMessage(cid, 22, "You got " .. collected .. " brass" .. (collected > 1 and "s" or "") .. " ore.") if (math.random(1,100) <= config.bonus_chance) then -- Bonus calc addCuttingTry(cid, true) doSendAnimatedText(player.position, "Bonus!", COLOR_ORANGE) end event_rockCut(rock) else if (math.random(0,100) <= (0-getCuttingInfo(cid).chance/0)) then doPlayerSendTextMessage(cid, 22, "You got nothing.") event_rockCut(rock) else doSendMagicEffect(rock.position, 3) doSendAnimatedText(rock.position, "Poff!", COLOR_GREEN) end end else doPlayerSendCancel(cid, "This can't be cut.") end end function event_rockCut(rock) addEvent(event_rockGrow, config.rock_delay * 1000, rock.position, rock.id) doTransformItem(rock.uid, 5104) doSendMagicEffect(rock.position, 3) doSendAnimatedText(rock.position, "Tack!", COLOR_GREEN) doItemSetAttribute(rock.uid, "name", "A trunk of " .. getItemNameById(rock.id)) end function event_rockGrow(rockPos, old_id) local rock = getThingFromPos(rockPos).uid doTransformItem(rock, old_id) doItemSetAttribute(rock, "name", getItemNameById(old_id)) doSendMagicEffect(rockPos, 3) end eu estou tentando editar para que dependendo da pedra, exemplo, 5092, venha o minerio 5097 e somente ele, eu tentei: if (config.stones[2] == rockid) then return config.stones[1] elseif (config.stones2[3] == rockid2) then return config.stones2[4] end mas não estou tendo resultado nenhum, nem erro, alguem poderia me dar uma luz?
  3. quando se mexe na função de de diminuir ou aumentar o campo de visão, o nome não fica fixo como o padrão, ele vai junto, desregulando tudo.
  4. Eu tenho um script de offline training no meu server e uso otclient, eu notei que na barra do otclient tem a função do CheckTime do OFF-Line Training, se eu conseguir adaptar ele vai informar o time? na aba de skills?, eu dei uma editada e apareceu a função lá só que sem tempo, isso é possivel ? sem ter q editar sources
  5. shanden4502 postou uma resposta no tópico em Suporte Tibia OTServer
    Olá, estou implementando sistemas no meu atual server 7.60, e queria saber qual é o nome daquele sistema do tibia que muda a cor na hora de falar com o npc, exemplo quando você fala Hi pro NPC, a opção TRADE fica com a cor do amarelo queimado? Já tentei colocar {trade}, mas ele ignora os {}, e não muda a cor.
  6. eu estou usando OTC, seria trabalhoso?, achei a função em uma source que ela esta habilitada 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 local talkUser,msg = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid,string.lower(msg) local weaponsTypes = {"head", "armor", "legs", "feet", "shield", "sword", "wand", "rod", "club", "axe", "distance", "ammunition", "others", "all"} if isInArray({'apprise', 'check', 'items', 'item', 'list'}, msg) then local qry,k,str = db.getResult("SELECT `item_id`, `count`, `price` FROM `shop_npc` WHERE `player_id` = "..getPlayerGUID(cid)),0,"My Items Deposited:\n\n" if(qry:getID() ~= -1) then repeat k = k + 1 str = str..""..qry:getDataInt("count").." "..getItemNameById(qry:getDataInt("item_id")).." - "..qry:getDataInt("price").." Gps "..(tonumber(qry:getDataInt("count")) > 1 and "Each" or "").."\n" until not (qry:next()) or k >= _config_npc_shop.items_limit qry:free() doShowTextDialog(cid, ITEM_ACTION_BOOK, str) else selfSay("Currently you do not have items deposited in shop", cid) end elseif isInArray({'report', 'withdraw'}, msg) then if getDepositNpc(cid) <= 0 then selfSay("Sorry, but your balance is 0.", cid) else selfSay("You have "..getDepositNpc(cid).." gps deposited, you want to remove how many gps?", cid) talkState[talkUser] = 8 end elseif talkState[talkUser] == 8 then if tonumber(msg) and tonumber(msg) > 0 and tonumber(msg) <= getDepositNpc(cid) then setPlayerStorageValue(cid, _config_npc_shop.WithDraw_storage, (getDepositNpc(cid)-tonumber(msg))) doPlayerAddMoney(cid, tonumber(msg)) selfSay("you withdrew "..msg.." gps, now you have "..getDepositNpc(cid).." of balance.", cid) talkState[talkUser] = 0 else selfSay("You can not remove that amount.", cid) talkState[talkUser] = 0 end elseif isInArray({'deposit', 'depositar', 'sell', 'selling','vender'}, msg) then if getRowsShopByPlayer(getPlayerGUID(cid)) < _config_npc_shop.items_limit then selfSay('Which item you want to put for sale?', cid) talkState[talkUser] = 2 else selfSay('Sorry, you can only add '.._config_npc_shop.items_limit..' items per time.', cid) talkState[talkUser] = 0 end elseif talkState[talkUser] == 2 then name,item = msg,getItemByName(msg) if msg == '' or tonumber(msg) or not item then talkState[talkUser] = 0 selfSay("This item does not exist.", cid) return true elseif not isItemMovable(item) or isInArray(_config_npc_shop.items_block, getItemIdByName(name)) then talkState[talkUser] = 0 selfSay("you can not add this item.", cid) return true end item = getItemIdByName(name) selfSay('how many of that item you want to add to the shop?', cid) talkState[talkUser] = 3 elseif talkState[talkUser] == 3 then if tonumber(msg) and tonumber(msg) > 0 and tonumber(msg) <= 100 and getPlayerItemCount(cid, item) >= tonumber(msg) then count = tonumber(msg) selfSay('very well, and that each item will cost how much?', cid) talkState[talkUser] = 4 else selfSay(getPlayerItemCount(cid, item) < tonumber(msg) and 'Sorry, but you not have '..msg..' items to deposit' or 'enter a valid number from 1 to 100.', cid) end elseif talkState[talkUser] == 4 then if tonumber(msg) and tonumber(msg) > 0 and tonumber(msg) < 9999999 then price = msg selfSay('You really want to put {'..count..' '..name..'} per {'..price..'} gps '..(count > 1 and 'each' or '')..' for sale? Will cost '.. _config_npc_shop.each_deposit ..' by deposit, ok? {yes}', cid) talkState[talkUser] = 6 else selfSay('choose a valid number.', cid) end elseif msgcontains(msg, "yes") and talkState[talkUser] == 6 then if doPlayerRemoveMoney(cid, _config_npc_shop.each_deposit) then item,price = getItemIdByName(name),price if doPlayerRemoveItem(cid, item, count) then doAddItemShop(cid, item, count, getItemType(item), tonumber(price)) selfSay('Congratulations, the item was successfully added to the list and will be sold to date: '..os.date("%d %B %Y %X ", (os.time() + _config_npc_shop.days_limit*24*60*60))..'.', cid) talkState[talkUser] = 0 else selfSay('Sorry, but could not be completed because you do not have the items.', cid) talkState[talkUser] = 0 end else selfSay('Sorry, but you do not have gps sufficient to deposit this item.', cid) talkState[talkUser] = 0 end elseif isInArray({'trade', 'comprar', 'buy', 'buying', 'shop'}, msg) then selfSay('What type of item you want to buy: {head}, {armor}, {legs}, {feet}, {shield}, {sword}, {wand}, {rod}, {club}, {axe}, {distance}, {ammunition}, {others} or {all}?', cid) talkState[talkUser] = 7 elseif talkState[talkUser] == 7 then if isInArray(weaponsTypes, msg) then if msg == "rod" then msg = "wand" end local qry = msg == "all" and db.getResult("SELECT `id`, `player_id`, `item_id`, `count`, `price` FROM `shop_npc`;") or db.getResult("SELECT `id`, `player_id`, `item_id`, `count`, `price` FROM `shop_npc` WHERE `type` = "..db.escapeString(msg)) local trade,show = {},true if(qry:getID() ~= -1) then repeat if not _config_npc_shop.ShowMyItems_shop and qry:getDataInt("player_id") == getPlayerGUID(cid) then show = false end if show == true then table.insert(trade,{id= qry:getDataInt("item_id"), buy= qry:getDataInt("price"), db= qry:getDataInt("id"), name= getItemNameById(qry:getDataInt("item_id")), amount = qry:getDataInt("count")}) end until not(qry:next()) qry:free() else selfSay('Sorry, but there is no such item at the moment.', cid) return true end local items = {} for _, item in ipairs(trade) do items[item.id] = {item_id = item.id, buyPrice = item.buy, changeDb = item.db, subType = item.amount, realName = item.name} end local onBuy = function(cid, item, subType, amount, ignoreCap, inBackpacks) if items[item].buyPrice ~= 0 and amount <= items[item].subType then if isItemInShop(items[item].changeDb, amount) then doPlayerRemoveMoney(cid, amount * items[item].buyPrice) if isItemStackable(items[item].item_id) then doPlayerAddItem(cid, items[item].item_id, amount) else for i = 1, amount do doPlayerAddItem(cid, items[item].item_id, 1) end end local player,sell_price = getPlayerByNameWildcard(getPlayerByShopID(items[item].changeDb)),amount*items[item].buyPrice if(not player) then doSetDepositNpc(getPlayerGUIDByName(getPlayerByShopID(items[item].changeDb)), sell_price, "add") local file = io.open(OfflineMessagesConfig.messageSavingDirectory .. getPlayerByShopID(items[item].changeDb) .. '.Gandhi', 'a+') if(not file) then return true end local msgfrom, msgoff = "[Npc Auction]",{"Were sold "..amount.." "..getItemNameById(items[item].item_id).." and you received "..sell_price.." gps by items."} file:write(OfflineMessagesConfig.messageFormatString:format(os.date(OfflineMessagesConfig.dateFormatString), msgfrom, table.concat(msgoff, OfflineMessagesConfig.separatorAfterNickname)) .. '\n') file:close() else setPlayerStorageValue(player,_config_npc_shop.WithDraw_storage, getDepositNpc(player)+sell_price) doPlayerSendTextMessage(player, MESSAGE_STATUS_CONSOLE_ORANGE,"[Npc Auction] Were sold "..amount.." "..getItemNameById(items[item].item_id).." and you received "..sell_price.." gps by items.") end if amount == items[item].subType then doDeleteShopItem(items[item].changeDb) else doRemoveShopItem(items[item].changeDb, amount) end selfSay('Here your item, Thanks!', cid) closeShopWindow(cid) else selfSay('desculpe mas este item acabou de ser comprado.', cid) closeShopWindow(cid) end else selfSay('you can only buy '..items[item].subType..'x of items.', cid) end end openShopWindow(cid, trade, onBuy, onSell) else selfSay('do not sell this item type.', cid) end elseif isInArray({'retirar', 'remove', 'retire', 'pegar', 'get'}, msg) then selfSay('What item do you want to remove from my shop? reminding that I return the total amount of the item!', cid) talkState[talkUser] = 15 elseif talkState[talkUser] == 15 then name,item = msg,getItemByName(msg) if msg == '' or tonumber(msg) or not item then selfSay("This item does not exist.", cid) return true end local qry = db.getResult("SELECT `id`, `item_id`, `count` FROM `shop_npc` WHERE `player_id` = "..getPlayerGUID(cid).." and `item_id` = "..getItemIdByName(name)) if(qry:getID() ~= -1) then local id, item, amount = qry:getDataInt("id"), qry:getDataInt("item_id"), qry:getDataInt("count") if isItemStackable(item) then doPlayerAddItem(cid, item, amount) else for i = 1, amount do doPlayerAddItem(cid, item, 1) end end doDeleteShopItem(id) selfSay("Okay, removed "..amount.." "..name.." from my shop, thanks!", cid) talkState[talkUser] = 0 else selfSay("Sorry, but you not have this item!", cid) end elseif msg == "no" and talkState[talkUser] >= 1 then selfSay("okay then...", cid) talkState[talkUser] = 0 npcHandler:releaseFocus(cid) end return true end npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) npcHandler:addModule(FocusModule:new()) Tenho esse script que você configura o NPC para vender itens, como se fosse um MARKET, só que ele usa a função openShopWindow, teria como adaptar para não usar?, aparecer no chat?
  7. Boa noite, seria possivel adicionar a função openShopWindow no tfs 0.3.6 server 7.6? ou substituir por um igual
  8. não teria uma função pra checkar se o char esta banido?, uso mysql e sei que vai pra database, ai caso sim forçar o logout
  9. esse ban fica no config.lua, quando o player abusa de matar players, aparece a mensagem em verde que ele foi banido so que ele continua online de pk red, ai quando ele desloga que o ban pega e ele n consegue mais jogar
  10. Alguem me ajuda, o player é banido mas fica online, ai depois que ele desloga que não pode logar mais, nesse caso é no script de auto ban ao matar muitos players.
  11. Olá, eu queria a ajudar a entender esse script ele é assim: -- 0.4 - offline training - login.lua function onLogin(cid) OfflineTraining_initialize(cid) if(OfflineTraining_isTraining(cid)) then OfflineTraining_turnOffTraining(cid) -- we add skill/mlvl, we select lower value: time that player was offline OR offline training time [bar in game - 9.6] OfflineTraining_addTrainedSkills(cid, math.min(OfflineTraining_getTime(cid), OfflineTraining_getOfflineTime(cid))) -- we remove offline training time [bar in game - 9.6], -- if player was offline longer then his 'offline training time' it will add him time [like on RL tibia] -- got '3 hours offline training time', stay logged off for 8 hours, you get skills for 3 hours and on login you got '5 hours offline training time' OfflineTraining_setTime(cid, math.abs(OfflineTraining_getTime(cid) - OfflineTraining_getOfflineTime(cid))) OfflineTraining_onEndTraining(cid) local left = ((OfflineTraining_getTime(cid) / 60) * 60 * 60) left = {hour = math.floor(left/3600), minutes = math.ceil((left % 3600)/60)} doCreatureSay(cid, 'You still have '.. left.hour ..' hour and '..left.minutes..' minutes in OFF-Training.', 2) else -- offline training time also regenerate when you are offline, but NOT train local lefts = ((OfflineTraining_getTime(cid) / 60) * 60 * 60) OfflineTraining_setTime(cid, OfflineTraining_getTime(cid) + OfflineTraining_getOfflineTime(cid)) lefts = {hour = math.floor(lefts/3600), minutes = math.ceil((lefts % 3600)/60)} doCreatureSay(cid, 'You have '.. lefts.hour ..' hour and '..lefts.minutes..' minutes in OFF-Training.', 2) end return true end O que acontece, ao logar o player que esta falando "'You have '.. lefts.hour ..' hour and '..lefts.minutes..' minutes in OFF-Training.'" eu estou tentando fazer com que essa mensagem apareça no chat, editando assim: -- 0.4 - offline training - login.lua function onLogin(cid) OfflineTraining_initialize(cid) if(OfflineTraining_isTraining(cid)) then OfflineTraining_turnOffTraining(cid) -- we add skill/mlvl, we select lower value: time that player was offline OR offline training time [bar in game - 9.6] OfflineTraining_addTrainedSkills(cid, math.min(OfflineTraining_getTime(cid), OfflineTraining_getOfflineTime(cid))) -- we remove offline training time [bar in game - 9.6], -- if player was offline longer then his 'offline training time' it will add him time [like on RL tibia] -- got '3 hours offline training time', stay logged off for 8 hours, you get skills for 3 hours and on login you got '5 hours offline training time' OfflineTraining_setTime(cid, math.abs(OfflineTraining_getTime(cid) - OfflineTraining_getOfflineTime(cid))) OfflineTraining_onEndTraining(cid) local left = ((OfflineTraining_getTime(cid) / 60) * 60 * 60) left = {hour = math.floor(left/3600), minutes = math.ceil((left % 3600)/60)} doPlayerSendTextMessage(cid, 'You still have '.. left.hour ..' hour and '..left.minutes..' minutes in OFF-Training.', MESSAGE_STATUS_CONSOLE_BLUE) else -- offline training time also regenerate when you are offline, but NOT train local lefts = ((OfflineTraining_getTime(cid) / 60) * 60 * 60) OfflineTraining_setTime(cid, OfflineTraining_getTime(cid) + OfflineTraining_getOfflineTime(cid)) lefts = {hour = math.floor(lefts/3600), minutes = math.ceil((lefts % 3600)/60)} doPlayerSendTextMessage(cid, 'You have '.. lefts.hour ..' hour and '..lefts.minutes..' minutes in OFF-Training.', MESSAGE_STATUS_CONSOLE_BLUE) end return true end So que o cliente crasha, uso TFS 0.3.6, alguem poderia me ajudar e me mostrar pq o erro ta acontecendo?
  12. Funcionou, só tem um porem, ele fica aparecendo encima de outro item Teria como por pra ele checkar e se tiver o item ele não aparecer?
  13. Que bizarro, agora não da erro nenhum mas não cria o item, verifiquei as posições estão ok
  14. [Error - GlobalEvent Interface] data/globalevents/scripts/spawnitem.lua:onThink Description: data/globalevents/scripts/spawnitem.lua:14: attempt to call global 'Tile' (a nil value) stack traceback: data/globalevents/scripts/spawnitem.lua:14: in function <data/globalevents/scripts/spawnitem.lua:7> [Error - GlobalEvents::think] Couldn't execute event: createitem
  15. [Error - Event::checkScript] Event onThink not found (data/globalevents/scripts/spawnitem.lua)
  16. Opa, obrigado amigo, poderia em ajudar para que os itens não fosse stackeis, só respawnasse quando o item sumisse do local q foi respawnado? Codigo: local fromx = 32369 -- posiçao x superior a esquerda da area que sera analisada local tox = 32370 -- posiçao x inferior a direita da area que sera analisada local fromy = 32229 -- posiçao y superior a esquerda da area que sera analisada local toy = 32231 -- posiçao y inferior a direita da area que sera analisada local floor = 7 -- posição z referece ao andar que criara o item -- Inicio e Fim devem ser 0, pois serão preenchidos de acordo com sua chance, -- e se você preencher não fará diferença pois o valor será modificado mesmo assim :D -- Quanto maior o número em "Chance" maior será a probabilidade de ser o item escolhido local Itens = { {Item = 2160, Chance = 60, Inicio = 0, Fim = 0}, {Item = 2161, Chance = 30, Inicio = 0, Fim = 0}, {Item = 2164, Chance = 10, Inicio = 0, Fim = 0} } function onThink(cid, interval, lastExecution) local pos = {x= math.random(fromx, tox), y=math.random(fromy, toy), z=floor} local ItemSpawn = RetornarItemRandom() if ItemSpawn > 0 then if doCreateItem(ItemSpawn, 1, pos) == true then return true end end return true end function RetornarItemRandom() local Num = 0 -- Adicionar probabilidades for i = 1, #Itens do Itens[i].Inicio = Num Num = ((Num + Itens[i].Chance) - 1) Itens[i].Fim = Num end -- Criar a chance local Math = math.random(0, Num) -- Retornar item for i = 1, #Itens do if Itens[i].Inicio <= Math and Itens[i].Fim >= Math then return Itens[i].Item end end return 0 end
  17. eu uso tfs 0.3.6, eu queria que 3x itens spawnasse em x local do mapa com uma chance disso acontecer, alguem poderia me ajudar?
  18. shanden4502 postou uma resposta no tópico em Suporte Tibia OTServer
    Estou tentando configurar o Off Trainer mas me vem esse erro: [Error - Test Interface] data/creaturescripts/scripts/login.lua Description: (luaGetCreatureName) Creature not found [Error - Test Interface] data/creaturescripts/scripts/login.lua Description: data/creaturescripts/scripts/login.lua:66: attempt to concatenate global 'name' (a nil value) [Error - Event::checkScript] Cannot load script (data/creaturescripts/scripts/login.lua) Codigo: -- CONFIG local secondsPerHit = 2 -- THE ATTACKSPEED (1 hit per 2 seconds; default) local manaGenPerSec = 10 -- MANA USED PER SEC local offlineModifier = 0.5 -- FROM 0-1 (or higher if you wish). How fast you are skillin on offline training compared to normal (0.5 = 50%) local maxSecondsTraining = 60 * 60 * 12 -- (Default 12 hours) --END of config local accid = getAccountNumberByPlayerName(getCreatureName(cid)) local name = getCreatureName(cid) local checkTraining = db.storeQuery("SELECT * FROM offline_training WHERE `account_id`=".. accid .." AND `name`='".. name .."';") local skills = {[8]=MAGIC, [4]=SKILL_DISTANCE,[1]=SKILL_CLUB, [3]=SKILL_AXE,[2]=SKILL_SWORD} local skillNames = {[8]="Magic Level", [4]="Distance Fighting",[1]="Club Fighting", [3]="AxeFighting",[2]="Sword Fighting"} if checkTraining then local skill = result.getDataInt(checkTraining, "type") local timeTrained = result.getDataInt(checkTraining, "start_training") local secondsTrained = os.time()-timeTrained local skillTries = math.floor((secondsTrained/secondsPerHit)*offlineModifier) local skillBefore local skillAfter if timeTrained > maxSecondsTraining then timeTrained = maxSecondsTraining end if skill ~= 8 then skillBefore = getPlayerSkillLevel(cid, skills[skill]) doPlayerAddSkillTry(cid, skills[skill], skillTries) skillAfter = getPlayerSkillLevel(cid, skills[skill]) else skillBefore = getPlayerMagLevel(cid) doPlayerAddSpentMana(cid, manaGenPerSec*secondsTrained) skillAfter = getPlayerMagLevel(cid) end local skillBeforeShield = getPlayerSkillLevel(cid, 5) doPlayerAddSkillTry(cid, 5, skillTries) local skillAfterShield = getPlayerSkillLevel(cid, 5) doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Your ".. skillNames[skill] .." skill changed from level ".. skillBefore.." to level ".. skillAfter ..".") doPlayerSendTextMessage(cid, MESSAGE_EVENT_DEFAULT, "Your Shielding skill changed from level ".. skillBeforeShield.." to level ".. skillAfterShield ..". ") db.query("DELETE FROM offline_training WHERE `account_id`=".. accid .." AND `name`='".. name .."';") end Alguem poderia me ajudar?

Informação Importante

Confirmação de Termo