• 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!

TFS 1.X+ TFS 1.2 Problems rewards and first items

Eduardo170

Well-Known Member
Joined
Jan 7, 2014
Messages
422
Solutions
3
Reaction score
66
Location
Caracas, Venezuela
Hi guys, In the first items script nothing happens, it dont show errors, but neither does it grant the articles to new players.
problem first item solved by @d0gw4r (check out down)
creaturescript.xml
Code:
<event type="login" name="FirstItems" script="others/firstitems.lua" />
Code:
-- Without Rookgaard
local config = {
    [1] = {
        --equipment spellbook, wand of vortex, magician's robe, mage hat, studded legs, leather boots, scarf
        items = {{2175, 1}, {2190, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}, {2661, 1}},
        --container rope, shovel, mana potion
        container = {{2120, 1}, {2554, 1}, {7620, 1}}
    },
    [2] = {
        --equipment spellbook, snakebite rod, magician's robe, mage hat, studded legs, leather boots scarf
        items = {{2175, 1}, {2182, 1}, {8819, 1}, {8820, 1}, {2468, 1}, {2643, 1}, {2661, 1}},
        --container rope, shovel, mana potion
        container = {{2120, 1}, {2554, 1}, {7620, 1}}
    },
    [3] = {
        --equipment dwrven shield, 5 spear, ranger's cloak, ranger legs scarf, legion helmet
        items = {{2525, 1}, {2389, 5}, {2660, 1}, {8923, 1}, {2643, 1}, {2661, 1}, {2480, 1}},
        --container rope, shovel, health potion, bow, 50 arrow
        container = {{2120, 1}, {2554, 1}, {7618, 1}, {2456, 1}, {2544, 50}}
    },
    [4] = {
        --equipment dwarven shield, steel axe, brass armor, brass helmet, brass legs scarf
        items = {{2525, 1}, {8601, 1}, {2465, 1}, {2460, 1}, {2478, 1}, {2643, 1}, {2661, 1}},
        --container jagged sword, daramian mace, rope, shovel, health potion
        container = {{8602, 1}, {2439, 1}, {2120, 1}, {2554, 1}, {7618, 1}}
    }
}

function onLogin(player)
    local targetVocation = config[player:getVocation():getId()]
    if not targetVocation then
        return true
    end

    if player:getLastLoginSaved() ~= 0 then
        return true
    end

    for i = 1, #targetVocation.items do
        player:addItem(targetVocation.items[i][1], targetVocation.items[i][2])
    end

    local backpack = player:addItem(1988)
    if not backpack then
        return true
    end

    for i = 1, #targetVocation.container do
        backpack:addItem(targetVocation.container[i][1], targetVocation.container[i][2])
    end
    return true
end
login.lua
Code:
player:registerEvent("FirstItems")




2-This scripts dont rewards with items established. It also lets you open all the chests.

Code:
local storage_id = 2000

local rewards = {
    [1] = {chest_uid = 2001, reward_id = 2494, reward_count = 1}, --demon armor
    [2] = {chest_uid = 2002, reward_id = 2400, reward_count = 1}, --magic sword
    [3] = {chest_uid = 2003, reward_id = 2431, reward_count = 1}, --stonecuter axe
    [4] = {chest_uid = 2004, reward_id = 2421, reward_count = 1} --thunder hammer
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local storage = player:getStorageValue(storage_id)
    if storage > 0 then
        return player:sendTextMessage(MESSAGE_INFO_DESCR, "It is empty.")
    end

    local reward
    for i = 1, #rewards do
        if rewards[i].chest_uid == item.uid then
            reward = rewards[i]
            break
        end
    end

    local reward_type = ItemType(reward.reward_id)
    if reward_type then
        if player:addItem(reward.reward_id, reward.reward_count, false, 1, CONST_SLOT_WHEREEVER) then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have found a " .. reward_type:getName():lower() .. ".")
            player:setStorageValue(storage_id, 1)
        else
            local weight = reward_type:getWeight()
            player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have found an item weighing ' .. weight / 100 .. ' oz it\'s too heavy or you do not have enough room.')
        end
    end
    return true
end

Code:
19:00 You have found a dead orc.
19:00 You have found a dead goblin.
19:00 You have found a dead elf.
19:00 You have found a remains of a mummy.
 
Last edited:
Solution
I don't have any player:registerEvent("FirstItems") into my login.lua, but first items are working fine for me, my TFS is v1.3, you can try my firstitems.lua if you want to.


Place this inside you creaturescripts.xml:

XML:
<event type="login" name="FirstItems" script="others/firstitems.lua" />



And put this inside /data/creaturescripts/scripts/others:

firstitems.lua
I don't have any player:registerEvent("FirstItems") into my login.lua, but first items are working fine for me, my TFS is v1.3, you can try my firstitems.lua if you want to.


Place this inside you creaturescripts.xml:

XML:
<event type="login" name="FirstItems" script="others/firstitems.lua" />



And put this inside /data/creaturescripts/scripts/others:

firstitems.lua
 

Attachments

Solution
I don't have any player:registerEvent("FirstItems") into my login.lua, but first items are working fine for me, my TFS is v1.3, you can try my firstitems.lua if you want to.


Place this inside you creaturescripts.xml:

XML:
<event type="login" name="FirstItems" script="others/firstitems.lua" />



And put this inside /data/creaturescripts/scripts/others:

firstitems.lua
I think it lacked the rookgard, that script was took without change anything, and didn't work, yours worked perfectly for me. Thank you. Now only the second script was missing
 
Me fala o caminho específico e o arquivo do script (percebi que você era br só depois que postei a mensagem anterior).
 
Me envie os arquivos e deixe os caminhos deles para que eu possa ver aqui, comparar, quem sabe os do meu otserver não lhe sirva bem, como o firstitems.lua já lhe serviu.
 
2-This scripts dont rewards with items established. It also lets you open all the chests.

Code:
local storage_id = 2000

local rewards = {
    [1] = {chest_uid = 2001, reward_id = 2494, reward_count = 1}, --demon armor
    [2] = {chest_uid = 2002, reward_id = 2400, reward_count = 1}, --magic sword
    [3] = {chest_uid = 2003, reward_id = 2431, reward_count = 1}, --stonecuter axe
    [4] = {chest_uid = 2004, reward_id = 2421, reward_count = 1} --thunder hammer
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local storage = player:getStorageValue(storage_id)
    if storage > 0 then
        return player:sendTextMessage(MESSAGE_INFO_DESCR, "It is empty.")
    end

    local reward
    for i = 1, #rewards do
        if rewards[i].chest_uid == item.uid then
            reward = rewards[i]
            break
        end
    end

    local reward_type = ItemType(reward.reward_id)
    if reward_type then
        if player:addItem(reward.reward_id, reward.reward_count, false, 1, CONST_SLOT_WHEREEVER) then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "You have found a " .. reward_type:getName():lower() .. ".")
            player:setStorageValue(storage_id, 1)
        else
            local weight = reward_type:getWeight()
            player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have found an item weighing ' .. weight / 100 .. ' oz it\'s too heavy or you do not have enough room.')
        end
    end
    return true
end

Code:
19:00 You have found a dead orc.
19:29 You have found a dead goblin.
19:29 You have found a dead elf.
19:29 You have found a remains of a mummy.
Refresh error in the second script.
37040
 
Back
Top