• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

Action [new][buff towers] Max mana and Max health increase

King Simon

Learning Lua
Joined
Jul 29, 2013
Messages
16
Reaction score
3
Hey guys so the script im posting today is for two buff towers, Mana and Health. Basically what the towers do is for a configured time and for a configured price your max mana/ max health is increased. I got this idea from playing MMORPG's which have buff towers in their guild castles. Shout out to CorneX and Wavoz for helping me out.

well here it is :D

Dont forget to rep++ if i helped :)


Heres the health tower:
Lua:
 --Made By King Simon
--Credits to Wavoz and CorneX for helping out!!!

local config  = { 

    newHealthMage = 0.05, -- this multiplied by their level is how much they gain
	newHealthPaladin = 0.1,
	newHealthKnight =	0.2,
	storage = 43690,
	cost = 20000,	-- how much it costs
	timing = 2* 60 * 60 * 1000, -- currently set at 2 hours
 
}
local function stop(cid)
  if isSorcerer(cid) or isDruid(cid) then
			setCreatureMaxHealth(cid, (getCreatureMaxHealth(cid)-(lvl * config.newHealthMage)))
			doSendMagicEffect(getPlayerPosition(cid), 2)
			doSendAnimatedText(getPlayerPosition(cid), "Buff Over", math.random(1, 255))
			setPlayerStorageValue(cid, config.storage, -1)
			
		elseif isPaladin(cid) then
			setCreatureMaxHealth(cid, (getCreatureMaxHealth(cid)-(lvl * config.newHealthPaladin)))
			doSendMagicEffect(getPlayerPosition(cid), 2)
			doSendAnimatedText(getPlayerPosition(cid), "Buff Over", math.random(1, 255))
			setPlayerStorageValue(cid, config.storage, -1)
			
		elseif isKnight(cid) then
			setCreatureMaxHealth(cid, (getCreatureMaxHealth(cid)-(lvl * config.newHealthKnight)))
			doSendMagicEffect(getPlayerPosition(cid), 2)
			doSendAnimatedText(getPlayerPosition(cid), "Buff Over", math.random(1, 255))
			setPlayerStorageValue(cid, config.storage, -1)
		end
  return true
end
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
local lvl = getPlayerLevel(cid)
if getPlayerStorageValue(cid, config.storage) == -1 then
	if doPlayerRemoveMoney(cid, config.cost) == TRUE then
		if isSorcerer(cid) or isDruid(cid) then
			setCreatureMaxHealth(cid, (getCreatureMaxHealth(cid)+(lvl * config.newHealthMage)))
			doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_BLUE)
			doSendAnimatedText(getPlayerPosition(cid), "Buffed", math.random(1, 255))
			setPlayerStorageValue(cid, config.storage, 1)
			addEvent(stop, config.timing,cid)
		elseif isPaladin(cid) then
			setCreatureMaxHealth(cid, (getCreatureMaxHealth(cid)+(lvl * config.newHealthPaladin)))
			doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_BLUE)
			doSendAnimatedText(getPlayerPosition(cid), "Buffed", math.random(1, 255))
			setPlayerStorageValue(cid, config.storage, 1)
			addEvent(stop, config.timing,cid)
		elseif isKnight(cid) then
			setCreatureMaxHealth(cid, (getCreatureMaxHealth(cid)+(lvl * config.newHealthKnight)))
			doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_BLUE)
			doSendAnimatedText(getPlayerPosition(cid), "Buffed", math.random(1, 255))
			setPlayerStorageValue(cid, config.storage, 1)
			addEvent(stop, config.timing,cid)
		end
		
	else
			doPlayerSendCancel(cid, "You Do Not Have Enough Money!")
			doSendMagicEffect(getPlayerPosition(cid), 2)
		
	end	
else
		doPlayerSendCancel(cid, "You Already Have This Buff!")
		doSendMagicEffect(getPlayerPosition(cid), 2)
		
end
 return TRUE 
end

and here is the Mana Tower:
Lua:
 --Made By King Simon
--Credits to Wavoz and CorneX for helping out!!!

local config  = {
newManaMage = 0.7,
newManaPaladin = 0.5,
newManaKnight = 0.3,
storage = 43632,
cost = 20000,
timing = 2 * 60 * 1000,
}
 
local function stop(cid)
local lvl = getPlayerLevel(cid)
  if isSorcerer(cid) or isDruid(cid) then
   setCreatureMaxMana(cid, (getCreatureMaxMana(cid)-(lvl * config.newManaMage)))
   doSendMagicEffect(getPlayerPosition(cid), 2)
   doSendAnimatedText(getPlayerPosition(cid), "Buff Over", math.random(1, 255))
   setPlayerStorageValue(cid, config.storage, -1)
   
  elseif isPaladin(cid) then
   setCreatureMaxMana(cid, (getCreatureMaxMana(cid)-(lvl * config.newManaPaladin)))
   doSendMagicEffect(getPlayerPosition(cid), 2)
   doSendAnimatedText(getPlayerPosition(cid), "Buff Over", math.random(1, 255))
   setPlayerStorageValue(cid, config.storage, -1)
   
  elseif isKnight(cid) then
   setCreatureMaxMana(cid, (getCreatureMaxMana(cid)-(lvl * config.newManaKnight)))
   doSendMagicEffect(getPlayerPosition(cid), 2)
   doSendAnimatedText(getPlayerPosition(cid), "Buff Over", math.random(1, 255))
   setPlayerStorageValue(cid, config.storage, -1)
  end
  return true
end
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
local lvl = getPlayerLevel(cid)
if getPlayerStorageValue(cid, config.storage) == -1 then
 if doPlayerRemoveMoney(cid, config.cost) == TRUE then
  if isSorcerer(cid) or isDruid(cid) then
   setCreatureMaxMana(cid, (getCreatureMaxMana(cid)+(lvl * config.newManaMage)))
   doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_BLUE)
   doSendAnimatedText(getPlayerPosition(cid), "Buffed", math.random(1, 255))
   setPlayerStorageValue(cid, config.storage, 1)
   addEvent(stop, config.timing,cid)
 
  elseif isPaladin(cid) then
   setCreatureMaxMana(cid, (getCreatureMaxMana(cid)+(lvl * config.newManaPaladin)))
   doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_BLUE)
   doSendAnimatedText(getPlayerPosition(cid), "Buffed", math.random(1, 255))
   
   setPlayerStorageValue(cid, config.storage, 1)
   addEvent(stop, config.timing,cid)
 
  elseif isKnight(cid) then
   setCreatureMaxMana(cid, (getCreatureMaxMana(cid)+(lvl * config.newManaKnight)))
   doSendMagicEffect(getPlayerPosition(cid), CONST_ME_MAGIC_BLUE)
   doSendAnimatedText(getPlayerPosition(cid), "Buffed", math.random(1, 255))
   setPlayerStorageValue(cid, config.storage, 1)
   addEvent(stop, config.timing,cid)
   
  end
 
 else
   doPlayerSendCancel(cid, "You Do Not Have Enough Money!")
   doSendMagicEffect(getPlayerPosition(cid), 2)
 
 end
else
  doPlayerSendCancel(cid, "You Already Have This Buff!")
  doSendMagicEffect(getPlayerPosition(cid), 2)
 
end
 return TRUE
end

Come To my Server if u want a custom script of some sort. I am Always up for the challenge and dont forget to rep++ :D
Visit me at : samcityot.servegame.com
My name is Simon on the server :D
 
What if the player logs out before the function 'stop' gets to be called?
I might be wrong, but seems to me like his HP/mana would remain buffed forever, and his storage wouldn't run out since addEvent's function won't be called if the player is not online.
 
It's decent, but you should learn how to loop instead of copying and pasting functions. It can make your server much smaller, and less lagg.
 
What if the player logs out before the function 'stop' gets to be called?
I might be wrong, but seems to me like his HP/mana would remain buffed forever, and his storage wouldn't run out since addEvent's function won't be called if the player is not online.

I think that ' setCreatureMaxMana' is only temporary and lose its effect after logout, not 100% sure tho.
 
It's something like my buffs from hotc. :D GJ although it can be shortened using tables.
 
Hahaha Yea guys sorry im new to coding so i wont have the best code. Just putting it out there for comments on how to improve and maybe someone will enjoy it :)
 
Back
Top