Ir para conteúdo

Vodkart

Herói
  • Total de itens

    3406
  • Registro em

  • Última visita

  • Dias Ganhos

    111

Posts postados por Vodkart

  1.  

    function onPrepareDeath(cid, lastHitKiller, mostDamageKiller)
    local from,to =  {x = 154, y = 68, z = 7},{x = 160, y = 70, z = 7}
    if isPlayer(cid) and isMonster(lastHitKiller[1]) and isInRange(getCreaturePosition(cid), from, to) then
    doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
    doCreatureAddHealth(cid, getCreatureMaxHealth(cid), 65535, 256, true)
    doCreatureAddMana(cid, getCreatureMaxMana(cid))
    doRemoveConditions(cid, false)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce saiu da arena.")
    return false
    end
    return true
    end
  2. ACTIONS



    nome do seu script.lua

    local t = {
    lvl = 100,
    entrada = {
    {x = 710, y = 1420, z = 5}, -- pos players
    {x = 709, y = 1420, z = 5},
    {x = 708, y = 1420, z = 5},
    {x = 707, y = 1420, z = 5}
    },
    saida = {
    {x = 710, y = 1420, z = 6}, -- pos para onde eles irão
    {x = 709, y = 1420, z = 6},
    {x = 708, y = 1420, z = 6},
    {x = 707, y = 1420, z = 6}
    }
    }
    function onUse(cid, item, fromPosition, itemEx, toPosition)
    local check = {}
    for _, k in ipairs(t.entrada) do
    local x = getTopCreature(k).uid
    if(x == 0 or not isPlayer(x) or getPlayerLevel(x) < t.lvl) then
    doPlayerSendCancel(cid, 'Está faltando player ou alguém não possui level '..t.lvl..' ou mais.') return true
    end
    table.insert(check, x)
    end
    for i, tid in ipairs(check) do
    doSendMagicEffect(t.entrada[i], CONST_ME_POFF)
    doTeleportThing(tid, t.saida[i], false)
    doSendMagicEffect(t.saida[i], CONST_ME_ENERGYAREA)
    end
    doTransformItem(item.uid, item.itemid == 1945 and 1946 or 1945)
    return true
    end
  3. ------------------------------

     

    se não der então tenta assim:

     

     

    <event type="look" name="MarryLook" event="script"><![CDATA[
    domodlib('marry_func')
    function onLook(cid, thing, position, lookDistance)
    if isPlayer(thing.uid) and isMarried(thing.uid) then 
    if thing.uid ~= cid then
    doPlayerSetSpecialDescription(thing.uid,', '..(getPlayerSex(thing.uid) == 0 and 'esposa' or 'marido')..' de '..getPartner(thing.uid))
    else
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, '.\n'..(getPlayerSex(cid) == 0 and 'She' or 'He')..' is married to '..getPartner(cid))
    end
    end 
    return true
    end]]>
    </event>
  4. troca essa parte:


    <event type="look" name="MarryLook" event="script"><![CDATA[
    domodlib('marry_func')
    function onLook(cid, thing, position, lookDistance)
    if isPlayer(thing.uid) and isMarried(thing.uid) then
    if thing.uid ~= cid then
    doPlayerSetSpecialDescription(thing.uid,', '..(getPlayerSex(thing.uid) == 0 and 'esposa' or 'marido')..' de '..getPartner(thing.uid))
    else
    doPlayerSetSpecialDescription(cid,', '..(getPlayerSex(thing.uid) == 0 and 'esposa' or 'marido')..' de '..getPartner(thing.uid))
    end
    end
    return true
    end]]>
    </event>


    por


    <event type="look" name="MarryLook" event="script"><![CDATA[
    domodlib('marry_func')
    function onLook(cid, thing, position, lookDistance)
    if isPlayer(thing.uid) and isMarried(thing.uid) then
    doPlayerSetSpecialDescription(thing.uid,'.\n'..(getPlayerSex(thing.uid) == 0 and 'She' or 'He')..' is married to '..getPartner(thing.uid))
    elseif isPlayer(cid) and isMarried(cid) then
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, '.\n'..(getPlayerSex(cid) == 0 and 'She' or 'He')..' is married to '..getPartner(cid))
    end
    return true
    end]]></event>
  5.  

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <mod name="Characters Market System" version="1.0" author="LuckOake" contact="none" enabled="yes">
    ------------------------------------------------------------------------------------
    <config name="market"><![CDATA[
    price = 27112
    owner = 27113
    level = 30 -- Level mínimo que o character deve ter para ser vendido
    min_price = 1 -- Preço mínimo de um character
    max_price = 1000 -- Preço máximo de um character
     
     
    function pegarPoints(acc)
    local info = db.getResult("SELECT `p_points` FROM `accounts` WHERE `id` = "..acc)
    return info:getDataInt("p_points") < 0 and 0 or info:getDataInt("p_points")
    end
     
    function doTransferCharacter(cid, accId)
    return db.executeQuery("UPDATE `players` SET `account_id` = "..accId.." WHERE `id` = "..getPlayerGUIDByName(cid).."")
    end
     
    function doOfflinePlayerAddMoney(guid, money)
    return db.executeQuery("UPDATE `players` SET `balance` = `balance` + '"..money.."' WHERE `id` = '"..getPlayerGUIDByName(guid).."';")
    end
     
    function setOfflinePlayerStorageValue(name, key, value)
    local result = db.getResult("SELECT * FROM `player_storage` WHERE `player_id` = ".. getPlayerGUIDByName(name) .." AND `key` = ".. key ..";")
    if result:getID() == -1 then
    return db.executeQuery("INSERT INTO `player_storage` (`player_id`, `key`, `value`) VALUES (".. getPlayerGUIDByName(name) ..", ".. key ..", ".. value ..");")
    else
    result:free()
    return db.executeQuery("UPDATE `player_storage` SET `value` = ".. value .." WHERE `player_id` = ".. getPlayerGUIDByName(name) .." AND `key` = ".. key ..";")
    end
    end
     
    function getOfflinePlayerStorageValue(name, key)
    local result, ret = db.getResult("SELECT `value` FROM `player_storage` WHERE `player_id` = '".. getPlayerGUIDByName(name) .."' AND `key` = ".. key ..";")
    if result:getID() == -1 then
    return nil
    end
    ret = result:getDataInt("value")
    result:free()
    return ret
    end
     
    function getOfflinePlayerValue(name, value)
    local result, ret = db.getResult("SELECT `"..value.."` FROM `players` WHERE `id` = "..getPlayerGUIDByName(name)..";")
    ret = result:getDataInt(value)
    result:free()
    return ret
    end
     
    function isCharacterForSale(name)
    if not getOfflinePlayerStorageValue(name, price) or getOfflinePlayerStorageValue(name, price) < 1 then
    return false
    else
    return true
    end
    end
    ]]></config>
    ------------------------------------------------------------------------------------
    <talkaction words="!character" event="buffer"><![CDATA[
    domodlib('market')
    local t = string.explode(param, ",")
     
    if t[1] == "sell" then
    if not t[3] or not tonumber(t[3]) or t[4] or tonumber(t[2]) then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Incorrect Params. Specify the character name and the price.") return true
    elseif getPlayerAccountId(cid) ~= getAccountIdByName(t[2]) then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This is not your character.") return true
    elseif isCharacterForSale(t[2]) then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character is already for sale.") return true
    elseif getPlayerGUIDByName(t[2]) == getPlayerGUID(cid) then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You cannot sell yourself.") return true
    elseif getPlayerByName(t[2]) then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "The character must be offline to be sold.") return true
    elseif getOfflinePlayerValue(t[2], "level") < level then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your character can't be sold until it has level "..level..".") return true
    elseif tonumber(t[3]) < min_price then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Sorry, but the minimum price for selling a character is "..min_price..".") return true
    elseif tonumber(t[3]) > max_price then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Sorry, but the maximum price for selling a character is "..max_price..".") return true
    end
     
    setOfflinePlayerStorageValue(t[2], price, t[3])
    setOfflinePlayerStorageValue(t[2], owner, getPlayerGUID(cid))
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'Your character "'..t[2]..'" is now for sale for the price of "'..t[3]..'" points.')
    elseif t[1] == "buy" then
    if not t[2] then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Incorrect Params. Specify the character name.") return true
    elseif not playerExists(t[2]) then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character doesn't exist.") return true
    elseif getPlayerAccountId(cid) == getAccountIdByName(t[2]) then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You can't buy your own character.") return true
    elseif not isCharacterForSale(t[2]) then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character is not for sale.") return true
    elseif getPoints(cid) < getOfflinePlayerStorageValue(t[2], price) then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Not enough points. This character's price is "..getOfflinePlayerStorageValue(t[2], price).." points") return true
    end
    local pp = getOfflinePlayerStorageValue(t[2], price)
    local dono = getAccountIdByName(t[2])
    db.executeQuery("UPDATE `accounts` SET `p_points` = " .. pegarPoints(dono) + pp .. " WHERE `id` = "..dono)
    if not getPlayerByGUID(getOfflinePlayerStorageValue(t[2], owner)) then
    setOfflinePlayerStorageValue(getPlayerNameByGUID(getOfflinePlayerStorageValue(t[2], owner)), 41792, getPlayerGUIDByName(t[2]))
    else
    doPlayerSendTextMessage(getPlayerByGUID(getOfflinePlayerStorageValue(t[2], owner)), MESSAGE_STATUS_CONSOLE_BLUE, 'Your character "'..t[2]..'" has been sold for the price of '..getOfflinePlayerStorageValue(t[2], price)..' points.')
    end
    doPlayerRemovePoints(cid, getOfflinePlayerStorageValue(t[2], price))
    doTransferCharacter(t[2], getPlayerAccountId(cid))
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You bought the character "'..t[2]..'" for the price of '..getOfflinePlayerStorageValue(t[2], price)..' points.')
    setOfflinePlayerStorageValue(t[2], owner, -1)
    setOfflinePlayerStorageValue(t[2], price, -1) return true
    elseif t[1] == "remove" then
    if not t[2] then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Incorrect Params. Specify the character name.") return true
    elseif getPlayerAccountId(cid) ~= getAccountIdByName(t[2]) then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This is not your character.") return true
    elseif not isCharacterForSale(t[2]) then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "This character is not for sale.") return true
    end
    setOfflinePlayerStorageValue(t[2], price, -1)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, 'You removed the character "'..t[2]..'" from the Characters Market.') return true
    elseif t[1] == "list" then
    local result = db.getResult("SELECT `name` FROM `players`")
    if result:getID() == -1 then
    return true
    end
    local msg = "Characters for Sale:\n\n"
    while true do
    local name = result:getDataString("name")
    if isCharacterForSale(name) then
    local sex = getOfflinePlayerValue(name, "sex") == 1 and "Male" or "Female"
    msg = ""..msg.." - ".. name .." (Level: "..getOfflinePlayerValue(name, "level").." / Vocation: "..getVocationInfo(getOfflinePlayerValue(name, "vocation")).name.." / Sex: "..sex.." / Owner: "..getPlayerNameByGUID(getOfflinePlayerStorageValue(name, owner))..") [Price: "..getOfflinePlayerStorageValue(name, price).."] \n"
    end
    if not result:next() then
    break
    end
    end
    doPlayerPopupFYI(cid, msg) return true
    elseif not t[1] or t[1] ~= "buy" or t[1] ~= "sell" or t[1] ~= "remove" or t[1] ~= "list" then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Incorrect params. You can only 'buy' or 'sell' a character, 'remove' it from the Characters Market or see the 'list' of characters for sale.") return true
    end
    return true
    ]]></talkaction>
    ------------------------------------------------------------------------------------
    <event type="login" name="MarketLogin" event="script"><![CDATA[
    function onLogin(cid)
    domodlib('market')
    if getPlayerStorageValue(cid, price) > 0 then return false
    elseif getPlayerStorageValue(cid, 41792) ~= -1 then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "You sold the character "..getPlayerNameByGUID(getPlayerStorageValue(cid, 41792))..". The points is in your account.")
    setPlayerStorageValue(cid, 41792, -1)
    end
    return true
    end
    ]]></event>
    </mod>
  6. troca


    if msgcontains(msg, 'yes') and getPlayerItemCount(cid,2197) >= 1 then


    por


    if msgcontains(msg, 'yes') and getPlayerSlotItem(cid, CONST_SLOT_NECKLACE).itemid == 2197 then

  7. já existe

     

    function onSay(cid, words, param) 
    local femaleOutfits = { ["citizen"]={136}, ["hunter"]={137}, ["mage"]={138}, ["knight"]={139}, ["noblewoman"]={140}, ["summoner"]={141}, ["warrior"]={142}, ["barbarian"]={147}, ["druid"]={148}, ["wizard"]={149}, ["oriental"]={150}, ["pirate"]={155}, ["assassin"]={156}, ["beggar"]={157}, ["shaman"]={158}, ["norsewoman"]={252}, ["nightmare"]={269}, ["jester"]={270}, ["brotherhood"]={279}, ["demonhunter"]={288}, ["yalaharian"]={324}, ["warmaster"]={336} } 
    local maleOutfits = { ["citizen"]={128}, ["hunter"]={129}, ["mage"]={130}, ["knight"]={131}, ["nobleman"]={132},["summoner"]={133}, ["warrior"]={134}, ["barbarian"]={143}, ["druid"]={144}, ["wizard"]={145}, ["oriental"]={146}, ["pirate"]={151}, ["assassin"]={152}, ["beggar"]={153}, ["shaman"]={154}, ["norsewoman"]={251}, ["nightmare"]={268}, ["jester"]={273}, ["brotherhood"]={278}, ["demonhunter"]={289}, ["yalaharian"]={325}, ["warmaster"]={335}, ["wayfarer"]={366} } 
    local msg = {"Command requires GOOD param!", "You dont have Addon Doll!", "Bad param!", "Full Addon Set sucesfully added!"} 
    local x = string.explode(param, ",") 
    if(getPlayerItemCount(cid, 8982) > 0) then 
    if param ~= "" then 
    if maleOutfits[x[1]:lower()] and femaleOutfits[x[1]:lower()] then
    if (x[2] == '1' or x[2] == '2') then
    doPlayerRemoveItem(cid, 8982, 1) 
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, msg[4]) 
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_GIFT_WRAPS) 
    if(getPlayerSex(cid) == 0)then 
    doPlayerAddOutfit(cid, femaleOutfits[x[1]:lower()][1], x[2]) 
    else 
    doPlayerAddOutfit(cid, maleOutfits[x[1]:lower()][1], x[2]) 
    end
    else
    doPlayerSendTextMessage(cid, 27, msg[3])
    end
    else
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, msg[3])
    end
    else 
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, msg[1]) 
    end 
    else 
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, msg[2]) 
    end
    return true
    end
    exemplo:
    !addon knight, 1
  8. no mods tenta trocar essa parte:

     

    <event type="login" name="itemstats_login" event="buffer"><![CDATA[
    registerCreatureEvent(cid, 'itemstats')
    ]]></event>
    por essa:
    <event type="login" name="itemstats_login" event="script"><![CDATA[
    function onLogin(cid)
    registerCreatureEvent(cid, 'itemstats')
        return true
        end]]></event>

     

    no mods tenta trocar essa parte:

     

    <event type="login" name="itemstats_login" event="buffer"><![CDATA[
    registerCreatureEvent(cid, 'itemstats')
    ]]></event>
    por essa:
    <event type="login" name="itemstats_login" event="script"><![CDATA[
    function onLogin(cid)
    registerCreatureEvent(cid, 'itemstats')
        return true
        end]]></event>

     

     

     

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

     

    se o usar o script troca:

     

    function onLogin(player)
    player:registerEvent("randomstats_loot")
    return true
    end
    por
    function onLogin(cid)
    registerCreatureEvent(cid, 'itemstats')
    return true
    end

    no mods tenta trocar essa parte:

     

    <event type="login" name="itemstats_login" event="buffer"><![CDATA[
    registerCreatureEvent(cid, 'itemstats')
    ]]></event>
    por essa:
    <event type="login" name="itemstats_login" event="script"><![CDATA[
    function onLogin(cid)
    registerCreatureEvent(cid, 'itemstats')
        return true
        end]]></event>

     

     

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

     

    se o usar o script troca:

     

    function onLogin(player)
    player:registerEvent("randomstats_loot")
    return true
    end
    por
    function onLogin(cid)
    registerCreatureEvent(cid, 'itemstats')
    return true
    end

    no mods tenta trocar essa parte:

     

    <event type="login" name="itemstats_login" event="buffer"><![CDATA[
    registerCreatureEvent(cid, 'itemstats')
    ]]></event>
    por essa:
    <event type="login" name="itemstats_login" event="script"><![CDATA[
    function onLogin(cid)
    registerCreatureEvent(cid, 'itemstats')
        return true
        end]]></event>

     

     

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

     

    se o usar o script troca:

     

    function onLogin(player)
    player:registerEvent("randomstats_loot")
    return true
    end
    por
    function onLogin(cid)
    registerCreatureEvent(cid, 'itemstats')
    return true
    end

    TD BUGADO ISSO MEU DEUS

     

    -----------

     

    NO SCRIPT TROCA ESSA PARTE:

     

    function onLogin(player)
    player:registerEvent("randomstats_loot")
    return true
    end
    por
    function onLogin(cid)
    registerCreatureEvent(cid, 'itemstats')
    return true
    end
  9. arrumei, é só um MODS...

     

    caso não de certo tenta:

     

    creaturescripts.xml:
    <event type="login" name="randomstats_register" script="randomstats.lua"/>
       <event type="kill" name="randomstats_loot" script="randomstats.lua"/>
    randomstats.lua
    local rare_popup = true
    local rare_text = "*rare*"
    local rare_effect = true
    local rare_effect_id = CONST_ME_MAGIC_GREEN
     
    local tiers = {
    [1] = {
    prefix = 'rare',
    showattr = true, -- attr prefix will be shown instead
    extra = {0, 0},
    chance = {
    [1] = 10000, -- chance for basic stat
    [2] = 5000 -- chance for second stat
    }
    },
     
    [2] = {
    prefix = 'epic',
    extra = {7, 20}, -- additional percent bonus
    chance = {
    [1] = 3333,
    [2] = 25000
    }
    },
     
    [3] = {
    prefix = 'legendary',
    extra = {20, 35},
    chance = {
    [1] = 1000,
    [2] = 100000 -- 2 bonuses always
    }
    },
    }
     
    --! attributes
    local attr = {
    atk = {
    name = 'atk',
    prefix = 'sharpened',
    percent = {7, 25},
    },
    def = {
    name = 'def',
    prefix = 'fortified',
    percent = {7, 25},
    },
    extradef = {
    name = 'extra def',
    prefix = 'balanced',
    percent = {7, 25},
    },
    arm = {
    name = 'arm',
    prefix = 'flawless',
    percent = {7, 20},
    },
    hitchance = {
    name = 'accuracy',
    prefix = 'accurate',
    percent = {10, 25},
    },
    shootrange = {
    name = 'range',
    prefix = 'powerful',
    percent = {17, 34},
    },
    charges = {
    name = 'charges',
    prefix = 'charged',
    percent = {30, 45},
    },
    duration = {
    name = 'time',
    prefix = 'unique',
    percent = {35, 50},
    },
     
    --[[ not available in 1.1
    attackSpeed = {},
    extraAttack = {},
    ]]
    }
     
    local stats = {
    [1] = {ITEM_ATTRIBUTE_ATTACK, attr.atk},
    [2] = {ITEM_ATTRIBUTE_DEFENSE, attr.def},
    [3] = {ITEM_ATTRIBUTE_EXTRADEFENSE, attr.extradef},
    [4] = {ITEM_ATTRIBUTE_ARMOR, attr.arm},
    [5] = {ITEM_ATTRIBUTE_HITCHANCE, attr.hitchance},
    [6] = {ITEM_ATTRIBUTE_SHOOTRANGE, attr.shootrange},
    [7] = {ITEM_ATTRIBUTE_CHARGES, attr.charges},
    [8] = {ITEM_ATTRIBUTE_DURATION, attr.duration},
    -- not available in 1.1
    -- [9] = {ITEM_ATTRIBUTE_ATTACKSPEED, attr.attackSpeed},
    -- [10] = {ITEM_ATTRIBUTE_EXTRAATTACK, attr.extraAttack},
    }
     
    function stat_getItemDuration(item)
    local it_id = item:getId()
    local tid = ItemType(it_id):getTransformEquipId()
    if tid > 0 then
    item:transform(tid)
    local vx = item:getAttribute(ITEM_ATTRIBUTE_DURATION)
    item:transform(it_id)
    item:removeAttribute(ITEM_ATTRIBUTE_DURATION)
    return vx
    end
    return 0
    end
     
    function loot_attrToVal(item, attr)
    local id = ItemType(item:getId())
    local v = {
    [ITEM_ATTRIBUTE_ATTACK] = id:getAttack(),
    [ITEM_ATTRIBUTE_DEFENSE] = id:getDefense(),
    [ITEM_ATTRIBUTE_EXTRADEFENSE] = id:getExtraDefense(),
    [ITEM_ATTRIBUTE_ARMOR] = id:getArmor(),
    [ITEM_ATTRIBUTE_HITCHANCE] = id:getHitChance(),
    [ITEM_ATTRIBUTE_SHOOTRANGE] = id:getShootRange(),
    [ITEM_ATTRIBUTE_CHARGES] = id:getCharges(),
    [ITEM_ATTRIBUTE_DURATION] = stat_getItemDuration(item),
     
    -- not available in 1.1
    -- [ITEM_ATTRIBUTE_ATTACKSPEED] = item:getAttackSpeed(),
    -- [ITEM_ATTRIBUTE_EXTRAATTACK] = item:getExtraAttack(),
    }
    return v[attr]
    end
     
    function assign_loot_Stat(c)
    local rares = 0
    local h = c:getItemHoldingCount()
    if h > 0 then
    for i = 1, h do
    local available_stats = {}
    local it_u = c:getItem(i - 1)
    local it_id = ItemType(it_u:getId())
    if it_u:isContainer() then
    local crares = assign_loot_Stat(it_u)
    rares = rares + crares
    else
    if not it_id:isStackable() then
    local wp = it_id:getWeaponType()
    if wp > 0 then
    if wp == WEAPON_SHIELD then -- type shield
    table.insert(available_stats, stats[2])
    elseif wp == WEAPON_DISTANCE then -- type bow
    table.insert(available_stats, stats[1])
    table.insert(available_stats, stats[5])
    table.insert(available_stats, stats[6])
    -- not available in 1.1
    -- table.insert(available_stats, stats[9])
    elseif wp == WEAPON_WAND then -- type wand
    table.insert(available_stats, stats[6])
    -- not available in 1.1
    -- table.insert(available_stats, stats[9])
    elseif isInArray({WEAPON_SWORD, WEAPON_CLUB, WEAPON_AXE}, wp) then -- melee weapon
     
    if it_id:getAttack() > 0 then
    table.insert(available_stats, stats[1])
    end
     
    if it_id:getDefense() > 0 then
    table.insert(available_stats, stats[2])
    end
     
    if it_id:getExtraDefense() ~= 0 then
    table.insert(available_stats, stats[3])
    end
    -- not available in 1.1
    -- table.insert(available_stats, stats[10])
    end
    else -- armors, amulets, runes and rings
    if it_id:getArmor() > 0 then
    table.insert(available_stats, stats[4])
    end
     
    if it_id:getCharges() > 0 then
    table.insert(available_stats, stats[7])
    end
     
    local eq_id = it_id:getTransformEquipId()
    if eq_id > 0 then
    table.insert(available_stats, stats[8])
    end
    end
    end
    end
     
    if #available_stats > 0 then
    -- skips it all if it's empty
    local tier = math.random(1, #tiers)
    if #tiers[tier].chance > 0 then
    local statsStored = 0
    local stats_used = {}
    for stat = 1, #tiers[tier].chance do
    if #available_stats > 0 then
    -- stops if no more stats available
    if stat - 1 == statsStored then
    -- checks when it's time to stop adding stats
    if math.random(1, 100000) <= tiers[tier].chance[stat] then
    statsStored = statsStored + 1
     
    local selected_stat = math.random(1, #available_stats)
    table.insert(stats_used, available_stats[selected_stat])
    table.remove(available_stats, selected_stat)
    end
    end
    end
    end
     
    if #stats_used > 0 then
    rares = rares + 1
    local stat_desc = {}
    for stat = 1, #stats_used do
    local v = math.random(
    stats_used[stat][2].percent[1],
    stats_used[stat][2].percent[2]
    ) + math.random(
    tiers[tier].extra[1],
    tiers[tier].extra[2]
    )
    local basestat = loot_attrToVal(it_u, stats_used[stat][1])
    it_u:setAttribute(stats_used[stat][1], basestat + math.abs(basestat * v / 100))
    table.insert(stat_desc, '[' .. stats_used[stat][2].name .. ': +' .. v .. '%]')
    end
     
    if tiers[tier].showattr then
    for stat = 1, #stats_used do
    it_u:setAttribute(ITEM_ATTRIBUTE_NAME, "[" .. stats_used[stat][2].prefix .. "]" .. it_u:getAttribute(ITEM_ATTRIBUTE_NAME))
    end
    it_u:setAttribute(ITEM_ATTRIBUTE_NAME, it_u:getAttribute(ITEM_ATTRIBUTE_NAME) .. " " .. it_id:getName())
    else
    it_u:setAttribute(ITEM_ATTRIBUTE_NAME, tiers[tier].prefix .. " " .. it_id:getName())
    end
     
    it_u:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, table.concat(stat_desc, "\n"))
    end
    end
    end
    end
    end
    return rares
    end
     
    function find_loot_Container(pos)
    local rares = 0
    local c = Tile(pos):getTopDownItem()
    if c ~= nil then
    if c:isContainer() then
    rares = rares + assign_loot_Stat(c)
    if rares > 0 then
    if rare_popup then
    local spectators = Game.getSpectators(pos, false, true, 7, 7, 5, 5)
    for i = 1, #spectators do
    spectators[i]:say(rare_text, TALKTYPE_MONSTER_SAY, false, spectators[i], pos)
    end
    end
     
    if rare_effect then
    pos:sendMagicEffect(rare_effect_id)
    end
    end
    return true
    end
    end
    end
     
    function onKill(player, target, lastHit)
    if (not isSummon(target)) then
    addEvent(find_loot_Container, 2, target:getPosition())
    end
    return true
    end
     
    function onLogin(player)
    player:registerEvent("randomstats_loot")
    return true
    end

  10. MODS:



    ItemStats.xml


    <?xml version="1.0" encoding="UTF-8"?>
    <mod name="Random Item Stats" enabled="1">
    <config name="itemstats_conf"><![CDATA[
    -- //
    extra_loot_key = 123 --: optional storage for higher loot rate
    vocation_base_attackspeed = getVocationInfo(1).attackSpeed --: used for attackSpeed stat
    -- //

    tiers, attr = {}, {}

    tiers['rare'] = {
    color = 66, -- color of 'RARE' text
    extra = {0, 0},
    attrNames = true, -- show attribute names instead of rare
    chance = {
    [1] = 10000,
    [2] = 5000 -- chance for 2nd stat
    }
    }
    tiers['epic'] = {
    color = 35,
    extra = {7, 20}, -- additional percent bonus
    chance = {
    [1] = 3333,
    [2] = 25000
    }
    }
    tiers['legendary'] = {
    color = 149,
    extra = {20, 35},
    chance = {
    [1] = 1000,
    [2] = 100000 -- 2 bonuses always
    }
    }

    MELEE = 0
    DISTANCE = 1
    ARMOR = 2
    SHIELD = 3
    WAND = 4
    DURATION_RING = 5
    CHARGES = 6

    --! attributes
    attr['quick'] = {
    attr = 'attackSpeed',
    name = 'Attack Speed',
    percent = {6, 20},
    types = {MELEE, DISTANCE, WAND}
    }
    attr['fortified'] = {
    attr = 'extraDefense',
    base = 'defense',
    name = 'Defense',
    percent = {7, 25},
    types = {MELEE, SHIELD}
    }
    attr['deadly'] = {
    attr = 'extraAttack',
    base = 'attack',
    name = 'Attack',
    types = {MELEE},
    percent = {7, 25}
    }
    attr['strong'] = {
    attr = 'armor',
    name = 'Armor',
    percent = {7, 20},
    types = {ARMOR}
    }
    attr['hawkeye\'s'] = {
    attr = 'hitChance',
    name = 'Hit Chance',
    percent = {10, 25},
    types = {DISTANCE}
    }
    --[[ // not available without source edit
    attr['farsight'] = {
    attr = 'shootRange',
    name = 'Shoot Range',
    percent = {17, 34},
    types = {DISTANCE, WAND}
    }
    ]]
    attr['charged'] = {
    attr = 'charges',
    name = 'Charges',
    percent = {30, 45},
    types = {CHARGES}
    }
    attr['divine'] = {
    attr = 'duration',
    name = 'Duration',
    percent = {35, 50},
    types = {DURATION_RING}
    }
    --/ attributes

    rate = getConfigInfo('rateLoot')

    if( getConfigInfo('monsterLootMessage') ~= 0 )then
    print('[Notice] Set monsterLootMessage = 0 to prevent duplicate loot messages')
    end
    ]]></config>

    <event type="kill" name="itemstats" event="script"><![CDATA[
    domodlib('itemstats_conf')

    function round(n, s)
    return tonumber(('%.' .. (s or 0) .. 'f'):format(n))
    end

    function getContentDescription(uid, sep)
    local ret, i, containers = '', 0, {}
    while( i < getContainerSize(uid) )do
    local v, s = getContainerItem(uid, i), ''
    local k = getItemInfo(v.itemid)
    k.name = getItemAttribute(v.uid, 'name') or k.name
    if( k.name ~= '' )then
    if( v.type > 1 and k.stackable and k.showCount )then
    s = v.type .. ' ' .. k.plural
    else
    local article = getItemAttribute(v.uid, 'article') or k.article
    s = (article == '' and '' or article .. ' ') .. k.name
    end
    ret = ret .. (i == 0 and not sep and '' or ', ') .. s
    if( isContainer(v.uid) and getContainerSize(v.uid) ~= 0 )then
    table.insert(containers, v.uid)
    end
    else
    ret = ret .. (i == 0 and not sep and '' or ', ') .. 'an item of type ' .. v.itemid .. ', please report it to gamemaster'
    end
    i = i + 1
    end
    for i = 1, #containers do
    ret = ret .. getContentDescription(containers, true)
    end
    return ret
    end

    local function send(cid, corpse, monster)
    if( isPlayer(cid) )then
    local ret = corpse and isContainer(corpse) and getContentDescription(corpse)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Loot of ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing'))
    local party = getPlayerParty(cid)
    if( party )then
    for _, pid in ipairs(getPartyMembers(party)) do
    doPlayerSendChannelMessage(pid, '', 'Loot of ' .. monster .. ': ' .. (ret ~= '' and ret or 'nothing'), TALKTYPE_CHANNEL_W, CHANNEL_PARTY)
    end
    end
    end
    end

    local function createLoot(i, ext)
    local item = type(i.id) == 'table' and i.id[math.random(#i.id)] or i.id
    local random = math.ceil(math.random(100000) / ext)
    local tmpItem, f

    if( random < i.chance )then
    if i.subType == -1 then
    f = getItemInfo(item)
    end
    tmpItem = doCreateItemEx(item,
    i.subType ~= -1 and i.subType or
    f.stackable and random % i.count + 1 or
    f.charges ~= 0 and f.charges or
    1
    )
    end

    if( not tmpItem )then
    return
    end

    if( i.actionId ~= -1 )then
    doItemSetAttribute(tmpItem, 'aid', i.actionId)
    end

    if( i.uniqueId ~= -1 )then
    doItemSetAttribute(tmpItem, 'uid', i.uniqueId)
    end

    if( i.text ~= '' )then
    doItemSetAttribute(tmpItem, 'text', i.text)
    end

    local ret, done

    for k, v in pairs(tiers) do
    local cur, used = {}, {}
    for i = 1, #v.chance do
    if( math.random(100000) <= v.chance )then
    if( f )then
    f = getItemInfo(item)
    end
    if( not f.stackable )then
    for m, n in pairs(attr) do
    if( not table.find(used, m) and
    (
    ( table.find(n.types, MELEE) and table.find({WEAPON_SWORD, WEAPON_CLUB, WEAPON_AXE}, f.weaponType) ) or
    ( table.find(n.types, DISTANCE) and f.weaponType == WEAPON_DIST and f.ammoType ~= 0 ) or
    ( table.find(n.types, ARMOR) and f.armor ~= 0 and f.wieldPosition ~= CONST_SLOT_NECKLACE ) or
    ( table.find(n.types, SHIELD) and f.defense ~= 0 and f.weaponType == WEAPON_SHIELD ) or
    ( table.find(n.types, WAND) and f.weaponType == WEAPON_WAND ) or
    ( table.find(n.types, DURATION_RING) and f.wieldPosition == CONST_SLOT_RING and f.transformEquipTo ~= 0 ) or
    ( table.find(n.types, CHARGES) and table.find({CONST_SLOT_RING, CONST_SLOT_NECKLACE}, f.wieldPosition) and f.charges ~= 0 )
    ) )then
    table.insert(cur, m)
    end
    end

    if( #cur ~= 0 )then
    local n = cur[math.random(#cur)]
    table.insert(used, n)

    n = attr[n]
    local percent, new, tmp = math.random(n.percent[1] + (v.extra[1] or 0), n.percent[2] + (v.extra[2] or 0))
    -- hacks
    if( n.attr == 'duration' )then
    tmp = getItemInfo(f.transformEquipTo)
    if tmp.transformDeEquipTo ~= item then
    break
    end
    new = round( tmp.decayTime * (1 + percent / 100) * 1000 )
    elseif( n.attr == 'attackSpeed' )then
    new = round( vocation_base_attackspeed / (1 + percent / 100) )
    elseif( n.attr == 'hitChance' ) then
    new = round(
    f.hitChance == -1 and
    percent
    or
    f.hitChance * (1 + percent / 100)
    )
    else
    new = round(
    n.base and
    f[n['attr']] + f[n['base']] * (percent / 100)
    or
    f[n['attr']] * (1 + percent / 100)
    )

    if( new == f[n[n.base and 'base' or 'attr']] )then -- no improvement
    break
    end
    end

    doItemSetAttribute(tmpItem, n.attr:lower(), new)

    local name = getItemAttribute(tmpItem, 'name')
    if( v.attrNames or not name )then
    local name = (v.attrNames and used[#used] or k) .. ' ' .. (name or f.name)
    doItemSetAttribute(tmpItem, 'name', name)

    if( f.article ~= '' )then
    local article = getArticle(name)
    if( article ~= f.article )then
    doItemSetAttribute(tmpItem, 'article', article)
    end
    end
    end

    local desc = getItemAttribute(tmpItem, 'description') or f.description
    doItemSetAttribute(tmpItem, 'description', '[' .. n.name .. ': +' .. percent .. '%]' .. (desc == '' and '' or '\n' .. desc))

    ret = k
    end
    cur = {}
    if( #v.chance == i )then
    done = true
    end
    end
    else
    done = i ~= 1
    break
    end
    end
    if( done )then
    break
    end
    end

    return tmpItem, ret
    end

    local function createChildLoot(parent, i, ext, pos)
    if( not i or #i == 0 )then
    return true
    end

    local size, cap = 0, getContainerCap(parent)
    for k = 1, #i do
    if( size == cap )then
    break
    end
    local tmp, ret = createLoot(i[k], ext)
    if( tmp )then
    if( isContainer(tmp) )then
    if( createChildLoot(tmp, i[k].child, ext, pos) )then
    doAddContainerItemEx(parent, tmp)
    size = size + 1
    else
    doRemoveItem(tmp)
    end
    else
    if( ret )then
    doSendMagicEffect(pos, CONST_ME_MAGIC_GREEN)
    doSendAnimatedText(pos, ret:upper(), tiers[ret].color)
    end
    doAddContainerItemEx(parent, tmp)
    size = size + 1
    end
    end
    end

    return size > 0
    end

    local function dropLoot(pos, v, ext, master, cid, target)
    local corpse
    if( not master or master == target )then -- 0.3/4
    corpse = getTileItemById(pos, v.lookCorpse).uid
    if( isContainer(corpse) )then
    for i = 1, getContainerSize(corpse) do
    doRemoveItem(getContainerItem(corpse, 0).uid)
    end
    local size, cap = 0, getContainerCap(corpse)
    for i = 1, #v.loot do
    if( size == cap )then
    break
    end
    local tmp, ret = createLoot(v.loot, ext)
    if( tmp )then
    if( isContainer(tmp) )then
    if( createChildLoot(tmp, v.loot.child, ext, pos) )then
    doAddContainerItemEx(corpse, tmp)
    size = size + 1
    else
    doRemoveItem(tmp)
    end
    else
    if( ret )then
    doSendMagicEffect(pos, CONST_ME_MAGIC_GREEN)
    doSendAnimatedText(pos, ret:upper(), tiers[ret].color)
    end
    doAddContainerItemEx(corpse, tmp)
    size = size + 1
    end
    end
    end
    end
    end
    send(cid, corpse, v.description)
    end

    function onKill(cid, target, damage, flags)
    if( (damage == true or bit.band(flags, 1) == 1) and isMonster(target) )then -- 0.3/4
    local v = getMonsterInfo(getCreatureName(target))
    if( v and v.lookCorpse ~= 0 )then
    local s = getCreatureStorage(cid, extra_loot_key)
    addEvent(dropLoot, 0, getThingPos(target), v, s == -1 and rate or s, getCreatureMaster(target), cid, target)
    end
    end
    return true
    end
    ]]></event>

    <event type="login" name="itemstats_login" event="buffer"><![CDATA[
    registerCreatureEvent(cid, 'itemstats')
    ]]></event>

    </mod>


  11. e daí? mas vc uso o and <= 49

     

    então vai pegar todos lvl acima de 20 e todos lvl igual ou abaixo de 49

     

    vc sabe para que serve o "and"?

    if getPlayerLevel(cid) >= 20 and getPlayerLevel(cid) < 50 then
    ...
    elseif getPlayerLevel(cid) >= 50 and getPlayerLevel(cid) < 100 then
    ...
    end
    
    
  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
×
×
  • Criar Novo...