• 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 Experience Ring TFS 0.3.5 PL1

dragaoart

Since 2009...
Joined
May 10, 2009
Messages
97
Reaction score
9
Hello!

I'm trying to run this code: exp_ring.lua

Lua:
function onEquip(cid, item, slot)
doTransformItem(item.uid, 10612, 1)
doPlayerSendTextMessage(cid, 22, 'Now you have 2x extra experience!')
doPlayerSetExperienceRate(cid, 2)


return TRUE
end

function onDeEquip(cid, item, slot)
doTransformItem(item.uid, 10613, 1)
doPlayerSendTextMessage(cid, 22, 'Extra experience ended.')
doPlayerSetExperienceRate(cid, 1)


return TRUE
end

It's called in movement.lua:
HTML:
	<movevent type="Equip" itemid="10612" slot="ring" event="script" value="vip_items/exp_ring.lua"/><!-- EXPERIENCE RING IN USE-->
	<movevent type="DeEquip" itemid="10612" slot="ring" event="script" value="vip_items/exp_ring.lua"/><!-- EXPERIENCE RING IN USE-->
	<movevent type="Equip" itemid="10613" slot="ring" event="script" value="vip_items/exp_ring.lua"/><!-- EXPERIENCE RING OFF USE-->
	<movevent type="DeEquip" itemid="10613" slot="ring" event="script" value="vip_items/exp_ring.lua"/><!-- EXPERIENCE RING OFF USE-->

In items.xml i got:
HTML:
	<!-- Exp Ring-->
	
	<!-- ON -->
	<item id="10612" article="an" name="experience ring">
		<attribute key="weight" value="500"/>
		<attribute key="slotType" value="ring"/>
		
		<attribute key="duration" value="43200"/>
		<attribute key="decayTo" value="0"/>
		<attribute key="showduration" value="1"/>
		
		<attribute key="transformDeEquipTo" value="10613"/>
	</item>
	<!-- OFF -->
	<item id="10613" article="an" name="experience ring">
		<attribute key="weight" value="500"/>
		<attribute key="slotType" value="ring"/>
		
		<attribute key="stopduration" value="1"/>
		<attribute key="showduration" value="1"/>
		
		<attribute key="transformEquipTo" value="10612"/>
	</item>

There is a problem:

The extra experience given looks quite unstable.

I've created a creature whose give 1 exp.
And inside stages.xml, a level 200+ got 1x exp
1x1 = 1 *lol*

The ring just give 3 exp point when you kill that creature.

I would like to:
•The script work like this way, 2x exp when worn and back to normal when "deequip". SOLVED
•Add duration time countdown.

Any Ideas on how to fix it?

Thanks for your time.

-------- EDIT

EXP FIXED, DURATION TIME STILL DOESN'T WORK!
 
Last edited:
Lua:
function onEquip(cid, item, slot)
	if getPlayerSlotItem(cid, CONST_SLOT_RING).itemid == 10613 then
		doTransformItem(item.uid, 10612, 1)
		doPlayerSendTextMessage(cid, 22, "Now you have 2x extra experience!")
		doPlayerSetExtraExpRate(cid, getExperienceStage(getPlayerLevel(cid))+2)
	end
	return TRUE
end

function onDeEquip(cid, item, slot)
	if getPlayerSlotItem(cid, CONST_SLOT_RING).itemid ~= 10612 then
		doTransformItem(item.uid, 10613, 1)
		doPlayerSendTextMessage(cid, 22, "Extra experience ended.")
		doPlayerSetExtraExpRate(cid, getExperienceStage(getPlayerLevel(cid))-2)
	end
	return TRUE
end

This will probably not work. Test it anyways...
(It should get the players experience stage, for his level, then add 2x exp).
 
Lua:
function onEquip(cid, item, slot)
	if getPlayerSlotItem(cid, CONST_SLOT_RING).itemid == 10613 then
		doTransformItem(item.uid, 10612, 1)
		doPlayerSendTextMessage(cid, 22, "Now you have 2x extra experience!")
		doPlayerSetExtraExpRate(cid, getExperienceStage(getPlayerLevel(cid))+2)
	end
	return TRUE
end

function onDeEquip(cid, item, slot)
	if getPlayerSlotItem(cid, CONST_SLOT_RING).itemid ~= 10612 then
		doTransformItem(item.uid, 10613, 1)
		doPlayerSendTextMessage(cid, 22, "Extra experience ended.")
		doPlayerSetExtraExpRate(cid, getExperienceStage(getPlayerLevel(cid))-2)
	end
	return TRUE
end

This will probably not work. Test it anyways...
(It should get the players experience stage, for his level, then add 2x exp).

I've tried a dozen times, but the "doPlayerSetExtraExpRate" function doesn't work(the server said can't find), instead of it, I'm using the function "doPlayerSetExperienceRate(cid, value)".

It seems that the problem now is the duration time that doesn't work.

It's supposed to countdown by the value shown in items.xml:
HTML:
<attribute key="duration" value="43200"/>

but it just doesn't work <_<...

Have any idea to fix it?

BTW Thanks for helping!!! :thumbup:
 
I think the duration is too long.
43200 = 720 minutes.

Can you explain a little bit more on the duration problem?
Like what doesn't work about it or...?
 
Last edited by a moderator:
the duration doesn't countdown... no mather the time.

If the script doesn't load (i.e. an error) the countdown works.
 
So, the script works...but you want the ring to have TIME?
Like a life ring?

PHP:
<attribute key="duration" value="14400"/> -- 240 Minutes(6 Hours)

Try lowering the Decay time.
 
Back
Top