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

Fix/Patch OnTarget(cid,creature) fix (return false in lua scripts)

Doggynub

LUA / C++
Joined
Sep 28, 2008
Messages
2,541
Reaction score
186
Well as you may know that this is bugged on tfs 0.4 so i looked around a bit in the code and it was clearly obvious it was messed out so here is the fix.



go to combat.cpp:

find
[cpp]
ReturnValue Combat::canTargetCreature[/cpp]

search in this function block for
[cpp]
if(deny)
return RET_NOERROR;[/cpp]
replace with [cpp]
if(deny)
return RET_YOUARENOTTHEOWNER;//just any thing that isn't related[/cpp]


now go to game.cpp:

find [cpp]bool Game::playerSetAttackedCreature[/cpp]

search in this function block for [cpp]
if(ret != RET_NOERROR)
{
player->sendCancelMessage(ret);
player->sendCancelTarget();
player->setAttackedCreature(NULL);
return false;
}[/cpp]

now replace with
[cpp]
if(ret != RET_NOERROR)
{
if(ret != RET_YOUARENOTTHEOWNER)
player->sendCancelMessage(ret);

player->sendCancelTarget();
player->setAttackedCreature(NULL);
return false;
}[/cpp]
 
Example:
Lua:
function onTarget(cid, target)
  if isMonster(target) and getCreatureName(target) == 'Demon' then
    return false
  end
  return true
end
With that code you cannot target (on battle list/right mouse + attack) monster with name 'Demon'.
 
Doggy should add this example in main post.
Ty Gesior
Example:
Lua:
function onTarget(cid, target)
  if isMonster(target) and getCreatureName(target) == 'Demon' then
    return false
  end
  return true
end
With that code you cannot target (on battle list/right mouse + attack) monster with name 'Demon'.
 
Back
Top