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

Solved Movement Add Attribute

HeberPcL

[PowerOT.com.br]
Joined
Aug 21, 2007
Messages
1,292
Reaction score
51
Location
Brazil
GitHub
heberpcl
Gentlemen, I can't get the movement add the Magic Level to the player using Script.

Any idea how to solve?

items.xml
PHP:
    <item id="2542" article="a" name="tempest shield">
        <attribute key="weight" value="5100"/>
        <attribute key="defense" value="30"/>
        <attribute key="weaponType" value="shield"/>
        <attribute key="magiclevelpoints" value="3"/>
    </item>

movements.xml
No script, add magic level 3.
PHP:
    <movevent type="Equip" itemid="2542" slot="shield" event="function" value="onEquipItem">
        <vocation id="1"/>
        <vocation id="5" showInDescription="1"/>
        <vocation id="2"/>
        <vocation id="6" showInDescription="1"/>
    </movevent>
    <movevent type="DeEquip" itemid="2542" slot="shield" event="function" value="onDeEquipItem"/>

Need work magic level with script.
PHP:
    <movevent event="Equip" itemid="2542" slot="shield" function="onEquipItem" script="EquipAlert.lua">
        <vocation id="1"/>
        <vocation id="5" showInDescription="1"/>
        <vocation id="2"/>
        <vocation id="6" showInDescription="1"/>
    </movevent>
    <movevent event="DeEquip" itemid="2542" slot="shield" function="onDeEquipItem" script="EquipAlert.lua"/>[/COLOR]
EquipAlert.lua Script
PHP:
function onEquip(cid, item, slot)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Equip Tempest Shield - Magic Level +3")
    return true
end
function onDeEquip(cid, item, slot)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "DeEquip Tempest Shield - Magic Level -3")
    return true
end
 
Last edited:
You can add the condition CONDITION_ATTRIBUTES with CONDITION_PARAM_STAT_MAGICLEVEL in the Lua script instead of in items.xml.
The xml attributes that only work when the items are added to movements don't work when you use a Lua script instead of function.
 
You can just set CONDITION_PARAM_TICKS to -1, so it will be forever and remove the condition with onDeEquip, it will have the same effect as in items.xml.
 
Code:
function="script" value="EquipAlert.lua"

Now your script will execute, but onEquip thing will stop work. You have to remove +3mlv from items.xml and move it to your script.

Like here:
Code:
local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_STAT_MAGICLEVEL, 3)
setConditionParam(condition, CONDITION_PARAM_TICKS, -1)
setConditionParam(condition, CONDITION_PARAM_SUBID, 12345)

function onEquip(cid, item, slot)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Equip Tempest Shield - Magic Level +3")
    doAddCondition(cid, condition)
    return true
end

function onDeEquip(cid, item, slot)
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "DeEquip Tempest Shield - Magic Level -3")
    doRemoveCondition(cid, CONDITION_ATTRIBUTES, 12345)
    return true
end
 
Last edited:
Back
Top