• 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.X+ Help me with rewite?

norrow

Member
Joined
Dec 16, 2012
Messages
129
Reaction score
7
Location
Poland
hello, could someone help me rewrite it on version 1.2?
Lua:
local vocation= {
-- Random
    [17] = {625, 399},
    [18] = {781, 498},
    [91] = {451, 523},
    [96] = {322, 292}
}

function onLogout(cid)
    local Player = vocation[getPlayerVocation(cid)]
        if (Player == nil) then
        return true
    end

    setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)-Player[1])
    doCreatureAddHealth(cid, -Player[1])
    setCreatureMaxMana(cid, getCreatureMaxMana(cid)-Player[2])
    doCreatureAddMana(cid, -Player[2])
return true
end
 
Solution
Lua:
local vocation= {
-- Random
    [17] = {625, 399},
    [18] = {781, 498},
    [91] = {451, 523},
    [96] = {322, 292}
}

function onLogout(player)
    local voc = vocation[player:getVocation():getId()]
    if not voc then
        return true
    end
    
    player:setMaxHealth(player:getMaxHealth() - voc[1])
    player:addHealth(-voc[1])
    player:setMaxHealth(player:getMaxMana() - voc[2])
    player:addMana(-voc[2])
    
    return true
end
Lua:
local vocation= {
-- Random
    [17] = {625, 399},
    [18] = {781, 498},
    [91] = {451, 523},
    [96] = {322, 292}
}

function onLogout(player)
    local voc = vocation[player:getVocation():getId()]
    if not voc then
        return true
    end
    
    player:setMaxHealth(player:getMaxHealth() - voc[1])
    player:addHealth(-voc[1])
    player:setMaxHealth(player:getMaxMana() - voc[2])
    player:addMana(-voc[2])
    
    return true
end
 
Solution
Thank you very much! works beautifully :) I would like to have the last request, could you write again but this?
Lua:
local profesions = {
    {vocid=91, backvoc=15, mana=11, looktype=456, removedhp=451, removedmp=523},
}

local value = {}

function onThink(cid, interval)
    for i=1, #profesions do
        value = profesions[i]
        if(getPlayerVocation(cid) == value.vocid) then
            if(getCreatureMana(cid) >= value.mana) then
                if(getPlayerStorageValue(cid, 504205) <= os.time()) then
                    setPlayerStorageValue(cid, 504205, os.time() + 2)
                    doCreatureAddMana(cid, -value.mana)
                end
            else
                local outfit = getCreatureOutfit(cid)
                outfit.lookType = value.looktype
                doCreatureChangeOutfit(cid, outfit)
                doPlayerSetVocation(cid, value.backvoc)
                setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)-value.removedhp)
                doCreatureAddHealth(cid, -value.removedhp)
                setCreatureMaxMana(cid, getCreatureMaxMana(cid)-value.removedmp)
                doCreatureAddMana(cid, -value.removedmp)
            end
        end
    end
    return true
end
 
Lua:
local profesions = {
    {vocid=91, backvoc=15, mana=11, looktype=456, removedhp=451, removedmp=523},
}

local value = {}
    
function onThink(creature, interval)
    for i=1, #profesions do
        value = profesions[i]
        if(creature:getVocation():getId() == value.vocid) then
            if(creature:getMana() >= value.mana) then
                if(creature:getStorageValue(504205) <= os.time()) then
                    creature:setStorageValue(504205, os.time() + 2)
                    creature:addMana(-value.mana)
                end
            else
                local outfit = creature:getOutfit()
                outfit.lookType = value.looktype
                creature:setOutfit(outfit)
                
                creature:setVocation(value.backvoc)
                creature:setMaxHealth(creature:getMaxHealth() - value.removedhp)
                creature:addHealth(-value.removedhp)
                creature:setMaxMana(creature:getMaxMana() - value.removedmp)
                creature:addMana(-value.removedmp)
            end
        end
    end
    return true
end
 
Back
Top