• 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 Quest Chests

Status
Not open for further replies.

JDB

OtLand Veteran
Joined
Jun 1, 2009
Messages
4,145
Solutions
2
Reaction score
115
Closed
 
Last edited:
AFF, I maked this script to, atm, i wantet to post them but then i saw yours, <_<.

PS: Nice script.
 
Code:
<action uniqueid="1001" script="anni_chest.lua" />
<action uniqueid="1002" script="anni_chest.lua" />
<action uniqueid="1003" script="anni_chest.lua" />
<action uniqueid="1004" script="anni_chest.lua" />
can be replaced with:
Code:
<action uniqueid="1001-1004" script="anni_chest.lua" />

Isn't it better to use TFS' quest system instead of scrypting every quest rewards? :P
 
If that works,
I guess it is better. :confused:
 
Not many understands how TFS's quest system works though. Perhaps somebody should make a tutorial about it :o

edit1:
Converted the code to make it work for 0.2.

LUA:
--- Created by JDB, converted to 0.2 by Znote ---
local chests = {
    [1001] = {prize = xxxx},
    [1002] = {prize = xxxx},
    [1003] = {prize = xxxx},
    [1004] = {prize = xxxx}
}

local status = 20000 -- Storage for quest
local questLevel = 30 -- Level to open chest

function onUse(cid, item, fromPosition, itemEx, toPosition)
local questStatus = getPlayerStorageValue(cid, status)
local playerPos = getCreaturePosition(cid)
    if questStatus == 1 then
        doPlayerSendTextMessage(cid, "You have already chosen your reward.")
    return TRUE
    end
    if getPlayerLevel(cid) >= questLevel then
        doPlayerAddItem(cid, chests[item.uid].prize, 1)
        setPlayerStorageValue(cid, status, 1)
        doSendMagicEffect(playerPos, CONST_ME_GIFT_WRAPS)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Here is your reward!")
    end
    return TRUE
end

Tested and works perfectly. :)
 
Last edited:
It shouldn't work because getCreaturePosition is not in 0.2.5.
Edited first post myself.
:thumbup:
 
Not many understands how TFS's quest system works though. Perhaps somebody should make a tutorial about it :o

I guess elf's one is enough:
http://otland.net/f55/0-3-quest-system-15890/ (idk about 0.2)

scripts like those in this thread can be used to script some rewards which come from (for an example) a ground tile, not from container, to the containers (like chests) it's better to use quest system
 
TFS 0.2.5 got both getcreatureposition and getplayerposition. And can be used for same purpose as far as I know.

edit:
LUA:
--- Created by JDB, converted to 0.2 by Znote ---
  local chests = {
    [1001] = {prize = xxxx},
    [1002] = {prize = xxxx},
    [1003] = {prize = xxxx},
    [1004] = {prize = xxxx}
}

local status = 21000 -- Storage for quest
local questLevel = 50 -- Level to open chest

function onUse(cid, item, fromPosition, itemEx, toPosition)
local questStatus = getPlayerStorageValue(cid, status)
local playerPos = getCreaturePosition(cid)
    if questStatus == 1 then
        doPlayerSendTextMessage(cid, "You have already chosen your reward.")
    return TRUE
    end
    if getPlayerLevel(cid) >= questLevel then
        doPlayerAddItem(cid, chests[item.uid].prize, 1)
        setPlayerStorageValue(cid, status, 1)
        doSendMagicEffect(playerPos, CONST_ME_GIFT_WRAPS)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Here is your reward!")
			else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need level "..questLevel.." to get the rewards!")
    end
    return TRUE
end

Fixed: If you need level 50 to take the quest, and you are below it, it will say that you need level 50 to take the chest. Or any value that you choose in local questlevel.

This works on TFS 0.2.5

I basically only added
Code:
			else
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need level "..questLevel.." to get the rewards!")
Before end and return true at the bot of the script.

edit2:
After taking the reward, and you try to click on it, instead of leaving a message "you have already taken reward blabla". Nothing comes up.

Else than an console error.
Code:
[10/08/2009 00:46:40] Lua Script Error: [Action Interface] 
[10/08/2009 00:46:40] data/actions/scripts/quests/optionable.lua:onUse

[10/08/2009 00:46:40] luaDoPlayerSendTextMessage(). Player not found
 
Last edited:
Dont work pls fix!
[11/12/2009 20:03:51] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/anni_chests.lua)
[11/12/2009 20:03:51] data/actions/scripts/anni_chests.lua:3: '}' expected near 'Armor'

0.3.5
 
Dont work pls fix!
[11/12/2009 20:03:51] [Warning - Event::loadScript] Cannot load script (data/actions/scripts/anni_chests.lua)
[11/12/2009 20:03:51] data/actions/scripts/anni_chests.lua:3: '}' expected near 'Armor'

0.3.5
use item ids instead of names
 
Dont work pls help!
PHP:
local chests = 
{

    [1001] = {2494},
    [1002] = {2400},
    [1003] = {2431},
    [1004] = {2421}
}

local status = 12345 -- Storage for quest
local questLevel = 100 -- Level to open chest

function onUse(cid, item, fromPosition, itemEx, toPosition)
local name = getItemNameById(chests[item.uid].prize)
local questStatus = getPlayerStorageValue(cid, status)
local playerPos = getCreaturePosition(cid)
    if questStatus == 1 then
        doPlayerSendTextMessage(cid, "You have already chosen your reward.")
    return TRUE
    end
    if getPlayerLevel(cid) >= questLevel then
        doPlayerAddItem(cid, chests[item.uid].prize, 1)
        setPlayerStorageValue(cid, status, 1)
        doSendMagicEffect(playerPos, CONST_ME_GIFT_WRAPS)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have chosen a ".. name .." as your reward.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must be atleast level ".. questLevel .." to open this chest.")
    end
    return TRUE
end

What i doing wrong?
When i click a item i dont get it but it says i will have it:(
 
LUA:
local chests =  
{ 
    [1001] = {2494},
    [1002] = {2400},
    [1003] = {2431},
    [1004] = {2421}
} 

local status = 12345 -- Storage for quest 
local questLevel = 100 -- Level to open chest 

function onUse(cid, item, fromPosition, itemEx, toPosition) 
local name = getItemNameById(chests[item.uid].prize) 
local questStatus = getPlayerStorageValue(cid, status) 
local playerPos = getCreaturePosition(cid) 
    if questStatus == 1 then 
        doPlayerSendTextMessage(cid, "You have already chosen your reward.")
        return true
    end
    doPlayerAddItem(cid, chests[item.uid].prize, 1) 
    setPlayerStorageValue(cid, status, 1)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have chosen a ".. name .." as your reward.")
    return true
end
 
Last edited:
Nothing work:(

Pls i need help i dont get a item and the name of the item dosent shown:(
 
Status
Not open for further replies.
Back
Top