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

Manarune problem!

Saj

Remember my name
Joined
Feb 26, 2008
Messages
2,127
Reaction score
6
I get this error when I use my manarune and my code is down:
Code:
[11/10/2008  04:18:03] Lua Script Error: [Action Interface] 
[11/10/2008  04:18:03] data/actions/scripts/manarunevipnytest.lua:onUse

[11/10/2008  04:18:03] data/actions/scripts/manarunevipnytest.lua:38: attempt to call global 'exhaust' (a nil value)
[11/10/2008  04:18:03] stack traceback:
[11/10/2008  04:18:03] 	data/actions/scripts/manarunevipnytest.lua:38: in function <data/actions/scripts/manarunevipnytest.lua:25>

manarune script:
Code:
-- Script 90% by Colandus and 10% by Souldrainer(Except for the exhaustion system).
-- If you edit this script, make sure to leave the credits to me, Colandus and me Souldrainer :) .
 
-- >>CONFIG<< --
local ACCESS = {NO_REMOVE = 5, NO_EXHAUST = 5} -- The access of players that does not lose charges/get exhausted using the rune.
local MIN_MANA = 100 -- How much mana minium will you get?
local MAX_MANA = 120 -- How much mana max will you get?
local STORE_VALUE = 3567 -- Value where exhaust is saved.
local EXHAUST_TIME = 1 -- Exhaust time in seconds.
local ANIMATION_COLOR = 41 -- The color of the "animation".
local VOCATIONS = {9, 10, 11, 12} -- Vocations that may use this rune.
-- >>CONFIG<< --
 
local vocMultiply = {0.35, 0.35, 0.85, 1.05, 0, 0, 0.65, 1.05}
local removeMana = 0

function comparePos(pos_1,pos_2)
	if pos_1.x ~= pos_2.x or pos_1.y ~= pos_2.y then
		return FALSE
	else
		return TRUE
	end
end
 
function onUse(cid, item, frompos, item2, topos)
	if isInArray(VOCATIONS, getPlayerVocation(cid)) == TRUE then
		if isPlayer(item2.uid) == 1 then
			local maxMana = getPlayerMaxMana(item2.uid)
			local randMana = math.random(MIN_MANA, MAX_MANA)
			if getPlayerVocation(cid) >= 1 and getPlayerVocation(cid) <= 8 then
				removeMana = vocMultiply[getPlayerVocation(cid)]
			end
			local newMana = math.ceil(randMana + getPlayerLevel(cid) + getPlayerMagLevel(cid) - (randMana * removeMana))
			if (maxMana - newMana) < 0 then
				newMana = maxMana - getPlayerMana(cid)
			end
			if getPlayerMana(item2.uid) < maxMana then
				if exhaust(cid, STORE_VALUE, EXHAUST_TIME) > 0 or getPlayerAccess(cid) >= ACCESS.NO_EXHAUST then
					if getPlayerAccess(cid) < ACCESS.NO_REMOVE and math.random(1, 3) == 2 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)) == TRUE then
						doSendMagicEffect(getPlayerPosition(cid), 12)
						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)) == TRUE 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
	else
		doPlayerSendCancel(cid, "Your vocation cannot use this rune.")
		doSendMagicEffect(getPlayerPosition(cid), 2)
	end
	return 1
end
 
Add this to your global.lua
Code:
function exhaust(cid, storeValue, exhaustTime)
    newExhaust = os.time()
    oldExhaust = getPlayerStorageValue(cid, storeValue)
    if (oldExhaust == nil or oldExhaust < 0) then
        oldExhaust = 0
    end
    if (exhaustTime == nil or exhaustTime < 0) then
        exhaustTime = 120000
    end
    diffTime = os.difftime(newExhaust, oldExhaust)
    if (diffTime >= exhaustTime) then
        setPlayerStorageValue(cid, storeValue, newExhaust) 
        return 1
    else
        return 0
    end
end
 
Back
Top