• 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 Need help with manarune script

haxborn

server dominando, cry is free
Joined
Dec 1, 2011
Messages
126
Reaction score
7
Location
Sweden
Hi there, I'm putting up a server and got a small problem, since I'm not a good scripter I just want a small help.

I'm using a mana rune since my server is 8.50 and using tfs 0.2.2

It works perfectly, though the mana rune disapears when used, I want it to stay.

Could you help me out?

Here's the script:

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)

function onCastSpell(cid, var)

local level = getPlayerLevel(cid)
local mlevel = getPlayerMagLevel(cid)
local pos = getPlayerPosition(cid)

-- Mana Formula Settings --
-- You can use "level" and "mlevel" --
local mana_minimum = (level * 3) + (mlevel * 3) - 50
local mana_maximum = (level * 4) + (mlevel * 3)
-- Mana Formula Settings END --
local mana_add = math.random(mana_minimum, mana_maximum)
doSendMagicEffect(pos,28)
doPlayerAddMana(cid, mana_add)
doSendAnimatedText(pos, mana_add, TEXTCOLOR_LIGHTBLUE)
doCreatureSay(cid, "_+_MaNa PoWeR_+_", TALKTYPE_ORANGE_1)
return doCombat(cid, combat, var)
end

btw looking for scripter if someone is intrested, will make a deal then.
 
Last edited:
try this
Lua:
function onUse(cid, item, frompos, item2, topos)
local level = getPlayerLevel(cid)
local mlevel = getPlayerMagLevel(cid)
-- Exhausted Settings --
local exhausted_seconds = 1 -- How many seconds manarune will be unavailible to use. --
local exhausted_storagevalue = 7000 -- Storage Value to store exhaust. It MUST be unused! --
-- Exhausted Settings END --
-- Mana Formula Settings --
-- You can use "level" and "mlevel" --
local mana_minimum = (level * 5) + (mlevel * 3) - 50
local mana_maximum = (level * 5) + (mlevel * 4)
-- Mana Formula Settings END --
local mana_add = math.random(mana_minimum, mana_maximum)
-- We check the charges. --
if(item.type > 1) then
-- Exhausted check. --
if(os.time() > getPlayerStorageValue(cid, exhausted_storagevalue)) then
-- Entity is player? --
if(isPlayer(item2.uid) == 1) then
doChangeTypeItem(item.uid,item.type-1)
doSendMagicEffect(frompos, CONST_ME_LOSEENERGY)
doPlayerAddMana(item2.uid, mana_add)
setPlayerStorageValue(cid, exhausted_storagevalue, os.time() + exhausted_seconds)
else
doSendMagicEffect(frompos, CONST_ME_POFF)
doPlayerSendCancel(cid, "You cannot use that object.")
end
else
doSendMagicEffect(frompos, CONST_ME_POFF)
doPlayerSendCancel(cid, "You are exhausted.")
end
else
if(item.type == 1) then
-- Exhausted check. --
if(os.time() > getPlayerStorageValue(cid, exhausted_storagevalue)) then
-- Entity is player? --
if(isPlayer(item2.uid) == 1) then
doSendMagicEffect(frompos, CONST_ME_LOSEENERGY)
doPlayerAddMana(item2.uid, mana_add)
setPlayerStorageValue(cid, exhausted_storagevalue, os.time() + exhausted_seconds)
else
doSendMagicEffect(frompos, CONST_ME_POFF)
doPlayerSendCancel(cid, "You cannot use that object.")
end
else
doSendMagicEffect(frompos, CONST_ME_POFF)
doPlayerSendCancel(cid, "You are exhausted.")
end
end
end
return 1
end
 
Last edited:
That script didnt work, I think it can't handle the local exhausted_storagevalue but I'm not sure, I'm trying to fix it myself as an action now but cant script so it's kinda hard.
 
I actually fixed it, the only thing I need help with now is adding an exhaust to the script. Can someone help me?

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)

function onUse(cid, var)

local level = getPlayerLevel(cid)
local mlevel = getPlayerMagLevel(cid)
local pos = getPlayerPosition(cid)

-- Mana Formula Settings --
-- You can use "level" and "mlevel" --
local mana_minimum = (level * 3) + (mlevel * 3) - 50
local mana_maximum = (level * 4) + (mlevel * 3)
-- Mana Formula Settings END --
local mana_add = math.random(mana_minimum, mana_maximum)
doSendMagicEffect(pos,28)
doPlayerAddMana(cid, mana_add)
doSendAnimatedText(pos, mana_add, TEXTCOLOR_LIGHTBLUE)
doCreatureSay(cid, "_+_MaNa PoWeR_+_", TALKTYPE_ORANGE_1)
return doCombat(cid, combat, var)
end
 
Lua:
 local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
 
Lua:
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') + 1000))
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)
 
function onUse(cid, var)
 
local level = getPlayerLevel(cid)
local mlevel = getPlayerMagLevel(cid)
local pos = getPlayerPosition(cid)
 
-- Mana Formula Settings --
-- You can use "level" and "mlevel" --
local mana_minimum = (level * 3) + (mlevel * 3) - 50
local mana_maximum = (level * 4) + (mlevel * 3)
-- Mana Formula Settings END --
local mana_add = math.random(mana_minimum, mana_maximum)
doSendMagicEffect(pos,28)
doPlayerAddMana(cid, mana_add)
doSendAnimatedText(pos, mana_add, TEXTCOLOR_LIGHTBLUE)
doCreatureSay(cid, "_+_MaNa PoWeR_+_", TALKTYPE_ORANGE_1)
return doCombat(cid, combat, var)
end

Using this now, works but still gives no exhaust, and evertime I use it I get this server message:

PHP:
[05/12/2011 14:49:22] Lua Script Error: [Action Interface] 
[05/12/2011 14:49:22] data/actions/scripts/other/manarune.lua:onUse

[05/12/2011 14:49:22] luaDoCombat(). Variant not found
Any ideas?
 
change
Lua:
function onUse(cid, var)

to

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)

and
Lua:
return doCombat(cid, combat, var)

to

Lua:
return doCombat(cid, combat)

Im noob btw, just test some things in order to fix it ;p
 
Well now it says:

/12/2011 15:19:47] attempt to index a number value
[05/12/2011 15:19:47] stack traceback:
[05/12/2011 15:19:47] [C]: in function 'doCombat'
[05/12/2011 15:19:47] data/actions/scripts/other/manarune.lua:24: in function <data/actions/scripts/other/manarune.lua:8>
 
I just tested this and it works, though I'm not sure if it will work for you too since your server is 0.2.2 :|
But here it is for anyone who can use it:

Code:
function onUse(cid, var, item, fromPosition, toPosition, itemEx)
 
local level = getPlayerLevel(cid)
local mlevel = getPlayerMagLevel(cid)
local pos = getPlayerPosition(cid)

--Exhaustion Settings:
local exhaustionStorage = 2555
local time = 30 -- in seconds
------------------------
 
-- Mana Formula Settings --
-- You can use "level" and "mlevel" --
local mana_minimum = (level * 3) + (mlevel * 3) - 50
local mana_maximum = (level * 4) + (mlevel * 3)
-- Mana Formula Settings END --

if not(exhaustion.check(cid,exhaustionStorage)) then
local mana_add = math.random(mana_minimum, mana_maximum)
doSendMagicEffect(pos,28)
doPlayerAddMana(cid, mana_add)
doSendAnimatedText(pos, mana_add, TEXTCOLOR_LIGHTBLUE)
doCreatureSay(cid, "_+_MaNa PoWeR_+_", TALKTYPE_ORANGE_1)
		doSendMagicEffect(getCreaturePosition(cid),13)
				 exhaustion.set(cid,exhaustionStorage,time)
else
		doSendMagicEffect(getCreaturePosition(cid),2)
end
return true
end


Btw, huge protip: Switch to some newer distro. I know your server might be in long development in that old one and stuff, but you seriously need to, else you're missing on a lot of stuff and scripts available for newer distros.
 
Back
Top