• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Solved Golden Key gain - Rookgaard graves script

xardas33

New Member
Joined
Jan 28, 2010
Messages
83
Reaction score
0
Hello guys. I want to make script to get Golden Key like in this film:
watch from 0:57 to 1:10

But I want to do that in my own version:
You put six same items (with same id) on graves, and put other item in central grave, later using on central grave vial of blood, items are removed and you gain golden key.
Now i created this script:
GoldenKey.lua
Code:
function onUse(cid, item, frompos, item2, topos)
skullpos1 = {x=31978, y=32142, z=10, stackpos=1}
skullpos2 = {x=31979, y=32142, z=10, stackpos=1}
skullpos3 = {x=31980, y=32142, z=10, stackpos=1}
skullmpos4 = {x=31981, y=32142, z=10, stackpos=1}
skullpos5 = {x=31982, y=32142, z=10, stackpos=1}
skullpos6 = {x=31983, y=32142, z=10, stackpos=1}
skullpos7 = {x=31984, y=32142, z=10, stackpos=1}
bloodpos = {x=31981, y=32142, z=10}
getskull1 = getThingfromPos(skullpos1)
getskull2 = getThingfromPos(skullpos2)
getskull3 = getThingfromPos(skullpos3)
getskullm4 = getThingfromPos(skullmpos4)
getskull5 = getThingfromPos(skullpos5)
getskull6 = getThingfromPos(skullpos6)
getskull7 = getThingfromPos(skullpos7)
getblood = getThingfromPos(bloodpos)

if item.itemid == 8059 and getskull1.itemid == 2320 and getskull2.itemid == 2320 and getskull3.itemid == 2320 and getskull5.itemid == 2320 and getskull6.itemid == 2320 and getskull7.itemid == 2320 and getPlayerStorageValue(cid,50021) == 8  then
   if item.itemid == 8059 and item.uid == 60007 and getskullm4.itemid == 5669 and getblood.itemid == 2016 then
     doRemoveItem(getskull1.uid,1)
     doSendMagicEffect(skullpos1,13)
     doRemoveItem(getskull2.uid,1)
     doSendMagicEffect(skullpos2,13)
     doRemoveItem(getskull3.uid,1)
     doSendMagicEffect(skullpos3,13)
     doRemoveItem(getskullm4.uid,1)
     doSendMagicEffect(skullmpos4,36)
     doRemoveItem(getskull5.uid,1)
     doSendMagicEffect(skullpos5,13)
     doRemoveItem(getskull6.uid,1)
     doSendMagicEffect(skullpos6,13)
     doRemoveItem(getskull7.uid,1)
     doSendMagicEffect(skullpos7,13)
     local item = doPlayerAddItem(cid,2091,1)
     doItemSetAttribute(item,"aid",4602)
     setPlayerStorageValue(cid,55021,9)
     doPlayerSendTextMessage(cid,25,"You have found a golden key.")
   end
end
return 1
end

Actions.xml
Code:
<action uniqueid="60007" event="script" value="quests/GoldenKey.lua"/>
Graves have normally id 8059, and i writed extra uniqueid 60007 for central grave. And this script doesn't work.
what i should edit? Someone can help?
 
Last edited:
Like this?
aPkbP16d.png

Then you use an item on the middle grave with skull id 5669 and then all 7 skull dissappear and you get golden key with actionid 4602?
 
Code:
local graves = {   
     {pos = {x=31978, y=32142, z=10}, id = 2320},
     {pos = {x=31979, y=32142, z=10}, id = 2320},
     {pos = {x=31980, y=32142, z=10}, id = 2320},
   
     {pos = {x=31981, y=32142, z=10}, id = 5669},
   
     {pos = {x=31982, y=32142, z=10}, id = 2320},
     {pos = {x=31983, y=32142, z=10}, id = 2320},
     {pos = {x=31984, y=32142, z=10}, id = 2320}
}


function onUse(cid, item, fromPosition, itemEx, toPosition)

   if getTileItemById(toPosition, 1406).uid == 60007 then
       for x = 1, #graves do
           if getTileItemById(graves[x].pos, graves[x].id).uid == 0 then
               return doPlayerSendCancel(cid, "Something is wrong.") and doSendMagicEffect(graves[x].pos, CONST_ME_POFF)
           end
       end
       for r = 1, #graves do
           doRemoveItem(getTileItemById(graves[r].pos, graves[r].id).uid)
           doSendMagicEffect(graves[r].pos, CONST_ME_MAGIC_RED)
       end
       local thing = doPlayerAddItem(cid, 2091, 1)
       doItemSetAttribute(thing, "aid", 4602)
       setPlayerStorageValue(cid, 55021, 9)
       doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a golden key.")
   end
   return true
end
Add it with itemid of the item you use of the grave in actions.xml.
 
I tested script and I see it doesn't work... Just nothing happened.
If I add any item, it doesn't work. And when I trying to add in actions.xml itemid=2006, normal script with vials stops working. I need to use on central grave vial of blood, and getPlayerStorageValue(cid,50021) == 8
 
You can only use an itemid 1x in actions.xml, so you can add this to that script and check for item.itemid and item.type.
Code:
if item.itemid == 2006 and item.type = TYPE_BLOOD and getPlayerStorageValue(cid, 50021) == 8 and getTileItemById(toPosition, 1406).uid == 60007 then


Just remove
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)

And return true end at the bottom of the script and add the graves table above function onUse in that script.
 
Like that?
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local graves = {   
  {pos = {x=31978, y=32142, z=10}, id = 2320},
  {pos = {x=31979, y=32142, z=10}, id = 2320},
  {pos = {x=31980, y=32142, z=10}, id = 2320},
   
  {pos = {x=31981, y=32142, z=10}, id = 5669},
   
  {pos = {x=31982, y=32142, z=10}, id = 2320},
  {pos = {x=31983, y=32142, z=10}, id = 2320},
  {pos = {x=31984, y=32142, z=10}, id = 2320}
}

   if item.itemid == 2006 and item.type = TYPE_BLOOD and getPlayerStorageValue(cid, 50021) == 8 and getTileItemById(toPosition, 1406).uid == 60007 then  <--- error here...
  for x = 1, #graves do
  if getTileItemById(graves[x].pos, graves[x].id).uid == 0 then
  return doPlayerSendCancel(cid, "Something is wrong.") and doSendMagicEffect(graves[x].pos, CONST_ME_POFF)
  end
  end
  for r = 1, #graves do
  doRemoveItem(getTileItemById(graves[r].pos, graves[r].id).uid)
  doSendMagicEffect(graves[r].pos, CONST_ME_MAGIC_RED)
  end
  local thing = doPlayerAddItem(cid, 2091, 1)
  doItemSetAttribute(thing, "aid", 4602)
  setPlayerStorageValue(cid, 55021, 9)
  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a golden key.")
  end
  return true
end

Error:
[Error - LuaScriptInterface::loadFile] data/actions/scripts/quests/GoldenKey.lua:14: 'then' expected near '='
[Warning - Event::loadScript] Cannot load script (data/actions/scripts/quests/GoldenKey.lua)
data/actions/scripts/quests/GoldenKey.lua:14: 'then' expected near '='
 
I made a typo :p
~~
if item.itemid == 2006 and item.type == TYPE_BLOOD and getPlayerStorageValue(cid, 50021) == 8 and getTileItemById(toPosition, 1406).uid == 60007 then

Add it to containers.lua.
 
Open containers.lua in data/actions/scripts/liquids, then paste this under function onUse
Code:
  if item.itemid == 2006 and item.type == TYPE_BLOOD and getPlayerStorageValue(cid, 50021) == 8 and getTileItemById(toPosition, 1406).uid == 60007 then
       for x = 1, #graves do
           if getTileItemById(graves[x].pos, graves[x].id).uid == 0 then
               return doPlayerSendCancel(cid, "Something is wrong.") and doSendMagicEffect(graves[x].pos, CONST_ME_POFF)
           end
       end
       for r = 1, #graves do
           doRemoveItem(getTileItemById(graves[r].pos, graves[r].id).uid)
           doSendMagicEffect(graves[r].pos, CONST_ME_MAGIC_RED)
       end
       local thing = doPlayerAddItem(cid, 2091, 1)
       doItemSetAttribute(thing, "aid", 4602)
       setPlayerStorageValue(cid, 55021, 9)
       doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a golden key.")
   end

Add this above function onUse
Code:
local graves = {
{pos = {x=31978, y=32142, z=10}, id = 2320},
{pos = {x=31979, y=32142, z=10}, id = 2320},
{pos = {x=31980, y=32142, z=10}, id = 2320},

{pos = {x=31981, y=32142, z=10}, id = 5669},

{pos = {x=31982, y=32142, z=10}, id = 2320},
{pos = {x=31983, y=32142, z=10}, id = 2320},
{pos = {x=31984, y=32142, z=10}, id = 2320}
}
 
It's part with added script in containers.lua
Code:
setConditionParam(poison, CONDITION_PARAM_MINVALUE, -50) -- Minimum damage the condition can do at total
setConditionParam(poison, CONDITION_PARAM_MAXVALUE, -120) -- Maximum damage
setConditionParam(poison, CONDITION_PARAM_STARTVALUE, -5) -- The damage the condition will do on the first hit
setConditionParam(poison, CONDITION_PARAM_TICKINTERVAL, 4000) -- Delay between damages
setConditionParam(poison, CONDITION_PARAM_FORCEUPDATE, true) -- Re-update condition when adding it(ie. min/max value)

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

local graves = {
{pos = {x=31978, y=32142, z=10}, id = 2320},
{pos = {x=31979, y=32142, z=10}, id = 2320},
{pos = {x=31980, y=32142, z=10}, id = 2320},

{pos = {x=31981, y=32142, z=10}, id = 5669},

{pos = {x=31982, y=32142, z=10}, id = 2320},
{pos = {x=31983, y=32142, z=10}, id = 2320},
{pos = {x=31984, y=32142, z=10}, id = 2320}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 2006 and item.type == TYPE_BLOOD and getPlayerStorageValue(cid, 50021) == 8 and getTileItemById(toPosition, 1406).uid == 60007 then
  for x = 1, #graves do
  if getTileItemById(graves[x].pos, graves[x].id).uid == 0 then
  return doPlayerSendCancel(cid, "Something is wrong.") and doSendMagicEffect(graves[x].pos, CONST_ME_POFF)
  end
  end
  for r = 1, #graves do
  doRemoveItem(getTileItemById(graves[r].pos, graves[r].id).uid)
  doSendMagicEffect(graves[r].pos, CONST_ME_MAGIC_RED)
  end
  local thing = doPlayerAddItem(cid, 2091, 1)
  doItemSetAttribute(thing, "aid", 4602)
  setPlayerStorageValue(cid, 55021, 9)
  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a golden key.")
  end

Still doesn't work, nothing happened when i placed skulls and used vial on blood on central skull, just nothing, and console doesn't show any error... ;/
Central grave has uniqueid 60007 in map editor.
 
Code:
local DISTILLERY = {5513, 5514, 5469, 5470}
local ITEM_RUM_FLASK = 5553
local ITEM_POOL = 2016

local TYPE_EMPTY = 0
local TYPE_WATER = 1
local TYPE_BLOOD = 2
local TYPE_BEER = 3
local TYPE_SLIME = 4
local TYPE_MANA_FLUID = 7
local TYPE_LIFE_FLUID = 10
local TYPE_OIL = 11
local TYPE_WINE = 15
local TYPE_MUD = 19
local TYPE_LAVA = 26
local TYPE_RUM = 27
local TYPE_SWAMP = 28

local oilLamps = {[2046] = 2044}
local casks = {[1771] = TYPE_WATER, [1772] = TYPE_BEER, [1773] = TYPE_WINE}
local alcoholDrinks = {TYPE_BEER, TYPE_WINE, TYPE_RUM}
local poisonDrinks = {TYPE_SLIME, TYPE_SWAMP}

local drunk = createConditionObject(CONDITION_DRUNK)
setConditionParam(drunk, CONDITION_PARAM_TICKS, 60000)

local poison = createConditionObject(CONDITION_POISON)
setConditionParam(poison, CONDITION_PARAM_DELAYED, true) -- Condition will delay the first damage from when it's added
setConditionParam(poison, CONDITION_PARAM_MINVALUE, -50) -- Minimum damage the condition can do at total
setConditionParam(poison, CONDITION_PARAM_MAXVALUE, -120) -- Maximum damage
setConditionParam(poison, CONDITION_PARAM_STARTVALUE, -5) -- The damage the condition will do on the first hit
setConditionParam(poison, CONDITION_PARAM_TICKINTERVAL, 4000) -- Delay between damages
setConditionParam(poison, CONDITION_PARAM_FORCEUPDATE, true) -- Re-update condition when adding it(ie. min/max value)

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))

local graves = {
{pos = {x=31978, y=32142, z=10}, id = 2320},
{pos = {x=31979, y=32142, z=10}, id = 2320},
{pos = {x=31980, y=32142, z=10}, id = 2320},

{pos = {x=31981, y=32142, z=10}, id = 5669},

{pos = {x=31982, y=32142, z=10}, id = 2320},
{pos = {x=31983, y=32142, z=10}, id = 2320},
{pos = {x=31984, y=32142, z=10}, id = 2320}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == 2006 and item.type == TYPE_BLOOD and getPlayerStorageValue(cid, 50021) == 8 and getTileItemById(toPosition, 1406).uid == 60007 then
  for x = 1, #graves do
  if getTileItemById(graves[x].pos, graves[x].id).uid == 0 then
  return doPlayerSendCancel(cid, "Something is wrong.") and doSendMagicEffect(graves[x].pos, CONST_ME_POFF)
  end
  end
  for r = 1, #graves do
  doRemoveItem(getTileItemById(graves[r].pos, graves[r].id).uid)
  doSendMagicEffect(graves[r].pos, CONST_ME_MAGIC_RED)
  end
  local thing = doPlayerAddItem(cid, 2091, 1)
  doItemSetAttribute(thing, "aid", 4602)
  setPlayerStorageValue(cid, 55021, 9)
  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a golden key.")
  end
   if(itemEx.uid == cid) then
     if(item.type == TYPE_EMPTY) then
       doPlayerSendCancel(cid, "It is empty.")
       return true
     end

     if(item.type == TYPE_MANA_FLUID) then
       if(hasCondition(cid, CONDITION_EXHAUST_HEAL)) then
         doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
         return true
       end

       if(not doPlayerAddMana(cid, math.random(80, 160))) then
         return false
       end

       doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
       doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE)
       doAddCondition(cid, exhaust)
     elseif(item.type == TYPE_LIFE_FLUID) then
       if(hasCondition(cid, CONDITION_EXHAUST_HEAL)) then
         doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
         return true
       end

       if(not doCreatureAddHealth(cid, math.random(40, 75))) then
         return false
       end

       doCreatureSay(cid, "Aaaah...", TALKTYPE_ORANGE_1)
       doSendMagicEffect(toPosition, CONST_ME_MAGIC_BLUE)
       doAddCondition(cid, exhaust)
     elseif(isInArray(alcoholDrinks, item.type)) then
       if(not doTargetCombatCondition(0, cid, drunk, CONST_ME_NONE)) then
         return false
       end

       doCreatureSay(cid, "Aaah...", TALKTYPE_ORANGE_1)
     elseif(isInArray(poisonDrinks, item.type)) then
       if(not doTargetCombatCondition(0, cid, poison, CONST_ME_NONE)) then
         return false
       end

       doCreatureSay(cid, "Urgh!", TALKTYPE_ORANGE_1)
     else
       doCreatureSay(cid, "Gulp.", TALKTYPE_ORANGE_1)
     end

     doChangeTypeItem(item.uid, TYPE_EMPTY)
     return true
   end

   if(not isCreature(itemEx.uid)) then
     if(item.type == TYPE_EMPTY) then
       if(item.itemid == ITEM_RUM_FLASK and isInArray(DISTILLERY, itemEx.itemid)) then
         if(itemEx.actionid == 100) then
           doItemEraseAttribute(itemEx.uid, "description")
           doItemEraseAttribute(itemEx.uid, "aid")
           doChangeTypeItem(item.uid, TYPE_RUM)
         else
           doPlayerSendCancel(cid, "You have to process the bunch into the distillery to get rum.")
         end
         return true
       end

       if(isItemFluidContainer(itemEx.itemid) and itemEx.type ~= TYPE_EMPTY) then
         doChangeTypeItem(item.uid, itemEx.type)
         doChangeTypeItem(itemEx.uid, TYPE_EMPTY)
         return true
       end

       if(casks[itemEx.itemid] ~= nil) then
         doChangeTypeItem(item.uid, casks[itemEx.itemid])
         return true
       end

       local fluidEx = getFluidSourceType(itemEx.itemid)
       if(fluidEx ~= false) then
         doChangeTypeItem(item.uid, fluidEx)
         return true
       end

       doPlayerSendCancel(cid, "It is empty.")
       return true
     end

     if(item.type == TYPE_OIL and oilLamps[itemEx.itemid] ~= nil) then
       doTransformItem(itemEx.uid, oilLamps[itemEx.itemid])
       doChangeTypeItem(item.uid, TYPE_NONE)
       return true
     end

     if(hasProperty(itemEx.uid, CONST_PROP_BLOCKSOLID)) then
       return false
     end
   end

   doDecayItem(doCreateItem(ITEM_POOL, item.type, toPosition))
   doChangeTypeItem(item.uid, TYPE_EMPTY)
return true
end
 
Does your character has storagevalue 8 from storage 50021?
Code:
   if item.itemid == 2006 and item.type == TYPE_BLOOD and getTileItemById(toPosition, 1406).uid == 60007 then
       if getPlayerStorageValue(cid, 50021) ~= 8 then
           return doPlayerSendCancel(cid, "You need to do something else first.")
       end
       for x = 1, #graves do
           if getTileItemById(graves[x].pos, graves[x].id).uid == 0 then
               return doPlayerSendCancel(cid, "Something is wrong.") and doSendMagicEffect(graves[x].pos, CONST_ME_POFF)
           end
       end
       for r = 1, #graves do
           doRemoveItem(getTileItemById(graves[r].pos, graves[r].id).uid)
           doSendMagicEffect(graves[r].pos, CONST_ME_MAGIC_RED)
       end
       local thing = doPlayerAddItem(cid, 2091, 1)
       doItemSetAttribute(thing, "aid", 4602)
       setPlayerStorageValue(cid, 55021, 9)
       doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have found a golden key.")
   end
I changed the storage part, if the character doesn't have the storagevalue you will get a message.
 
Yes my character have StorageValue 50021,8 - I checked it. Okey I will check now you script


Nothing happened as you see... ;/ maybe this script cannot work ?
 
Last edited:
I've tested it (I test every script I make that has more than 10 lines for possible type mistakes).
Add this under function onUse.
Code:
print(item.itemid)
print(item.type)
print(getTileItemById(toPosition, 1406).uid)
Look in console what it says.

There is no such thing as a script that "cannot work". There can be things wrong, but these things can be changed.
 
But why console doesn't say any errors? i adden any my console says when I use vial of blood on central grave:
[16/09/2014 10:25:46] Fitula has logged in.
[16/09/2014 10:25:48] 2006
[16/09/2014 10:25:48] 2
[16/09/2014 10:25:48] 0
 
Back
Top