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

Lua TFS 1.4 - 10.98 - Adding Experience as part of a quest reward

xYzPrototype

Just a standard member
Joined
Feb 27, 2015
Messages
49
Reaction score
4
Location
EUW
Hello,

I am new to coding so please be nice

So this is a really simple one, but i cannot see what is wrong with this script. Basically, i want this quest to give 50 experience to the player as well as the reward item. I have the following script and i don't know why the exp part isn't working. The script isn't throwing up any errors and it still gives the item as intended.

EDIT: The exp does work it just doesn't come up with the experience as if you killed a monster, does anybody know how to show the experience come up on use?

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(1000) == 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'The loose board is empty.')
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found a doublet.')
        player:addItem(2485, 1)
        player:addExperience(50)
        player:setStorageValue(1000, 1)
    end
    return true
end
 
Solution
Hello,

I am new to coding so please be nice

So this is a really simple one, but i cannot see what is wrong with this script. Basically, i want this quest to give 50 experience to the player as well as the reward item. I have the following script and i don't know why the exp part isn't working. The script isn't throwing up any errors and it still gives the item as intended.

EDIT: The exp does work it just doesn't come up with the experience as if you killed a monster, does anybody know how to show the experience come up on use?

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(1000) == 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'The loose board is empty.')...
Hello,

I am new to coding so please be nice

So this is a really simple one, but i cannot see what is wrong with this script. Basically, i want this quest to give 50 experience to the player as well as the reward item. I have the following script and i don't know why the exp part isn't working. The script isn't throwing up any errors and it still gives the item as intended.

EDIT: The exp does work it just doesn't come up with the experience as if you killed a monster, does anybody know how to show the experience come up on use?

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(1000) == 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'The loose board is empty.')
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found a doublet.')
        player:addItem(2485, 1)
        player:addExperience(50)
        player:setStorageValue(1000, 1)
    end
    return true
end

It works but if u want to show up the experience then add a true after the exp

player:addExperience(50, true)

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local storage = 1000
    if player:getStorageValue(storage) == 1 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'The loose board is empty.')
        return true
    end
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, 'You have found a doublet.')
    player:addItem(2485, 1)
    player:addExperience(50, true)
    player:setStorageValue(storage, 1)
    return true
end
 
Solution
Back
Top