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

Charges on a item, like a scroll?

Bam

Active Member
Joined
Aug 11, 2007
Messages
1,442
Reaction score
39
Location
Sweden
Hey! I was wondering how you add charges to another item then a rune or items that have "built in" charges..

Lets say I got a regular scroll

Code:
23:25 You see a scroll.
It weighs 0.50 oz.
ItemID: [1949].

Now I made it into an action, an onUse function which gives the player 100hp when using it.

But then it disappears cause I have the
Code:
doRemoveItem(item.uid)
line, to prevent spam clicking the hp in this case.


How would I make the scroll not only have one charge, but lets say 3?

Use this script as an example how to add it in please
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerLevel(cid) <= 200 then
		doCreatureSay(cid, "You gained 15000000 experience!", TALKTYPE_ORANGE_1)
		doPlayerAddExp(cid, 15000000)
		doSendMagicEffect(fromPosition, CONST_ME_GIFT_WRAPS)
		doRemoveItem(item.uid)
	return TRUE
	else
		doCreatureSay(cid, "Can only be used lower then level 200.", TALKTYPE_ORANGE_1)
	end
end

Thanks!
 
No, you need to set actionids in the script itself. And they should be used to determine how many charges the item has.
 
Code:
local config = {
	exp = 15000000,
	charges = 3,
	level = 200,
	effect = CONST_ME_GIFT_WRAPS
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if getPlayerLevel(cid) <= config.level then
		if item.actionid <= 0 then
			doSetItemActionId(item.uid, 100 + config.charges)
		end
		doCreatureSay(cid, "You gained " .. config.exp .. " experience!", TALKTYPE_ORANGE_1)
		doPlayerAddExp(cid, config.exp)
		doSendMagicEffect(fromPosition, config.effect)
		doSetItemActionId(item.uid, item.actionid - 1)
		if item.actionid == 100 then
			doRemoveItem(item.uid)
		end
	else
		doCreatureSay(cid, "Only players of level " .. config.level .. " or lower may use this item.", TALKTYPE_ORANGE_1)
	end
	return TRUE
end
 
Last edited:
Back
Top