Ir para conteúdo
  • Cadastre-se

Posts Recomendados

se algum puder me ajudar preciso de um NPC que troque item mais diferente e que reaja a esse item .

ex : eu tenho uma  'ice raper'   falo com o npc "QUER FORTIFICAR SUA ICE RAPER ?"  i ele troca , tem chance de perder tudo ou melhor a minha sword 

caso ganhe o npc vai dar o um sword um poco mais forte "Superior Ice raper" esses items editados ja existem .

 

se tiver um npc que troca por item aleatorios tbm serve mais tem que ser de arma pra arma 

agradeço desde ja!

10 horas atrás, dersinho disse:

se algum puder me ajudar preciso de um NPC que troque item mais diferente e que reaja a esse item .

ex : eu tenho uma  'ice raper'   falo com o npc "QUER FORTIFICAR SUA ICE RAPER ?"  i ele troca , tem chance de perder tudo ou melhor a minha sword 

caso ganhe o npc vai dar o um sword um poco mais forte "Superior Ice raper" esses items editados ja existem .

 

se tiver um npc que troca por item aleatorios tbm serve mais tem que ser de arma pra arma 

agradeço desde ja!

 

 consegui dar um geito arumei um npc que entrega os itens mas preciso colocar mais itens e colocar chance de o npc quebrar a arma chance de erro  preciso colcar outras armas e mais itens a serem trocados quem puder me ajuda agradeço desde ja!

 

Citar

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
 
function onCreatureAppear(cid)         npcHandler:onCreatureAppear(cid)         end
function onCreatureDisappear(cid)      npcHandler:onCreatureDisappear(cid)         end
function onCreatureSay(cid, type, msg)   npcHandler:onCreatureSay(cid, type, msg:lower())   end
function onThink()                  npcHandler:onThink()                  end
local talkState = {}
 
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, "Demorage sword") then
        selfSay("Voce tem certeza que deseja fazer Forja ?", cid)
        talkState[talkUser] = 1
    elseif (msgcontains(msg, "yes") and talkState[talkUser] == 1) and (getPlayerItemCount(cid, 2160) < 2) or (getPlayerItemCount(cid, 10558) < 2) then
        selfSay("Desculpe, voce precisa ter 30 jemas e 2  kk.", cid)
        talkState[talkUser] = 1
    elseif (msgcontains(msg, "yes") and talkState[talkUser] == 1) and (getPlayerItemCount(cid, 2160) >= 2) and (getPlayerItemCount(cid, 10558) >= 2)  then
        doPlayerRemoveItem(cid, 2160, 2)
        doPlayerRemoveItem(cid, 10558, 2)
        doPlayerAddEditedItem(cid, 103, 1)
        selfSay("Obrigado, Tome sua Fusion Armor !", cid)
        talkState[talkUser] = 0
    end
   return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

Editado por dersinho (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

Veja se você tem essas funções na lib, se não tiver as coloque!

 

function getItemsFromList(items)
	local str = ''
	if table.maxn(items) > 0 then
		for i = 1, table.maxn(items) do
			str = str .. items[i][2] .. ' ' .. getItemNameById(items[i][1])
			if i ~= table.maxn(items) then str = str .. ', ' 
			end 
		end 
	end
	return str
end
function doRemoveItemsFromList(cid,items)
	local count = 0
	if table.maxn(items) > 0 then
		for i = 1, table.maxn(items) do
			if getPlayerItemCount(cid,items[i][1]) >= items[i][2] then
			count = count + 1 end 
		end 
	end
	if count == table.maxn(items) then
		for i = 1, table.maxn(items) do doPlayerRemoveItem(cid,items[i][1],items[i][2]) end
	else 
		return false 
	end
	return true 
end

 

 

-------------------------------

 

Data/npc

 

 

Aldro Forjador.xml

<?xml version="1.0"?>
<npc name="Aldro Forjador" script="data/npc/scripts/forjar_itens.lua" walkinterval="50000" floorchange="0">
<health now="100" max="100"/>
<look type="129" head="95" body="116" legs="121" feet="115" addons="3"/>
<parameters>
<parameter key="message_greet" value="Ola |PLAYERNAME|.Eu posso forjar alguns {itens} itens para voce!" />
</parameters>
</npc>

 

 

Data/npc/scripts

 

 

forjar_itens.lua

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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 doChangeWeapon(cid, message, keywords, parameters, node) -- by vodka
if(not npcHandler:isFocused(cid)) then
return false
end
if (isPlayerPremiumCallback == nil or isPlayerPremiumCallback(cid) == true or parameters.premium == false) then
if(parameters.level ~= nil and getPlayerLevel(cid) < parameters.level) then
npcHandler:say('Desculpe, voce precisa ter level ' .. parameters.level .. ' ou mais para forjar este item.', cid)
elseif not doRemoveItemsFromList(cid,parameters.items) then
npcHandler:say('Desculpe, mas voce não tem '..getItemsFromList(parameters.items)..' para forjar este item!', cid)
else
local r = parameters.chance
local v = math.random(1, 100)
if r > v then
npcHandler:say('Sucesso! Aqui esta seu item.', cid)
doPlayerAddItem(cid,parameters.give,1)
doSendMagicEffect(getPlayerPosition(cid), math.random(28,30)) 
else
npcHandler:say('Desculpe, mas seu item falho na forja!', cid)
doSendMagicEffect(getPlayerPosition(cid), 2) 
end
npcHandler:resetNpc()
end
else
npcHandler:say('Desculpe, mas apenas forjo esse item para jogadores premium account.', cid)
end
npcHandler:resetNpc()
return true
end
local list = {
{"demon armor", items = {{2466,3},{2160,2}}, item_give = 2494, chance = 30, level = 10, premium = false},
{"solar axe", items = {{2432,10},{2160,5},{8924,1}}, item_give = 8925, chance = 50, level = 15, premium = true},
{"broadsword", items = {{2376,10},{2160,2}}, item_give = 2413, chance = 90, level = 15, premium = false},
{"magic longsword", items = {{2400,5},{2393,5},{2160,5}}, item_give = 2390, chance = 90, level = 25, premium = false},
{"ice rapier", items = {{7449,2},{2160,5}}, item_give = 2396, chance = 10, level = 25, premium = false},
{"itens", text = "Eu posso te forjar alguns itens como: {demon armor},{solar axe},{broadsword} ou {magic longsword}!"}
}
for i = 1, #list do local get = list[i] if type(get.items) == "table" then
local node = keywordHandler:addKeyword({get[1]}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Para forjar o item " .. get[1] .. " é necessário "..getItemsFromList(get.items)..". Você tem tudo isso para me dar?"})
node:addChildKeyword({"yes"}, doChangeWeapon, {items = get.items, give = get.item_give, chance = get.chance, level = get.level, premium = get.premium})
node:addChildKeyword({"no"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "tudo bem entao.", reset = true})
else keywordHandler:addKeyword({get[1]}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = get.text}) end end
mounts = nil npcHandler:addModule(FocusModule:new())

 

 

 

explicando:

 

 

na tabela "list" existe essa linha por exemplo:

 

 

{"demon armor", items = {{2466,3},{2160,2}}, item_give = 2494, chance = 30, level = 10, premium = false},

 

"nome do item que vai ser trocado"

 

-------------------------------------

 

items = {} -- tabela de itens que vai ser preciso dar ao npc pra trocar de itens

 

coloque assim -- > {{itemid,quantidade}}

 

para mais de um item -- >  {{itemid, quantidade},{itemid, quantidade}}

 

exemplo que eu botei:

 

items = {{2466,3},{2160,2}} -- 3 golden armor e 2 crystal coin

 

---------------------------------------------------

 

item_give  -- aqui é o id final do item que vai ser dado ao jogador

 

-----------------------------------------------

 

chance -- é a chance de a forja dar certo, quanto maior a chance maior a chance de dar certoa forja do iten

 

------------------------------------

 

level -- é para forjar o item

 

----------------------------

premium -- se precisa ser premium pra forjar o itens em questao, true ou false.

 

 

 

 

 

 

 

 

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites

pra começa obrigado mais e asim eu criei uns itens mais so com a Sprite >>doPlayerAddEditedItem(cid, 103, 1)  preciso desse comando pra add o item no player %

ex : Demonrage sword  47 atk vai troca por Superior Demorage Sword 60 atk que no caso e o ide 101 os itens ja existem o npc troca o iten pelo outro item mais nao tem chance de quebra 

 

mais uma duvida pra que serve aquela lib  eu procuro ela na 000-constant ? 

Editado por dersinho (veja o histórico de edições)
Link para o post
Compartilhar em outros sites

a lib você joga na na pasta lib e abre o 050-function.lua

 

e joga la no final mesmo;.

 

 

sobre o npc, troque esta linha

 

doPlayerAddItem(cid,parameters.give,1)

 

por

 

doPlayerAddEditedItem(cid, parameters.give, 1)

 

isso adiciona o item editado ne? o 103 é o id do item editado?

vodkart_logo.png

[*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*]

 

DISCORDvodkart#6090

 

Link para o post
Compartilhar em outros sites

foi mau eu trampo so mecho de noite 

ta ai a lib

Spoiler

function doPlayerGiveItem(cid, itemid, amount, subType)
    local item = 0
    if(isItemStackable(itemid)) then
        item = doCreateItemEx(itemid, amount)
        if(doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR) then
            return false
        end
    else
        for i = 1, amount do
            item = doCreateItemEx(itemid, subType)
            if(doPlayerAddItemEx(cid, item, true) ~= RETURNVALUE_NOERROR) then
                return false
            end
        end
    end

    return true
end

function doPlayerGiveItemContainer(cid, containerid, itemid, amount, subType)
    for i = 1, amount do
        local container = doCreateItemEx(containerid, 1)
        for x = 1, getContainerCapById(containerid) do
            doAddContainerItem(container, itemid, subType)
        end

        if(doPlayerAddItemEx(cid, container, true) ~= RETURNVALUE_NOERROR) then
            return false
        end
    end

    return true
end

function doPlayerTakeItem(cid, itemid, amount)
    return getPlayerItemCount(cid, itemid) >= amount and doPlayerRemoveItem(cid, itemid, amount)
end

function doPlayerBuyItem(cid, itemid, count, cost, charges)
    return doPlayerRemoveMoney(cid, cost) and doPlayerGiveItem(cid, itemid, count, charges)
end

function doPlayerBuyItemContainer(cid, containerid, itemid, count, cost, charges)
    return doPlayerRemoveMoney(cid, cost) and doPlayerGiveItemContainer(cid, containerid, itemid, count, charges)
end

function doPlayerSellItem(cid, itemid, count, cost)
    if(not doPlayerTakeItem(cid, itemid, count)) then
        return false
    end

    if(not doPlayerAddMoney(cid, cost)) then
        error('[doPlayerSellItem] Could not add money to: ' .. getPlayerName(cid) .. ' (' .. cost .. 'gp).')
    end

    return true
end

function doPlayerWithdrawMoney(cid, amount)
    if(not getBooleanFromString(getConfigInfo('bankSystem'))) then
        return false
    end

    local balance = getPlayerBalance(cid)
    if(amount > balance or not doPlayerAddMoney(cid, amount)) then
        return false
    end

    doPlayerSetBalance(cid, balance - amount)
    return true
end

function doPlayerDepositMoney(cid, amount)
    if(not getBooleanFromString(getConfigInfo('bankSystem'))) then
        return false
    end

    if(not doPlayerRemoveMoney(cid, amount)) then
        return false
    end

    doPlayerSetBalance(cid, getPlayerBalance(cid) + amount)
    return true
end

function doPlayerAddStamina(cid, minutes)
    return doPlayerSetStamina(cid, getPlayerStamina(cid) + minutes)
end

function isPremium(cid)
    return (isPlayer(cid) and (getPlayerPremiumDays(cid) > 0 or getBooleanFromString(getConfigValue('freePremium'))))
end

function getMonthDayEnding(day)
    if(day == "01" or day == "21" or day == "31") then
        return "st"
    elseif(day == "02" or day == "22") then
        return "nd"
    elseif(day == "03" or day == "23") then
        return "rd"
    end

    return "th"
end

function getMonthString(m)
    return os.date("%B", os.time{year = 1970, month = m, day = 1})
end

function getArticle(str)
    return str:find("[AaEeIiOoUuYy]") == 1 and "an" or "a"
end

function isNumeric(str)
    return tonumber(str) ~= nil
end

function doNumberFormat(i)
    local str, found = string.gsub(i, "(%d)(%d%d%d)$", "%1,%2", 1), 0
    repeat
        str, found = string.gsub(str, "(%d)(%d%d%d),", "%1,%2,", 1)
    until found == 0
    return str
end

function doPlayerAddAddons(cid, addon)
    for i = 0, table.maxn(maleOutfits) do
        doPlayerAddOutfit(cid, maleOutfits, addon)
    end

    for i = 0, table.maxn(femaleOutfits) do
        doPlayerAddOutfit(cid, femaleOutfits, addon)
    end
end

function doPlayerWithdrawAllMoney(cid)
    return doPlayerWithdrawMoney(cid, getPlayerBalance(cid))
end

function doPlayerDepositAllMoney(cid)
    return doPlayerDepositMoney(cid, getPlayerMoney(cid))
end

function doPlayerTransferAllMoneyTo(cid, target)
    return doPlayerTransferMoneyTo(cid, target, getPlayerBalance(cid))
end

function playerExists(name)
    return getPlayerGUIDByName(name) ~= nil
end

function getTibiaTime()
    local minutes, hours = getWorldTime(), 0
    while (minutes > 60) do
        hours = hours + 1
        minutes = minutes - 60
    end

    return {hours = hours, minutes = minutes}
end

function doWriteLogFile(file, text)
    local f = io.open(file, "a+")
    if(not f) then
        return false
    end

    f:write("[" .. os.date("%d/%m/%Y %H:%M:%S") .. "] " .. text .. "\n")
    f:close()
    return true
end

function getExperienceForLevel(lv)
    lv = lv - 1
    return ((50 * lv * lv * lv) - (150 * lv * lv) + (400 * lv)) / 3
end

function doMutePlayer(cid, time)
    local condition = createConditionObject(CONDITION_MUTED)
    setConditionParam(condition, CONDITION_PARAM_TICKS, time == -1 and time or time * 1000)
    return doAddCondition(cid, condition)
end

function getPlayerGroupName(cid)
    return getGroupInfo(getPlayerGroupId(cid)).name
end

function getPlayerVocationName(cid)
    return getVocationInfo(getPlayerVocation(cid)).name
end

function getPromotedVocation(vid)
    return getVocationInfo(vid).promotedVocation
end

function doPlayerRemovePremiumDays(cid, days)
    return doPlayerAddPremiumDays(cid, -days)
end

function getPlayerMasterPos(cid)
    return getTownTemplePosition(getPlayerTown(cid))
end

function getHouseOwner(houseId)
    return getHouseInfo(houseId).owner
end

function getHouseName(houseId)
    return getHouseInfo(houseId).name
end

function getHouseEntry(houseId)
    return getHouseInfo(houseId).entry
end

function getHouseRent(houseId)
    return getHouseInfo(houseId).rent
end

function getHousePrice(houseId)
    return getHouseInfo(houseId).price
end

function getHouseTown(houseId)
    return getHouseInfo(houseId).town
end

function getHouseDoorsCount(houseId)
    return table.maxn(getHouseInfo(houseId).doors)
end

function getHouseBedsCount(houseId)
    return table.maxn(getHouseInfo(houseId).beds)
end

function getHouseTilesCount(houseId)
    return table.maxn(getHouseInfo(houseId).tiles)
end

function getItemNameById(itemid)
    return getItemDescriptionsById(itemid).name
end

function getItemPluralNameById(itemid)
    return getItemDescriptionsById(itemid).plural
end

function getItemArticleById(itemid)
    return getItemDescriptionsById(itemid).article
end

function getItemName(uid)
    return getItemDescriptions(uid).name
end

function getItemPluralName(uid)
    return getItemDescriptions(uid).plural
end

function getItemArticle(uid)
    return getItemDescriptions(uid).article
end

function getItemText(uid)
    return getItemDescriptions(uid).text
end

function getItemSpecialDescription(uid)
    return getItemDescriptions(uid).special
end

function getItemWriter(uid)
    return getItemDescriptions(uid).writer
end

function getItemDate(uid)
    return getItemDescriptions(uid).date
end

function getTilePzInfo(pos)
    return getTileInfo(pos).protection
end

function getTileZoneInfo(pos)
    local tmp = getTileInfo(pos)
    if(tmp.pvp) then
        return 2
    end

    if(tmp.nopvp) then
        return 1
    end

    return 0
end

function doShutdown()
    return doSetGameState(GAMESTATE_SHUTDOWN)
end

function doSummonCreature(name, pos, displayError)
    local displayError, cid = displayError or true, doCreateMonster(name, pos, displayError)
    if(not cid) then
        cid = doCreateNpc(name, pos, displayError)
    end

    return cid
end

function getOnlinePlayers()
    local players = {}
    for i, cid in ipairs(getPlayersOnline()) do
        table.insert(players, getCreatureName(cid))
    end

    return players
end

function getPlayerByName(name)
    local cid = getCreatureByName(name)
    return isPlayer(cid) and cid or nil
end

function isPlayer(cid)
    return isCreature(cid) and cid >= AUTOID_PLAYERS and cid < AUTOID_MONSTERS
end

function isPlayerGhost(cid)
    return isPlayer(cid) and (getCreatureCondition(cid, CONDITION_GAMEMASTER, GAMEMASTER_INVISIBLE) or getPlayerFlagValue(cid, PLAYERFLAG_CANNOTBESEEN))
end

function isMonster(cid)
    return isCreature(cid) and cid >= AUTOID_MONSTERS and cid < AUTOID_NPCS
end

function isNpc(cid)
    return isCreature(cid) and cid >= AUTOID_NPCS
end

function doPlayerSetExperienceRate(cid, value)
    return doPlayerSetRate(cid, SKILL__LEVEL, value)
end

function doPlayerSetMagicRate(cid, value)
    return doPlayerSetRate(cid, SKILL__MAGLEVEL, value)
end

function doPlayerAddLevel(cid, amount, round)
    local experience, level, amount = 0, getPlayerLevel(cid), amount or 1
    if(amount > 0) then
        experience = getExperienceForLevel(level + amount) - (round and getPlayerExperience(cid) or getExperienceForLevel(level))
    else
        experience = -((round and getPlayerExperience(cid) or getExperienceForLevel(level)) - getExperienceForLevel(level + amount))
    end

    return doPlayerAddExperience(cid, experience)
end

function doPlayerAddMagLevel(cid, amount)
    for i = 1, amount do
        doPlayerAddSpentMana(cid, getPlayerRequiredMana(cid, getPlayerMagLevel(cid, true) + 1) - getPlayerSpentMana(cid), false)
    end

    return true
end

function doPlayerAddSkill(cid, skill, amount, round)
    local amount = amount or 1
    if(skill == SKILL__LEVEL) then
        return doPlayerAddLevel(cid, amount, round)
    elseif(skill == SKILL__MAGLEVEL) then
        return doPlayerAddMagLevel(cid, amount)
    end

    for i = 1, amount do
        doPlayerAddSkillTry(cid, skill, getPlayerRequiredSkillTries(cid, skill, getPlayerSkillLevel(cid, skill) + 1) - getPlayerSkillTries(cid, skill), false)
    end

    return true
end

function getPartyLeader(cid)
    local party = getPartyMembers(cid)
    if(type(party) ~= 'table') then
        return 0
    end

    return party[1]
end

function isInParty(cid)
    return type(getPartyMembers(cid)) == 'table'
end

function isPrivateChannel(channelId)
    return channelId >= CHANNEL_PRIVATE
end

function doPlayerResetIdleTime(cid)
    return doPlayerSetIdleTime(cid, 0)
end

function doBroadcastMessage(text, class)
    local class = class or MESSAGE_STATUS_WARNING
    if(type(class) == 'string') then
        local className = MESSAGE_TYPES[class]
        if(className == nil) then
            return false
        end

        class = className
    elseif(class < MESSAGE_FIRST or class > MESSAGE_LAST) then
        return false
    end

    for _, pid in ipairs(getPlayersOnline()) do
        doPlayerSendTextMessage(pid, class, text)
    end

    print("> Broadcasted message: \"" .. text .. "\".")
    return true
end

function doPlayerBroadcastMessage(cid, text, class, checkFlag, ghost)
    local checkFlag, ghost, class = checkFlag or true, ghost or false, class or TALKTYPE_BROADCAST
    if(checkFlag and not getPlayerFlagValue(cid, PLAYERFLAG_CANBROADCAST)) then
        return false
    end

    if(type(class) == 'string') then
        local className = TALKTYPE_TYPES[class]
        if(className == nil) then
            return false
        end

        class = className
    elseif(class < TALKTYPE_FIRST or class > TALKTYPE_LAST) then
        return false
    end

    for _, pid in ipairs(getPlayersOnline()) do
        doCreatureSay(cid, text, class, ghost, pid)
    end

    print("> " .. getCreatureName(cid) .. " broadcasted message: \"" .. text .. "\".")
    return true
end

function getBooleanFromString(input)
    local tmp = type(input)
    if(tmp == 'boolean') then
        return input
    end

    if(tmp == 'number') then
        return input > 0
    end

    local str = string.lower(tostring(input))
    return (str == "yes" or str == "true" or (tonumber(str) ~= nil and tonumber(str) > 0))
end

function doCopyItem(item, attributes)
    local attributes = ((type(attributes) == 'table') and attributes or { "aid" })

    local ret = doCreateItemEx(item.itemid, item.type)
    for _, key in ipairs(attributes) do
        local value = getItemAttribute(item.uid, key)
        if(value ~= nil) then
            doItemSetAttribute(ret, key, value)
        end
    end

    if(isContainer(item.uid)) then
        for i = (getContainerSize(item.uid) - 1), 0, -1 do
            local tmp = getContainerItem(item.uid, i)
            if(tmp.itemid > 0) then
                doAddContainerItemEx(ret, doCopyItem(tmp, true).uid)
            end
        end
    end

    return getThing(ret)
end

function doRemoveThing(uid)
    if(isCreature(uid)) then
        return doRemoveCreature(uid)
    end

    return doRemoveItem(uid)
end

function setAttackFormula(combat, type, minl, maxl, minm, maxm, min, max)
    local min, max = min or 0, max or 0
    return setCombatFormula(combat, type, -1, 0, -1, 0, minl, maxl, minm, maxm, -min, -max)
end

function setHealingFormula(combat, type, minl, maxl, minm, maxm, min, max)
    local min, max = min or 0, max or 0
    return setCombatFormula(combat, type, 1, 0, 1, 0, minl, maxl, minm, maxm, min, max)
end

function doChangeTypeItem(uid, subtype)
    local thing = getThing(uid)
    if(thing.itemid < 100) then
        return false
    end

    local subtype = subtype or 1
    return doTransformItem(thing.uid, thing.itemid, subtype)
end

function doSetItemText(uid, text, writer, date)
    local thing = getThing(uid)
    if(thing.itemid < 100) then
        return false
    end

    doItemSetAttribute(uid, "text", text)
    if(writer ~= nil) then
        doItemSetAttribute(uid, "writer", tostring(writer))
        if(date ~= nil) then
            doItemSetAttribute(uid, "date", tonumber(date))
        end
    end

    return true
end

function doItemSetActionId(uid, aid)
    return doItemSetAttribute(uid, "aid", aid)
end

function getFluidSourceType(itemid)
    local item = getItemInfo(itemid)
    return item and item.fluidSource or false
end

function getDepotId(uid)
    return getItemAttribute(uid, "depotid") or false
end

function getItemDescriptions(uid)
    local thing = getThing(uid)
    if(thing.itemid < 100) then
        return false
    end

    local item = getItemInfo(thing.itemid)
    return {
        name = getItemAttribute(uid, "name") or item.name,
        plural = getItemAttribute(uid, "pluralname") or item.plural,
        article = getItemAttribute(uid, "article") or item.article,
        special = getItemAttribute(uid, "description") or "",
        text = getItemAttribute(uid, "text") or "",
        writer = getItemAttribute(uid, "writer") or "",
        date = getItemAttribute(uid, "date") or 0
    }
end

function getItemWeightById(itemid, count, precision)
    local item, count, precision = getItemInfo(itemid), count or 1, precision or false
    if(not item) then
        return false
    end

    if(count > 100) then
        -- print a warning, as its impossible to have more than 100 stackable items without "cheating" the count
        print('[Warning] getItemWeightById', 'Calculating weight for more than 100 items!')
    end

    local weight = item.weight * count
    --[[if(precision) then
        return weight
    end

    local t = string.explode(tostring(weight), ".")
    if(table.maxn(t) == 2) then
        return tonumber(t[1] .. "." .. string.sub(t[2], 1, 2))
    end]]--

    return weight
end

function getItemWeaponType(uid)
    local thing = getThing(uid)
    if(thing.itemid < 100) then
        return false
    end

    return getItemInfo(thing.itemid).weaponType
end

function getItemRWInfo(uid)
    local thing = getThing(uid)
    if(thing.itemid < 100) then
        return false
    end

    local item, flags = getItemInfo(thing.itemid), 0
    if(item.readable) then
        flags = 1
    end

    if(item.writable) then
        flags = flags + 2
    end

    return flags
end

function getItemLevelDoor(itemid)
    local item = getItemInfo(itemid)
    return item and item.levelDoor or false
end

function isItemStackable(itemid)
    local item = getItemInfo(itemid)
    return item and item.stackable or false
end

function isItemRune(itemid)
    local item = getItemInfo(itemid)
    return item and item.type == ITEM_TYPE_RUNE or false
end

function isItemDoor(itemid)
    local item = getItemInfo(itemid)
    return item and item.type == ITEM_TYPE_DOOR or false
end

function isItemContainer(itemid)
    local item = getItemInfo(itemid)
    return item and item.group == ITEM_GROUP_CONTAINER or false
end

function isItemFluidContainer(itemid)
    local item = getItemInfo(itemid)
    return item and item.group == ITEM_GROUP_FLUID or false
end

function isItemMovable(itemid)
    local item = getItemInfo(itemid)
    return item and item.movable or false
end

function isCorpse(uid)
    local thing = getThing(uid)
    if(thing.itemid < 100) then
        return false
    end

    local item = getItemInfo(thing.itemid)
    return item and item.corpseType ~= 0 or false
end

function getContainerCapById(itemid)
    local item = getItemInfo(itemid)
    if(not item or item.group ~= 2) then
        return false
    end

    return item.maxItems
end

function getMonsterAttackSpells(name)
    local monster = getMonsterInfo(name)
    return monster and monster.attacks or false
end

function getMonsterHealingSpells(name)
    local monster = getMonsterInfo(name)
    return monster and monster.defenses or false
end

function getMonsterLootList(name)
    local monster = getMonsterInfo(name)
    return monster and monster.loot or false
end

function getMonsterSummonList(name)
    local monster = getMonsterInfo(name)
    return monster and monster.summons or false
end

function choose(...)
    local arg = {...}
    return arg[math.random(1, table.maxn(arg))]
end


-- nao sei deve ser da vip

function CountGuildMembers(GuildName) -- function by vodkart
local count = 0
local lista = db.getResult("SELECT `name`, `rank_id` FROM `players` WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = " .. getGuildId(GuildName) .. ");")  
if(lista:getID() ~= -1) then  
repeat  count = count + 1 until not lista:next()  lista:free() return count end
end

function getCharacterAcess(cid)
local query = db.getResult("SELECT `vipacess` FROM `players` WHERE `id` = "..getPlayerGUID(cid))
if query:getID() ~= -1 then return query:getDataInt("vipacess") end
end
function getCharacterDays(cid)
local acess = math.ceil((getCharacterAcess(cid) - os.time())/(86400))
return acess <= 0 and 0 or acess
end
function HaveCharaterAcess(cid)
return getCharacterDays(cid) > 0 and true or false
end
function setAcessTime(cid, time)
return db.executeQuery("UPDATE `players` SET `vipacess` = "..time.." WHERE `id` = "..getPlayerGUID(cid))
end
function addCharacterAcess(cid, days)
local add = (days <= 0 and 1 or days)*86400
local time = getCharacterDays(cid) == 0 and (os.time() + add) or (getCharacterAcess(cid) + add)
return setAcessTime(cid, time)
end
function doRemoveCharacterAcess(cid, days)
local remove = days*86400
local time = getCharacterAcess(cid) - remove
return setAcessTime(cid, (time <= 0 and 1 or time))
end
function getVipAcessDate(cid)
if HaveCharaterAcess(cid) then return os.date("%d/%m/%y %X", getCharacterAcess(cid)) end
return false
end


-- Task
function isSummon(cid)
return getCreatureMaster(cid) ~= nil or false
end

function getItemsFromList(items)
    local str = ''
    if table.maxn(items) > 0 then
        for i = 1, table.maxn(items) do
            str = str .. items[2] .. ' ' .. getItemNameById(items[1])
            if i ~= table.maxn(items) then str = str .. ', ' 
            end 
        end 
    end
    return str
end
function doRemoveItemsFromList(cid,items)
    local count = 0
    if table.maxn(items) > 0 then
        for i = 1, table.maxn(items) do
            if getPlayerItemCount(cid,items[1]) >= items[2] then
            count = count + 1 end 
        end 
    end
    if count == table.maxn(items) then
        for i = 1, table.maxn(items) do doPlayerRemoveItem(cid,items[1],items[2]) end
    else 
        return false 
    end
    return true 
end

 

Link para o post
Compartilhar em outros sites
Spoiler

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
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 doChangeWeapon(cid, message, keywords, parameters, node) -- by vodka
if(not npcHandler:isFocused(cid)) then
return false
end
if (isPlayerPremiumCallback == nil or isPlayerPremiumCallback(cid) == true or parameters.premium == false) then
if(parameters.level ~= nil and getPlayerLevel(cid) < parameters.level) then
npcHandler:say('Desculpe, voce precisa ter level ' .. parameters.level .. ' ou mais para forjar este item.', cid)
elseif not doRemoveItemsFromList(cid,parameters.items) then
npcHandler:say('Desculpe, mas voce não tem '..getItemsFromList(parameters.items)..' para forjar este item!', cid)
else
local r = parameters.chance
local v = math.random(1, 100)
if r > v then
npcHandler:say('Sucesso! Aqui esta seu item.', cid)
doPlayerAddEditedItem(cid, parameters.give, 1)
doSendMagicEffect(getPlayerPosition(cid), math.random(28,30)) 
else
npcHandler:say('Desculpe, mas seu item falho na forja!', cid)
doSendMagicEffect(getPlayerPosition(cid), 2) 
end
npcHandler:resetNpc()
end
else
npcHandler:say('Desculpe, mas apenas forjo esse item para jogadores premium account.', cid)
end
npcHandler:resetNpc()
return true
end
local list = {
{"demon armor", items = {{2466,3},{2160,2}}, item_give = 101, chance = 30, level = 10, premium = false},
{"solar axe", items = {{2432,10},{2160,5},{8924,1}}, item_give = 8925, chance = 50, level = 15, premium = true},
{"broadsword", items = {{2376,10},{2160,2}}, item_give = 2413, chance = 90, level = 15, premium = false},
{"magic longsword", items = {{2400,5},{2393,5},{2160,5}}, item_give = 2390, chance = 90, level = 25, premium = false},
{"ice rapier", items = {{7449,2},{2160,5}}, item_give = 2396, chance = 10, level = 25, premium = false},
{"itens", text = "Eu posso te forjar alguns itens como: {demon armor},{solar axe},{broadsword} ou {magic longsword}!"}
}
for i = 1, #list do local get = list if type(get.items) == "table" then
local node = keywordHandler:addKeyword({get[1]}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "Para forjar o item " .. get[1] .. " é necessário "..getItemsFromList(get.items)..". Você tem tudo isso para me dar?"})
node:addChildKeyword({"yes"}, doChangeWeapon, {items = get.items, give = get.item_give, chance = get.chance, level = get.level, premium = get.premium})
node:addChildKeyword({"no"}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = "tudo bem entao.", reset = true})
else keywordHandler:addKeyword({get[1]}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = get.text}) end end
mounts = nil npcHandler:addModule(FocusModule:new())

 

Link para o post
Compartilhar em outros sites

foi mau entendi errado

Spoiler

<?xml version="1.0"?>
<npc name="Superior" script="Superior.lua" walkinterval="50000" floorchange="0">
<health now="100" max="100"/>
<look type="129" head="95" body="116" legs="121" feet="115" addons="3"/>
<parameters>
<parameter key="message_greet" value="Ola |PLAYERNAME|.Eu posso forjar alguns {itens} itens para voce!" />
</parameters>
</npc>

 

Link para o post
Compartilhar em outros sites

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.


  • Conteúdo Similar

    • Por cloudrun2023
      CloudRun - Sua Melhor Escolha para Hospedagem de OTServer!
      Você está procurando a solução definitiva para hospedar seu OTServer com desempenho imbatível e segurança inigualável? Não procure mais! Apresentamos a CloudRun, sua parceira confiável em serviços de hospedagem na nuvem.
       
      Recursos Exclusivos - Proteção DDoS Avançada:
      Mantenha seu OTServer online e seguro com nossa robusta proteção DDoS, garantindo uma experiência de jogo ininterrupta para seus jogadores.
       
      Servidores Ryzen 7 Poderosos: Desfrute do poder de processamento superior dos servidores Ryzen 7 para garantir um desempenho excepcional do seu OTServer. Velocidade e estabilidade garantidas!
       
      Armazenamento NVMe de Alta Velocidade:
      Reduza o tempo de carregamento do jogo com nosso armazenamento NVMe ultrarrápido. Seus jogadores vão adorar a rapidez com que podem explorar o mundo do seu OTServer.
       
      Uplink de até 1GB:
      Oferecemos uma conexão de alta velocidade com até 1GB de largura de banda, garantindo uma experiência de jogo suave e livre de lag para todos os seus jogadores, mesmo nos momentos de pico.
       
      Suporte 24 Horas:
      Estamos sempre aqui para você! Nossa equipe de suporte está disponível 24 horas por dia, 7 dias por semana, para resolver qualquer problema ou responder a qualquer pergunta que você possa ter. Sua satisfação é a nossa prioridade.
       
      Fácil e Rápido de Começar:
      Configurar seu OTServer na CloudRun é simples e rápido. Concentre-se no desenvolvimento do seu jogo enquanto cuidamos da hospedagem.
       
      Entre em Contato Agora!
      Website: https://central.cloudrun.com.br/index.php?rp=/store/cloud-ryzen-brasil
      Email: [email protected]
      Telefone: (47) 99902-5147

      Não comprometa a qualidade da hospedagem do seu OTServer. Escolha a CloudRun e ofereça aos seus jogadores a melhor experiência de jogo possível. Visite nosso site hoje mesmo para conhecer nossos planos e começar!
       
      https://central.cloudrun.com.br/index.php?rp=/store/cloud-ryzen-brasil
       
      CloudRun - Onde a Velocidade Encontra a Confiabilidade!
       

    • Por FeeTads
      SALVE rapaziada do TK, esses dias vim pensando em novos scripts pro meu OT, e em um deles eu precisava que determinada area não contasse frag pro player que matasse outros, PORÉM eu precisava que os players que morressem nessa area ainda assim tivessem as penalidades da sua morte, procurei por ai, achei alguns scripts que apenas tiravam o SKULL e não realmente o FRAG do player.

      **script atualizado 22/10/2023** - melhorado e otimizado, levei o script pra puxar as infos por .lua / creatureScripts

      vou disponibilizar o code aqui, e o que fazer pra determinada area não contar frag.

      SOURCE OTX 2 / TFS 0.x, Funciona em TFS 1.x mudando as tags e ajeitando as sintaxes.

      vá em creatureevent.cpp

      procure por:
      else if(type == "preparedeath") _type = CREATURE_EVENT_PREPAREDEATH;
      Adiciona abaixo:
      else if(type == "nocountfrag") _type = CREATURE_EVENT_NOCOUNTFRAG;

      procure por:
      case CREATURE_EVENT_PREPAREDEATH: return "onPrepareDeath";  
      Adicione abaixo: 
      case CREATURE_EVENT_NOCOUNTFRAG: return "noCountFragArea";

      procure por:
      case CREATURE_EVENT_PREPAREDEATH: return "cid, deathList";
      Adicione abaixo:
      case CREATURE_EVENT_NOCOUNTFRAG: return "cid, target";

      agora no mesmo arquivo, vá até o final do arquivo e adicione essa função:
      uint32_t CreatureEvent::executeNoCountFragArea(Creature* creature, Creature* target) { //noCountFragArea(cid, target) if(m_interface->reserveEnv()) { ScriptEnviroment* env = m_interface->getEnv(); if(m_scripted == EVENT_SCRIPT_BUFFER) { env->setRealPos(creature->getPosition()); std::ostringstream scriptstream; scriptstream << "local cid = " << env->addThing(creature) << std::endl; scriptstream << "local target = " << env->addThing(target) << std::endl; if(m_scriptData) scriptstream << *m_scriptData; bool result = true; if(m_interface->loadBuffer(scriptstream.str())) { lua_State* L = m_interface->getState(); result = m_interface->getGlobalBool(L, "_result", true); } m_interface->releaseEnv(); return result; } else { #ifdef __DEBUG_LUASCRIPTS__ std::ostringstream desc; desc << creature->getName(); env->setEvent(desc.str()); #endif env->setScriptId(m_scriptId, m_interface); env->setRealPos(creature->getPosition()); lua_State* L = m_interface->getState(); m_interface->pushFunction(m_scriptId); lua_pushnumber(L, env->addThing(creature)); lua_pushnumber(L, env->addThing(target)); bool result = m_interface->callFunction(2); m_interface->releaseEnv(); return result; } } else { std::clog << "[Error - CreatureEvent::noCountFragArea] Call stack overflow." << std::endl; return 0; } }

      agora vá em creatureevent.h

      procure por:
      CREATURE_EVENT_PREPAREDEATH
      adicione abaixo:
      CREATURE_EVENT_NOCOUNTFRAG

      procure por:
      uint32_t executePrepareDeath(Creature* creature, DeathList deathList);
      Adicione abaixo:
      uint32_t executeNoCountFragArea(Creature* creature, Creature* target);

      agora vá em player.cpp

      procure por:
      bool Player::onKilledCreature(Creature* target, DeathEntry& entry)
      abaixo de:
      War_t enemy; if(targetPlayer->getEnemy(this, enemy)) { if(entry.isLast()) IOGuild::getInstance()->updateWar(enemy); entry.setWar(enemy); }
      Adicione o seguinte código:
      if (targetPlayer){ CreatureEventList killEvents = getCreatureEvents(CREATURE_EVENT_NOCOUNTFRAG); for (const auto &event : killEvents) { if (!event->executeNoCountFragArea(this, target)) { return true; } } }

      //

      Feito isso, tudo completo na sua source, agora é necessário adicionar o creaturescript dentro do servidor

      vá até creaturescripts/scripts
      crie um arquivo chamado, "noCountFragInArea.lua"
      e dentro dele cole o código:
       
      --[[ script feito por feetads / TibiaKing ]]-- --[[ discord: feetads / FeeTads#0246 ]]-- -- Add positions here for which you do not want to count frags local areas = { [1] = {from = {x = 91, y = 122, z = 7}, to = {x = 98, y = 127, z = 7}}, -- from = area superior esquerda / to = area inferior direita (formando um quadrado) } local onlyKillerInArea = false -- only killer need to be in area? function noCountFragArea(cid, target) if not isCreature(cid) or not isCreature(target) then return true end local posKiller = getPlayerPosition(cid) local posTarget = getPlayerPosition(target) for i = 1, #areas do local area = areas[i] if isInArea(posKiller, area.from, area.to) then if onlyKillerInArea then return false elseif isInArea(posTarget, area.from, area.to) then return false end end end return true end
      agora em creaturescripts.xml
      <event type="nocountfrag" name="fragarea" event="script" value="noCountFragInArea.lua"/>
      agora em creaturescripts/scripts/login.lua
       procure por OU semelhante a esse:
      registerCreatureEvent(cid, "AdvanceSave")
      e abaixo adicione:
      registerCreatureEvent(cid, "fragarea")

      //


      Agora tudo certo, quando quiser adiciona uma area que não pega frag, vá até o script e apenas coloque a area, igual o demonstrado no script

      Exemplo:
      local areas = { [1] = {from = {x = 91, y = 122, z = 7}, to = {x = 98, y = 127, z = 7}}, [2] = {from = {x = 1000, y = 1000, z = 7}, to = {x = 1100, y = 1100, z = 7}}, }
      assim somente colocando a area no script e abrindo o server ou dando /reload, já funcionará a area como não pegar frag.
      Esse sistema pode ser bom pra areas de pvp ativo, onde você ainda quer que o player que morrer perca os atributos, como se fosse uma morte normal, porém não conta frag pra quem matar.
      Bom pra sistemas tipo castle 48h (guild war), onde há diversas mortes e risco de pegar red, atrapalhando a war.

      Façam bom proveito dos scripts, e deixem os créditos no script rsrs

      **Eu fiz as alterações e o simples código por isso vim disponibilizar, créditos meus**
    • Por Muvuka
      Abri canal a força creaturescript acho que funcione no creaturescript cria script creaturescript
       
      <channel id="9" name="HELP" logged="yes"/>
      <channel id="12" name="Report Bugs" logged="yes"/>
      <channel id="13" name="Loot" logged="yes"/>
      <channel id="14" name="Report Character Rules Tibia Rules" logged="yes"/>
      <channel id="15" name="Death Channel"/>
      <channel id="6548" name="DexSoft" level="1"/>
      <channel id="7" name="Reports" logged="yes"/>
       
      antes de 
              if(lastLogin > 0) then adicione isso:
                      doPlayerOpenChannel(cid, CHANNEL_HELP) doPlayerOpenChannel(cid, 1,  2, 3) = 1,2 ,3 Channels, entendeu? NÃO FUNCIONA EU QUERO UM MEIO DE ABRI SEM USA A SOURCE
       
      EU NÃO CONSEGUI ABRI EU NÃO TENHO SOURCE
       
       
    • Por bolachapancao
      Rapaziada seguinte preciso de um script que ao utilizar uma alavanca para até 4 jogadores.
      Os jogadores serão teleportados para hunt durante uma hora e depois de uma hora os jogadores serão teleportados de volta para o templo.
       
      Observação: caso o jogador morra ou saia da hunt o evento hunt é cancelado.

      Estou a base canary
      GitHub - opentibiabr/canary: Canary Server 13.x for OpenTibia community.
       
    • Por RAJADAO
      .Qual servidor ou website você utiliza como base? 
      Sabrehaven 8.0
      Qual o motivo deste tópico? 
      Ajuda com novos efeitos
       
      Olá amigos, gostaria de ajuda para introduzir os seguintes efeitos no meu servidor (usando o Sabrehaven 8.0 como base), adicionei algumas runas novas (avalanche, icicle, míssil sagrado, stoneshower & Thunderstorm) e alguns novos feitiços (exevo mas san, exori san, exori tera, exori frigo, exevo gran mas frigo, exevo gran mas tera, exevo tera hur, exevo frigo hur) mas nenhum dos efeitos dessas magias parece existir no servidor, alguém tem um link para um tutorial ou algo assim para que eu possa fazer isso funcionar?
      Desculpe pelo mau inglês, sou brasileiro.

      Obrigado!


      AVALANCHE RUNE id:3161 \/
      (COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
      (COMBAT_PARAM_EFFECT, CONST_ME_ICEAREA)
      (COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)

      STONESHOWER RUNE id:3175 \/
      (COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE)
      (COMBAT_PARAM_EFFECT, CONST_ME_STONES)
      (COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EARTH)

      THUNDERSTORM RUNE id:3202 \/
      (COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
      (COMBAT_PARAM_EFFECT, CONST_ME_E NERGYHIT)
      (COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGYBALL)

      ICICLE RUNE id:3158 \/
      COMBAT_ICEDAMAGE
      CONST_ME_ICEAREA
      CONST_ANI_ICE

      SANTO MÍSSIL RUNA id:3182 \/
      (COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
      (COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
      (COMBAT_PARAM_EFFECT, CONST_ME_HOLYAREA)
      (COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HOLY)

      CONST_ME_PLANTATTACK (exevo gran mas tera)
      CONST_ME_ICETORNADO (exevo gran mas frigo)
      CONST_ME_SMALLPLANTS (exevo tera hur)
      CONST_ME_ICEAREA (exevo frigo hur)
      CONST_ME_ICEATTACK (exori frigo)
      CONST_ME_CARNIPHILA (exori tera)

      EXORI SAN \/
      (COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SMALLHOLY)
      CONST_ME_HOLYDAM IDADE

      EXEVO MAS SAN \/
      CONST_ME_HOLYAREA
×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo