• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action Working Demon Oak Quest

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	queststatus = getPlayerStorageValue(cid, 12900)
	if queststatus < 1 then
		if item.uid == 12901 then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a Demon Legs.")
			doPlayerAddItem(cid, 2495, 1)
		elseif item.uid == 12902 then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a Rainbow Shield.")
			doPlayerAddItem(cid, 8905, 1)
		elseif item.uid == 12903 then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a Spellbook of Dark Mysteries.")
			doPlayerAddItem(cid, 8918, 1)
		elseif item.uid == 12904 then
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a Royal Crossbow.")
			doPlayerAddItem(cid, 8851, 1)
		end
		doPlayerSetStorageValue(cid, 12900, 1)
	else
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "It is empty.")
	end
	return true
end

this is a short version of demonoakchests.lua its half the amount of lines
 

this is a short version of demonoakchests.lua its half the amount of lines

this is a shorter version of demonoakchests.lua its more half the amount of lines
Lua:
local t = {
    [12901] = {msg = 'Demon Legs', item = 2495},
    [12902] = {msg = 'Rainbow  Shield', item = 8905},
    [12903] = {msg = 'Spellbook of Dark Mysteries', item = 8918},
    [12904] = {msg = 'Royal Crossbow', item = 8851},
    }

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, 12900) < 1 then
        if t[item.uid] then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found a '.. t[item.uid].msg)
            doPlayerAddItem(cid, t[item.uid].item, 1)
        end
        doPlayerSetStorageValue(cid, 12900, 1)
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty.')
        end
return true
end

can be shortest tho (getItemNameById(itemid) / getItemName(uid)) + a lua string caps function



 
Last edited:
this is a shorter version of demonoakchests.lua its more half the amount of lines
Lua:
local t = {
    [12901] = {msg = 'Demon Legs', item = 2495},
    [12902] = {msg = 'Rainbow  Shield', item = 8905},
    [12903] = {msg = 'Spellbook of Dark Mysteries', item = 8918},
    [12904] = {msg = 'Royal Crossbow', item = 8851},
    }

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, 12900) < 1 then
        if t[item.uid] then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found a '.. t[item.uid].msg)
            doPlayerAddItem(cid, t[item.uid].item, 1)
        end
        doPlayerSetStorageValue(cid, 12900, 1)
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty.')
        end
return true
end

can be shortest tho (getItemNameById(itemid) / getItemName(uid)) + a lua string caps function




:\ beat me by 3 lines. i knew there was even a better way to do it with tables to make it even shorter. but im not that good with them. anyway nice and thanks
 
this is a shorter version of demonoakchests.lua its more half the amount of lines
Lua:
local t = {
    [12901] = {msg = 'Demon Legs', item = 2495},
    [12902] = {msg = 'Rainbow  Shield', item = 8905},
    [12903] = {msg = 'Spellbook of Dark Mysteries', item = 8918},
    [12904] = {msg = 'Royal Crossbow', item = 8851},
    }

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, 12900) < 1 then
        if t[item.uid] then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'You have found a '.. t[item.uid].msg)
            doPlayerAddItem(cid, t[item.uid].item, 1)
        end
        doPlayerSetStorageValue(cid, 12900, 1)
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, 'It is empty.')
        end
return true
end

can be shortest tho (getItemNameById(itemid) / getItemName(uid)) + a lua string caps function





In real it'll say:
you have found demon legs and not a demon legs.
legs don't have the article....
 
Code:
[19/06/2010 22:34:35] data/npc/scripts/oldrak.lua
[19/06/2010 22:34:35] Description: 
[19/06/2010 22:34:35] data/npc/scripts/oldrak.lua:52: attempt to index global 'npcHandler' (a nil value)
[19/06/2010 22:34:35] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/oldrak.lua

I'm getting this, any idea how to fix it?
 
Code:
[19/06/2010 22:34:35] data/npc/scripts/oldrak.lua
[19/06/2010 22:34:35] Description: 
[19/06/2010 22:34:35] data/npc/scripts/oldrak.lua:52: attempt to index global 'npcHandler' (a nil value)
[19/06/2010 22:34:35] [Warning - NpcScript::NpcScript] Cannot load script: data/npc/scripts/oldrak.lua

I'm getting this, any idea how to fix it?

What distro are you using?

Edit:

The old npc script was working good but i've updated it, now is more compatible with another npc systems. It should work for you now
 
Last edited:
What distro are you using?

Edit:

The old npc script was working good but i've updated it, now is more compatible with another npc systems. It should work for you now

TFS 0.3.6 pl1

Anyway I'll try now rep++ if works..
 
Don't forget to give me credits for viewing this thread! Haha no just kidding.
 
The gravestone is not working for me , no clue why...
It has the correct Unique ID ingame and in Actions.xml.

Also after a player died he cannot enter demon oak again.

All the rest works, any idea how fix this ?
 
The gravestone is not working for me , no clue why...
It has the correct Unique ID ingame and in Actions.xml.

Also after a player died he cannot enter demon oak again.

All the rest works, any idea how fix this ?

Try changing the "onDeath" script to "onPrepareDeath" and test it
 
Hi, I have a problem with the script for the Demon Oak Quest. So when I go to do the Demon Oak, the tree - 'Dead Tree' writes: 'wait until my nick finish the quest' may know what's going on? Because I do not really understand
I would be very grateful for your help
 
Hi, I have a problem with the script for the Demon Oak Quest. So when I go to do the Demon Oak, the tree - 'Dead Tree' writes: 'wait until my nick finish the quest' may know what's going on? Because I do not really understand
I would be very grateful for your help

Check the console, the tree position is inside the quest-area position
 
Back
Top