• 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 TFS 1.2 onAttack() or onEquip() - help

OperatorMopa

Member
Joined
Feb 10, 2014
Messages
127
Reaction score
6
Hello, I have a problem with my script.
I need to execute one lua function when character attacks creature OR character equips item with specified ID.
I've tried with onEquip function and it works ( lua function executes ) but there is a bug - getWeapon() in c++ returns 0 (as if there were NO WEAPON). I think that it's caused by onEquip(), becouse when im using same lua funcion as a creaturescript onLogin() it works perfect, and getWeapon() in c++ returns everything fine.

So i decided to try with something else - execute lua function when character target/attack creature, but there is no onAttack() function in TFS 1.2.

Do you know any other solutions instead of writing own cpp function ?
 
The problem is, I need player (attacker) parametr to execute lua function (for example even simple onSay every time when character target a creature) , but there is only target.

EDIT.
Ok, i used "self" - keep fighting :D

EDIT 2.
THANK YOU ! : )
 
Last edited:
The problem is, I need player (attacker) parametr to execute lua function (for example even simple onSay every time when character target a creature) , but there is only target.

EDIT.
Ok, i used "self" - keep fighting :D

EDIT 2.
THANK YOU ! : )
no problem
 
Back
Top