• 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) - Action to insert in a Table.

lokolokio

Well-Known Member
Joined
Jan 7, 2009
Messages
201
Solutions
13
Reaction score
78
Location
Mexico
Hello Im looking for a script with a table but i dont know how to manage tables, the script works something like this:
Code:
local members = getSpectators(pos, 5, 5)
local list = {}
for i = 1, #members do
local m = mebers[i]
local hp = (m:getHealth()/m:getmaxhealth())*100
       if  hp <= 50 then
           table.insert(list, cid)
      end
end
its not a working function its just an example of what im trying to ask for. I want a script that verifies a players arround and ONLY if a players HP its below 50% he will be added to a table. I hope my explanation its fine thanks.
 
i know that theres errors, but its ONLY A EXAMPLE SCRIPT NOT A WORKING SCRIPT, its for take a idea of the script what i need.
 
Hello Im looking for a script with a table but i dont know how to manage tables
https://otland.net/threads/lua-broken-down.235555/
The tutorial isn't finished yet but it does discuss tables.

its not a working function its just an example of what im trying to ask for. I want a script that verifies a players arround and ONLY if a players HP its below 50% he will be added to a table. I hope my explanation its fine thanks.

Well to my knowledge the getSpectators() functions returns whoever is in the battle list, so storing who is in the battle list in a table isn't enough especially if they leave the vicinity you would need to call getSpectators() again at a later time to compare the current table to one generated by getSpectators()..

I guess it would be helpful if we knew what type of script you were writing so that we can write the proper logic since getSpectators() is a "in the moment function".
 
Last edited by a moderator:
the script that i try to make its for a Exura Sio Spell but this one is for monster, I making some kind of A.I.Spells, but this one is some hard for me because I dont know any about tables.
I shot take the function
Code:
function getFriendWhitLowHP(cid, magic, level)
local c = Creature(cid)
local t = c:getTarget()
local getFriends = c:getFriendList()
local newFriendList = {}
for i = getFriends(i) do
if getFriendHP < 50% then
      table.insert(newFriendList, creatureid)
  end
end
return newFriendList()
end
onCastSpell(cid)
local friend = getFriendWhitLowHP(cid, magic, level)
addHealth(friend.uid, math.random(100, 200))
end
And again ITS JUST AN EXAMPLE
 
Last edited:
Based on your code:
Code:
local members = getSpectators(pos, 5, 5)
local list = {}
for i = 1, #members do
    local m = members[i]
    local hp = math.ceil((m:etHealth() / m:getMaxHealth()) * 100)
    if  hp <= 50 then
        list[#list + 1] = cid
    end
end
 
Back
Top