• 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!

Fixing transform effect position.

Lopaskurwa

Active Member
Joined
Oct 6, 2017
Messages
873
Solutions
2
Reaction score
49
Hi
i have problem with transform effect position, it look like this
Untitled.png

And should look like this
Untitled1.png

Transform.lua
Code:
function onSay(player, words, param)
    local pid = player:getId()
   
    local TRANS = transform[player:getVocation():getId()]
   
    if not TRANS then
        player:sendCancelMessage("You cannot transform.")
        return false
    end
    if player:getLevel() < TRANS.level then
        player:sendCancelMessage("You must reach level "..TRANS.level.." to transform.")
        return false
    end
    if player:getSoul() < TRANS.rage then
        player:sendCancelMessage("You need "..TRANS.rage.." to transform.")
        return false
    end
    if player:getMana() < TRANS.mana then
        player:sendCancelMessage("You need "..TRANS.mana.." to transform.")
        return false
    end
   
    local outfit = player:getOutfit()
    outfit.lookType = TRANS.looktype
   
    if TRANS.constant then
        player:setOutfit(outfit)
    else
        player:setOutfit(outfit, false)
    end
   
    player:addSoul(-TRANS.rage)
    player:setMaxHealth(player:getMaxHealth() + TRANS.addHealth)
    player:setMaxMana(player:getMaxMana() + TRANS.addMana)
    player:getPosition():sendMagicEffect(TRANS.effect)
    player:setVocation(TRANS.newVoc)
    player:save()
    return false
end
I'm pretty sure that i have to edit getPosition, but i'm thinking, what if i in future will want to make transform effect that takes 32x32 so it will be fucked up again because now my effect take x128 i think. So what you think guys?
 
Solution
Code:
function onSay(player, words, param)
    local kurwa_gdzie_jest_efekt = Position(player:getPosition().x + 1, player:getPosition().y, player:getPosition().z)
    local pid = player:getId()

    local TRANS = transform[player:getVocation():getId()]

    if not TRANS then
        player:sendCancelMessage("You cannot transform.")
        return false
    end
    if player:getLevel() < TRANS.level then
        player:sendCancelMessage("You must reach level "..TRANS.level.." to transform.")
        return false
    end
    if player:getSoul() < TRANS.rage then
        player:sendCancelMessage("You need "..TRANS.rage.." to transform.")
        return false
    end
    if player:getMana() < TRANS.mana then...
Lua:
(player:getPosition() + Position(1, 0, 0)):sendMagicEffect(TRANS.effect)

or more professional:

Lua:
local toPos = player:getPosition() + Position(1, 0, 0)
toPos:sendMagicEffect(TRANS.effect)
 
Lua:
(player:getPosition() + Position(1, 0, 0)):sendMagicEffect(TRANS.effect)

or more professional:

Lua:
local toPos = player:getPosition() + Position(1, 0, 0)
toPos:sendMagicEffect(TRANS.effect)
Doesn't work
Code:
function onThink(interval)
    local players = Game.getPlayers()
    for i, v in ipairs(players) do
        player = Player(v)
        if player then
            TRANS = transform[player:getVocation():getId()]
            if TRANS then
                if TRANS.aura ~= nil then
                    local toPos = player:getPosition() + Position(1, 0, 0)
                    toPos:sendMagicEffect(TRANS.effect)
                end
            end
        end
    end
return true
end
no errors in console
 
Doesn't work
Code:
function onThink(interval)
    local players = Game.getPlayers()
    for i, v in ipairs(players) do
        player = Player(v)
        if player then
            TRANS = transform[player:getVocation():getId()]
            if TRANS then
                if TRANS.aura ~= nil then
                    local toPos = player:getPosition() + Position(1, 0, 0)
                    toPos:sendMagicEffect(TRANS.effect)
                end
            end
        end
    end
return true
end
no errors in console

Lua:
local auras =
{
  -- effect is required, offset is optional
  -- [vocationId] = { effect = effectId, offset = offsetFixPosition }
  [1] = { effect = 1 },
  [2] = { effect = 2, offset = Position(1, 0, 0) }
}

function onThink(interval)
  for _, player in ipairs(Game.getPlayers()) do
    local aura = auras[player:getVocation():getId()]
    if aura and aura.effect then
      local toPos = player:getPosition() + (aura.offset or Position())
      toPos:sendMagicEffect(aura.effect)
    end
  end
  return true
end

XML:
<globalevent name="Aura" interval="500" script="aura.lua"/>
 
Lua:
local auras =
{
  -- effect is required, offset is optional
  -- [vocationId] = { effect = effectId, offset = offsetFixPosition }
  [1] = { effect = 1 },
  [2] = { effect = 2, offset = Position(1, 0, 0) }
}

function onThink(interval)
  for _, player in ipairs(Game.getPlayers()) do
    local aura = auras[player:getVocation():getId()]
    if aura and aura.effect then
      local toPos = player:getPosition() + (aura.offset or Position())
      toPos:sendMagicEffect(aura.effect)
    end
  end
  return true
end

XML:
<globalevent name="Aura" interval="500" script="aura.lua"/>
Close to end :D but funny bug it wont stop doing effect, if you login to server effect start to flood with non stop without typing anything. P.s i have this code in global
Code:
transform = {
[1] = {voc = 1, newVoc = 5, from_looktype = 2, looktype = 3, level = 50, rage = 3, mana = 10, addHealth = 2500, addMana = 2500, effect = 79, aura = nil, constant = false}
}
So do i have to use "effect = 79" again in auras?
 
We don't know how your other scripts are setup to run and execute, and thus far we've only been guessing what is actually required.
The only way your going to get this resolved is to post all your scripts associated with what your trying to do.

I'd also suggest to summarize the posts thus-far, so people don't need to read through 20+ posts to get caught up.
 
We don't know how your other scripts are setup to run and execute, and thus far we've only been guessing what is actually required.
The only way your going to get this resolved is to post all your scripts associated with what your trying to do.

I'd also suggest to summarize the posts thus-far, so people don't need to read through 20+ posts to get caught up.
All script.
Global.lua
Code:
exhaust_transform = {}

transform = {
[1] = {voc = 1, newVoc = 5, from_looktype = 2, looktype = 3, level = 50, rage = 3, mana = 10, addHealth = 2500, addMana = 2500, effect = 79, aura = nil, constant = false}
}
transform.lua
Code:
function onSay(player, words, param)
    local pid = player:getId()
  
    local TRANS = transform[player:getVocation():getId()]
  
    if not TRANS then
        player:sendCancelMessage("You cannot transform.")
        return false
    end
    if player:getLevel() < TRANS.level then
        player:sendCancelMessage("You must reach level "..TRANS.level.." to transform.")
        return false
    end
    if player:getSoul() < TRANS.rage then
        player:sendCancelMessage("You need "..TRANS.rage.." to transform.")
        return false
    end
    if player:getMana() < TRANS.mana then
        player:sendCancelMessage("You need "..TRANS.mana.." to transform.")
        return false
    end
  
    local outfit = player:getOutfit()
    outfit.lookType = TRANS.looktype
  
    if TRANS.constant then
        player:setOutfit(outfit)
    else
        player:setOutfit(outfit, false)
    end
  
    player:addSoul(-TRANS.rage)
    player:setMaxHealth(player:getMaxHealth() + TRANS.addHealth)
    player:setMaxMana(player:getMaxMana() + TRANS.addMana)
    player:getPosition():sendMagicEffect(TRANS.effect)
    player:setVocation(TRANS.newVoc)
    player:save()
    return false
end

aura.lua
Code:
local auras =
{
  -- effect is required, offset is optional
  -- [vocationId] = { effect = effectId, offset = offsetFixPosition }
  [1] = { effect = 1 },
  [2] = { effect = 2, offset = Position(1, 0, 0) }
}

function onThink(interval)
  for _, player in ipairs(Game.getPlayers()) do
    local aura = auras[player:getVocation():getId()]
    if aura and aura.effect then
      local toPos = player:getPosition() + (aura.offset or Position())
      toPos:sendMagicEffect(aura.effect)
    end
  end
  return true
end
Problem - when you come to server effect start to flood with non stop without writing anything. Should work like this type "transform" effect applies properly but important part to keep this
Code:
  [1] = { effect = 1 },
  [2] = { effect = 2, offset = Position(1, 0, 0) }[/code}
Because i want to apply different size of effects for different vocations.
 
I don't know, but it's rather not normal that effect appears beside selected position.
Just align the sprite right.
 
It's already align perfectly. So that's why solution is only with position edit in lua
Untitled.png
And is lua aligning working? For me it would just move character to the other side of the effect and do nothing.
These sprites aren't just proper.
 
And is lua aligning working? For me it would just move character to the other side of the effect and do nothing.
These sprites aren't just proper.
Yea that one work where River KA made but it flood effect with non stop. "These sprites aren't just proper" explain me how they're not proper
 
Yea that one work where River KA made but it flood effect with non stop. "These sprites aren't just proper" explain me how they're not proper
Nevermind, i just realised it's 3x3 sprite.
Lua might be actually the only way i guess.
 
Back
Top