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

{Solved}

Cadyan

Well-Known Member
Joined
Mar 30, 2008
Messages
845
Reaction score
63
I have been researching monster storage values... but I have yet to find a way to do it on 0.2.15.
Any help is appreciated.
 
Last edited:
You can't do it in Lua. XML is parsed by C++ and any additions to .xml file will force you to change the source code as there is no other way to retrieve that value. It's not a rocket science.

Monsters can obtain a storage value, like players, so it may be helpful.
 
use creature uid as variable, lua state is global

sry for tabbing, I used this text field as notepad

if you need to remove creature later:
eg.
Code:
function removeMob(uid)
      if Creature(uid) then
            doRemoveCreature(uid)
      end
end

Code:
mob = doSummonCreature(name, pos) -- returns uid
addEvent(removeMob, 15000, mob)

if you need to set creature storage (with value)
Code:
monster_storages = {}

function on...(...)
pid = doSummonCreature(name, pos)
      if monster_storages[pid] == nil then monster_storages[pid] = {} end
      monster_storages[pid][23485] = 2 -- value
end




or simply do it this way(works till reload/server restart):

add this to lib file(global or compat or your own):
Code:
monster_storages = {}

function doCreatureSetStorage(cid, key, value)
       if monster_storages[cid] == nil then monster_storages[cid] = {} end
             monster_storages[cid][key] = value
       return true
end

function getCreatureStorage(cid, key, value)
      if monster_storages[cid] == nil then
             return -1
      else
             if monster_storages[cid][key] ~= nil then
                    return monster_storages[cid][key]
             else
                    return -1
             end
      end
end
 
Last edited:
Could you explain this a little better please?
I would like to set an ALREADY summoned monster's storage, when a tool is used.
 
Last edited:
Back
Top