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

Mount for X killed monster

Zeroone

Active Member
Joined
Dec 11, 2007
Messages
257
Reaction score
43
Location
Sweden
Hello,

I have a weird request for a system that gives you a mount for killing X monsters,

Senario
Kill 10 rats, be rewarded with "Rented Horse"
When killing a rat, it should say something like: "You have X rats left to kill for a reward."
When the X number of rats has been killed: "Congratulations, you killed 10 rats, heres your mount."

Is this possible?
 
What about making npc who will give you quest for killing 10 rats and then will give you a mount when you're done?
 
Okay mate i will help you, but be more specific, what monsters?, also, what mount?, what distro do you have? TFS 1.0?, and yes, its totally posible, i have this on my server just like you say, but a npc will give you the task?, or you will have it just for kill that monster?
 
Hello,

Thanks for the help!
The server is based on TFS 1.0 (10.31), a NPC wich gives the player a task to kill these monsters and reward them by giving mounts\EXP is perfect!

Thanks
 
Okay, sorry for not answer, i was busy, you will need fourth storage values

make a npc file .xml an put this on his/her script:

Code:
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

lvl = XX -- put here the leve requiered
mount = XX -- put here the mount id
startid = XXXX -- storagevalue to start task
bearid = XXXX -- storage of the bear task
bearcount = XXX -- storage to count the number of bears
bearsuccess = XX -- bear task done
bearnumber = XX -- number of bears to beat the task
expp = XX -- experience points

function task(cid, message, keywords, parameters, node)
    if(not npcHandler:isFocused(cid)) then
                return false
        end
   
    if getPlayerStorageValue(cid, startid) <= 0 then
    npcHandler:say("Hello, i have right now the {bear} task for you, you need to be level " .. lvl .. " to start this task", cid)
    else
        if getPlayerStorageValue(cid, bearsuccess) >= 1 then
        npcHandler:say("Great! you have finish the task, as a reward take a mount and exp", cid)
        setPlayerStorageValue(cid, startid, 0)
        setPlayerStorageValue(cid, bearid, 0)
        setPlayerStorageValue(cid, bearcount, 0)
        setPlayerStorageValue(cid, bearsuccess, 0)
        Player(cid):addMount(mount)
        Player(cid):addExperience(expp)
        npcHandler:resetNpc()
        else
            if getPlayerStorageValue(cid, startid) == 1 then
            npcHandler:say("I'm sorry, you are already in a task, finish first the task and then try to start other, say {!task} to check your progress", cid)
            npcHandler:resetNpc()
            end
        end
    end
return true
end

function bear(cid, message, keywords, parameters, node)
    if(not npcHandler:isFocused(cid)) then
                return false
        end

    if getPlayerLevel(cid) >= lvl then
    npcHandler:say('The bear task, you need to kill ' .. bearnumber .. ' bears, if you do it you will receive a mount and exp, will you do it?', cid)
    else
    npcHandler:say("Sorry, you don't have enough level to do this task", cid)
    npcHandler:resetNpc()
    end
return true
end

function acceptbear(cid, message, keywords, parameters, node)
    if(not npcHandler:isFocused(cid)) then
                return false
        end
   
    if getPlayerLevel(cid) >= lvl then
    npcHandler:say('Okay!, you have to kill ' .. bearnumber .. ' bears, no matter where they are, if you want to see your progress you can say {!task} or simple ask me, good hunting!', cid)
    setPlayerStorageValue(cid, startid, 1)
    setPlayerStorageValue(cid, bearid, 1)
    setPlayerStorageValue(cid, bearcount, 0)
    npcHandler:resetNpc()
    end
return true
end

local node1 = keywordHandler:addKeyword({'task'}, task)
local node2 = node1:addChildKeyword({'bear'}, bear)
local node3 = node2:addChildKeyword({'yes'}, acceptbear)
local node4 = node2:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Well, if you don\'t want...'})

npcHandler:addModule(FocusModule:new())

now, on creaturescripts.xml put this line:

Code:
<event type="kill" name="task" script="task.lua"/>

and make a file called task.lua and put this, you need to configure exactly with the same storages that you put on the npc file

Code:
function onKill(cid, target) 

bearid = XXXX -- storage of the bear task
bearcount = XXX -- storage to count the number of bears
bearsuccess = XX -- bear task done
bearnumber = XX -- number of bears to beat the task
expp = XX -- experience points

if getCreatureName(target) == "Bear" then
    if isPlayer(target) == FALSE then
        if getCreatureMaster(target) ~= cid then
            if getPlayerStorageValue(cid, bearid) == 1 then
                if getPlayerStorageValue(cid, bearcount) == 49 then
                setPlayerStorageValue(cid, bearcount, getPlayerStorageValue(cid, bearcount)+1)
                doPlayerSendTextMessage(cid, 4, "You have killed " .. getPlayerStorageValue(cid, bearcount) .. " of " .. bearnumber .. " bears")
                setPlayerStorageValue(cid, bearsuccess, 1)
            else
                if getPlayerStorageValue(cid, bearcount) < 49 then
                setPlayerStorageValue(cid, bearcount, getPlayerStorageValue(cid, bearcount)+1)
                doPlayerSendTextMessage(cid, 4, "You have killed " .. getPlayerStorageValue(cid, bearcount) .. " of " .. bearnumber .. " bears")
                end
                end
            end
        end
    end
end

return true
end

and on login.lua add this line:

Code:
player:registerEvent("task")

And, to finish, lets make a talkaction that show your progress, put this on talkactions.xml

Code:
<talkaction words="!task" script="tasks.lua"/>

and make the tasks.lua with this (remember to put correctly all the configuration values as same):

Code:
function onSay(cid, words, param)

local notask = "Right now, you dont have any task to do"
local bear = ""
local startid = XXX
local bearid = XX
local bearcount = XX
local bearnumber = XX

if getPlayerStorageValue(cid, startid) == 1 then
        if getPlayerStorageValue(cid, bearid) == 1 then
        bear = "You have killed " .. getPlayerStorageValue(cid, bearcount) .. " of " .. bearnumber .. " bears\n"
        end
    doPlayerPopupFYI(cid, "" .. bear .. "")
    else
    doPlayerPopupFYI(cid, "" ..notask.. "")
end
return true
end

let me know if it works!, and if you want to add other task with other monster study the script, is really easy to make but in this way is an headache
 
Back
Top