Ir para conteúdo

Featured Replies

Postado

Eai

 

Tô tentando colocar aleatoriedade em um script de aura onde a cada 700ms sobe um conjunto de mensagem do player. A situação é que só sobe um tipo de conjunto, eu gostaria que subisse aleatoriamente entre 4 conjunto de mensagens a cada 700ms.

 

Aqui o script:

Spoiler


local config = {
    [5] = 144; -- [VOCATION] = CORES;
    [6] = 66; 
    [7] = 35;
    [8] = 205;
}
 
function effectText(cid)
    local texts, eff = ".   ´ ,"
    for vocation, color in pairs(config) do
        if getPlayerVocation(cid) == vocation then
            eff = color
            break
        end
    end
    if eff then
        doSendAnimatedText(getThingPos(cid), texts, eff)
        addEvent(function()
            if isPlayer(cid) then
                effectText(cid)
            end
        end, 700)
    end
end
 
function onLogin(cid)
    effectText(cid)
    return true
end

 

 

no caso, em local texts iria ser outras pontuações, essas:

{"´ .    ,", ".    ´ ,", "`  .  ,", ",    ´ ."}

E seria aleatório, a cada 700ms poderia sair entre os 4 conjuntos acima.

 

Um exemplo da aleatoriedade é o script de gemas do FoxWorld:

Spoiler

gems = {
id = {2154, 2156, 2158, 2153, 2154, 2156, 2158, 2153},
storage = {5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008},
interval = {600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600}
}

gemMsg = {
rnd = {"´ .    ,", ".    ´ ,", "`  .  ,", ",    ´ ."},
colorDruid = {180,180},
colorSorcerer = {30,215},
colorPaladin = {251,10},
colorKnight = {204,212},
colorElderDruid = {180,180},
colorMasterSorcerer  = {30,215},
colorRoyalPaladin = {251,10},
colorEliteKnight = {204,212}
}

function doRemoveGemEffect(cid)

  local voc = getPlayerVocation(cid)

  if getPlayerPromotionLevel(cid) > 0 then
    voc = voc - (getPlayerPromotionLevel(cid) * 2)
  end

end

function doUseGem(cid, item)

  local level = getPlayerLevel(cid)
  local voc = getPlayerVocation(cid)
  local interval = gems.interval[voc]

  if getPlayerPromotionLevel(cid) > 0 then
    voc = voc - (getPlayerPromotionLevel(cid) * 2)
  end

  if item.itemid ~= gems.id[voc] or getPlayerStorageValue(cid, gems.storage[voc]) > 0 then
    return false
  end

  setPlayerStorageValue(cid, gems.storage[voc], 1)
  sendGemEffect(cid, gems.storage[voc], gems.interval[voc])
  doRemoveItem(item.uid, 1)

  return true 
end

function sendGemEffect(cid, storage, interval)

if isPlayer(cid) then

  local pos = getThingPos(cid)
  local voc = getPlayerVocation(cid)
  local level = getPlayerLevel(cid)
  local color = 1

  if level > 199 then

  if getPlayerPromotionLevel(cid) > 0 then
    voc = voc - (getPlayerPromotionLevel(cid) * 2)
  end
          if voc == 1 then
            color = gemMsg.colorDruid[math.random(1,#gemMsg.colorElderDruid)]
          elseif voc == 2 then
            color = gemMsg.colorSorcerer[math.random(1,#gemMsg.colorMasterSorcerer)]
          elseif voc == 3 then
            color = gemMsg.colorPaladin[math.random(1,#gemMsg.colorRoyalPaladin)]
          elseif voc == 4 then
            color = gemMsg.colorKnight[math.random(1,#gemMsg.colorEliteKnight)]
          end

  doSendAnimatedText(pos, gemMsg.rnd[math.random(1,#gemMsg.rnd)], color)
    if getPlayerStorageValue(cid, gems.storage[voc]) >= 1 then 
      addEvent(sendGemEffect, interval, cid, storage, interval)
    end

else
stopEvent(sendGemEffect(cid, storage, interval))
end

end

function isGemActivated(cid)

  local voc = getPlayerVocation(cid)

  if getPlayerPromotionLevel(cid) > 0 then
    voc = voc - (getPlayerPromotionLevel(cid) * 2)
  end

  if getPlayerStorageValue(cid, gems.storage[voc]) > 0 then
    return true
  end
  return false
end

  return true
end

 

 

Alguém pode me ajudar? Agradeço

Oi

  • Respostas 5
  • Visualizações 416
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • function effectText(cid) local texts, eff = {"´ . ,", ". ´ ,", "` . ,", ", ´ ."} for vocation, color in pairs(config) do if getPlayerVocation(cid) == vocation then eff = color bre

Postado

deixa assim local texts, eff = {"´ . ,", ". ´ ,", "` . ,", ", ´ ."}[math.random(1, 4)]

Todos os meus trabalhos importantes estão na seção "Sobre mim" no meu perfil; Dá uma passada lá!

"Há três caminhos para o fracasso: não ensinar o que se sabe, não praticar o que se ensina, e não perguntar o que se ignora." - São Beda

I7Pm6ih.png

(obg ao @Beeny por fazer essa linda sign <3)

Postado
  • Autor
7 minutos atrás, xWhiteWolf disse:

deixa assim local texts, eff = {"´ . ,", ". ´ ,", "` . ,", ", ´ ."}[math.random(1, 4)]

 

Deu erro e parou de sair os efeitos.

 

[Error - LuaInterface::loadFile] data/creaturescripts/scripts/aurapremium.lua:9: unexpected symbol near '['
[Warning - Event::loadScript] Cannot loead script (data/creaturescripts/scripts/aurapremium.lua
data/creaturescript/scripts/aurapremium.lua:9: unexpected symbol near '['

 

Oi

Postado

Tenta usar assim:

local msgs = {
	"Eu sou uma mensagem",
	"Eu sou outra mensagem",
	"Ah, eu tambem!",
	"Legal, mas tambem sou uma mensagem...",
}

gems = {
id = {2154, 2156, 2158, 2153, 2154, 2156, 2158, 2153},
storage = {5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008},
interval = {600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, 600}
}

gemMsg = {
colorDruid = {180,180},
colorSorcerer = {30,215},
colorPaladin = {251,10},
colorKnight = {204,212},
colorElderDruid = {180,180},
colorMasterSorcerer  = {30,215},
colorRoyalPaladin = {251,10},
colorEliteKnight = {204,212}
}

function doRemoveGemEffect(cid)

  local voc = getPlayerVocation(cid)

  if getPlayerPromotionLevel(cid) >  then
    voc = voc - (getPlayerPromotionLevel(cid) * 2)
  end

end

function doUseGem(cid, item)

  local level = getPlayerLevel(cid)
  local voc = getPlayerVocation(cid)
  local interval = gems.interval[voc]

  if getPlayerPromotionLevel(cid) >  then
    voc = voc - (getPlayerPromotionLevel(cid) * 2)
  end

  if item.itemid ~= gems.id[voc] or getPlayerStorageValue(cid, gems.storage[voc]) >  then
    return false
  end

  setPlayerStorageValue(cid, gems.storage[voc], 1)
  sendGemEffect(cid, gems.storage[voc], gems.interval[voc])
  doRemoveItem(item.uid, 1)

  return true 
end

function sendGemEffect(cid, storage, interval)

if isPlayer(cid) then

  local pos = getThingPos(cid)
  local voc = getPlayerVocation(cid)
  local level = getPlayerLevel(cid)
  local color = 1

  if level > 199 then

  if getPlayerPromotionLevel(cid) >  then
    voc = voc - (getPlayerPromotionLevel(cid) * 2)
  end
          if voc == 1 then
            color = gemMsg.colorDruid[math.random(1,#gemMsg.colorElderDruid)]
          elseif voc == 2 then
            color = gemMsg.colorSorcerer[math.random(1,#gemMsg.colorMasterSorcerer)]
          elseif voc == 3 then
            color = gemMsg.colorPaladin[math.random(1,#gemMsg.colorRoyalPaladin)]
          elseif voc == 4 then
            color = gemMsg.colorKnight[math.random(1,#gemMsg.colorEliteKnight)]
          end

  doSendAnimatedText(pos, msgs[math.random(#msgs)], color)
    if getPlayerStorageValue(cid, gems.storage[voc]) >= 1 then 
      addEvent(sendGemEffect, interval, cid, storage, interval)
    end

else
stopEvent(sendGemEffect(cid, storage, interval))
end

end

function isGemActivated(cid)

  local voc = getPlayerVocation(cid)

  if getPlayerPromotionLevel(cid) >  then
    voc = voc - (getPlayerPromotionLevel(cid) * 2)
  end

  if getPlayerStorageValue(cid, gems.storage[voc]) >  then
    return true
  end
  return false
end

  return true
end

 

Eternera Tibia Server - RPG

Postado
function effectText(cid)
	local texts, eff = {"´ .    ,", ".    ´ ,", "`  .  ,", ",    ´ ."}
	for vocation, color in pairs(config) do
		if getPlayerVocation(cid) == vocation then
			eff = color
			break
		end
	end
	if eff then
		doSendAnimatedText(getThingPos(cid), texts[math.random(#texts)], eff)
		addEvent(function()
			if isPlayer(cid) then
				effectText(cid)
			end
		end, 700)
	end
end

 

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo