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

Lua List several storages

New_Age

FoxWorld New Age
Joined
Jan 27, 2016
Messages
24
Reaction score
0
how to cite several arrays at the same time do so but unfortunately is giving this error
attempt to get length of local ´p´ <a userdata value>

Code:
for _,name in ipairs(Game.getPlayers()) do
   local p = Player(name)
   if killerGuild ~= nil then
     if isInAreaTest(getCreaturePosition(p)) == TRUE then
       for i = 1, name do
         p[i]:setStorageValue(60000, 1)
         addEvent(eventTest, 1000, p[i].uid)
       end
     end
   elseif p == killer and killerGuild == nil then
     p:setStorageValue(60000, 1)
     addEvent(eventTest, 1000, p.uid)
   end
end

ah but what you want to do? just set a storage the player if it is in the area and have a guild not only one will win
 
Last edited:
here it is @Printer
Code:
function onDeath(player, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
   if killer:isPlayer() then
    
   elseif killer:isMonster() then
     local summoner = killer:getMaster()
     if summoner and summoner:isPlayer() then
       killer = summoner
     else
       killer = FALSE
     end
   else
     killer = FALSE
   end

   local killerGuild = killer:getGuild()
  
   if killer == FALSE or killer:getStorageValue(60000) == 1 then
    
   else

     for _,name in ipairs(Game.getPlayers()) do
       local p = Player(name)
       if killerGuild ~= nil then
         if isInAreaTest(getCreaturePosition(p)) == TRUE then
           for i = 1, name do
             --print("hi")
             p[i]:setStorageValue(60000, 1)
           end
         end
       elseif p == killer and killerGuild == nil then
         --print("hihi2")
         p:setStorageValue(60000, 1)
       end
     end

     return true
   end

   return false
end
------------------
-- the function is not in the script is in date / lib
------------------
function isInAreaTest(pos)
   local fromPos = areat.fromPos
   local toPos = areat.toPos
   if pos.x >= fromPos.x and pos.y >= fromPos.y and pos.x <= toPos.x and pos.y <= toPos.y then
     return TRUE
   end
   return FALSE
end
is to only add to the guild members who are in the area of the event, I tried to make some modifications to also test unsuccessful
 
If you going to fetch creatures from a certain area, you should:
"Always use getSpectators for that task. getSpectators is highly optimized for that task." - Mark

So explain to me, what you are trying todo. Since i don't want to edit your code, rather make a fresh one.
 
When the player kill the creature add storage to it and if the player have a guild and some members are in the event area with him, they also receive the storage if it already has the storage nothing happens
 
Do they get a special storage when they enter the event area? Since checking big areas can be resource intensive.
 
I did an NPC that teleports them to this area but not put to add storage to the player entering
I think that would be an exellent idea why the area is great even
 
Now you just need to set the EVENT_STORAGE and also add the storage into the npc:

Code:
function onDeath(player, corpse, killer, mostDamageKiller, unjustified, mostDamageUnjustified)
    -- Make sure that the killer is a player and not a magic field or monster
    if not killer or not killer:isPlayer() then
        return true
    end

    -- Player is not even in the event
    if player:getStorageValue(EVENT_STORAGE) ~= 1 then
        return true
    end

    -- Remove the storage from player
    player:setStorageValue(EVENT_STORAGE, 0)

    -- Lets see if the killer has a guild, if not so just stop the code from continue and add killer storage
    local killerGuild = killer:getGuild()
    if not killerGuild then
        killer:setStorageValue(60000, 1)
        return true
    end

    -- Lets get the guild members and check if they are in the event and add storage
    for _, member in ipairs(killerGuild:getMembersOnline()) do
        if member:getStorageValue(EVENT_STORAGE) == 1 then
            member:setStorageValue(60000, 1)
        end
    end
    return true
end
 
Last edited:
Back
Top