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

TFS 1.2 Transform System

Lopaskurwa

Active Member
Joined
Oct 6, 2017
Messages
870
Solutions
2
Reaction score
49
Hi i was searching around google and i found this transform system
Transform system [table included]
But i stuck with first part, he didn't included where should i create that lua
Code:
{["voc"] = 1, ["newVoc"] = 2, ["looktype"] = 5, ["revertLooktype"] = 4, ["level"] = 50, ["rage"] = 3, ["kiToTrans"] = 10, ["addHp"] = 200, ["addKi"] = 150, ["effectOn"] = 236, ["aura"] = 0, ["constant"] = false},
 
Solution
Global
Lua:
exhaust_transform = {}

transform = {
[1] = {voc = 1, newVoc = 5, from_looktype = 55, looktype = 99, level = 50, rage = 3, mana = 10, addHealth = 200, addMana = 150, effect = CONST_ME_SMOKE, aura = nil, constant = false}
}

Tranform
Lua:
function onSay(player, words, param, channel)
    local pid = player:getId()

    if exhaust_transform[pid] ~= nil then
        return false
    end

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

    if not TRANS then return player:sendCancelMessage("You cannot transform.") end
    if player:getLevel() < TRANS.level then return player:sendCancelMessage("You must reach level "..TRANS.level.." to transform.") end
    if player:getSoul() < TRANS.rage then return...
Still doesn't work i can type transform like a regular word. Dont even functional. Log is clean no warnings no errors
Code:
    <talkaction words="transform;Transform;TRANSFORM" script="transform.lua" />
Lua
Code:
function onSay(player, words, param, channel)
    if exhaust_transform[pid] ~= nil then
        return false
    end
    TRANS = Trans[player:getVocation():getId()]

    if not TRANS then return player:sendCancelMessage("You cannot transform.") end

    if player:getLevel() < TRANS.level then return player:sendCancelMessage("You must reach level "..TRANS.level.." to transform.") end

    if player:getSoul() < TRANS.rage then return player:sendCancelMessage("You need "..TRANS.rage.." to transform.") end
    if player:getMana() < TRANS.mana then return player:sendCancelMessage("You need "..TRANS.mana.." to transform.") end

    if TRANS.constant then
        player:setOutfit({looktype = TRANS.looktype})
    else
        player:setOutfit({looktype = TRANS.looktype}, false)
    end

    local pid = player:getId()
    exhaust_transform[pid] = 1
    player:addSoul(-TRANS.rage)
    player:setMaxHealth(TRANS.addHealth)
    player:setMaxMana(TRANS.mana)
    player:addHealth(TRANS.addHealth)
    player:addMana(TRANS.addMana)
    player:getPosition():sendMagicEffect(TRANS.effect)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have transformed!")
    player:setVocation(TRANS.newVoc)
    player:save()
    addEvent(removeExhaust, 5 * 1000, pid)
return true
end
function removeExhaust(pid)
    exhaust_transform[pid] = nil
end

bump
 
Last edited by a moderator:
Try this version:
Lua:
function onSay(player, words, param, channel)
    print("TALKACTION: TRANSFORM EXECUTED, player: "..player:getName())
    if exhaust_transform[pid] ~= nil then
        return false
    end
    print("Step: 1")
    TRANS = Trans[player:getVocation():getId()]

    if not TRANS then return player:sendCancelMessage("You cannot transform.") end

    if player:getLevel() < TRANS.level then return player:sendCancelMessage("You must reach level "..TRANS.level.." to transform.") end

    if player:getSoul() < TRANS.rage then return player:sendCancelMessage("You need "..TRANS.rage.." to transform.") end
    if player:getMana() < TRANS.mana then return player:sendCancelMessage("You need "..TRANS.mana.." to transform.") end
    print("Step: 2")
    if TRANS.constant then
        player:setOutfit({looktype = TRANS.looktype})
    else
        player:setOutfit({looktype = TRANS.looktype}, false)
    end
    print("Step: 3")
    local pid = player:getId()
    exhaust_transform[pid] = 1
    player:addSoul(-TRANS.rage)
    player:setMaxHealth(TRANS.addHealth)
    player:setMaxMana(TRANS.mana)
    player:addHealth(TRANS.addHealth)
    player:addMana(TRANS.addMana)
    player:getPosition():sendMagicEffect(TRANS.effect)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have transformed!")
    player:setVocation(TRANS.newVoc)
    player:save()
    addEvent(removeExhaust, 5 * 1000, pid)
return true
end
function removeExhaust(pid)
    exhaust_transform[pid] = nil
end

Your console should get the message "TALKACTION: TRANSFORM EXECUTED" when you execute the action. Does this happen?
 
Try this version:
Lua:
function onSay(player, words, param, channel)
    print("TALKACTION: TRANSFORM EXECUTED, player: "..player:getName())
    if exhaust_transform[pid] ~= nil then
        return false
    end
    print("Step: 1")
    TRANS = Trans[player:getVocation():getId()]

    if not TRANS then return player:sendCancelMessage("You cannot transform.") end

    if player:getLevel() < TRANS.level then return player:sendCancelMessage("You must reach level "..TRANS.level.." to transform.") end

    if player:getSoul() < TRANS.rage then return player:sendCancelMessage("You need "..TRANS.rage.." to transform.") end
    if player:getMana() < TRANS.mana then return player:sendCancelMessage("You need "..TRANS.mana.." to transform.") end
    print("Step: 2")
    if TRANS.constant then
        player:setOutfit({looktype = TRANS.looktype})
    else
        player:setOutfit({looktype = TRANS.looktype}, false)
    end
    print("Step: 3")
    local pid = player:getId()
    exhaust_transform[pid] = 1
    player:addSoul(-TRANS.rage)
    player:setMaxHealth(TRANS.addHealth)
    player:setMaxMana(TRANS.mana)
    player:addHealth(TRANS.addHealth)
    player:addMana(TRANS.addMana)
    player:getPosition():sendMagicEffect(TRANS.effect)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have transformed!")
    player:setVocation(TRANS.newVoc)
    player:save()
    addEvent(removeExhaust, 5 * 1000, pid)
return true
end
function removeExhaust(pid)
    exhaust_transform[pid] = nil
end

Your console should get the message "TALKACTION: TRANSFORM EXECUTED" when you execute the action. Does this happen?
No, it doesn't even print in console wtf
 
You aren't putting the codes into the xml files correctly I dont think TFS 1.2 supports multi word scripts in talkaction like that. Try doing this:

Code:
 <talkaction words="transform" script="transform.lua" />
<talkaction words="Transform" script="transform.lua" />
<talkaction words="TRANSFORM" script="transform.lua" />
 
You aren't putting the codes into the xml files correctly I dont think TFS 1.2 supports multi word scripts in talkaction like that. Try doing this:

Code:
 <talkaction words="transform" script="transform.lua" />
<talkaction words="Transform" script="transform.lua" />
<talkaction words="TRANSFORM" script="transform.lua" />
Yes you was right. But i get error in console if i try to transform
Untitled.png
 
Did you add the top part into your global.lua file? data/global.lua

Lua:
exhaust_transform = {}
Trans = {
[1] = {voc = 1, newVoc = 2, looktype = 5, level = 50, rage = 3, mana = 10, addHealth = 200, addMana = 150, effect = CONST_ME_SMOKE, aura = nil, constant = false},
[2] = {voc = 2, newVoc = 3, looktype = 6, level = 130, rage = 5, mana = 50, addHealth = 450, addMana = 300, effect = CONST_ME_HOLY, aura = nil, constant = false}
}
 
Did you add the top part into your global.lua file? data/global.lua

Lua:
exhaust_transform = {}
Trans = {
[1] = {voc = 1, newVoc = 2, looktype = 5, level = 50, rage = 3, mana = 10, addHealth = 200, addMana = 150, effect = CONST_ME_SMOKE, aura = nil, constant = false},
[2] = {voc = 2, newVoc = 3, looktype = 6, level = 130, rage = 5, mana = 50, addHealth = 450, addMana = 300, effect = CONST_ME_HOLY, aura = nil, constant = false}
}
Yea i added.
Code:
Trans = {
[1] = {voc = 1, newVoc = 5, looktype = 99, level = 50, rage = 3, mana = 10, addHealth = 200, addMana = 150, effect = CONST_ME_SMOKE, aura = nil, constant = false}
}
Full global.lua
[C++] dofile('data/lib/lib.lua') STORAGEVALUE_PROMOTION = 30018 ropeSpots = {384 - Pastebin.com
 
You are missing

Code:
exhaust_transform = {}
Yea now it's seems to be fine, console is clean and nice. But i cant transform it's says "You cannot transform" but i dunno why, my vocation id is 1 and i transform to 5id "voc = 1, newVoc = 5" it should work but it doesn't. I created in vocations.xml so wtf
Code:
    <vocation id="1" clientid="3" name="Goku" description="Goku" gaincap="10" gainhp="5" gainmana="30" gainhpticks="6" gainhpamount="5" gainmanaticks="3" gainmanaamount="5" manamultiplier="1.1" attackspeed="2000" basespeed="220" soulmax="100" gainsoulticks="120" fromvoc="1">
        <formula meleeDamage="1.0" distDamage="1.0" defense="1.0" armor="1.0" />
        <skill id="0" multiplier="1.5" />
        <skill id="1" multiplier="2.0" />
        <skill id="2" multiplier="2.0" />
        <skill id="3" multiplier="2.0" />
        <skill id="4" multiplier="2.0" />
        <skill id="5" multiplier="1.5" />
        <skill id="6" multiplier="1.1" />
    </vocation>
Code:
    <vocation id="5" clientid="3" name="Goku" description="Kaioken" gaincap="10" gainhp="5" gainmana="30" gainhpticks="6" gainhpamount="5" gainmanaticks="3" gainmanaamount="5" manamultiplier="1.1" attackspeed="2000" basespeed="220" soulmax="100" gainsoulticks="120" fromvoc="1">
        <formula meleeDamage="1.0" distDamage="1.0" defense="1.0" armor="1.0" />
        <skill id="0" multiplier="1.5" />
        <skill id="1" multiplier="2.0" />
        <skill id="2" multiplier="2.0" />
        <skill id="3" multiplier="2.0" />
        <skill id="4" multiplier="2.0" />
        <skill id="5" multiplier="1.5" />
        <skill id="6" multiplier="1.1" />
</vocation>
 
Let me check the code real fast. Ill edit this post with a solution if I find the problem.



Try changing (in talkaction)

Lua:
TRANS = Trans[player:getVocation():getId()]

to

Lua:
local TRANS = Trans[player:getVocation():getId()]

if that works do it in the revert talkaction also.

I honestly cant see why you would have a problem here.
 
Let me check the code real fast. Ill edit this post with a solution if I find the problem.



Try changing (in talkaction)

Lua:
TRANS = Trans[player:getVocation():getId()]

to

Lua:
local TRANS = Trans[player:getVocation():getId()]

if that works do it in the revert talkaction also.

I honestly cant see why you would have a problem here.
still same -_- simple thinks can be so problematic sometimes.
 
add this

Lua:
local p_voc = player:getVocation():getId()
print(p_voc)

before

Lua:
local TRANS = Trans[player:getVocation():getId()]

In your console it should print your vocation id make sure its correct.
 
If that still doesnt work try replacing it all with these instead. It could be the way things are named

Global.lua
Lua:
exhaust_transform = {}

transform = {
[1] = {voc = 1, newVoc = 5, looktype = 99, level = 50, rage = 3, mana = 10, addHealth = 200, addMana = 150, effect = CONST_ME_SMOKE, aura = nil, constant = false}
}

Talkaction (transform)
Lua:
function onSay(player, words, param, channel)
    local pid = player:getId()

    if exhaust_transform[pid] ~= nil then
        return false
    end

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

    if not TRANS then return player:sendCancelMessage("You cannot transform.") end
    if player:getLevel() < TRANS.level then return player:sendCancelMessage("You must reach level "..TRANS.level.." to transform.") end
    if player:getSoul() < TRANS.rage then return player:sendCancelMessage("You need "..TRANS.rage.." to transform.") end
    if player:getMana() < TRANS.mana then return player:sendCancelMessage("You need "..TRANS.mana.." to transform.") end

    if TRANS.constant then
        player:setOutfit({looktype = TRANS.looktype})
    else
        player:setOutfit({looktype = TRANS.looktype}, false)
    end

    exhaust_transform[pid] = 1
    player:addSoul(-TRANS.rage)
    player:setMaxHealth(TRANS.addHealth)
    player:setMaxMana(TRANS.mana)
    player:addHealth(TRANS.addHealth)
    player:addMana(TRANS.addMana)
    player:getPosition():sendMagicEffect(TRANS.effect)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have transformed!")
    player:setVocation(TRANS.newVoc)
    player:save()
    addEvent(removeExhaust, 5 * 1000, pid)
return true
end

function removeExhaust(pid)
    exhaust_transform[pid] = nil
end

Talkaction: Revert
Lua:
function onSay(player, words, param, channel)
    local pid = player:getId()

    if exhaust_transform[pid] ~= nil then
        return false
    end

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

    if not TRANS then return player:sendCancelMessage("You cannot revert.") end

    if TRANS.constant then
        player:setOutfit({looktype = TRANS.looktype})
    else
        player:setOutfit({looktype = TRANS.looktype}, false)
    end

    exhaust_transform[pid] = 1
    player:setMaxHealth(TRANS.addHealth)
    player:setMaxMana(TRANS.mana)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have reverted!")
    player:setVocation(TRANS.voc)
    player:save()
    addEvent(removeExhaust, 5 * 1000, pid)
return true
end

function removeExhaust(pid)
    exhaust_transform[pid] = nil
end

GlobalEvent
Lua:
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
                    player:getPosition():sendMagicEffect(TRANS.aura)
                end
            end
        end
    end
return true
end
 
If that still doesnt work try replacing it all with these instead. It could be the way things are named

Global.lua
Lua:
exhaust_transform = {}

transform = {
[1] = {voc = 1, newVoc = 5, looktype = 99, level = 50, rage = 3, mana = 10, addHealth = 200, addMana = 150, effect = CONST_ME_SMOKE, aura = nil, constant = false}
}

Talkaction (transform)
Lua:
function onSay(player, words, param, channel)
    local pid = player:getId()

    if exhaust_transform[pid] ~= nil then
        return false
    end

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

    if not TRANS then return player:sendCancelMessage("You cannot transform.") end
    if player:getLevel() < TRANS.level then return player:sendCancelMessage("You must reach level "..TRANS.level.." to transform.") end
    if player:getSoul() < TRANS.rage then return player:sendCancelMessage("You need "..TRANS.rage.." to transform.") end
    if player:getMana() < TRANS.mana then return player:sendCancelMessage("You need "..TRANS.mana.." to transform.") end

    if TRANS.constant then
        player:setOutfit({looktype = TRANS.looktype})
    else
        player:setOutfit({looktype = TRANS.looktype}, false)
    end

    exhaust_transform[pid] = 1
    player:addSoul(-TRANS.rage)
    player:setMaxHealth(TRANS.addHealth)
    player:setMaxMana(TRANS.mana)
    player:addHealth(TRANS.addHealth)
    player:addMana(TRANS.addMana)
    player:getPosition():sendMagicEffect(TRANS.effect)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have transformed!")
    player:setVocation(TRANS.newVoc)
    player:save()
    addEvent(removeExhaust, 5 * 1000, pid)
return true
end

function removeExhaust(pid)
    exhaust_transform[pid] = nil
end

Talkaction: Revert
Lua:
function onSay(player, words, param, channel)
    local pid = player:getId()

    if exhaust_transform[pid] ~= nil then
        return false
    end

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

    if not TRANS then return player:sendCancelMessage("You cannot revert.") end

    if TRANS.constant then
        player:setOutfit({looktype = TRANS.looktype})
    else
        player:setOutfit({looktype = TRANS.looktype}, false)
    end

    exhaust_transform[pid] = 1
    player:setMaxHealth(TRANS.addHealth)
    player:setMaxMana(TRANS.mana)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You have reverted!")
    player:setVocation(TRANS.voc)
    player:save()
    addEvent(removeExhaust, 5 * 1000, pid)
return true
end

function removeExhaust(pid)
    exhaust_transform[pid] = nil
end

GlobalEvent
Lua:
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
                    player:getPosition():sendMagicEffect(TRANS.aura)
                end
            end
        end
    end
return true
end
Still same -_- "You cannot transform"
 
lookType not looktype
you shouldn't just send {lookType = x} anyways, save the outfit to a variable, do outfit.lookType = x and then set outfit back to player
 
Back
Top