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

exp quest / xp quest - problem to made functional

dropz

Member
Joined
May 4, 2022
Messages
46
Reaction score
24
hello!

im facing a issue to apply this feature(quest that gives experience) on nostalrius tfs 1.2.

well,
im using a script /data/actions/scripts/misc/questsXP.lua that grab a actionID of item from the map and when you click in it you receive the experience.
the problem is this script didn't apply for more than one actionID, so i tried replicate this function just changing the storage(actionID) to another and let the same code, but it works for only one "quest" when i go to another "quest" of the map and try click in it i receive the message like its already made.

note:
- yes, i did the respective changes at map adding the actionIDs on the items that i choose to give the experience, but just one of them(the first that i click) gaves me the xp. the others return to me the "else" condition (You have already received your experience.).

- i thought to make an array that store the actionsIDs that i set, but i don't know how to deal with it in .lua

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

here's the code to try get more clear:

/data/actions/scripts/misc/questsXP.lua :

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local config = {
        storage = 20000, -- change to your own storage value
        amount = 1500, -- change to amount
}
if getPlayerStorageValue(cid, config.storage) < 1 then
        setPlayerStorageValue(cid, config.storage, 1)
        doPlayerSendTextMessage(cid,21,"You have received " .. config.amount .. " experience points.")
        doSendMagicEffect(getThingPos(cid), 25)
        doPlayerAddExp(cid, config.amount)
else
        doPlayerSendTextMessage(cid,25,"You have already received your experience.")
end
return true
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
local config = {
        storage = 20001, -- change to your own storage value
        amount = 1500, -- change to amount
}
if getPlayerStorageValue(cid, config.storage) < 1 then
        setPlayerStorageValue(cid, config.storage, 1)
        doPlayerSendTextMessage(cid,21,"You have received " .. config.amount .. " experience points.")
        doSendMagicEffect(getThingPos(cid), 25)
        doPlayerAddExp(cid, config.amount)
else
        doPlayerSendTextMessage(cid,25,"You have already received your experience.")
end
return true
end


function onUse(cid, item, fromPosition, itemEx, toPosition)
local config = {
        storage = 20002, -- change to your own storage value
        amount = 1500, -- change to amount
}
if getPlayerStorageValue(cid, config.storage) < 1 then
        setPlayerStorageValue(cid, config.storage, 1)
        doPlayerSendTextMessage(cid,21,"You have received " .. config.amount .. " experience points.")
        doSendMagicEffect(getThingPos(cid), 25)
        doPlayerAddExp(cid, config.amount)
else
        doPlayerSendTextMessage(cid,25,"You have already received your experience.")
end
return true
end

/data/actions/actions.xml:

XML:
    <!--quest exp-->
    <action actionid="20000" script="misc/questsXP.lua" />
    <action actionid="20001" script="misc/questsXP.lua" />
    <action actionid="20002" script="misc/questsXP.lua" />
    <action actionid="20003" script="misc/questsXP.lua" />

so what can i do to solve it? someone already faced this trouble? cuz as i can see the script is working but just for only one of the quests and the goal is made a lot of them.
can be something about the storage value? its must be different for each one?

if im didnt get clear in the explanation, let me know.

thanks in advance!
 
Last edited:
Solution
Lua:
local exp_cfg = {
    [20000] = 1500,
    [20001] = 2000,
    [20002] = 2500,
}

function onUse(player, item, fromPosition, itemEx, toPosition)
    local aid = item:getActionId()
    if player:getStorageValue(aid) == 1 then
        return player:sendTextMessage(25, "You have already received your experience.")
    end
    player:setStorageValue(aid, 1)
    player:addExperience(exp_cfg[aid])
    player:sendTextMessage(21, "You have received " .. exp_cfg[aid] .. " experience points.")
    player:getPosition():sendMagicEffect(25)
    return true
end

Lua:
<action actionid="20000-20002" script="misc/questsXP.lua" />
Lua:
local exp_cfg = {
    [20000] = 1500,
    [20001] = 2000,
    [20002] = 2500,
}

function onUse(player, item, fromPosition, itemEx, toPosition)
    local aid = item:getActionId()
    if player:getStorageValue(aid) == 1 then
        return player:sendTextMessage(25, "You have already received your experience.")
    end
    player:setStorageValue(aid, 1)
    player:addExperience(exp_cfg[aid])
    player:sendTextMessage(21, "You have received " .. exp_cfg[aid] .. " experience points.")
    player:getPosition():sendMagicEffect(25)
    return true
end

Lua:
<action actionid="20000-20002" script="misc/questsXP.lua" />
 
Solution
Lua:
local exp_cfg = {
    [20000] = 1500,
    [20001] = 2000,
    [20002] = 2500,
}

function onUse(player, item, fromPosition, itemEx, toPosition)
    local aid = item:getActionId()
    if player:getStorageValue(aid) == 1 then
        return player:sendTextMessage(25, "You have already received your experience.")
    end
    player:setStorageValue(aid, 1)
    player:addExperience(exp_cfg[aid])
    player:sendTextMessage(21, "You have received " .. exp_cfg[aid] .. " experience points.")
    player:getPosition():sendMagicEffect(25)
    return true
end

Lua:
<action actionid="20000-20002" script="misc/questsXP.lua" />
you are a magemaster, thank you dud!
 
Back
Top