L2Tower Discord Let's keep the community alive with discord. Discussions about plugins and scripts L2Tower Discord

Post Reply 
 
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GetTarget() don't return monsters target ID
Author Message
Xerovator Offline
VIP Member
***

Posts: 2
Joined: Oct 2024
Reputation: 0
Version: 1.4.3.143
Post: #1
GetTarget() don't return monsters target ID

Hi Colegues!
Need help - I'm trying to create function to count monsters targeting (killing) me.
Needed for "train".

It's look like comparing ( monster:GetTarget() == myID ) never working ;(, Always "False".
I alwaiys receive "0" for monster target objectId..
Why?
Where is my fault?
Where is "My ID" in the monsters target?

Code:
me = GetMe();
myID = me:GetId();

targetedMobID = me:GetTarget()
Mob=GetUserById(targetedMobID)
MobTarget = Mob:GetTarget();


ShowToClient("#", tostring(os.date("%X")), L2ChatType.CHAT_HERO);
L2ChatType.CHAT_HERO);
ShowToClient("#", "myID " .. tostring(myID), L2ChatType.CHAT_HERO);
ShowToClient("#", "myTarget " .. targetedMobID, L2ChatType.CHAT_HERO);
ShowToClient("#", "MobID " .. Mob:GetId(), L2ChatType.CHAT_HERO);
ShowToClient("#", "MobTarget " ..  tostring(MobTarget), L2ChatType.CHAT_HERO);
ShowToClient("-", "-------------------------");

proof


Attached File(s) Thumbnail(s)
   

.lua  MobsTargettingMe.lua (Size: 1.82 KB / Downloads: 4)
(This post was last modified: 11-17-2024 08:50 AM by Xerovator.)
11-15-2024 17:53 PM
Find all posts by this user Quote this message in a reply
JennaDeh Offline
Administrator
*******

Posts: 38
Joined: Apr 2018
Reputation: 1001
Version: 1.4.3.143
Post: #2
RE: GetTarget() don't return monster target ID

You need object ID or ID npc? Look at this..
    LUA Programming
target:GetNpcId()

is target Display ID
    LUA Programming
target:GetId()

is target Object ID

FarmAI Plugin
(This post was last modified: 11-16-2024 15:16 PM by JennaDeh.)
11-16-2024 15:10 PM
Find all posts by this user Quote this message in a reply
Xerovator Offline
VIP Member
***

Posts: 2
Joined: Oct 2024
Reputation: 0
Version: 1.4.3.143
Post: #3
RE: GetTarget() don't return monster target ID

Is it possible to know which monster take me in target?
as i understand - I was looking my {objectID} in monster:GetTarget()
But it always == 0.

My steps:
1. Get My {objectID}
MyID = GetMe():GetId() -- return objectID == 11111111

2. take a random aggressive monster, move to it. Monster "take me in to Target". In his "User info" I'd like to see {MyID}

monster:GetTarget() - is in this plase My objectID ?


Code:
monsters = GetMonsterList();
for monster in monsters.list do
    ShowToClient("#", "monster:GetTarget " .. monster:GetTarget())  -- return 0
    --ShowToClient("#", "monster:GetTarget " .. monster:GetTarget():GetId()) -- return "Lua error (Script not valid) - ***: attempt to index a number value"
end;
(This post was last modified: 11-16-2024 18:23 PM by Xerovator.)
11-16-2024 18:22 PM
Find all posts by this user Quote this message in a reply
JennaDeh Offline
Administrator
*******

Posts: 38
Joined: Apr 2018
Reputation: 1001
Version: 1.4.3.143
Post: #4
RE: GetTarget() don't return monster target ID

Check plugin function...
    LUA Programming
function OnTargetSelected(user, target)
	ShowToClient("Plugin", "OnTargetSelected called");
end


FarmAI Plugin
(This post was last modified: 11-16-2024 20:00 PM by JennaDeh.)
11-16-2024 20:00 PM
Find all posts by this user Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  bot will target but not attack. elvis8925 3 3,794 04-09-2018 00:19 AM
Last Post: elvis8925
Star Remove Target canaldextiger 8 4,873 02-10-2018 22:19 PM
Last Post: canaldextiger
Information How to get 'PARTY MEMBER TARGET'? Caaioc 9 6,808 01-24-2016 09:57 AM
Last Post: TheQQmaster
  target for self buff manuel16007 1 3,265 01-22-2016 16:31 PM
Last Post: TheQQmaster
Rainbow Help to cancel target budarox 8 6,002 08-14-2015 06:31 AM
Last Post: budarox
  Change title to user's target vaskouf 4 4,252 06-28-2015 09:25 AM
Last Post: Vinter
  Clear target after kill mobs astalavista 0 2,975 06-07-2015 18:46 PM
Last Post: astalavista
  Target fix MoonSeed 5 7,450 03-23-2015 09:51 AM
Last Post: Fox
  How to remove the hold target? supera 5 4,369 12-26-2014 21:13 PM
Last Post: supera
  Fix target Tornet 6 5,218 11-22-2014 00:55 AM
Last Post: soul2eat



User(s) browsing this thread: 1 Guest(s)