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

Knight script

Ralfegor

New Member
Joined
Apr 6, 2008
Messages
297
Reaction score
1
i need this script when Knights equip a "item" lets say blessed stake (id = 5942) on ring slot it transform to Gold ring (id of gold ring is 2179)i tryed this ... but doesnt do anything when i equip


function onEquip(cid, item, slot)
doSendMagicEffect(frompos, 14)
doTransformItem(uid,2179)
end
 
Code:
	function onEquip(cid, item, slot) 
		if item.uid == 5942 and getPlayerVocation(cid) == 4 or getPlayerVocation(cid) == 8 then
			doSendMagicEffect(frompos, 14)
			doTransformItem(cid, 2179)
			doDecayItem(item.uid)
	end

	function onDeEquip(cid, item, slot)
		if item.uid == 5942 and getPlayerVocation(cid) == 4 or getPlayerVocation(cid) == 8 then
			doSendMagicEffect(frompos, 14)
			doTransformItem(cid, 5942)
			doDecayItem(item.uid)
	end
Save it as: knight.lua

I didn't test it, but I think it gonna work.

Code:
<movevent event="Equip" itemid="5942" function="onEquipItem" slot="ring" script="knight.lua"/>	
<movevent event="DeEquip" itemid="5942" function="onDeEquipItem" slot="ring" script="knight.lua"/>
 
First let's set blessed wooden stake to be a ring, because you can't wear it lol :p

Add this to blessed wooden stake in items.xml:
Code:
<attribute key="slotType" value="ring"/>

Then we should make transform of item. F**k lua, let's make this in items.xml! Add this to blessed wooden stake in items.xml:
Code:
<attribute key="transformEquipTo" value="2179"/>

Yeah, now It will transform ring. But if you take back golden ring from ring slot, it won't back to blessed wooden stake ;/ what we shall do? Add this line to golden ring in items.xml:
Code:
<attribute key="transformDeEquipTo" value="5942"/>

Yea, now it should work, but WTF?! Where are movements lines? Here you are:
Code:
	<movevent event="Equip" itemid="5942" slot="ring" function="onEquipItem"/>
	<movevent event="Equip" itemid="2179" slot="ring" function="onEquipItem"/>
	<movevent event="DeEquip" itemid="2179" slot="ring" function="onDeEquipItem"/>

Why 3 lines? There are just two items! It's because to prevent staying item in equipped state (then players can wear a ring, then take it back, and effect will be still working etc.

Ofc you can add some attribute effect to SECOND ITEM (to golden ring), like managain (with manaticks) or speed or skill points, if you want a list of attributes just take a look in items.cpp in source.

If you want to make item only for knights, edit movements lines to:
Code:
	<movevent event="Equip" itemid="5942" slot="ring" function="onEquipItem"/>
		<vocation name="Knight"/>
		<vocation name="Elite Knight" showInDescription="0"/>
	<movevent event="Equip" itemid="2179" slot="ring" function="onEquipItem"/>
		<vocation name="Knight"/>
		<vocation name="Elite Knight" showInDescription="0"/>
	<movevent event="DeEquip" itemid="2179" slot="ring" function="onDeEquipItem"/>

Regards,
Hermes
 
there is 1 thing is not working :/ all vocation can use the blessed stake :(

<movevent event="Equip" itemid="5942" slot="ring" function="onEquipItem"/>
<vocation name="Knight"/>
<vocation name="Elite Knight" showInDescription="0"/>
<movevent event="Equip" itemid="2179" slot="ring" function="onEquipItem"/>
<vocation name="Knight"/>
<vocation name="Elite Knight" showInDescription="0"/>

what do i have to do? make a script? can u help me
 
Last edited:
Change
Code:
if item.uid == 5942 and getPlayerVocation(cid) == 4 or getPlayerVocation(cid) == 8 then

By
Code:
if item.uid == 5942 and isKnight(cid) == TRUE then
 
@up
Lol, why do you want to use LUA when those things are alot easier in xml? Haha! Wasting of time! Wasting of space! ROTFL! When we can do this all in LUA why development made this all xml shit?

@topic
Aff, just forgotten to close movevent tags :p

Code:
<movevent event="Equip" itemid="5942" slot="ring" function="onEquipItem"/>
<vocation name="Knight"/>
<vocation name="Elite Knight" showInDescription="0"/>
</movevent>
<movevent event="Equip" itemid="2179" slot="ring" function="onEquipItem"/>
<vocation name="Knight"/>
<vocation name="Elite Knight" showInDescription="0"/>
</movevent>
<movevent event="DeEquip" itemid="2179" slot="ring" function="onDeEquipItem"/>

Replace those three lines I have posted with these up :>
 
Hermes if i put that the server display a error :/ i want to do it on xml now xD

The Forgotten Server - Version 0.2rc10 (Mystic Spirit).
A server developed by Talaturen, Kiper, Kornholijo, Jonern, Lithium & slawkens.
Visit our forum for updates, support and resources: http://otland.net/.

>> Loading config
>> Loading RSA key
>> Testing SQL connection... SqLite.
>> Loading bans
>> Loading vocations
>> Loading commands
>> Loading items
>> Loading script systems
data/movements/movements.xml:10: parser error : Opening and ending tag mismatch:
movements line 2 and movevent
</movevent>
^
data/movements/movements.xml:11: parser error : Extra content at the end of the
document
<movevent event="Equip" itemid="2179" slot="ring" function="onEquipItem"/>
^
Warning: [BaseEvents::loadFromXml] Can not open movements.xml
> ERROR: Unable to load MoveEvents!
 
<?xml version="1.0" encoding="UTF-8"?>
<movements>

<movevent event="Equip" itemid="5480" slot="ring" function="onEquipItem"/>
<movevent event="DeEquip" itemid="5480" slot="ring" function="onDeEquipItem"/>

<movevent event="Equip" itemid="2656" function="onEquipItem" slot="armor" script="bluerobe.lua"/>
<movevent event="DeEquip" itemid="2656" function="onDeEquipItem" slot="armor" script="bluerobe.lua"/>
<movevent event="Equip" itemid="7891" slot="feet" function="onEquipItem"/>
<movevent event="DeEquip" itemid="7891" slot="feet" function="onDeEquipItem"/>

<movevent event="Equip" itemid="5942" slot="ring" function="onEquipItem"/>
<vocation name="Knight"/>
<vocation name="Elite Knight" showInDescription="0"/>
</movements>
<movevent event="Equip" itemid="2179" slot="ring" function="onEquipItem"/>
<vocation name="Knight"/>
<vocation name="Elite Knight" showInDescription="0"/>
</movements>
<movevent event="DeEquip" itemid="2179" slot="ring" function="onDeEquipItem"/>


<movevent event="Equip" itemid="2139" function="onEquipItem" slot="necklace" script="chaosbangle.lua"/>
<movevent event="DeEquip" itemid="2139" function="onDeEquipItem" slot="necklace" script="chaosbangle.lua"/>
 
ok now im trying now with the Helmet of the ancients
its working tnx to u Hermes but still all vocations can use it

I want the ancient helmet with out gem which id is 2342 to transform in helmet of the ancients with the gem = 2343

so here are my items.xml

<item id="2342" article="a" name="helmet of the ancients">
<attribute key="description" value="Knights should power again the gem, this helmet increase knights +35 sword, +35 axe, +35 club and +35 shielding."/>
<attribute key="weight" value="2760"/>
<attribute key="armor" value="8"/>
<attribute key="slotType" value="head"/>
<attribute key="transformEquipTo" value="2343"/>
</item>
<item id="2343" article="a" name="helmet of the ancients">
<attribute key="description" value="Many mighty priests of Tibia have blessed this helmet"/>
<attribute key="weight" value="2000"/>
<attribute key="armor" value="10"/>
<attribute key="slotType" value="head"/>
<attribute key="skillSword" value="35" />
<attribute key="skillAxe" value="35" />
<attribute key="skillClub" value="35" />
<attribute key="skillShield" value="35" />
<attribute key="transformDeEquipTo" value="2342"/>
</item>

this is my movevent

<movevent event="Equip" itemid="2342" slot="head" function="onEquipItem"/>
<vocation name="Knight"/>
<vocation name="Elite Knight" showInDescription="0"/>
</movements>
<movevent event="Equip" itemid="2343" slot="head" function="onEquipItem"/>
<vocation name="Knight"/>
<vocation name="Elite Knight" showInDescription="0"/>
</movements>
<movevent event="DeEquip" itemid="2343" slot="head" function="onDeEquipItem"/>

if i put the movevent like that the server will display a error: Extra content at the end of the document

i tried without closing the </movements>

<movevent event="Equip" itemid="2342" slot="head" function="onEquipItem"/>
<vocation name="Knight"/>
<vocation name="Elite Knight" showInDescription="0"/>
<movevent event="Equip" itemid="2343" slot="head" function="onEquipItem"/>
<vocation name="Knight"/>
<vocation name="Elite Knight" showInDescription="0"/>
<movevent event="DeEquip" itemid="2343" slot="head" function="onDeEquipItem"/>

and the server don't show any error but all vocations can use it anyway :/ so doesn't work neither

can u check if i have any errors?
 
LOL, you closed this with a wrong tag -.-!

</movevent>

instead of

</movements>

..

so:

Code:
<movevent event="Equip" itemid="5942" slot="ring" function="onEquipItem"/>
<vocation name="Knight"/>
<vocation name="Elite Knight" showInDescription="0"/>
</movevent>
<movevent event="Equip" itemid="2179" slot="ring" function="onEquipItem"/>
<vocation name="Knight"/>
<vocation name="Elite Knight" showInDescription="0"/>
</movevent>
<movevent event="DeEquip" itemid="2179" slot="ring" function="onDeEquipItem"/>
 
<movevent event="Equip" itemid="2342" slot="head" function="onEquipItem"/>
<vocation name="Knight"/>
<vocation name="Elite Knight" showInDescription="0"/>
</movevent>
<movevent event="Equip" itemid="2343" slot="head" function="onEquipItem"/>
<vocation name="Knight"/>
<vocation name="Elite Knight" showInDescription="0"/>
</movevent>
<movevent event="DeEquip" itemid="2343" slot="head" function="onDeEquipItem"/>

lol still displaying the error :/ Opening and editing tag mismatch: movevent line 2 and movevent
</movevent>
-----------^
the "----" thats not what goes it just a space and ^
 
XML basics...
Code:
<movevent event="Equip" itemid="2342" slot="head" function="onEquipItem"[COLOR="Red"]/[/COLOR]>
<vocation name="Knight"/>
<vocation name="Elite Knight" showInDescription="0"/>
</movevent>
 
Back
Top