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

[Request] Magic Shield ring On/Off on click

Airstrike

New Member
Joined
Jun 24, 2009
Messages
48
Reaction score
0
Hey all,

I've searched through over 50 pages on the forum here and can't find anything like what I'm looking for, so decided to come here and request it.

I'm trying to make a custom ring with the ability to turn on or off the magic shield effect by clicking on the ring. Like being able to turn on, or off an energy ring, even if you're still wearing it.



I'd love it if someone could write up a quick script for this for me. I'm sure it's not too complicated, I just don't know how to myself.

Thanks in advance :)
 
Lua:
local mana = createConditionObject(CONDITION_MANASHIELD)
setConditionParam(mana, CONDITION_PARAM_TICKS, -1)

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

	if(getPlayerSlotItem(cid, CONST_SLOT_RING).itemid ~= item.itemid) then
		return doPlayerSendCancel(cid, "You must wear the ring")
	end

	if(getCreatureCondition(cid, CONDITION_MANASHIELD)) then
		doRemoveCondition(cid, CONDITION_MANASHIELD)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Manashield off.")
	else
		doTargetCombatCondition(0, cid, mana, CONST_ME_MAGIC_BLUE) 
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Manashield on.")
	end
	return true
end

Don't test it on a god char. And what if a player removes the ring, the manashield will be gone too?

@down, haha you're right, I was so used of using storage with on/off scripts that I forgot about it XD
 
Last edited:
You forgot to add which server you use, but try this
Lua:
local mana = createConditionObject(CONDITION_MANASHIELD)
setConditionParam(mana, CONDITION_PARAM_TICKS, -1)

function onUse(cid, item, fromPosition, itemEx, toPosition)
local storage = 29785

	if(getPlayerSlotItem(cid, CONST_SLOT_RING).itemid ~= item.itemid) then
		return doPlayerSendCancel(cid, "You must wear the ring")
	end

	if getPlayerStorageValue(cid, storage) == -1 then
		doTargetCombatCondition(0, cid, mana, CONST_ME_MAGIC_BLUE) 
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Manashield on.")
		setPlayerStorageValue(cid, storage, 1)
		return true
	else
		setPlayerStorageValue(cid, storage, -1)
		if(hasCondition(cid, CONDITION_MANASHIELD)) then
			doRemoveCondition(cid, CONDITION_MANASHIELD)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Manashield off.")
		end
	end
	return true
end

Don't test it on a god char. And what if a player removes the ring, the manashield will be gone too?

You don't need the storage for that, just simply use hasCondition and either turn it on or off :p
 
Awesome, thank you!

I'm using tfs 0.4 btw. I'll try it out when I get home and let you know how it goes.

+rep ofc if it works ^^
 
Back
Top