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

Reward Chest - Key

xsaint

ʜᴀᴜɴᴛᴇᴅ
Joined
Sep 3, 2019
Messages
92
Reaction score
281
Location
Launceston, Australia
Basically I have a door that has a NPC trapped inside, theres a crate in a different cave behind a boss that contains a key.

I want it so the key opens the door, but when the door opens the player gets a text message from the NPC "I knew you'd come back, please take this, it might not seem like a lot but my gratitude extends tenfold. Should you ever need anything, don't hesitate to ask any of my family members, I'll makes sure they know of your good deed." I want the player to gain 5000 experience, and 3500 cash.

I'm terrible at this, so I guess I'd want it so the NPC gives a quest, quest is to go find key, bring key back use on door, talk to npc, she rewards with exp + cash.

I've attached the NPC file of the NPC I want to do this.

Thank you!

Trolls4.png
 

Attachments

  • Tanalia Silverbane.xml
    3.1 KB · Views: 4 · VirusTotal
Last edited:
Solution
S
if the player doesn't have to talk with the npc and he will recieve the reward once he open the door then we can do it simply like this
use this in actions/scripts/quest12.lua
Code:
local key = 2086 -- Put your quest key ID
openned_door = 1226

function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    if player:removeItem(key) then
        item:transform(openned_door)
        player:teleportTo(toPosition, true)
        player:sendTextMessage(MESSAGE_MESSAGE_STATUS_CONSOLE_BLUE, "Tanalia Silverbane : I knew you'd come back, please take this, it might not seem like a lot but my gratitude extends tenfold. Should you ever need anything, don't hesitate to ask any of my family members, I'll makes sure they know of your good...
Please read Support board rules before posting your next thread.
You are breaking rule number #9
9. Monetary Offerings:
- Any offerings of money are not allowed in this section. If you want help, ask it but you don't have to offer anything in return other than thanks.
Also if you want to ask for paid jobs or hire someone you'll have to use this section Jobs
 
Last edited:
if the player doesn't have to talk with the npc and he will recieve the reward once he open the door then we can do it simply like this
use this in actions/scripts/quest12.lua
Code:
local key = 2086 -- Put your quest key ID
openned_door = 1226

function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    if player:removeItem(key) then
        item:transform(openned_door)
        player:teleportTo(toPosition, true)
        player:sendTextMessage(MESSAGE_MESSAGE_STATUS_CONSOLE_BLUE, "Tanalia Silverbane : I knew you'd come back, please take this, it might not seem like a lot but my gratitude extends tenfold. Should you ever need anything, don't hesitate to ask any of my family members, I'll makes sure they know of your good deed.")
        player:addItem(2152, 30)
        player:addExperience(5000)
    else
        player:sendTextMessage(MESSAGE_INFO_DESCR, "The door seems to be sealed against unwanted intruders.")
    end
return true
end
and add it in actions.xml

or you can add something like this in a lua file for your NPC
Code:
local doorpos = (1000, 1000, 7) -- the position of the door because players are forced to path through this position
local player = Player(cid)
            if player:getPosition(doorpos) then
                if not NpcHandler:isFocused(cid) then
                    NpcHandler:addFocus(cid)
                end
                selfSay("I knew you'd come back, please take this, it might not seem like a lot but my gratitude extends tenfold. Should you ever need anything, don't hesitate to ask any of my family members, I'll makes sure they know of your good deed.", cid)
                player:addItem(2152, 30)
                player:addExperience(5000)
            end

note both are 1.X let me know if you faced errors in any of both

EDIT - Little mistake in the second one ( Switching first if with the second )
 
Last edited by a moderator:
Solution
[Warning - NpcScript::NpcScript] Can not load script: Tanalia Silverbane.lua
data/npc/scripts/Tanalia Silverbane.lua:1: ')' expected near ','

Small error appeared, not sure if it was me when I changed the ID's.

Code:
local doorpos = (993, 1057, 5) -- the position of the door because players are forced to path through this position
local player = Player(cid)
            if player:getPosition(doorpos) then
                if not NpcHandler:isFocused(cid) then
                    NpcHandler:addFocus(cid)
                end
                selfSay("I knew you'd come back, please take this, it might not seem like a lot but my gratitude extends tenfold. Should you ever need anything, don't hesitate to ask any of my family members, I'll makes sure they know of your good deed.", cid)
                player:addItem(2152, 30)
                player:addExperience(5000)
            end
 
NPC scripts in lua can't be added alone
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
 
local doorpos = (993, 1057, 5) -- the position of the door because players are forced to path through this position
local player = Player(cid)
            if player:getPosition(doorpos) then
                if not NpcHandler:isFocused(cid) then
                    NpcHandler:addFocus(cid)
                end
                selfSay("I knew you'd come back, please take this, it might not seem like a lot but my gratitude extends tenfold. Should you ever need anything, don't hesitate to ask any of my family members, I'll makes sure they know of your good deed.", cid)
                player:addItem(2152, 30)
                player:addExperience(5000)
            end
 
Same error, I know nothing about scripting haha. (Sorry for the hassle)
So I have my normal NPC xml.

XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Tanalia Silverbane" script="Tanalia Silverbane.lua" walkinterval="1500" speed="100" walkradius="3" floorchange="0" speechbubble="3">
    <health max="100" now="100"/>
    <look type="136" head="79" body="102" legs="87" feet="94" addons="3" mount="0"/>
    <parameters>
        <!--MESSAGES-->
        <parameter key="message_greet" value="|PLAYERNAME|, thank the lords it's you, I didn't know if I'd see a familiar face again. "/>
        <parameter key="message_farewell" value="Oh |PLAYERNAME|, please don't leave me, I'm so afraid they'll return."/>
        <parameter key="message_idletimeout" value="Alone again, the saying goes &quot;If a tree falls in a forest, does anyone hear it?&quot; Well if I scream my lungs out inside of a mountain, will anyone hear it? I guess the answer is the same."/>
        <parameter key="message_walkaway_male" value="Oh |PLAYERNAME|, please don't leave me, I'm so afraid they'll return."/>
        <parameter key="message_walkaway_female" value="Oh |PLAYERNAME|, please don't leave me, I'm so afraid they'll return."/>
        <!--KEYWORDS-->
        <parameter key="module_keywords" value="1"/>
        <parameter key="keywords" value="troll;trolls;key;silverbane;dropped;wedge"/>
        <parameter key="keyword_reply1" value="Disgusting creatures, they've been outside taunting me all day, I do hope you can find the key before they do."/>
        <parameter key="keyword_reply2" value="Disgusting creatures, they've been outside taunting me all day, I do hope you can find the key before they do."/>
        <parameter key="keyword_reply3" value="I though I had left the key inside so I went back inside to check and the door closed behind me."/>
        <parameter key="keyword_reply4" value="My family name, we come from a long line of adventurers, we've struck our riches along the way. I'm sure I could arrange for a reward if you were able to spring me from this dusty disgusting troll hole."/>
        <parameter key="keyword_reply5" value="I think it may have fallen off the edge, I doubt you'll be able to get down to it. Maybe you could find something to wedge open this door?"/>
        <parameter key="keyword_reply6" value="Something sharp would do, if you were to try lift the frame, I could push from the inside and maybe the door would budge."/>
    </parameters>
</npc>

And then in data/npc/scripts - I have

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

local doorpos = (993, 1057, 5) -- the position of the door because players are forced to path through this position
local player = Player(cid)
            if player:getPosition(doorpos) then
                if not NpcHandler:isFocused(cid) then
                    NpcHandler:addFocus(cid)
                end
                selfSay("I knew you'd come back, please take this, it might not seem like a lot but my gratitude extends tenfold. Should you ever need anything, don't hesitate to ask any of my family members, I'll makes sure they know of your good deed.", cid)
                player:addItem(2152, 30)
                player:addExperience(5000)
            end
 
Same error, I know nothing about scripting haha. (Sorry for the hassle)
So I have my normal NPC xml.

XML:
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Tanalia Silverbane" script="Tanalia Silverbane.lua" walkinterval="1500" speed="100" walkradius="3" floorchange="0" speechbubble="3">
    <health max="100" now="100"/>
    <look type="136" head="79" body="102" legs="87" feet="94" addons="3" mount="0"/>
    <parameters>
        <!--MESSAGES-->
        <parameter key="message_greet" value="|PLAYERNAME|, thank the lords it's you, I didn't know if I'd see a familiar face again. "/>
        <parameter key="message_farewell" value="Oh |PLAYERNAME|, please don't leave me, I'm so afraid they'll return."/>
        <parameter key="message_idletimeout" value="Alone again, the saying goes &quot;If a tree falls in a forest, does anyone hear it?&quot; Well if I scream my lungs out inside of a mountain, will anyone hear it? I guess the answer is the same."/>
        <parameter key="message_walkaway_male" value="Oh |PLAYERNAME|, please don't leave me, I'm so afraid they'll return."/>
        <parameter key="message_walkaway_female" value="Oh |PLAYERNAME|, please don't leave me, I'm so afraid they'll return."/>
        <!--KEYWORDS-->
        <parameter key="module_keywords" value="1"/>
        <parameter key="keywords" value="troll;trolls;key;silverbane;dropped;wedge"/>
        <parameter key="keyword_reply1" value="Disgusting creatures, they've been outside taunting me all day, I do hope you can find the key before they do."/>
        <parameter key="keyword_reply2" value="Disgusting creatures, they've been outside taunting me all day, I do hope you can find the key before they do."/>
        <parameter key="keyword_reply3" value="I though I had left the key inside so I went back inside to check and the door closed behind me."/>
        <parameter key="keyword_reply4" value="My family name, we come from a long line of adventurers, we've struck our riches along the way. I'm sure I could arrange for a reward if you were able to spring me from this dusty disgusting troll hole."/>
        <parameter key="keyword_reply5" value="I think it may have fallen off the edge, I doubt you'll be able to get down to it. Maybe you could find something to wedge open this door?"/>
        <parameter key="keyword_reply6" value="Something sharp would do, if you were to try lift the frame, I could push from the inside and maybe the door would budge."/>
    </parameters>
</npc>

And then in data/npc/scripts - I have

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

local doorpos = (993, 1057, 5) -- the position of the door because players are forced to path through this position
local player = Player(cid)
            if player:getPosition(doorpos) then
                if not NpcHandler:isFocused(cid) then
                    NpcHandler:addFocus(cid)
                end
                selfSay("I knew you'd come back, please take this, it might not seem like a lot but my gratitude extends tenfold. Should you ever need anything, don't hesitate to ask any of my family members, I'll makes sure they know of your good deed.", cid)
                player:addItem(2152, 30)
                player:addExperience(5000)
            end
Lua:
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

local function onCreatureAppear(cid)
local doorpos = Position(1000, 1000, 7) -- the position of the door because players are forced to path through this position
local player = Player(cid)
            if player:getPosition() == doorpos and player:getStorageValue(17945) == 1 then
                    npcHandler:addFocus(cid)
                selfSay("I knew you'd come back, please take this, it might not seem like a lot but my gratitude extends tenfold. Should you ever need anything, don't hesitate to ask any of my family members, I'll makes sure they know of your good deed.", cid)
                player:addItem(2152, 30)
                player:addExperience(5000)
                player:setStorageValue(17945, 1)
    else
            end
        return true
    end
npcHandler:setCallback(CALLBACK_CREATURE_APPEAR, onCreatureAppear)
npcHandler:addModule(FocusModule:new())
forgot 1 word
 
Last edited by a moderator:
Lua Script Error: [Npc interface]
data/npc/scripts/Tanalia Silverbane.lua
data/npc/scripts/Tanalia Silverbane.lua:12: attempt to index local 'player' (a nil value)
stack traceback:
[C]: in function '__index'
data/npc/scripts/Tanalia Silverbane.lua:12: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Tanalia Silverbane.lua

New error :( I wish I knew how to code. If it still doesn't work, I understand if you can't help. I don't want you to waste lots of time on this haha.
 
Lua Script Error: [Npc interface]
data/npc/scripts/Tanalia Silverbane.lua
data/npc/scripts/Tanalia Silverbane.lua:12: attempt to index local 'player' (a nil value)
stack traceback:
[C]: in function '__index'
data/npc/scripts/Tanalia Silverbane.lua:12: in main chunk
[Warning - NpcScript::NpcScript] Can not load script: Tanalia Silverbane.lua

New error :( I wish I knew how to code. If it still doesn't work, I understand if you can't help. I don't want you to waste lots of time on this haha.
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

local function onCreatureAppear(cid)
local doorpos = Position(1000, 1000, 7) -- the position of the door because players are forced to path through this position
local player = Player(cid)
            if player:getPosition() == doorpos and player:getStorageValue(17945) == 1 then
                    npcHandler:addFocus(cid)
                selfSay("I knew you'd come back, please take this, it might not seem like a lot but my gratitude extends tenfold. Should you ever need anything, don't hesitate to ask any of my family members, I'll makes sure they know of your good deed.", cid)
                player:addItem(2152, 30)
                player:addExperience(5000)
                player:setStorageValue(17945, 1)
    else
            end
        return true
    end
npcHandler:setCallback(CALLBACK_CREATURE_APPEAR, onCreatureAppear)
npcHandler:addModule(FocusModule:new())
try now , set your old positions again
 
Houston, we have a problem. :{

Code:
Lua Script Error: [Npc interface]
data/npc/scripts/Tanalia Silverbane.lua:onCreatureAppear
data/npc/scripts/Tanalia Silverbane.lua:13: attempt to index local 'player' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/npc/scripts/Tanalia Silverbane.lua:13: in function 'callback'
        data/npc/lib/npcsystem/npchandler.lua:367: in function 'onCreatureAppear'
        data/npc/scripts/Tanalia Silverbane.lua:5: in function <data/npc/scripts/Tanalia Silverbane.lua:5>
 
Houston, we have a problem. :{

Code:
Lua Script Error: [Npc interface]
data/npc/scripts/Tanalia Silverbane.lua:onCreatureAppear
data/npc/scripts/Tanalia Silverbane.lua:13: attempt to index local 'player' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/npc/scripts/Tanalia Silverbane.lua:13: in function 'callback'
        data/npc/lib/npcsystem/npchandler.lua:367: in function 'onCreatureAppear'
        data/npc/scripts/Tanalia Silverbane.lua:5: in function <data/npc/scripts/Tanalia Silverbane.lua:5>
your npcsystem is different than mine :/ sorry i can't do anymore brother you can use the action script till anybody help in this
 
Back
Top