• 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 0.X TASK % EXP of Kill

OTcreator

Active Member
Joined
Feb 14, 2022
Messages
417
Solutions
1
Reaction score
44
Hello.
How I Can change exp value to % of kill exp?
ETC - I KILL 100 trolls ---> reward: 20% of 100 kill trolls experience?

Lua:
local tasks =
{
    [1] = {questStarted = 1510, questStorage = 65000, killsRequired = 70, raceName = "Trolls", rewards = {{enable = true, type = "exp", values = *20% of kill monsters*}, {enable = true, type = "money", values = 1500}}}
}
 
local rankStorage = 32150
local storage = 64521
 
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
local voc = {}
 
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
 
function creatureSayCallback(cid, type, msg)
 
    local s = getCreatureStorage(cid, storage)
 
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_PRIVATE and 0 or cid
    if msgcontains(msg, "task") then
 
        if(s < 1) then
            doCreatureSetStorage(cid, storage, 1)
            s = getCreatureStorage(cid, storage)
        end
 
        if(getCreatureStorage(cid, rankStorage) < 1) then
            doCreatureSetStorage(cid, rankStorage, 0)
        end
 
        if tasks[s] then
            if(getCreatureStorage(cid, tasks[s].questStarted) < 1) then
                if(getCreatureStorage(cid, tasks[s].creatureStorage) < 0) then
                    doCreatureSetStorage(cid, tasks[s].creatureStorage, 0)
                end
 
                if(getCreatureStorage(cid, tasks[s].questStorage) < 0) then
                    doCreatureSetStorage(cid, tasks[s].questStorage, 0)
                end
 
                doCreatureSetStorage(cid, tasks[s].questStarted, 1)
                selfSay("You have started the task number " .. getPlayerStorageValue(cid, storage) .. ", in this task you need to kill " .. tasks[s].killsRequired .. " " .. tasks[s].raceName .. ".", cid)
            else
                selfSay("You are currently making the task about " .. tasks[s].raceName .. ", task number " .. getPlayerStorageValue(cid, storage) .. "/40.", cid)
            end
        else
            print("[Warning - Error::Killing in the name of::Tasks config] Something is wrong.")
        end
 
    elseif msgcontains(msg, "report") then
        if tasks[s] and tasks[s].questStarted > 0 then
            if(getCreatureStorage(cid, tasks[s].creatureStorage) < 0) then
                doCreatureSetStorage(cid, tasks[s].creatureStorage, 0)
            end
 
            if(getCreatureStorage(cid, tasks[s].questStorage) < 0) then
                doCreatureSetStorage(cid, tasks[s].questStorage, 0)
            end
 
            if(getCreatureStorage(cid, tasks[s].questStorage) >= tasks[s].killsRequired) then
                for i = 1, table.maxn(tasks[s].rewards) do
                    if(tasks[s].rewards[i].enable) then
                        if isInArray({"boss", "teleport", 1}, tasks[s].rewards[i].type) then
                            doTeleportThing(cid, tasks[s].rewards[i].values)
                        elseif isInArray({"exp", "experience", 2}, tasks[s].rewards[i].type) then
                            doPlayerAddExperience(cid, tasks[s].rewards[i].values)
                        elseif isInArray({"item", 3}, tasks[s].rewards[i].type) then
                            doPlayerAddItem(cid, tasks[s].rewards[i].values[1], tasks[s].rewards[i].values[2])
                        elseif isInArray({"money", 4}, tasks[s].rewards[i].type) then
                            doPlayerAddMoney(cid, tasks[s].rewards[i].values)
                        elseif isInArray({"storage", "stor", 5}, tasks[s].rewards[i].type) then
                            doCreatureSetStorage(cid, tasks[s].rewards[i].values[1], tasks[s].rewards[i].values[2])
                        elseif isInArray({"points", "rank", 2}, tasks[s].rewards[i].type) then
                            doCreatureSetStorage(cid, rankStorage, getCreatureStorage(cid, rankStorage) + tasks[s].rewards[i].values)
                        else
                            print("[Warning - Error::Killing in the name of::Tasks config] Bad reward type: " .. tasks[s].rewards[i].type .. ", reward could not be loaded.")
                        end
                    end
                end

        if getPlayerStorageValue(cid, 65051) > 0 then
            selfSay('You have already all task!!', cid)
        end
                local rank = getCreatureStorage(cid, rankStorage)
                selfSay("Great!... you have finished the task number " .. s .. "" .. (rank > 4 and ", you are a " or "") .. "" .. (((rank > 4 and rank < 10) and ("Huntsman") or (rank > 9 and rank < 20) and ("Ranger") or (rank > 19 and rank < 30) and ("Big Game Hunter") or (rank > 29 and rank < 50) and ("Trophy Hunter") or (rank > 49) and ("Elite Hunter")) or "") .. ". Good job.", cid)
                doCreatureSetStorage(cid, storage, s + 1)
            else
                selfSay("Current " .. getCreatureStorage(cid, tasks[s].questStorage) .. " " .. tasks[s].raceName .. " killed, you need to kill " .. tasks[s].killsRequired .. ".", cid)
            end
        else
            selfSay("You do not have started any task.", cid)
        end
    end
    return true
end
 
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Back
Top