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

How do I check players weapons?

Togu

Advanced OT User
Joined
Jun 22, 2018
Messages
308
Solutions
1
Reaction score
178
Location
Brazil
I need to check if a player is wielding two weapons (I'm using a dual wielding system) in OTClient but I didn't find any lua function like getPlayerWeapon.

Any tips?

Lua:
function onBaseSkillChange(localPlayer, id, baseLevel)
  setSkillBase('skillId'..id, localPlayer:getSkillLevel(id), baseLevel)
  setSkillValue('attackspeed', ((localPlayer:getSkillBaseLevel(4) - 8)/2 + 100) .. "%")
end

I want to change the attack speed value if player is wielding 2 weapons.

Edit:
Now I need to know how to check if some item in hand slot has attack attribute
 
Last edited:
This should get you started:

Lua:
local slot = CONST_SLOT_LEFT
local item = player:getSlotItem(slot)
if item then
    print(item:getName())
end
 
Check if items in both hand slots have attack attribute.
Now I just need to know how to check attack attribute in an item :D

Edit:
Code:
ERROR: protected lua call failed: LUA ERROR:
/game_skills/skills.lua:403: attempt to call method 'getSlotItem' (a nil value)
stack traceback:
    [C]: in function 'getSlotItem'
    /game_skills/skills.lua:403: in function 'onBaseSkillChange'
    /game_skills/skills.lua:399: in function 'onSkillChange'
    /game_skills/skills.lua:216: in function </game_skills/skills.lua:195>
ERROR: protected lua call failed: LUA ERROR:
/game_skills/skills.lua:403: attempt to call method 'getSlotItem' (a nil value)
stack traceback:
    [C]: in function 'getSlotItem'
    /game_skills/skills.lua:403: in function 'onBaseSkillChange'
    /game_skills/skills.lua:399: in function </game_skills/skills.lua:393>
ERROR: protected lua call failed: LUA ERROR:
/game_skills/skills.lua:403: attempt to call method 'getSlotItem' (a nil value)
stack traceback:
    [C]: in function 'getSlotItem'
    /game_skills/skills.lua:403: in function </game_skills/skills.lua:402>

Edit: solution how to get item
Code:
local item = localPlayer:getInventoryItem(InventorySlotLeft)
 
Last edited:
Wait. You are doing this in Otclient?
If you are using this Feature - True dual wielding for TFS 1.x you just edit bonus speed rate in config.lua.
But my OTClient is changed to show "Attack Speed = 100%" on Skills Window, the server sources are working, attack speed is changing. But in the client interface (where it shows the value to the player) its showing wrong (cause I developed this to show Attack Speed based on level and dexterity skill).
 
But my OTClient is changed to show "Attack Speed = 100%" on Skills Window, the server sources are working, attack speed is changing. But in the client interface (where it shows the value to the player) its showing wrong (cause I developed this to show Attack Speed based on level and dexterity skill).
You cannot check attribute of item in OTClient. Attributes are only visible as text when you 'look' at item, but whole 'look' action and text generation is done on server side.
On client side (OTClient) you can only get item ID (client ID, not items.xml ID), count and attributes from .dat file.
To show 'extra info' in client, you need to create your own 'network packet'. Make server send that packet with information about current attack speed (everytime it changes on server, change item in hands?) and make OTClient handle that packet and store somewhere information about attack speed of items.
You can also add that extra information to original tibia 'player info' packet, as extra uint32 after all skills and make OTClient read it.
 
Back
Top