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

Lua Can you look at my onDeath Script?

Jfrye

Mapper, trying to learn scripting
Joined
Jan 8, 2009
Messages
366
Solutions
5
Reaction score
86
Location
Mexico Missouri
This script doesnt seem to work. I am trying to make it set a storage value (which should update the questlog), but it does not work.

script.lua
Code:
function onKill(cid, target)
local monsters = {
    ["creature"] = {storage = 20001, value = 2}
    }

    for i,v in pairs(monsters) do
    if getCreatureName(target) == i then
        doPlayerSetStorageValue(cid, v.storage,v.value)
    end
    return true
    end
end

creaturescripts.xml
Code:
    <event type="kill" name="creature" script="script.lua"/>

Added this to login.lua (inside creaturescripts.lua)
Code:
    registerCreatureEvent(cid, "creature")

Basically, they have to kill a creature to loot an item. I would like the quest log to update after the creature has been killed. After creature has been killed, it finishes Mission 1, and I hope it can start Mission 2 at the same time. So does it need to add a second storage value of 20002 in this script as well?

HalfAway helped me get the main part of the quest log working for this last night, but here is the quest.xml for this quest

Code:
    <quest name="The Lost Ring" startstorageid="20001" startstoragevalue="1">
        <mission name="Finding the Ring" storageid="20001" startvalue="1" endvalue="2">
            <missionstate id="1" description="You are trying to help find a lost ring. The NPC told you to check near a water vortex in the swimming area in town." />
        </mission>
        <mission name="Returning the Ring" storageid="20002" startvalue="1" endvalue="1">
            <missionstate id="1" description="You have found the ring. You should return it to the NPC." />
        </mission>
    </quest>

So, they find the ring by killing "creature". Once killed, "Finding the Ring" should be complete. Once "Finding the Ring" is completed, "Returning the Ring" should pop up in the quest log. I hope I have been clear in what I am trying to do here. Im not sure if all of this is possible in this one onKill script or not. (The script may not be completed all the way for what I am looking for)
 
Last edited:
Code:
local monsters = {-- monster names should be lowercase
    ["creature"] = {storage = 20001, value = 2}
}

function onKill(cid, target)
    local creature = monsters[getCreatureName(target):lower()]
    if creature then
        doPlayerSetStorageValue(cid, creature.storage, creature.value)
    end
    return true
end
 
Thanks for responding @Codex NG. Unfortunately when i kill the creature it does not work. I kill the creature, and nothing happens.

So, do I have this registered wrong?
 
Last edited:
Still having issues. Here is the script. I added a print message to the script to see if it is actually working, but nothing prints in the console.

Code:
local pos = {x = 2343, y = 301, z = 8}
local monsters = {-- monster names should be lowercase
    ["creature"] = {storage = 20001, value = 2}
}

function onKill(cid, target)
    local creature = monsters[getCreatureName(target):lower()]
    if creature then
    print("test")
        doPlayerSetStorageValue(cid, creature.storage, creature.value)
        doCreateItem(1386, 1, pos)
    end
    return true
end
 

Similar threads

Back
Top