Ir para conteúdo

Featured Replies

Postado

Yo boyz, 

 

então, no meu servidor tem o script de !fly (que eu peguei aqui no fórum há alguns dias, no código está como "NORD" o nome do autor, mas não achei aqui no fórum) e eu gostaria de melhorar ele. Atualmente, o comando tem uma velocidade fixa e configurável nessa linha: addEvent(autoWalk, 500, cid, id)

Só que ter uma velocidade fixa para todos os pokémon é um problema, o ideal seria que pegasse a velocidade de cada pokémon.

 

OBS: "500" é a velocidade em milissegundos.

 

Função do comando:

Quando você ativa o comando !fly, seu char (caso esteja voando) irá andar reto até você dizer !fly novamente, desativando o comando.

 

Agradeço desde já.

 

talkactions/scripts/!fly.lua

Spoiler

local configuration = {
    storage = 918311,
    fly_storage = 17000,    --Storage do Fly no seu servidor.
}
function isWalkable(pos, creature, proj, pz)-- by Nord
    if getTopCreature(pos).uid > 0 and creature then return false end
    if getTileInfo(pos).protection and pz then return false, true end
    local n = not proj and 3 or 2
    for i = 0, 255 do
        pos.stackpos = i
        local tile = getTileThingByPos(pos)
        if tile.itemid ~= 0 and not isCreature(tile.uid) then
            if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
                return false
            end
        end
    end
    return true
end  
function autoWalk(cid, id)
    if not isCreature(cid) then 
        if id then
            return db.executeQuery("UPDATE player_storage SET value = -1 WHERE key = 918311 AND player_id = "..id)
        end
    elseif getPlayerStorageValue(cid, configuration.storage) < 1 then
        return true
    end
    local topos = getPosByDir(getThingPos(cid), getCreatureLookDir(cid))
    if topos then
        if getPlayerStorageValue(cid, configuration.storage) < 1 or getPlayerStorageValue(cid, configuration.fly_storage) < 1 then
            if getPlayerStorageValue(cid, configuration.fly_storage) < 1 then
                setPlayerStorageValue(cid, configuration.storage, -1)
            end
            return true
        elseif isWalkable(topos) then
            if getTileThingByPos({x = topos.x, y = topos.y, z = topos.z, stackpos = 0}).itemid == 0 then
                doCombatAreaHealth(cid, 0, topos, 0, 0, 0, CONST_ME_NONE)
                doCreateItem(11676, 1, topos)
            end
            doTeleportThing(cid, topos)
        else
            setPlayerStorageValue(cid, configuration.storage, -1)
            doPlayerSendTextMessage(cid, 27, "Há algum objeto à sua frente impedindo a passagem.")
            doPlayerSetNoMove(cid, false)
            return true
        end
    else
        doPlayerSendCancel(cid, "Sorry, not possible.")
        setPlayerStorageValue(cid, configuration.storage, -1)
        doPlayerSetNoMove(cid, false)
        return true
    end
    addEvent(autoWalk, 500, cid, id)
end
function onSay(cid, words)
    if getPlayerStorageValue(cid, configuration.fly_storage) < 1 then
        doPlayerSendCancel(cid, "Para usar este comando, você deve estar em Fly.")
    elseif getPlayerStorageValue(cid, configuration.storage) >= 1 then
        setPlayerStorageValue(cid, configuration.storage, -1)
        doPlayerSendTextMessage(cid, 27, "Comando !fly desativado.")
        doPlayerSetNoMove(cid, false)
    else
        doPlayerSendTextMessage(cid, 27, "Comando !fly ativado.")
        setPlayerStorageValue(cid, configuration.storage, 1)
        doPlayerSetNoMove(cid, true)
        autoWalk(cid, getPlayerGUID(cid))
    end
    return true
end

 

 

Editado por Talesigorvr (veja o histórico de edições)

Não dou suporte via PM, crie um tópico caso tenha dúvidas.

Isso previne que outras pessoas com a mesma dúvida criem tópicos desnecessários.

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.8k

Informação Importante

Confirmação de Termo