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

Update this script system to TFS 1.3

Zak.Tibiam

New Member
Joined
Mar 25, 2012
Messages
150
Reaction score
3
hi guys i am wanting to update this script to tfs 1.3 can anyone help me? It's from an 8.40 server that I played at the time. Thanks

1572903450683.png

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
 gem = gems.id[getPlayerVocation(cid)]
 if item.itemid == gem then
doUseGem(cid, item, getPlayerVocation(cid))
 end
 return TRUE
end
---------------------------------

Lua:
function doUseGem(cid, item)
local voc = getPlayerVocation(cid)
 local interval = gems.interval[voc]
if item.itemid ~= gems.id[voc] or getPlayerStorageValue(cid, gems.storage[voc]) > 0 then
return FALSE
 end
 setPlayerStorageValue(cid, gems.storage[voc], 1)
 sendGemEffect(cid, gems.storage[voc], gems.interval[voc])
 doRemoveItem(item.uid, 1)
 return TRUE
end

function sendGemEffect(cid, storage, interval)
local pos = getThingPos(cid)
local voc = getPlayerVocation(cid)
local color = 1
if voc == 1 then
 color = gemMsg.colorDruid[math.random(1,#gemMsg.colorElderDruid)]
elseif voc == 2 then
 color = gemMsg.colorSorcerer[math.random(1,#gemMsg.colorMasterSorcerer)]
elseif voc == 3 then
 color = gemMsg.colorPaladin[math.random(1,#gemMsg.colorRoyalPaladin)]
elseif voc == 4 then
 color = gemMsg.colorKnight[math.random(1,#gemMsg.colorEliteKnight)]
end
doSendAnimatedText(pos, gemMsg.rnd[math.random(1,#gemMsg.rnd)], color)
 if getPlayerStorageValue(cid, gems.storage[getPlayerVocation(cid)]) >= 1 then
addEvent(sendGemEffect, interval, cid, storage, interval)
 end
end
function doRemoveGemEffect(cid)
 if getPlayerStorageValue(cid, gems.storage[getPlayerVocation(cid)]) < 1 then
return FALSE
 end
 setPlayerStorageValue(cid, gems.storage[getPlayerVocation(cid)], 0)
 return TRUE
end
function doRemoveAllGemEffect(cid)
 for i = 1, table.maxn(gms.storage) do
setPlayerStorageValue(cid, gems.storage[i], 0)
 end
 return TRUE
function isGemActivated(cid)
if getPlayerStorageValue(cid, gems.storage[getPlayerVocation(cid)]) > 0 then
 return TRUE
 end
 return FALSE
end


-----------------------------

Lua:
gems = {
id = {2156, 2155, 2158, 2154, 2156, 2155, 2158, 2154},
storage = {5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008},
interval = {750, 750, 750, 750, 750, 750, 750, 750}, -- Intervalo dos efeitos
}
gemMsg = {
rnd = {"´ .    ,", ".    ´ ,", "`  .  ,", ",    ` ."},
colorDruid = {180,180},
colorSorcerer = {30,215},
colorPaladin = {251,10},
colorKnight = {204,212},
colorElderDruid = {180,180},
colorMasterSorcerer = {30,215},
colorRoyalPaladin = {251,10},
colorEliteKnight = {204,212}
}

---------------------------------

Lua:
local config =
{
minLevel = 200, -- Level mínimo para adquirir a gema.
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
if getPlayerLevel(cid) >= config.minLevel then
 gem = gems.id[getPlayerVocation(cid)]
 if item.itemid == gem then
doUseGem(cid, item, getPlayerVocation(cid))
 doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Você adquiriu uma gema espíritual.")
  doSendMagicEffect(getCreaturePosition(cid), 65)
 end
else
  doPlayerSendCancel(cid, "Voc\ê precisa ser level "..config.minLevel.." para adquirir a gema esp\íritual.")
 end
 return TRUE
end

----------------------------------------

Lua:
function onLogin(cid)
setPlayerStorageValue(cid, 47112120, 2)
local voc = getPlayerVocation(cid)
if getPlayerStorageValue(cid, gems.storage[getPlayerVocation(cid)]) > 0 then
sendGemEffect(cid, gems.storage[voc], gems.interval[voc])
end
return TRUE
end

---------------------------------------



 
Hope this work for you...

Lua:
gems = {
id = {2156, 2155, 2158, 2154, 2156, 2155, 2158, 2154},
storage = {5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008},
interval = {750, 750, 750, 750, 750, 750, 750, 750}, -- Intervalo dos efeitos
}

gemMsg = {
rnd = {"´ .    ,", ".    ´ ,", "`  .  ,", ",    ` ."},
colorDruid = {180,180},
colorSorcerer = {30,215},
colorPaladin = {251,10},
colorKnight = {204,212},
colorElderDruid = {180,180},
colorMasterSorcerer = {30,215},
colorRoyalPaladin = {251,10},
colorEliteKnight = {204,212}
}

function Player.sendGemEffect(self, storage, interval)
    local pos = self:getPosition()
    local voc = self:getVocation():getId()
    local color = 1
    if voc == 1 then
        color = gemMsg.colorDruid[math.random(1,#gemMsg.colorElderDruid)]
    elseif voc == 2 then
        color = gemMsg.colorSorcerer[math.random(1,#gemMsg.colorMasterSorcerer)]
    elseif voc == 3 then
        color = gemMsg.colorPaladin[math.random(1,#gemMsg.colorRoyalPaladin)]
    elseif voc == 4 then
        color = gemMsg.colorKnight[math.random(1,#gemMsg.colorEliteKnight)]
    end
    self:say(gemMsg.rnd[math.random(1,#gemMsg.rnd)], TALKTYPE_MONSTER_SAY)
    if self:getStorageValue(gems.storage[voc]) >= 1 then
        addEvent(sendGemEffect, interval, self, storage, interval)
    end
end
function Player.doUseGem(self, item)
    local voc = self:getVocation():getId()
    local interval = gems.interval[voc]
    if item.itemid ~= gems.id[voc] or self:getStorageValue(gems.storage[voc]) > 0 then
        return FALSE
    end
    self:setStorageValue(gems.storage[voc], 1)
    self:sendGemEffect(gems.storage[voc], gems.interval[voc])
    Item(item.uid):remove(1)
 return TRUE
end
function Player.doRemoveAllGemEffect(self)
    for i = 1, table.maxn(gms.storage) do
        self:setStorageValue(gems.storage[i], 0)
    end
    return TRUE
end
function Player:isGemActivated(self)
        if self:getStorageValue(gems.storage[getPlayerVocation(cid)]) > 0 then
            return TRUE
        end
    return FALSE
end

function Player.doRemoveGemEffect(self)
    if self:getStorageValue(gems.storage[self:getVocation():getId()]) < 1 then
        return FALSE
    end
    self.setStorageValue(gems.storage[self:getVocation():getId()], 0)
    return TRUE
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local minLevel = 200
    if player:getLevel() >= config.minLevel then
        gem = gems.id[player:getVocation():getId()]
        if item.itemid == gem then
            player:doUseGem(item, getPlayerVocation(cid))
            player:sendTextMessage(MESSAGE_STATUS_WARNING, "You have acquired a spiritual gem.")
            player:getPosition():sendMagicEffect(65)
        end
    else
        player:sendCancelMessage("You need level "..config.minLevel.." to acquire a spiritual gem.")
    end
    return TRUE
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local voc = player:getVocation():getId()
    local gem = gems.id[voc]
    if item.itemid == gem then
        player:doUseGem(item, voc)
    end
 return TRUE
end
function onLogin(player)
    player:setStorageValue(47112120, 2)
    local voc = player:getVocation():getId()
    if player:getStorageValue(gems.storage[voc]) > 0 then
        player:sendGemEffect(gems.storage[voc], gems.interval[voc])
    end
    return TRUE
end
 
When i try login this error show on console
Code:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/logingema.lua:onLogin
data/creaturescripts/scripts/logingema.lua:4: attempt to index global 'gems' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/creaturescripts/scripts/logingema.lua:4: in function <data/creaturescripts/scripts/logingema.lua:1>
 
When i try login this error show on console
Lua:
Lua Script Error: [CreatureScript Interface]
data/creaturescripts/scripts/logingema.lua:onLogin
data/creaturescripts/scripts/logingema.lua:4: attempt to index global 'gems' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/creaturescripts/scripts/logingema.lua:4: in function <data/creaturescripts/scripts/logingema.lua:1>

Maybe you need to add the gems list to the logingem.lua, something like this:
Lua:
gems = {
id = {2156, 2155, 2158, 2154, 2156, 2155, 2158, 2154},
storage = {5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008},
interval = {750, 750, 750, 750, 750, 750, 750, 750}, -- Intervalo dos efeitos
}
function onLogin(player)
    player:setStorageValue(47112120, 2)
    local voc = player:getVocation():getId()
    if player:getStorageValue(gems.storage[voc]) > 0 then
        player:sendGemEffect(gems.storage[voc], gems.interval[voc])
    end
    return TRUE
end
 
Maybe you need to add the gems list to the logingem.lua, something like this:
Lua:
gems = {
id = {2156, 2155, 2158, 2154, 2156, 2155, 2158, 2154},
storage = {5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008},
interval = {750, 750, 750, 750, 750, 750, 750, 750}, -- Intervalo dos efeitos
}
function onLogin(player)
    player:setStorageValue(47112120, 2)
    local voc = player:getVocation():getId()
    if player:getStorageValue(gems.storage[voc]) > 0 then
        player:sendGemEffect(gems.storage[voc], gems.interval[voc])
    end
    return TRUE
end
Work but i don't wanna receive exp or money just effect that effect on character
31568-5feed6f5e65c68dd216bf26b1dbdd1dc.jpg
 
it should work... try using the compat.lua file to convert the easier parts of it, and if there is some error on console, post where so we can help! trial and error 😁
data/actions/scripts/gems.lua:10: attempt to call method 'doUseGem' (a nil value)
stack traceback:
[C]: in function 'doUseGem'
data/actions/scripts/gems.lua:10: in function <data/actions/scripts/gems.lua:5>
 
data/actions/scripts/gems.lua:10: attempt to call method 'doUseGem' (a nil value)
stack traceback:
[C]: in function 'doUseGem'
data/actions/scripts/gems.lua:10: in function <data/actions/scripts/gems.lua:5>

First of all, why not create a file on 'data/lib/' called: 'gemLib.lua'. (data/lib/gemLib.lua)
Lua:
gems = {
id = {2156, 2155, 2158, 2154, 2156, 2155, 2158, 2154},
storage = {5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008},
interval = {750, 750, 750, 750, 750, 750, 750, 750}, -- Intervalo dos efeitos
}

gemMsg = {
rnd = {"´ .    ,", ".    ´ ,", "`  .  ,", ",    ` ."},
colorDruid = {180,180},
colorSorcerer = {30,215},
colorPaladin = {251,10},
colorKnight = {204,212},
colorElderDruid = {180,180},
colorMasterSorcerer = {30,215},
colorRoyalPaladin = {251,10},
colorEliteKnight = {204,212}
}

function Player.sendGemEffect(self, storage, interval)
    local pos = self:getPosition()
    local voc = self:getVocation():getId()
    local color = 1
    if voc == 1 then
        color = gemMsg.colorDruid[math.random(1,#gemMsg.colorElderDruid)]
    elseif voc == 2 then
        color = gemMsg.colorSorcerer[math.random(1,#gemMsg.colorMasterSorcerer)]
    elseif voc == 3 then
        color = gemMsg.colorPaladin[math.random(1,#gemMsg.colorRoyalPaladin)]
    elseif voc == 4 then
        color = gemMsg.colorKnight[math.random(1,#gemMsg.colorEliteKnight)]
    end
    self:say(gemMsg.rnd[math.random(1,#gemMsg.rnd)], TALKTYPE_MONSTER_SAY)
    if self:getStorageValue(gems.storage[voc]) >= 1 then
        addEvent(sendGemEffect, interval, self, storage, interval)
    end
end
function Player.doUseGem(self, item)
    local voc = self:getVocation():getId()
    local interval = gems.interval[voc]
    if item.itemid ~= gems.id[voc] or self:getStorageValue(gems.storage[voc]) > 0 then
        return FALSE
    end
    self:setStorageValue(gems.storage[voc], 1)
    self:sendGemEffect(gems.storage[voc], gems.interval[voc])
    Item(item.uid):remove(1)
 return TRUE
end
function Player.doRemoveAllGemEffect(self)
    for i = 1, table.maxn(gms.storage) do
        self:setStorageValue(gems.storage[i], 0)
    end
    return TRUE
end
function Player.isGemActivated(self)
        if self:getStorageValue(gems.storage[getPlayerVocation(cid)]) > 0 then
            return TRUE
        end
    return FALSE
end

function Player.doRemoveGemEffect(self)
    if self:getStorageValue(gems.storage[self:getVocation():getId()]) < 1 then
        return FALSE
    end
    self.setStorageValue(gems.storage[self:getVocation():getId()], 0)
    return TRUE
end
Then use your actions, and login as you wish. onUse(...
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local minLevel = 200
    if player:getLevel() >= config.minLevel then
        gem = gems.id[player:getVocation():getId()]
        if item.itemid == gem then
            player:doUseGem(item, player:getVocation():getId())
            player:sendTextMessage(MESSAGE_STATUS_WARNING, "You have acquired a spiritual gem.")
            player:getPosition():sendMagicEffect(65)
        end
    else
        player:sendCancelMessage("You need level "..config.minLevel.." to acquire a spiritual gem.")
    end
    return TRUE
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local voc = player:getVocation():getId()
    local gem = gems.id[voc]
    if item.itemid == gem then
        player:doUseGem(item, voc)
    end
 return TRUE
end
OnLogin(...
Lua:
function onLogin(player)
    player:setStorageValue(47112120, 2)
    local voc = player:getVocation():getId()
    if player:getStorageValue(gems.storage[voc]) > 0 then
        player:sendGemEffect(gems.storage[voc], gems.interval[voc])
    end
    return TRUE
end
 
First of all, why not create a file on 'data/lib/' called: 'gemLib.lua'. (data/lib/gemLib.lua)
Lua:
gems = {
id = {2156, 2155, 2158, 2154, 2156, 2155, 2158, 2154},
storage = {5001, 5002, 5003, 5004, 5005, 5006, 5007, 5008},
interval = {750, 750, 750, 750, 750, 750, 750, 750}, -- Intervalo dos efeitos
}

gemMsg = {
rnd = {"´ .    ,", ".    ´ ,", "`  .  ,", ",    ` ."},
colorDruid = {180,180},
colorSorcerer = {30,215},
colorPaladin = {251,10},
colorKnight = {204,212},
colorElderDruid = {180,180},
colorMasterSorcerer = {30,215},
colorRoyalPaladin = {251,10},
colorEliteKnight = {204,212}
}

function Player.sendGemEffect(self, storage, interval)
    local pos = self:getPosition()
    local voc = self:getVocation():getId()
    local color = 1
    if voc == 1 then
        color = gemMsg.colorDruid[math.random(1,#gemMsg.colorElderDruid)]
    elseif voc == 2 then
        color = gemMsg.colorSorcerer[math.random(1,#gemMsg.colorMasterSorcerer)]
    elseif voc == 3 then
        color = gemMsg.colorPaladin[math.random(1,#gemMsg.colorRoyalPaladin)]
    elseif voc == 4 then
        color = gemMsg.colorKnight[math.random(1,#gemMsg.colorEliteKnight)]
    end
    self:say(gemMsg.rnd[math.random(1,#gemMsg.rnd)], TALKTYPE_MONSTER_SAY)
    if self:getStorageValue(gems.storage[voc]) >= 1 then
        addEvent(sendGemEffect, interval, self, storage, interval)
    end
end
function Player.doUseGem(self, item)
    local voc = self:getVocation():getId()
    local interval = gems.interval[voc]
    if item.itemid ~= gems.id[voc] or self:getStorageValue(gems.storage[voc]) > 0 then
        return FALSE
    end
    self:setStorageValue(gems.storage[voc], 1)
    self:sendGemEffect(gems.storage[voc], gems.interval[voc])
    Item(item.uid):remove(1)
return TRUE
end
function Player.doRemoveAllGemEffect(self)
    for i = 1, table.maxn(gms.storage) do
        self:setStorageValue(gems.storage[i], 0)
    end
    return TRUE
end
function Player.isGemActivated(self)
        if self:getStorageValue(gems.storage[getPlayerVocation(cid)]) > 0 then
            return TRUE
        end
    return FALSE
end

function Player.doRemoveGemEffect(self)
    if self:getStorageValue(gems.storage[self:getVocation():getId()]) < 1 then
        return FALSE
    end
    self.setStorageValue(gems.storage[self:getVocation():getId()], 0)
    return TRUE
end
Then use your actions, and login as you wish. onUse(...
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local minLevel = 200
    if player:getLevel() >= config.minLevel then
        gem = gems.id[player:getVocation():getId()]
        if item.itemid == gem then
            player:doUseGem(item, player:getVocation():getId())
            player:sendTextMessage(MESSAGE_STATUS_WARNING, "You have acquired a spiritual gem.")
            player:getPosition():sendMagicEffect(65)
        end
    else
        player:sendCancelMessage("You need level "..config.minLevel.." to acquire a spiritual gem.")
    end
    return TRUE
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local voc = player:getVocation():getId()
    local gem = gems.id[voc]
    if item.itemid == gem then
        player:doUseGem(item, voc)
    end
return TRUE
end
OnLogin(...
Lua:
function onLogin(player)
    player:setStorageValue(47112120, 2)
    local voc = player:getVocation():getId()
    if player:getStorageValue(gems.storage[voc]) > 0 then
        player:sendGemEffect(gems.storage[voc], gems.interval[voc])
    end
    return TRUE
end

the mechanics are working perfectly but the effect is going wrong. It should look the same as this video. But it's just like the image I sent

how is it working gema.png


how should it work: Effect
 
Back
Top