• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Dualwield Movement Script

Codinablack

Dreamer
Content Editor
Joined
Dec 26, 2013
Messages
2,122
Solutions
14
Reaction score
1,514
Location
USA
GitHub
Codinablack
I tried making an item that would be able to be dualwielded if you were a certain vocation...

Code:
function onEquip(cid, item, slot)
  if(getPlayerVocation(cid)) == 8 then
  getItemAttribute(2410, "dualwield")
  doItemSetAttribute(2410, "dualwield", 1)
  end
return true
end 

function onDeEquip(cid, item, slot)
  if(getPlayerVocation(cid)) == 8 then
  getItemAttribute(2410, "dualwield")
  doItemSetAttribute(2410, "dualwield", -1)
  end
return true
end

I got this error
Code:
[18/1/2014 3:56:25] [Error - MoveEvents Interface]
[18/1/2014 3:56:25] data/movements/scripts/dualwield.lua:onDeEquip
[18/1/2014 3:56:25] Description:
[18/1/2014 3:56:26] (LuaInterface::luaDoItemSetAttribute) Item not found

I am using

[18/1/2014 3:54:55] The OTX Server Version: (2.51 - SE - 1549) - Codename: (Necron)

Can someone show me how to properly do this? Also if you would please, I don't want to have to do this for every item, can I have it check what item its being called to be used on? It is already defined in the movements.xml


Code:
    <movevent type="Equip" itemid="2410" slot="hand" event="script" value="dualwield.lua"/>
    <movevent type="DeEquip" itemid="2410" slot="hand" event="script" value="dualwield.lua"/>

Any and all help would be much appreciated. Thank you very much!
 
Tried like this....

Code:
function onEquip(cid, item, slot)

  if (getPlayerVocation(cid)) == 8 then
  if (getItemAttribute(item.uid, 'dualwield', -1)) then
    doItemSetAttribute(item.uid, 'dualwield', 1)
  end
return true
end 
end



function onDeEquip(cid, item, slot)
  if (getPlayerVocation(cid)) == 8 then
  if (getItemAttribute(item.uid, 'dualwield', 1)) then
    doItemSetAttribute(item.uid, 'dualwield', -1)
  end
return true
end
end

Still get this....

Code:
[21/1/2014 11:5:33] [Error - MoveEvents Interface]
[21/1/2014 11:5:33] data/movements/scripts/dualwield.lua:onEquip
[21/1/2014 11:5:33] Description:
[21/1/2014 11:5:33] (LuaInterface::luaGetItemAttribute) Item not found

[21/1/2014 11:5:33] [Error - MoveEvents Interface]
[21/1/2014 11:5:33] data/movements/scripts/dualwield.lua:onEquip
[21/1/2014 11:5:33] Description:
[21/1/2014 11:5:33] (LuaInterface::luaGetItemAttribute) Item not found

[21/1/2014 11:5:33] [Error - MoveEvents Interface]
[21/1/2014 11:5:33] data/movements/scripts/dualwield.lua:onEquip
[21/1/2014 11:5:33] Description:
[21/1/2014 11:5:33] (LuaInterface::luaGetItemAttribute) Item not found

Man I have been trying to get this to work for a week now, tried soooooo many different ways.... I really appreciate you trying to help me.... I am wondering though even if script runs without errors will it still do what I want it to do? Will it add the attribute to the weapon so that only certain vocs can dualwield it?
 
Code:
function onEquip(cid, item, slot)

  if getPlayerVocation(cid) == 8 then
  if getItemAttribute(item.uid, 'dualwield') == -1 then
    doItemSetAttribute(item.uid, 'dualwield', 1)
  end
return true
end
end



function onDeEquip(cid, item, slot)
  if getPlayerVocation(cid) == 8 then
  if getItemAttribute(item.uid, 'dualwield') == 1 then
    doItemSetAttribute(item.uid, 'dualwield', -1)
  end
return true
end
end
 
[22/1/2014 12:49:31] [Error - MoveEvents Interface]
[22/1/2014 12:49:31] data/movements/scripts/dualwield.lua:eek:nDeEquip
[22/1/2014 12:49:31] Description:
[22/1/2014 12:49:31] (LuaInterface::luaGetItemAttribute) Item not found

Still doesn't work... :(
 
getItemAttribute(item.uid, 'dualwield') == 1
->
getItemAttribute(item.uid, 'dualwield') ~= nil
getItemAttribute(item.uid, 'dualwield') == -1
->
getItemAttribute(item.uid, 'dualwield') == nil
? :)
 
getItemAttribute(item.uid, 'dualwield') == 1
->
getItemAttribute(item.uid, 'dualwield') ~= nil
getItemAttribute(item.uid, 'dualwield') == -1
->
getItemAttribute(item.uid, 'dualwield') == nil
? :)

Still not working... doesn't return error this time tho... are those in the exact order>?
 
Try to debug it with this code. If after deEquipping your character says item ID, or says sth after equipping - then problem is with your doItemSetAttribute(item.uid, 'dualwield', 1)
Becouse error occurs only in onDeEquip you have to check for: Is your onEquip work properly?
After you do that, tell us results.


Code:
function onEquip(cid, item, slot)
    local text = "" --debug
    if getPlayerVocation(cid) == 8 then
        if getItemAttribute(item.uid, 'dualwield') == -1 then
            if doItemSetAttribute(item.uid, 'dualwield', 1) == true then --debug
                text = "onEquip work corectly!" --debug
            else
                text = "doItemSetAttribute(item.uid, 'dualwield', 1) is bugged!" --debug
            end
        else
            text = "getItemAttribute(item.uid, 'dualwield') is bugged!" --debug
        end
    else
        text = "Bug with player vocation!" --debug
    end
    doCreatureSay(cid, text, 1) --debug
    return true
end



function onDeEquip(cid, item, slot)
    doCreatureSay(cid, item.itemid, 1) --debug
    return true
end
 
Last edited:
The error item not found can be solved this way ... add after the function [ onDeEquip / onEquip ]
PHP:
if (item.uid < 70001 ) and (item.uid > 0 ) or item.uid = nil   then
       return false
end
that usualy hapens when u remove it, because when u equipe the item will stay there with the same uid,
but when u remove the uid of the item change ( avoid the old bug [ player cloning items ] )
the same hapens when u drop a item on the ground or move a item on the ground its UID change!

AND for your script i dont undestand what you really want ?
dual wielding ? DID u tryed to equipt 2 weapons, tell us what hapens, because most of all ot server still allow you to use 2 weapons, what the global dont.
DUAL blablabla GOOD so what, what is next it !
 
Back
Top