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

Lua mana rune script not working tfs 0.3.5

Gregor

New Member
Joined
Feb 29, 2008
Messages
770
Reaction score
3
Location
UK/POLAND
Hello! My mana rune script stop working on tfs 0.3.5 it was working on 0.3.4pl2
PHP:
-- Script 100% by Colandus (Except for the exhaustion system).
-- If you edit this script, make sure to leave the credits to me, Colandus.

-- >>CONFIG<< --
local REMOVE_CHARGES = false -- true/false shall it remove charges?
local MIN_MANA = 1000 -- How much mana minium will you get?
local MAX_MANA = 1500 -- How much mana max will you get?
local USE_STATS = false -- Shall given mana be affected by player level and magic level?
local STORE_VALUE = 3567 -- Value where exhaust is saved.
local EXHAUST_TIME = 1 -- Exhaust time in seconds.
local ANIMATION_COLOR = 210 -- The color of the "animation".
-- >>CONFIG<< --

local vocMultiply = {0.35, 0.35, 0.85, 1.05, 0, 0, 0.65, 1.05} -- Remove and/or comment it out if you wish not to use it.
local removeMana = 0

function onUse(cid, item, frompos, item2, topos)
    if isPlayer(item2.uid) == TRUE then
        local maxMana = getPlayerMaxMana(item2.uid)
        if vocMultiply and getPlayerVocation(cid) >= 1 and getPlayerVocation(cid) <= 8 then
            removeMana = vocMultiply[getPlayerVocation(cid)]
        end
        local newMana = math.random(MIN_MANA, MAX_MANA)
        if USE_STATS then
            newMana = math.ceil(newMana + getPlayerLevel(cid) + getPlayerMagLevel(cid) - (newMana * removeMana))
        end
        if (maxMana - newMana) < 0 then
            newMana = maxMana - getPlayerMana(cid)
        end
        if getPlayerMana(item2.uid) < maxMana then
            if exhaust(cid, STORE_VALUE, EXHAUST_TIME) > TRUE then
                if REMOVE_CHARGES then
                    if item.type > 1 then
                        doChangeTypeItem(item.uid, item.type - 1)
                    else
                        doRemoveItem(item.uid, 1)
                    end
                end
                if comparePos(getPlayerPosition(cid), getPlayerPosition(item2.uid)) then
                    doSendMagicEffect(getPlayerPosition(cid), 12)
                    doSendMagicEffect(getPlayerPosition(cid), 36)
                    doSendMagicEffect(getPlayerPosition(cid), 48)
                    doSendMagicEffect(getPlayerPosition(cid), 47)
                    doPlayerSendTextMessage(cid, 23, "You received " .. newMana .. " mana.")
                else
                    doSendMagicEffect(getPlayerPosition(cid), 14)
                    doSendMagicEffect(getPlayerPosition(item2.uid), 12)
                    doPlayerSendTextMessage(item2.uid, 23, "You received " ..  newMana .. " mana from " .. getPlayerName(cid) .. ".")
                    doPlayerSendTextMessage(cid, 23, "You gave " .. getPlayerName(item2.uid) .. " " .. newMana .. " mana.")
                end
                doPlayerAddMana(item2.uid, newMana)
                doSendAnimatedText(getPlayerPosition(item2.uid), newMana, ANIMATION_COLOR)
            else
                doPlayerSendCancel(cid, "You are exhausted.")
            end
        else
            if comparePos(getPlayerPosition(cid), getPlayerPosition(item2.uid)) then
                doPlayerSendCancel(item2.uid, "Your mana is already full.")
            else
                doPlayerSendCancel(cid, getPlayerName(item2.uid) .. " mana is already full.")
            end
            doSendMagicEffect(getPlayerPosition(cid), 2)
        end
    else
        doPlayerSendCancel(cid, "You can only use this rune on players.")
        doSendMagicEffect(getPlayerPosition(cid), 2)
    end
    return 1
end

also i use this functions in lib/function.lua

PHP:
function setExhaust(cid, storage)
    setPlayerStorageValue(cid, storage, os.time())
end

PHP:
function isExhausted(cid, storage, exhaust)
    local exhaustTime = getPlayerStorageValue(cid, storage)
    if exhaustTime == -1 then
        return FALSE
    end
    local isExhausted = os.time() - exhaustTime < exhaust
    return isExhausted and TRUE or FALSE
end

PHP:
function comparePos(pos1,pos2)
    return pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z
end


and the error:

PHP:
[13/08/2009 23:06:47] Lua Script Error: [Action Interface] 
[13/08/2009 23:06:47] data/actions/scripts/tools/promanarune.lua:onUse

[13/08/2009 23:06:47] data/actions/scripts/tools/promanarune.lua:31: attempt to call global 'exhaust' (a nil value)
[13/08/2009 23:06:47] stack traceback:
[13/08/2009 23:06:47] 	data/actions/scripts/tools/promanarune.lua:31: in function <data/actions/scripts/tools/promanarune.lua:17>

Thanks a lot :p
 
Try replace
Code:
if exhaust
to
Code:
if isExhausted

Regards

new error now:

PHP:
[14/08/2009 14:23:53] Lua Script Error: [Action Interface] 
[14/08/2009 14:23:53] data/actions/scripts/tools/promanarune.lua:onUse

[14/08/2009 14:23:53] data/actions/scripts/tools/promanarune.lua:31: attempt to compare two boolean values
[14/08/2009 14:23:53] stack traceback:
[14/08/2009 14:23:53] 	data/actions/scripts/tools/promanarune.lua:31: in function <data/actions/scripts/tools/promanarune.lua:17>
 
That error mean's there are two thing's that are conflicting.
You must change it so it shall work properly.

Example:
Lua:
local level = getPlayerLevel(cid)
if level == 100 then
 
if isExhausted(cid, STORE_VALUE, EXHAUST_TIME) > TRUE then
should be
if isExhausted(cid, STORE_VALUE, EXHAUST_TIME) == TRUE then
or
if isExhausted(cid, STORE_VALUE, EXHAUST_TIME) > NUMBER then
 

Similar threads

Back
Top Bottom