Array vazio

Geraldoida
em Lixeira Pública

Geraldoida

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 23/11/13Posts: 25

Galera, to aqui de novo, uma pergunta, como fazer uma condição(if) de 'se o array tiver vazio( {} ) ' ?

não sei como faze-lo. tipo if #array == 0 then . Valeu galera !

end

Slicer

Insanity
avatar
Príncipe
Príncipe

INFOS

Grupo: PríncipeRegistrado: 19/08/10Posts: 4014Gênero: Masculino

eh bem como tu boto ae ms o.O

if #array == 0 then

tb pode ser:

 

if not next(array) then

"Só a beira do abismo que os seres humanos acham forças para mudar."... E isso me da nojo... ¬¬

"Insanity is doing the exact... same fucking thing... over and over again expecting... shit to change... That. Is. Crazy." -Vass/Einstein

 

Geraldoida

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 23/11/13Posts: 25

slicer, olha ai meu script, eu acho que não estou colocando a condição no lugar certo. ajuda nos ae fazendo favor

 

local rand = array[math.random(#array)]
for k, v in ipairs(array) do
if #array == 0 then
selfSay('oi',cid)
if (rand == v) then
print(rand)
table.remove(array,k)
addEvent(table.insert,10000,array,v)
doPlayerAddItem(cid,rand,1)
selfSay('Va com Deus, o amor nao esta aqui, va com Deus.',cid)
end
end
end
end

Slicer

Insanity
avatar
Príncipe
Príncipe

INFOS

Grupo: PríncipeRegistrado: 19/08/10Posts: 4014Gênero: Masculino

achu q a ideia eh ser algu +/- assim n?

if #array == 0 then
   selfSay('oi',cid)
else
   local rand = array[math.random(#array)]
   for k, v in ipairs(array) do
      if (rand == v) then
         print(rand)
         table.remove(array, k)
         addEvent(table.insert, 10000, array, v)
         doPlayerAddItem(cid, rand, 1)
         selfSay('Va com Deus, o amor nao esta aqui, va com Deus.',cid)
      end
   end
end
end

"Só a beira do abismo que os seres humanos acham forças para mudar."... E isso me da nojo... ¬¬

"Insanity is doing the exact... same fucking thing... over and over again expecting... shit to change... That. Is. Crazy." -Vass/Einstein

 

Slicer

Insanity
avatar
Príncipe
Príncipe

INFOS

Grupo: PríncipeRegistrado: 19/08/10Posts: 4014Gênero: Masculino

n mexo mais com lua... -soh to aki no forum ainda por tedio...-

"Só a beira do abismo que os seres humanos acham forças para mudar."... E isso me da nojo... ¬¬

"Insanity is doing the exact... same fucking thing... over and over again expecting... shit to change... That. Is. Crazy." -Vass/Einstein

 

Geraldoida

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 23/11/13Posts: 25

Slicer, sou teu fã. Muito obrigado. Um dia vou scriptear tão bem quanto tu manow :D

Slicer

Insanity
avatar
Príncipe
Príncipe

INFOS

Grupo: PríncipeRegistrado: 19/08/10Posts: 4014Gênero: Masculino

/\ eh mas vai q tenha uma array assim:

 

local array = {
   [2] = 1
}

 

kkk'

"Só a beira do abismo que os seres humanos acham forças para mudar."... E isso me da nojo... ¬¬

"Insanity is doing the exact... same fucking thing... over and over again expecting... shit to change... That. Is. Crazy." -Vass/Einstein