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

Solved Improve mission after killing a monster

Exoltes

Novia OTserv Developer
Joined
Jul 2, 2009
Messages
563
Reaction score
47
Location
Belgium
I've been checking like 20 threads of killing in the name of quest etc and I can't seem to fix it :s

What I'm trying to do is learn this step by step.
I've created 50 missions and in each mission the number of killed monsters will increase.
But I can't seem to find a way to make the mission actually increase after killing the monster.

So first of all I'm looking for a script that just simply adds a mission value after killing a monster and secondly I would love to see a script that stops increasing the mission state after x kills.

I'm working on a 8.54 Open Tibia Server using The Forgotten Server - Version 0.2.7 (Mystic Spirit).

Thanks in advance.
 
Actually you can, but you can also change it in the script, just remove the +1 from the getPlayerStorageValue parts (not in the setPlayerStorageValue lines).

Just can't seem to get this right :s
removed the +1 @ if getPlayerStorageValue(cid, monster.storage) >= -1 and (getPlayerStorageValue(cid, monster.storage)) <---
and still getting
22:19 Task message: 2 of 50 Rats killed.
after the first kill
Code:
local config = {
     ['rat'] = {amount = 50, storage = 6701, startstorage = 6700, startvalue = 1}
}
function onKill(cid, target)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have already completed this quest.")
if getCreatureName(target):lower() == "demodras" then
     setPlayerStorageValue(cid,7200,1)
     setPlayerStorageValue(cid,7201,1)
end
     local monster = config[getCreatureName(target):lower()]
if isPlayer(target) == TRUE or not monster or isSummon(target) == TRUE then
   return true
end

     if getPlayerStorageValue(cid, monster.storage) >= -1 and (getPlayerStorageValue(cid, monster.storage)) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) >= monster.startvalue then
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(getPlayerStorageValue(cid, monster.storage)+1)..' of '..monster.amount..' '..getCreatureName(target)..'s killed.')
     end
     if (getPlayerStorageValue(cid, monster.storage)+1) == monster.amount then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s and completed the '..getCreatureName(target)..'s mission.')
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
     end
     return true
end
 
Remove it also from the textmessage.
You can btw remove the () aswell since the +1 isn't there anymore.
(getPlayerStorageValue(cid, monster.storage))
 
doesn't fix it.
22:48 Task message: 2 of 50 Rats killed.

kill.lua
Code:
local config = {
     ['rat'] = {amount = 50, storage = 6701, startstorage = 6700, startvalue = 1}
}
function onKill(cid, target)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have already completed this quest.")
if getCreatureName(target):lower() == "demodras" then
     setPlayerStorageValue(cid,7200,1)
     setPlayerStorageValue(cid,7201,1)
end
     local monster = config[getCreatureName(target):lower()]
if isPlayer(target) == TRUE or not monster or isSummon(target) == TRUE then
   return true
end

     if getPlayerStorageValue(cid, monster.storage) >= -1 and getPlayerStorageValue(cid, monster.storage) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) >= monster.startvalue then
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
         doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(getPlayerStorageValue(cid, monster.storage)+1)..' of '..monster.amount..' '..getCreatureName(target)..'s killed.')
     end
     if getPlayerStorageValue(cid, monster.storage) == monster.amount then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s and completed the '..getCreatureName(target)..'s mission.')
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
     end
     return true
end
 
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(getPlayerStorageValue(cid, monster.storage)+1)..' of '..monster.amount..' '..getCreatureName(target)..'s killed.')

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s and completed the '..getCreatureName(target)..'s mission.')

That's because you have set it to 0 in login.lua, login.lua is executed every time someone logs in.
 
23:12 Task message: 2 of 50 Rats killed.

kill.lua
Code:
local config = {
     ['rat'] = {amount = 50, storage = 6701, startstorage = 6700, startvalue = 1}
}
function onKill(cid, target)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have already completed this quest.")
if getCreatureName(target):lower() == "demodras" then
     setPlayerStorageValue(cid,7200,1)
     setPlayerStorageValue(cid,7201,1)
end
     local monster = config[getCreatureName(target):lower()]
if isPlayer(target) == TRUE or not monster or isSummon(target) == TRUE then
   return true
end

     if getPlayerStorageValue(cid, monster.storage) >= -1 and getPlayerStorageValue(cid, monster.storage) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) >= monster.startvalue then
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(getPlayerStorageValue(cid, monster.storage)+1)..' of '..monster.amount..' '..getCreatureName(target)..'s killed.')
     end
     if getPlayerStorageValue(cid, monster.storage) == monster.amount then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s and completed the '..getCreatureName(target)..'s mission.')
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
     end
     return true
end
 
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..(getPlayerStorageValue(cid, monster.storage)+1)..' of '..monster.amount..' '..getCreatureName(target)..'s killed.')

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..(getPlayerStorageValue(cid, monster.storage)+1)..' '..getCreatureName(target)..'s and completed the '..getCreatureName(target)..'s mission.')
Remove the parts I made red.
 
23:28 Task message: 1 of 50 Rats killed.

Thx :)

23:29 Task message: 49 of 50 Rats killed.
23:30 Task message: 50 of 50 Rats killed.

<missionstate id="49" description="You have killed 49/50 rats."/>
<missionstate id="50" description="You helped fighting the sewer problem. Report to Quintus he will be glad to hear of this information."/>
<missionstate id="51" description="You helped fighting the sewer problem."/>

Here it skipps mission 50

nvm, found out why i'll just add a blank mission there.
 
15:51 Task message: 1 of 1000 Cyclopss killed.
15:51 Task message: 2 of 1000 Cyclops Drones killed.
15:51 Task message: 3 of 1000 Cyclops Smiths killed.
15:51 Task message: 4 of 1000 Cyclopss killed.

Is there maybe a way to fix that this will say 'cyclops' whenever a drone, smith or normal is killed?

Also a way to remove the 's' while it stays at my other tasks
 
You can add the name in the table instead of using getCreatureName(target).
For example: name = "Cyclops" in the table, then instead of getCreatureName(target): monster.name.
To remove the s you can just remove the s after getCreatureName(target) in the textmessage.
Then add all monsters with name = in the table.
 
Gave it a try but can't really seem to get it working.

22:56 Task message: 14 of 1000 Cyclopss killed.

Code:
     if getPlayerStorageValue(cid, monster.storage) >= -1 and getPlayerStorageValue(cid, monster.storage) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) >= monster.startvalue then
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
       if getCreatureName(target) == 'cyclops' or getCreatureName(target) == 'cyclops smith' or getCreatureName(target) == 'cyclops drone'  then
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..getPlayerStorageValue(cid, monster.storage)..' of '..monster.amount..' Cyclops killed.')
    else
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..getPlayerStorageValue(cid, monster.storage)..' of '..monster.amount..' '..getCreatureName(target)..'s killed.')
     end
end
 
I mean add it in the table.
Code:
['cyclops'] = {amount = 50, storage = 6701, startstorage = 6700, startvalue = 1, name = "Cyclops"}
Then instead of: '..getCreatureName(target)..'s
Code:
'..monster.name..'

If you have alot of monsters in the table and you don't want to add all names as extra, you can check if name exists for that monster in the table.
Code:
if monster.name then
    -- text with monster.name
else
    -- text with getCreatureName(target)
end
 
Thanks, got it fixed now :)

Code:
local config = {
     ['rat'] = {amount = 50, storage = 6701, startstorage = 6700, startvalue = 1, name = "Rat"},
     ['behemoth'] = {amount = 500, storage = 6601, startstorage = 6602, startvalue = 1, name = "Behemoth"},
     ['demon'] = {amount = 500, storage = 6603, startstorage = 6604, startvalue = 1, name = "Demon"},
     ['deer'] = {amount = 100, storage = 6607, startstorage = 6608, startvalue = 1, name = "Deer"},
     ['dragon lord'] = {amount = 500, storage = 6611, startstorage = 6612, startvalue = 1, name = "Dragon Lord"},
     ['cyclops'] = {amount = 1000, storage = 6609, startstorage = 6610, startvalue = 1, name = "Cyclop"},
     ['cyclops drone'] = {amount = 1000, storage = 6609, startstorage = 6610, startvalue = 1, name = "Cyclop"},
     ['cyclops smith'] = {amount = 1000, storage = 6609, startstorage = 6610, startvalue = 1, name = "Cyclop"},
     ['minotaur'] = {amount = 1000, storage = 6605, startstorage = 6606, startvalue = 1, name = "Minotaur"},
     ['minotaur guard'] = {amount = 1000, storage = 6605, startstorage = 6606, startvalue = 1, name = "Minotaur"},
     ['minotaur mage'] = {amount = 1000, storage = 6605, startstorage = 6606, startvalue = 1, name = "Minotaur"},
     ['minotaur archer'] = {amount = 1000, storage = 6605, startstorage = 6606, startvalue = 1, name = "Minotaur"}
}
function onKill(cid, target)
if getCreatureName(target):lower() == "demodras" then
     setPlayerStorageValue(cid,7200,1)
     setPlayerStorageValue(cid,7201,1)
end
if getCreatureName(target):lower() == "the pit lord" then
     setPlayerStorageValue(cid,7200,1)
     setPlayerStorageValue(cid,7202,1)
end
if getCreatureName(target):lower() == "big foot" then
     setPlayerStorageValue(cid,7200,1)
     setPlayerStorageValue(cid,7203,1)
end
if getCreatureName(target):lower() == "undead tortoise" then
     setPlayerStorageValue(cid,7200,1)
     setPlayerStorageValue(cid,7204,1)
end
     local monster = config[getCreatureName(target):lower()]
if isPlayer(target) == TRUE or not monster or isSummon(target) == TRUE then
   return true
end


     if getPlayerStorageValue(cid, monster.storage) >= -1 and getPlayerStorageValue(cid, monster.storage) < monster.amount and getPlayerStorageValue(cid, monster.startstorage) >= monster.startvalue then
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Task message: '..getPlayerStorageValue(cid, monster.storage)..' of '..monster.amount..' '..monster.name..'s killed.')
    end
     if getPlayerStorageValue(cid, monster.storage) == monster.amount then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'Congratulations, you have killed '..getPlayerStorageValue(cid, monster.storage)..' '..getCreatureName(target)..'s and completed the '..monster.name..'s mission.')
         setPlayerStorageValue(cid, monster.storage, getPlayerStorageValue(cid, monster.storage) + 1)
     end
     return true
end

I know it isn't 100% what you meant but I preferred the capital letters there :p
 
Back
Top