OTClient Problem use runes in yourself

gohamvsgoku

Member
Joined
Aug 21, 2017
Messages
150
Reaction score
6
i can't use runes on myself, i got this msg there.

You are not allowed to shoot directly on players.

how can i fix this?
 

xKrazyx

Old School
Joined
Oct 23, 2012
Messages
868
Solutions
6
Reaction score
602
I cant remember what I did to fix this but il get you started

game_interface interface.lua
Code:
function onUseWith(clickedWidget, mousePosition)
  if clickedWidget:getClassName() == 'UIGameMap' then
    local tile = clickedWidget:getTile(mousePosition)
    if tile then
      if selectedThing:isFluidContainer() or selectedThing:isMultiUse() then
        g_game.useWith(selectedThing, tile:getTopMultiUseThing())
      else
        g_game.useWith(selectedThing, tile:getTopUseThing())
      end
    end
  elseif clickedWidget:getClassName() == 'UIItem' and not clickedWidget:isVirtual() then
    g_game.useWith(selectedThing, clickedWidget:getItem())
  elseif clickedWidget:getClassName() == 'UICreatureButton' then
    local creature = clickedWidget:getCreature()
    if creature then
      g_game.useWith(selectedThing, creature)
    end
  end
end

in OTClient tile.cpp start at line 398, its one of the getTop~ lines.


Im guessing you dont want ppl to use hotkeys?
 
OP
G

gohamvsgoku

Member
Joined
Aug 21, 2017
Messages
150
Reaction score
6
I cant remember what I did to fix this but il get you started

game_interface interface.lua
Code:
function onUseWith(clickedWidget, mousePosition)
  if clickedWidget:getClassName() == 'UIGameMap' then
    local tile = clickedWidget:getTile(mousePosition)
    if tile then
      if selectedThing:isFluidContainer() or selectedThing:isMultiUse() then
        g_game.useWith(selectedThing, tile:getTopMultiUseThing())
      else
        g_game.useWith(selectedThing, tile:getTopUseThing())
      end
    end
  elseif clickedWidget:getClassName() == 'UIItem' and not clickedWidget:isVirtual() then
    g_game.useWith(selectedThing, clickedWidget:getItem())
  elseif clickedWidget:getClassName() == 'UICreatureButton' then
    local creature = clickedWidget:getCreature()
    if creature then
      g_game.useWith(selectedThing, creature)
    end
  end
end

in OTClient tile.cpp start at line 398, its one of the getTop~ lines.


Im guessing you dont want ppl to use hotkeys?

Yeah, i need fix this, because my server is old school... then i dont want ppl to use hotkeys.
but i have this problem ;s
 

Apollos

Dude who does stuff
Joined
Apr 22, 2009
Messages
764
Solutions
114
Reaction score
538
Location
United States
i can't use runes on myself, i got this msg there.

You are not allowed to shoot directly on players.

how can i fix this?
In tibia client when you use an item on a player it uses playerUseItemEx instead of playerUseWithCreature. If you are using a 7.92 and below server and this fix does work for you as well then let me know and I'll create a pull request on the otclient repo.

So if you replace this line:
otland/otclient (https://github.com/otland/otclient/blob/eb4fd24a311169fa4955506be9d2d13b1a92aacc/src/client/game.cpp#L865)

With this:
C++:
if(toThing->isCreature() && !toThing->isPlayer())

And replace this function:
otland/otclient (https://github.com/otland/otclient/blob/eb4fd24a311169fa4955506be9d2d13b1a92aacc/modules/game_interface/gameinterface.lua#L411)

With this:
Lua:
function onUseWith(clickedWidget, mousePosition)
  if clickedWidget:getClassName() == 'UIGameMap' then
    local tile = clickedWidget:getTile(mousePosition)
    if tile then
      if selectedThing:isFluidContainer() or selectedThing:isMultiUse() then
        g_game.useWith(selectedThing, tile:getTopMultiUseThing())
      else
        g_game.useWith(selectedThing, tile:getTopUseThing())
      end
    end
  elseif clickedWidget:getClassName() == 'UIItem' and not clickedWidget:isVirtual() then
    g_game.useWith(selectedThing, clickedWidget:getItem())
  elseif clickedWidget:getClassName() == 'UICreatureButton' then
    local creature = clickedWidget:getCreature()
    if creature then
      if creature:isPlayer() then
        g_game.useInventoryItemWith(selectedThing:getId(), creature)
      else
        g_game.useWith(selectedThing, creature)
      end
    end
  end
end
 

Demnish

Tibian Hero
Joined
Sep 28, 2011
Messages
389
Solutions
2
Reaction score
55
Location
Sweden
This was a very nice fix, please try and add it to the main branch of OTC.

Any idea on how to completely remove the "pick item for hotkey" feature?
Since in oldschool you couldn't hotkey items.
 
Top