• 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.
 
The thing with more missions is that i want to be able to keep track of the amount of monsters i killed in my quest log.

That's why i came up with adding a mission state for every kill until enough kills have been reached.

Also I must say that the thread u gave me is already really helpful with another couple problems i was going to have soon :D So Thanks!
 
Made a full copy of your script (new line in creaturescripts.xml - <event type="kill" name="Kill" script="kill.lua"/> -, new file at Server\data\creaturescripts, new file at Server\data\npc\scripts, made one of my npcs load that file and i did put in a new line in the login.lua - registerCreatureEvent(cid, "Kill") -)

21:47 Banker: I have a mission for you to kill 5 dragons and 3 dragon lords, do you accept?
21:47 Vinie [976]: yes
21:47 Banker: Good, come back when you killed them.

21:47 Loot of a dragon: a steel shield, 31 gold coins, dragon ham, a crossbow.
21:47 Loot of a dragon: a steel shield, 12 gold coins, a crossbow.
21:47 Loot of a dragon: a steel shield, 8 gold coins, dragon ham.
21:47 Loot of a dragon: a short sword, 46 gold coins, 12 gold coins.
21:48 Loot of a dragon: a mace, 30 gold coins.
21:48 Loot of a dragon: 58 gold coins, 33 gold coins, dragon ham.
21:48 Loot of a dragon lord: 20 gold coins, 16 gold coins, 44 gold coins, dragon ham.
21:48 Loot of a dragon: 45 gold coins, 10 burst arrows.
21:48 Loot of a dragon lord: a green mushroom, 36 gold coins, 12 gold coins, dragon ham.
21:48 Loot of a dragon lord: a power bolt, 78 gold coins, 36 gold coins, a fire sword.

21:49 Vinie [976]: mission
21:49 Banker: Did you kill 5 dragons and 3 dragon lords?
21:49 Vinie [976]: yes
21:49 Banker: You didn't kill them all.
 
Last edited:
Do you get errors?
You can add print under function onKill to see if the script is loading.
Code:
print("script loading test")

If it loads you will see this message in your console when you kill something.
 
creaturescripts.xml

<?xml version="1.0" encoding="UTF-8"?>
<creaturescripts>
<event type="login" name="PlayerLogin" script="login.lua"/>
<event type="login" name="FirstItems" script="firstitems.lua"/>
<event type="death" name="PlayerDeath" script="playerdeath.lua"/>
<event type="kill" name="Kill" script="kill.lua"/>
print("script loading test")
</creaturescripts>

no messages after killing


also not getting any errors
 
local config = {
['dragon'] = {amount = 5, storage = 19000, startstorage = 5002, startvalue = 1},
['dragon lord'] = {amount = 3, storage = 19001, startstorage = 5002, startvalue = 1}
}
function onKill(cid, target)
print("script loading test")
local monster = config[getCreatureName(target):lower()]
if isPlayer(target) or not monster or isSummon(target) then
return true
end

if getPlayerStorageValue(cid, monster.storage) >= -1 and (getPlayerStorageValue(cid, monster.storage)+1) < 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


12:24 You deal 1000 damage to a dragon.
12:24 You deal 1000 damage to a dragon.
12:24 You deal 1000 damage to a dragon.
12:24 You deal 1000 damage to a dragon.
12:24 You deal 1000 damage to a dragon.
12:24 You deal 1900 damage to a dragon lord.
12:24 You deal 1900 damage to a dragon lord.
12:24 You deal 1900 damage to a dragon lord.
12:24 Loot of a dragon lord: a small sapphire, 18 gold coins, dragon ham.
12:24 Loot of a dragon: a steel shield, a steel helmet, 42 gold coins, dragon ham.
12:24 Loot of a dragon lord: 82 gold coins, dragon ham.
12:24 Loot of a dragon: 34 gold coins.
12:24 Loot of a dragon: 23 gold coins, dragon ham.
12:24 Loot of a dragon: a gold coin, 42 gold coins, dragon ham.
12:24 Loot of a dragon: 60 gold coins, 41 gold coins, dragon ham, a crossbow.
12:24 Loot of a dragon lord: 26 gold coins.


Loads without errors but no msg or anything
 
function onLogin(cid)
registerCreatureEvent(cid, "PlayerDeath")
registerCreatureEvent(cid, "Kill")
return TRUE
end

ya already had it there (also already said this in my 3rd post :p)

PS: I also didn't get any msg in my console.
 
And you don't get errors? If you don't get that message after killing something, it means it's not loading the script.
 
no errors and i noticed that the script doesn't load, but any solutions? :D cuz I have no clue where to look atm :s

Maybe you could just write a few lines of code that improve missions state after a kill, maybe that might work :p

Either way I'm grateful for u'r help already.
 
If the script doesn't load then it doesn't matter what is in the script.
If you do the same thing with an other onKill script, do you also not get the message in your console when you kill something?
Code:
function onKill(cid, target)
    print("script loading test")
    return true
end
 
function onKill(cid, target)
print("script loading test")
return true
end

Also doesn't load :s

Seems like the 'The Forgotten Server - Version 0.2.7 (Mystic Spirit)' doesn't recognize the onKill function. Which is strange since the 'killing in the name of ... quest' was introduced the tibia 8.5 client update.

Checked my 'LUA_FUNCTIONS' document in the 'Server\doc' folder and only things I can find with the word kill are skill related.

Maybe we can make it related to the default msg you get after killing a monster?
 
Last edited:
This is my LUA_FUNCTIONS Document

Code:
"get" functions
        getPlayerFood(cid)
        getCreatureHealth(cid)
        getCreatureMaxHealth(cid)
        getPlayerMana(cid)
        getPlayerMaxMana
        getPlayerLevel(cid)
        getPlayerMagLevel(cid)
        getPlayerName(cid)
        getPlayerAccess(cid)
        getPlayerPosition(cid)
        getPlayerSkill(cid, skillid)
        getPlayerTown(cid)
        getPlayerVocation(cid)
        getPlayerItemCount(cid,itemid)
        getPlayerSoul(cid)
        getPlayerFreeCap(cid)
        getPlayerLight(cid)
        getPlayerSlotItem(cid, slot)
        getPlayerDepotItems(cid, depotid)
        getPlayerSex(cid)
        getPlayerLookDir(cid)
        getPlayerGUID(cid)
        getPlayerFlagValue(cid, flag)
        getPlayerGroupId(cid)
        getPlayerGuildId(cid)
        getPlayerGuildName(cid)
        getPlayerGuildRank(cid)
        getPlayerGuildNick(cid)

"do" functions
        doPlayerSendCancel(cid, text)

[ TODO - Info, example use
    setPlayerGroupId(cid, newGroupId)
    playerLearnInstantSpell(cid, name)
    canPlayerLearnInstantSpell(cid, name)
    getPlayerLearnedInstantSpell(cid, name)
    getPlayerInstantSpellCount(cid)
    getPlayerInstantSpellInfo(cid, index)
    getInstantSpellInfoByName(cid, name)
    getInstantSpellWords(name)
    setPlayerStorageValue(uid, valueid, newvalue)
    getGlobalStorageValue(valueid)
    setGlobalStorageValue(valueid, newvalue)
    getTilePzInfo(pos)
    getTileHouseInfo(pos)
    getItemRWInfo(uid)
    getThingfromPos(pos)
    getThing(uid)
    queryTileAddThing(uid, pos, <optional> flags)
    getThingPos(uid)
    doRemoveItem(uid, <optional> n)
    doPlayerFeed(cid, food)

    doPlayerSendDefaultCancel(cid, ReturnValue)
    doTeleportThing(cid, newpos, <optional> pushmove)
    doTransformItem(uid, toitemid, <optional> count/subtype)
    doCreatureSay(cid, text, type)
    doSendMagicEffect(pos, type)
    doSendDistanceShoot(frompos, topos, type)
    doChangeTypeItem(uid, newtype)
    doSetItemActionId(uid, actionid)
    doSetItemText(uid, text)
    doSetItemSpecialDescription(uid, desc)
    doSendAnimatedText(pos, text, color)
    doPlayerAddSkillTry(cid, skillid, n)
    doCreatureAddHealth(cid, health)
    doPlayerAddMana(cid, mana)
    doPlayerAddManaSpent(cid, mana)
    doPlayerAddSoul(cid, soul)
    doPlayerAddItem(uid, itemid, <optional> count/subtype)
    doPlayerAddItemEx(cid, uid, <optional: default: 0> useCidPosOnFail)
    doPlayerSendTextMessage(cid, MessageClasses, message)
    doPlayerRemoveMoney(cid, money)
    doShowTextDialog(cid, itemid, text)
    doDecayItem(uid)
    doCreateItem(itemid, type/count, pos)
    doCreateItemEx(itemid, <optional> count/subtype)
    doTileAddItemEx(pos, uid)
    doCreateTeleport(itemid, topos, createpos)
    doSummonCreature(name, pos)
    doConvinceCreature(cid, target)
    doRemoveCreature(cid)
    doMoveCreature(cid, direction)
    doPlayerSetTown(cid, townid)
    doPlayerSetVocation(cid,voc)
    doPlayerRemoveItem(cid,itemid,count)
    doPlayerAddExp(cid,exp)
    doPlayerSetGuildId(cid, id)
    doPlayerSetGuildRank(cid, rank)
    doPlayerSetGuildNick(cid, nick)
    doPlayerAddOutfit(cid,looktype,addons)
    doPlayerRemOutfit(cid,looktype,addons)
    doSetCreatureLight(cid, lightLevel, lightColor, time)
    doSetCreatureDropLoot(cid, doDrop)
    getCreatureCondition(cid, condition)
    isPlayer(cid)
    isCreature(cid)
    isContainer(uid)
    isMoveable(uid)
    getPlayerByName(name)
    getPlayerGUIDByName(name)
    registerCreatureEvent(uid, eventName)
    getContainerSize(uid)
    getContainerCap(uid)
    getContainerItem(uid, slot)
    doAddContainerItem(uid, itemid, <optional> count/subtype)
    getHouseOwner(houseid)
    getHouseName(houseid)
    getHouseEntry(houseid)
    getHouseRent(houseid)
    getHouseTown(houseid)
    getHouseAccessList(houseid, listid)
    getHouseByPlayerGUID(playerGUID)
    setHouseAccessList(houseid, listid, listtext)
    setHouseOwner(houseid, ownerGUID)
    getWorldType()
    getWorldTime()
    getWorldLight()
    getWorldCreatures(type)
    getWorldUpTime()
    broadcastMessage(message, type)
    getGuildId(guild_name)
    getPlayerSex(cid)
    doPlayerSetSex(cid, newSex)
    createCombatArea( {area}, <optional> {extArea} )
    createConditionObject(type)
    setCombatArea(combat, area)
    setCombatCondition(combat, condition)
    setCombatParam(combat, key, value)
    setConditionParam(condition, key, value)
    addDamageCondition(condition, rounds, time, value)
    addOutfitCondition(condition, lookTypeEx, lookType, lookHead, lookBody, lookLegs, lookFeet)
    setCombatCallBack(combat, key, function_name)
    setCombatFormula(combat, type, mina, minb, maxa, maxb)
    setConditionFormula(combat, mina, minb, maxa, maxb)
    doCombat(cid, combat, param)
    createCombatObject()
    doAreaCombatHealth(cid, type, pos, area, min, max, effect)
    doTargetCombatHealth(cid, target, type, min, max, effect)
    doAreaCombatMana(cid, pos, area, min, max, effect)
    doTargetCombatMana(cid, target, min, max, effect)
    doAreaCombatCondition(cid, pos, area, condition, effect)
    doTargetCombatCondition(cid, target, condition, effect)
    doAreaCombatDispel(cid, pos, area, type, effect)
    doTargetCombatDispel(cid, target, type, effect)
    doChallengeCreature(cid, target)
    numberToVariant(number)
    stringToVariant(string)
    positionToVariant(pos)
    targetPositionToVariant(pos)
    variantToNumber(var)
    variantToString(var)
    variantToPosition(var)
    doChangeSpeed(cid, delta)
    doSetMonsterOutfit(cid, name, time)
    doSetItemOutfit(cid, item, time)
    doSetCreatureOutfit(cid, outfit, time)
    getCreatureOutfit(cid)
    getCreaturePosition(cid)
    getCreatureName(cid)
    getCreatureSpeed(cid)
    getCreatureBaseSpeed(cid)
    getCreatureTarget(cid)
    isItemStackable(itemid)
    isItemRune(itemid)
    isItemDoor(itemid)
    isItemContainer(itemid)
    isItemFluidContainer(itemid)
    getItemName(itemid)
    getItemWeight(itemid, count)
    debugPrint(text)
    isInArray(array, value)
    addEvent(callback, delay, parameter)
    stopEvent(eventid)
    doPlayerPopupFYI(cid, message)
    mayNotLogout(cid, value)
    mayNotMove(cid, value)
    doPlayerAddPremiumDays(cid, days)
    doPlayerRemovePremiumDays(cid, days)
    getPlayerPremiumDays(cid)
    getPlayerSkullType(cid)
    getPromotedVocation(vocation)
    getPlayerBlessing(cid, blessing)
    doPlayerAddBlessing(cid, blessing)
    saveData()
    escapeString(str)
 
Last edited:
Since it wont work without 'function onKill(cid, target)'. Does anyone know how to add this function into my server. I guess it's c++ related.
Any advice is welcome.
 
I've looked into the source of 0.2.7 and it has kill as creaturescript type.
CreatureEvent types TFS 0.2.7:
Code:
login
logout
think
preparedeath
death
kill
Function onKill is btw a main function/scriptsystem function, like function onUse, onCastSpell, onSay etc.
This function is executed when you kill something (if the script is registered and added in creaturescripts.xml) so it works different than the normal Lua functions you add in your Lua scripts.

Do you get errors?
 
Back
Top