Ir para conteúdo

Featured Replies

Postado
local storageValues = {
    [1234] = 10, -- Cor 1
    [12345] = 30, -- Cor 2
    [12346] = 50, -- Cor 3
    [123457] = 70  -- Cor 4
}

function ariseText(cid)
    if not isPlayer(cid) then
        return true
    end
    
    local texts = {"' .    ,", ".    ' ,", "'  .  ,", ",    ' ."}
    local playerStorage = getPlayerStorageValue(cid)
    
    if storageValues[playerStorage] then
        local text = texts[math.random(1, #texts)]
        local color = storageValues[playerStorage]
        
        doSendAnimatedText(getCreaturePosition(cid), text, color)
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
    end
    
    addEvent(ariseText, 1000, cid)
    
    return true
end

function onLogin(cid)
    local playerStorage = getPlayerStorageValue(cid)
    if storageValues[playerStorage] then
        ariseText(cid)
    end
    
    return true
end

Ajustei o código com o valor "1234" para representar o storage. Basta você substituir esse valor pelo storage específico do seu servidor.



Faça o teste e verifique os erros que aparecerem no console e compartilhe-os aqui para que eu possa ver.

  • Respostas 14
  • Visualizações 451
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • Seria tipo isso?   data > creaturescripts > creaturescripts.xml   <event type="login" name="playerTextEffect" event="script" value="playerTextEffect.lua"/>    

Postado
  • Autor
24 minutos atrás, Vortex disse:

local storageValues = {
    [1234] = 10, -- Cor 1
    [12345] = 30, -- Cor 2
    [12346] = 50, -- Cor 3
    [123457] = 70  -- Cor 4
}

function ariseText(cid)
    if not isPlayer(cid) then
        return true
    end
    
    local texts = {"' .    ,", ".    ' ,", "'  .  ,", ",    ' ."}
    local playerStorage = getPlayerStorageValue(cid)
    
    if storageValues[playerStorage] then
        local text = texts[math.random(1, #texts)]
        local color = storageValues[playerStorage]
        
        doSendAnimatedText(getCreaturePosition(cid), text, color)
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
    end
    
    addEvent(ariseText, 1000, cid)
    
    return true
end

function onLogin(cid)
    local playerStorage = getPlayerStorageValue(cid)
    if storageValues[playerStorage] then
        ariseText(cid)
    end
    
    return true
end

Ajustei o código com o valor "1234" para representar o storage. Basta você substituir esse valor pelo storage específico do seu servidor.



Faça o teste e verifique os erros que aparecerem no console e compartilhe-os aqui para que eu possa ver.

Deu o seguinte error !

[9:49:53.615] [Error - CreatureScript Interface]
[9:49:53.616] data/creaturescripts/scripts/voc.lua:onLogin
[9:49:53.617] Description:
[9:49:53.618] (luaGetCreatureStorage) Creature not found

Postado
local storageValues = {
    [xxx] = 10, -- Cor 1
    [xxx] = 30, -- Cor 2
    [xxx] = 50, -- Cor 3
    [xxx] = 70  -- Cor 4
}

function ariseText(cid)
    if not isPlayer(cid) then
        return true
    end
    
    local texts = {"' .    ,", ".    ' ,", "'  .  ,", ",    ' ."}
    local playerStorage = getPlayerStorageValue(cid)
    
    if storageValues[playerStorage] then
        local text = texts[math.random(1, #texts)]
        local color = storageValues[playerStorage]
        
        doSendAnimatedText(getCreaturePosition(cid), text, color)
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
    end
    
    addEvent(ariseText, 1000, cid)
    
    return true
end

function onLogin(cid)
    if isPlayer(cid) then
        local playerStorage = getPlayerStorageValue(cid)
        if storageValues[playerStorage] then
            ariseText(cid)
        end
    end
    
    return true
end

 

Postado
  • Autor
1 hora atrás, Vortex disse:

local storageValues = {
    [xxx] = 10, -- Cor 1
    [xxx] = 30, -- Cor 2
    [xxx] = 50, -- Cor 3
    [xxx] = 70  -- Cor 4
}

function ariseText(cid)
    if not isPlayer(cid) then
        return true
    end
    
    local texts = {"' .    ,", ".    ' ,", "'  .  ,", ",    ' ."}
    local playerStorage = getPlayerStorageValue(cid)
    
    if storageValues[playerStorage] then
        local text = texts[math.random(1, #texts)]
        local color = storageValues[playerStorage]
        
        doSendAnimatedText(getCreaturePosition(cid), text, color)
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
    end
    
    addEvent(ariseText, 1000, cid)
    
    return true
end

function onLogin(cid)
    if isPlayer(cid) then
        local playerStorage = getPlayerStorageValue(cid)
        if storageValues[playerStorage] then
            ariseText(cid)
        end
    end
    
    return true
end

 

Error...

[11:7:13.846] [Error - CreatureScript Interface]
[11:7:13.847] data/creaturescripts/scripts/voc.lua
[11:7:13.847] Description:
[11:7:13.848] data/creaturescripts/scripts/voc.lua:3: table index is nil
[11:7:13.848] [Warning - Event::loadScript] Cannot load script (data/creaturescripts/scripts/voc.lua)

Postado
9 horas atrás, Doidodepeda disse:

Esse scritp funciona com vocation, gostaria por gentileza que tirasse por vocation e adicionasse por STORAGE. Caso o player tem a storage ficaraia saindo o efeito TEXT.

desde de ja, muito grato !


 

 

 

 

Seria tipo isso?

 

data > creaturescripts > creaturescripts.xml

 

	<event type="login" name="playerTextEffect" event="script" value="playerTextEffect.lua"/>

 

 

data > creaturescripts > scripts > playerTextEffect.lua

 

local config = {
   storage     = 808072, -- Storage que o player precisa ter.
   colorsText  = {10, 30, 50, 70}, -- valores que o player poderá ter no storage (cada valor corresponde a uma coloração diferente de texto)
   texts       = {"' .    ,", ".    ' ,", "'  .  ,", ",    ' ."} -- Textos que ficará saindo do jogador.
}

function ariseText(cid) 

   if not isPlayer(cid) then
      return true
   end
   
   local playerColorTextEffect = getPlayerStorageValue(cid, config.storage)
   
   if not isInArray(config.colorsText, playerColorTextEffect) then
      return true
   end

   local playerPosition   = getCreaturePosition(cid)
   local randomTextEffect = config.texts[math.random(1, #config.texts)]

   doSendAnimatedText(playerPosition, randomTextEffect, playerColorTextEffect)
   doSendMagicEffect(playerPosition, CONST_ME_MAGIC_GREEN) -- Efeito mágico adicionado

   addEvent(ariseText, 1000, cid)

   return true

end

function onLogin(cid)
   ariseText(cid)
   return true
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.6k

Informação Importante

Confirmação de Termo