• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

NPC Testserver Assistant | Gives level, skills and magic depending on the day

kito2

www.masteria.net
Joined
Mar 9, 2009
Messages
3,766
Solutions
1
Reaction score
225
Location
Chile, Santiago
Hello

Just on zombie mode and created this useful script.
1) It will trade top tier items for 1 gp.
2) It will give for free Tibia Coins.
3) It will give for free money.
4) Add levels depending on day:
- Monday max level 100, and capped ml and skills.
- Tuesday max level 200, and capped ml and skills.
- Wednesday max level 300, and capped ml and skills.
- Thursday max level 400, and capped ml and skills.
- Friday till Sunday max level 500, and capped ml and skills.​

The max ml and skills can be easily configured on the configuration table:
Lua:
[character_vocation] = {
            [cap_level1] = {max_magic = max_ml1},
            [cap_level2] = {max_magic = max_ml1},
            [cap_level3] = {max_magic = max_ml1},
            [cap_level4] = {max_magic = max_ml1}
            },
...

The default configuration table is:
Lua:
local vocation_setup = {
    [1] = {
            [100] = {max_magic = 75},
            [200] = {max_magic = 90},
            [300] = {max_magic = 98},
            [400] = {max_magic = 105}
            },
    [2] = {
            [100] = {max_magic = 70},
            [200] = {max_magic = 88},
            [300] = {max_magic = 95},
            [400] = {max_magic = 101}
            },
    [3] = {
        [100] = {max_magic = 17, max_distance = 101, max_shielding = 87},
        [200] = {max_magic = 23, max_distance = 107, max_shielding = 93},
        [300] = {max_magic = 28, max_distance = 115, max_shielding = 98},
        [400] = {max_magic = 31, max_distance = 120, max_shielding = 101}
        },
    [4] = {
        [100] = {max_magic = 11, max_melee = 99, max_shielding = 95},
        [200] = {max_magic = 11, max_melee = 105, max_shielding = 100},
        [300] = {max_magic = 12, max_melee = 108, max_shielding = 104},
        [400] = {max_magic = 12, max_melee = 112, max_shielding = 108}
        }
}

The entire LUA script on data/npc/scripts/testserverAssistant.lua is:

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

local limit_level = 100

local vocation_setup = {
    [1] = {
            [100] = {max_magic = 75},
            [200] = {max_magic = 90},
            [300] = {max_magic = 98},
            [400] = {max_magic = 105}
            },
    [2] = {
            [100] = {max_magic = 70},
            [200] = {max_magic = 88},
            [300] = {max_magic = 95},
            [400] = {max_magic = 101}
            },
    [3] = {
        [100] = {max_magic = 17, max_distance = 101, max_shielding = 87},
        [200] = {max_magic = 23, max_distance = 107, max_shielding = 93},
        [300] = {max_magic = 28, max_distance = 115, max_shielding = 98},
        [400] = {max_magic = 31, max_distance = 120, max_shielding = 101}
        },
    [4] = {
        [100] = {max_magic = 11, max_melee = 99, max_shielding = 95},
        [200] = {max_magic = 11, max_melee = 105, max_shielding = 100},
        [300] = {max_magic = 12, max_melee = 108, max_shielding = 104},
        [400] = {max_magic = 12, max_melee = 112, max_shielding = 108}
        }
}

local itemList = {
    {name ="ferumbras' staff", id =    25420    , buy = 1},
    {name ="boots of homecoming", id =    25429    , buy = 1},
    {name ="ferumbras' amulet", id =    25423    , buy = 1},
    {name ="rod of carving (overcharged)", id =    25998    , buy = 1},
    {name ="rod of remedy (overcharged)", id =    25958    , buy = 1},
    {name ="rod of mayhem (overcharged)", id =    25918    , buy = 1},
    {name ="wand of carving (overcharged)", id =    25994    , buy = 1},
    {name ="wand of remedy (overcharged)", id =    25954    , buy = 1},
    {name ="wand of mayhem (overcharged)", id =    25917    , buy = 1},
    {name ="blade of carving (overcharged)", id =    25962    , buy = 1},
    {name ="blade of remedy (overcharged)", id =    25922    , buy = 1},
    {name ="blade of mayhem (overcharged)", id =    25909    , buy = 1},
    {name ="slayer of carving (overcharged)", id =    25966    , buy = 1},
    {name ="slayer of remedy (overcharged)", id =    25926    , buy = 1},
    {name ="slayer of mayhem (overcharged)", id =    25910    , buy = 1},
    {name ="axe of carving (overcharged)", id =    25970    , buy = 1},
    {name ="axe of remedy (overcharged)", id =    25930    , buy = 1},
    {name ="axe of mayhem (overcharged)", id =    25911    , buy = 1},
    {name ="chopper of carving (overcharged)", id =    25974    , buy = 1},
    {name ="chopper of remedy (overcharged)", id =    25934    , buy = 1},
    {name ="chopper of mayhem (overcharged)", id =    25912    , buy = 1},
    {name ="hammer of carving (overcharged)", id =    25982    , buy = 1},
    {name ="hammer of remedy (overcharged)", id =    25942    , buy = 1},
    {name ="hammer of mayhem (overcharged)", id =    25914    , buy = 1},
    {name ="mace of carving (overcharged)", id =    25978    , buy = 1},
    {name ="mace of remedy (overcharged)", id =    25938    , buy = 1},
    {name ="mace of mayhem (overcharged)", id =    25913    , buy = 1},
    {name ="bow of carving (overcharged)", id =    25986    , buy = 1},
    {name ="bow of remedy (overcharged)", id =    25946    , buy = 1},
    {name ="bow of mayhem (overcharged)", id =    25915    , buy = 1},
    {name ="crossbow of carving (overcharged)", id =    25990    , buy = 1},
    {name ="crossbow of remedy (overcharged)", id =    25950    , buy = 1},
    {name ="crossbow of mayhem (overcharged)", id =    25916    , buy = 1},
    {name ="energetic backpack", id =    26181    , buy = 1},
    {name ="void boots", id =    26133    , buy = 1},
    {name ="tiara of power", id =    26130    , buy = 1},
    {name ="collar of blue plasma", id =    26198    , buy = 1},
    {name ="collar of red plasma", id =    26200    , buy = 1},
    {name ="collar of green plasma", id =    26199    , buy = 1},
    {name ="ring of blue plasma", id =    26185    , buy = 1},
    {name ="ring of green plasma", id =    26187    , buy = 1},
    {name ="ring of red plasma", id =    26189    , buy = 1},
    {name ="werewolf helmet", id =    24718    , buy = 1},
    {name ="moonlight crystals", id =    24739    , buy = 1},
    {name ="umbral master blade", id =    22400    , buy = 1},
    {name ="umbral master slayer", id =    22403    , buy = 1},
    {name ="umbral master axe", id =    22406    , buy = 1},
    {name ="umbral master chopper", id =    22409    , buy = 1},
    {name ="umbral master mace", id =    22412    , buy = 1},
    {name ="umbral master mace", id =    22415    , buy = 1},
    {name ="umbral master bow", id =    22418    , buy = 1},
    {name ="umbral master crossbow", id =    22421    , buy = 1},
    {name ="umbral master spellbook", id =    22424    , buy = 1},
    {name ="infernal bolt", id =    6529    , buy = 1},
    {name ="crystalline arrow", id = 18304    , buy = 1},
    {name ="unrealized dream", id =    22598    , buy = 1},
   
    {name ="whacking driller of fate.", id = 10515        , buy = 1},
    {name ="squeezing gear of girlpower", id = 10513        , buy = 1},
    {name ="sneaky stabber of eliteness", id = 10511        , buy = 1},
    {name ="dwarven armor", id =    2503    , buy = 1},
    {name ="dwarven legs", id =    2504    , buy = 1},
    {name ="dwarven helmet", id =    2502    , buy = 1},
    {name ="golden boots", id =    2646    , buy = 1},
    {name ="great shield", id =    2522    , buy = 1},
    {name ="ornate chestplate", id =    15406    , buy = 1},
    {name ="ornate legs", id =    15412    , buy = 1},
    {name ="prismatic helmet", id =    18403    , buy = 1},
    {name ="depth calcei", id = 15410        , buy = 1},
    {name ="ornate shield", id =15413        , buy = 1},
    {name ="depth lorica", id =15407        , buy = 1},
    {name ="prismatic legs", id =18405        , buy = 1},
    {name ="elite draken helmet", id =12645        , buy = 1},
    {name ="assassin star", id =7368        , buy = 1},
    {name ="demonic essence", id =6500        , buy = 1},
    {name ="gill gugel", id =18398        , buy = 1},
    {name ="gill legs", id =18400        , buy = 1},
    {name ="yalahari mask", id =9778        , buy = 1},

   
}

local function setNewTradeTable(table)
    local items, item = {}
    for i = 1, #table do
        item = table[i]
        items[item.id] = {itemId = item.id, buyPrice = item.buy, sellPrice = item.sell, subType = 0, realName = item.name}
    end
    return items
end

local function greetCallback(cid)
    local player = Player(cid)
        npcHandler:setMessage(MESSAGE_GREET, "Welcome " .. player:getName() .. ", here you can {trade} items, get some {money}, get a bit of {experience} and receive {tibia coins}.")
       
   
    return true
end

local function creatureSayCallback(cid, type, msg)
    if not npcHandler:isFocused(cid) then
        return false
    end
    local player = Player(cid)
   
   
   
    if msgcontains(msg, "money") then
        player:addItem(2160, 50)
        npcHandler:say("Here is some money, enjoy!", cid)
    elseif msgcontains(msg, "magic") or msgcontains(msg, "skill") or msgcontains(msg, "skills or magic") then
        local vocation, level = player:getVocation():getBase():getId(), player:getLevel()
        local level_cap = math.min(400, math.max(100,math.floor(level / 100) * 100))
        local voc_parameter = vocation_setup[vocation]
       
       
        local magic = voc_parameter[level_cap].max_magic and voc_parameter[level_cap].max_magic or 0
        local dist = voc_parameter[level_cap].max_distance and voc_parameter[level_cap].max_distance or 0
        local melee = voc_parameter[level_cap].max_melee and voc_parameter[level_cap].max_melee or 0
        local shield = voc_parameter[level_cap].max_shielding and voc_parameter[level_cap].max_shielding or 0
       
        local text = "I have increased your magic to " .. magic
       
        if player:getMagicLevel() < magic then
            player:addManaSpent(player:getVocation():getRequiredManaSpent(magic) - player:getManaSpent())
        else
            text = "You have already reached the maximum magic level cap of " .. magic
        end
       
        if player:getSkillLevel(SKILL_DISTANCE) < dist and player:getSkillLevel(SKILL_SHIELD, shield) < shield and vocation == 3 then
       
            player:addSkillTries(SKILL_DISTANCE, player:getVocation():getRequiredSkillTries(SKILL_DISTANCE, dist) - player:getSkillTries(SKILL_DISTANCE))
            player:addSkillTries(SKILL_SHIELD, player:getVocation():getRequiredSkillTries(SKILL_SHIELD, shield) - player:getSkillTries(SKILL_SHIELD))
            text = text .. ", your distance to " .. dist
            text = text .. ", your shield skill to " .. shield
        elseif vocation == 3 then
            text = "You have already reached the maximum distance cap of " .. dist .. " and shield cap of " .. shield
        end
       
        if (player:getSkillLevel(SKILL_CLUB) < melee or player:getSkillLevel(SKILL_SWORD) < melee or player:getSkillLevel(SKILL_AXE) < melee) and player:getSkillLevel(SKILL_SHIELD, shield) < shield and vocation == 4 then
            player:addSkillTries(SKILL_CLUB, player:getVocation():getRequiredSkillTries(SKILL_CLUB, melee) - player:getSkillTries(SKILL_CLUB))
            player:addSkillTries(SKILL_SWORD, player:getVocation():getRequiredSkillTries(SKILL_SWORD, melee) - player:getSkillTries(SKILL_SWORD))
            player:addSkillTries(SKILL_AXE, player:getVocation():getRequiredSkillTries(SKILL_AXE, melee) - player:getSkillTries(SKILL_AXE))
            player:addSkillTries(SKILL_SHIELD, player:getVocation():getRequiredSkillTries(SKILL_SHIELD, shield) - player:getSkillTries(SKILL_SHIELD))
            text = text .. ", your melee skills to " .. melee
            text = text .. ", your shield skill to " .. shield
        elseif vocation == 4 then
            text = "You have already reached the maximum melee skills cap of " .. melee .. " and shield cap of " .. shield
        end
       
       
        npcHandler:say(text .. ".", cid)
       
    elseif msgcontains(msg, "experience") then
        limit_level = (os.date("%A") == "Monday") and 100 or ((os.date("%A") == "Tuesday") and 200 or ((os.date("%A") == "Wednesday") and 300 or ((os.date("%A") == "Thursday") and 400 or 500)))
        if player:getLevel() < limit_level then
            local exp_add = 5000000 * limit_level / 100 * 2
            player:addExperience(exp_add)
            local expMsg = format_num(exp_add,0)
            npcHandler:say("I have added you " .. expMsg .. ", enjoy!", cid)
        else
            npcHandler:say("Oh my child, you are over level ".. limit_level .. ", I can't give you more experience.", cid)
        end
    elseif msgcontains(msg, "tibia") or msgcontains(msg, "coin") then
        --db.query("UPDATE `accounts` SET `coins` = `coins` + 1000 WHERE `accounts`.`id` = " .. player:getAccountId())
        npcHandler:say("I'm sorry, but on this test server, the Tibia Coins has been disabled. All products on market have price 0 by the way.", cid)
    elseif msgcontains(msg, "trade") then
            local items = setNewTradeTable(itemList)
            local function onBuy(cid, item, subType, amount, ignoreCap, inBackpacks)
                if (ignoreCap == false and (player:getFreeCapacity() < ItemType(items[item].itemId):getWeight(amount) or inBackpacks and player:getFreeCapacity() < (ItemType(items[item].itemId):getWeight(amount) + ItemType(1988):getWeight()))) then
                    return player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You don\'t have enough cap.')
                end
                if items[item].buyPrice <= (player:isPremium() and (player:getMoney() + player:getBankBalance()) or player:getMoney()) then
                    if inBackpacks then
                        local container = Game.createItem(1988, 1)
                        local bp = player:addItemEx(container)
                        if (bp ~= 1) then
                            return player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You don\'t have enough container.')
                        end
                        for i = 1, amount do
                            container:addItem(items[item].itemId, items[item])
                        end
                    else
                        return
                        player:addItem(items[item].itemId, amount, false, items[item]) and
                        player:removeMoneyNpc(amount * items[item].buyPrice) and
                        player:sendTextMessage(MESSAGE_INFO_DESCR, 'You bought '..amount..'x '..items[item].realName..' for '..items[item].buyPrice * amount..' gold coins.')
                    end
                    player:sendTextMessage(MESSAGE_INFO_DESCR, 'You bought '..amount..'x '..items[item].realName..' for '..items[item].buyPrice * amount..' gold coins.')
                    player:removeMoneyNpc(amount * items[item].buyPrice)
                else
                    player:sendTextMessage(MESSAGE_STATUS_SMALL, 'You do not have enough money.')
                end
                return true
            end

            local function onSell(cid, item, subType, amount, ignoreEquipped)
                if items[item].sellPrice then
                    return
                    player:removeItem(items[item].itemId, amount, -1, ignoreEquipped) and
                    player:addMoney(items[item].sellPrice * amount) and

                    player:sendTextMessage(MESSAGE_INFO_DESCR, 'You sold '..amount..'x '..items[item].realName..' for '..items[item].sellPrice * amount..' gold coins.')
                end
                return true
            end

            openShopWindow(cid, itemList, onBuy, onSell)
            npcHandler:say({
            "Keep in mind " .. player:getName() .. ", here you can {trade} items, get some {money}, get a bit of {experience}, {skills or magic} and receive {tibia coins}. ...",
            "There are several caps depending on the day, on monday max level will be 100, tuesday 200, wednesday 300, thursday 400 and friday, saturday and sunday will be 500. ...",
            "Also there will be caps for magic level, skills melee and distance, and also shielding."
            }, cid) --cambiar
    end
    return true
end

npcHandler:setCallback(CALLBACK_GREET, greetCallback)
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

The NPC xml files on data/npc/Testserver Assistant.xml:
HTML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Testserver Assistant" script="Testserver Assistant.lua" walkinterval="2000" floorchange="0">
    <health now="100" max="100" />
    <look type="63" head="60" body="24" legs="38" feet="0" addons="0" />
</npc>

Hope it helps!
 
Back
Top