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
Alarm
Author Message
b4db0yx Offline
Amber Basilisk
*

Posts: 34
Joined: Dec 2011
Reputation: 0
Version: 1.4.3.143
Post: #1
Alarm

I would like to make a script that automatically answers to a PM from certain persons or when it sees certain persons (GMs) writing in chat. Could anyone help me with the line of script needed to do that?

Also, how could I make a script to detect a debuff, such as Anchor?
04-19-2014 15:03 PM
Find all posts by this user Quote this message in a reply
eustach3 Offline
VIP Member
***

Posts: 324
Joined: Sep 2011
Reputation: 133
Version: 1.4.3.143
Post: #2
RE: Alarm

For the first problem with pm answering, amiroo made a very nice plugin for it:
http://forum.l2tower.eu/thread-automatic-answer-on-pms
----------------
For the second thing, you need to make a script or plugin, i prefer plugin.
It will be something like this:
Code:
debufflist = {22,222,2222,222222);
for k,w in pairs(debufflist) do
if GetMe():GotBuff(w) then
----whatever you want to do when you get debuffed
end;
end;
04-19-2014 19:02 PM
Find all posts by this user Quote this message in a reply
b4db0yx Offline
Amber Basilisk
*

Posts: 34
Joined: Dec 2011
Reputation: 0
Version: 1.4.3.143
Post: #3
RE: Alarm

I assume the debufflist contains the ID of any debuff I want, right?
If so, how can I find a list of those ids? I can't exactly use anchor on myself and record it. GM seems to use it to detect players botting Smile.

Last thing: what is the code for ALL Chat (ex: function OnChatUserMessage(chatType, nick, msg) chatType = ?). I know that chatType = 2 is the PM.
(This post was last modified: 04-20-2014 03:03 AM by b4db0yx.)
04-20-2014 02:59 AM
Find all posts by this user Quote this message in a reply
eustach3 Offline
VIP Member
***

Posts: 324
Joined: Sep 2011
Reputation: 133
Version: 1.4.3.143
Post: #4
RE: Alarm

Yes it must be set the id, it`s simple go to your tower folder like this:
X:\l2tower\config\X__Games_Lineage_2_system_\skills.txt, then use ctrl + f to search what you need, i had a list but not on this computer sadly.

For the chatType question, honestly i dont know how these numbers are, you can find them on forum but you can simply do it like this:
Code:
if (chatType == L2ChatType.CHAT_PUBLIC)

other chatType are :
L2ChatType.CHAT_ALLY
L2ChatType.CHAT_CLAN
L2ChatType.CHAT_CMD
L2ChatType.CHAT_CMD2
L2ChatType.CHAT_HERO
L2ChatType.CHAT_INTERNAL
L2ChatType.CHAT_PARTY
L2ChatType.CHAT_PM
L2ChatType.CHAT_SHOUT
L2ChatType.CHAT_TRADE
04-20-2014 15:06 PM
Find all posts by this user Quote this message in a reply
b4db0yx Offline
Amber Basilisk
*

Posts: 34
Joined: Dec 2011
Reputation: 0
Version: 1.4.3.143
Post: #5
RE: Alarm

Thank you eustach3. I tried putting L2ChatType.CHAT_PUBLIC (or any other one you typed) but for some reason it crashes my game. If I put numbers instead, it works. Do you know where I could find a library with all functions and stuff?
04-20-2014 16:59 PM
Find all posts by this user Quote this message in a reply
eustach3 Offline
VIP Member
***

Posts: 324
Joined: Sep 2011
Reputation: 133
Version: 1.4.3.143
Post: #6
RE: Alarm

Hmm, must be something wrong, it should have work, try also like this:
    LUA Programming
if chatType.CHAT_PARTY then 
----what you wish



Anyway, if you get crash its not a big deal chatType == 2 is for PM, chatType ==3 is for party i guess you have to play with the others and test if you get crash.
As for the second question.. you can find them by pressing the Editor View button in l2tower, you will find support for lua scripting.

For functions available only in plugin look here:
    LUA Programming
function OnCreate()
	--Event called after plugin is loaded, you should setup here any default vars,
	--and register to any commands or [/b]other things.
end;
 
function OnDestroy()
	--Event called before plugin gets destroy, make sure you kill any threads what you created.
end;
 
function OnTick()
	--Event called very 100ms, you can use it to check anything, don't put lot of code here.
	--Event is called always, some data maybe unavaible when no user is logged in.
	--Also calling some functions can make game crash (or force you to diconnect).
end;
 
function OnLTick()
	--Event called very 100ms, you can use it to check anything, don't put lot of code here.
	--This event is called only if user is loged in.
end;
 
function OnTick500ms()
	--Event called very 500ms, you can use it to check anything, don't put lot of code here.
	--Event is called always, some data maybe unavaible when no user is logged in.
	--Also calling some functions can make game crash (or force you to diconnect).
end;
 
function OnLTick500ms()
	--Event called very 500ms, you can use it to check anything, don't put lot of code here.
	--This event is called only if user is loged in.
end;
 
function OnTick1s()
	--Event called very 1s, you can use it to check anything, don't put lot of code here.
	--Event is called always, some data maybe unavaible when no user is logged in.
	--Also calling some functions can make game crash (or force you to diconnect).
end;
 
function OnLTick1s()
	--Event called very 1s, you can use it to check anything, don't put lot of code here.
	--This event is called only if user is loged in.
end;
 
function OnLogin(username)
	--Event called after user login	
end;
 
function OnLogout()
	--Event called before user logout
end;
 
function OnAttackCanceled(user)
	--Event called when some player/npc cancel his attack.
end;
 
function OnAttack(user, target)
	--Event called when some player/npc attack other.
end;
 
function OnAttacked(user, target)
	--Event called when some player/npc attacked other.
end;
 
function OnAutoAttackStart(user, target)
	--Event called when some player/npc activate auto attack.
end;
 
function OnUserInfo(user)
	--Event called when we get some info about ourself
end;
 
function OnCharInfo(player)
	--Event called when we get some info about someother players (he spawn)
end;
 
function OnNpcInfo(npc)
	--Event called when we get some info about some npc/monster (he spawn)
end;
 
function OnDeleteUser(user)
	--Event called when some npc/player/user dissaper from map.
end;
 
function OnDie(user, spoiled)
	--Event called when some npc/player/user die.
end;
 
function OnRevive(user)
	--Event called when some npc/player/user revive.
end;
 
function OnMagicSkillCanceled(user)
	--Event called when some npc/player/user cancel magic skill.
end;
 
function OnMagicSkillLaunched(user, target, skillId)
	--Event called when some npc/player/user casted magic skill on someone other. 
	--For AOE skills this event will be called for every target.
end;
 
function OnMagicSkillUse(user, target, skillId)
	--Event called when some npc/player/user start cast magic skill on someone other. 
end;
 
function OnTargetSelected(user, target)
	--Event called when some npc/player/user select target.
end;
 
function OnMyTargetSelected(target)
	--Event called when our target got change.
end;
 
function OnTargetUnselected(user)
	--Event called when some npc/player/we cancel target.
end;
 
function OnChangeMoveType(user)
	--Event called when some npc/player/we change move type from walk to run for example.
end;
 
function OnChangeWaitType(user)
	--Event called when some npc/player/we change wait type from sit to stand for example.
end;
 
function OnChatUserMessage(chatType, nick, msg)
	--Event called someone say something on chat. chatType is a EChatType enum.
end;
 
function OnChatSystemMessage(id, msg)
	--Event called some system message show up on chat (id - integer, msg - string).
end;

(This post was last modified: 04-20-2014 19:04 PM by eustach3.)
04-20-2014 19:03 PM
Find all posts by this user Quote this message in a reply
b4db0yx Offline
Amber Basilisk
*

Posts: 34
Joined: Dec 2011
Reputation: 0
Version: 1.4.3.143
Post: #7
RE: Alarm

(I am farming 1 single mob with 1 min respawn in a safe zone)

Thank you again eustache. I played with the numbers and 0 is all chat. It doesn't crash when I use 0 instead. I made it so that when a player types something on all chat (usually the GM - I have a list of names), it responds.

I wanted also to make a plugin that makes the player move randomly after killing the mob, but if I put in in OnLTick it crashes my game and every 100/500/1000 ms is too fast. I think I will use OnTargetUnselected(user) and make it move afterwards.

Lastly, if I use a MoveTo command in a function like OnTargetUnselected, it crashes my game. How can I make the character move upon deselection ?
(This post was last modified: 04-21-2014 17:59 PM by b4db0yx.)
04-21-2014 16:23 PM
Find all posts by this user Quote this message in a reply
eustach3 Offline
VIP Member
***

Posts: 324
Joined: Sep 2011
Reputation: 133
Version: 1.4.3.143
Post: #8
RE: Alarm

We can use MoveToNoWait for that
04-21-2014 18:44 PM
Find all posts by this user Quote this message in a reply
b4db0yx Offline
Amber Basilisk
*

Posts: 34
Joined: Dec 2011
Reputation: 0
Version: 1.4.3.143
Post: #9
RE: Alarm

I want to move more times than once. If I use multiple move commands with that it just goes straight to the last one after processing the code. Also, if I try to use sleep in between, it freezes the game and does nothing.

Code:
function GetRandomElement()
    return math.ceil(math.random(11))
end;

function OnTargetUnselected(user)
    if (aiureaMove == true) then
        --[[GGG=GetRandomElement
        MoveToNoWait(coordX[GGG], coordY[GGG], coordZ[GGG]);
        Sleep(2346);
        GGG=GetRandomElement
        MoveToNoWait(coordX[GGG], coordY[GGG], coordZ[GGG]);
        Sleep(1400);
        GGG=GetRandomElement
        MoveToNoWait(coordX[GGG], coordY[GGG], coordZ[GGG]);
        Sleep(2000);
        GGG=GetRandomElement
        MoveToNoWait(coordX[GGG], coordY[GGG], coordZ[GGG]);]]--
        MoveToNoWait(-34323, 128851, -3358);
        Sleep(3000);
        MoveToNoWait(-34082, 129017, -3428);
    end;
end;

---
Also, how can I make a plugin for using potions but with delay between them? If I use Sleep(x) in a plugin it freezes the game. If I don't put any delay, they spam so fast that only the first and last are used.

Code:
function OnChatUserMessage(chatType, nick, msg)
    if chatType == 2 and nick == GetMe():GetName() and string.lower(msg) == "rebuff" then
        UseItem(1062); -- Haste Potion
        Sleep(350);
        UseItem(726); -- Mana Drug
        Sleep(350);
        UseItem(65); -- Red Potion
        Sleep(350);
        UseItem(733); -- Endeavor Potion
        Sleep(500);
        UseItem(3929); -- L2Day - Greater Acumen Scroll
        Sleep(500);
        UseItem(3931); -- L2Day - Agility Scroll
    end;
end;
(This post was last modified: 04-22-2014 02:13 AM by b4db0yx.)
04-21-2014 19:44 PM
Find all posts by this user Quote this message in a reply
eustach3 Offline
VIP Member
***

Posts: 324
Joined: Sep 2011
Reputation: 133
Version: 1.4.3.143
Post: #10
RE: Alarm

Ok, im sure there is another way to do it but im to sleepy now.. You cannot use certain features during plugin: Sleep, MoveTo , etc. like you use them in a script.
Try this one:
    LUA Programming
usepots = coroutine.wrap ( function()
 UseItem(1062); -- Haste Potion
 Sleep(350);
 UseItem(726); -- Mana Drug
 Sleep(350);
 UseItem(65); -- Red Potion
 Sleep(350);
 UseItem(733); -- Endeavor Potion
 Sleep(500);
 UseItem(3929); -- L2Day - Greater Acumen Scroll
 Sleep(500);
 UseItem(3931); -- L2Day - Agility Scroll
 coroutine.yield());
 
function OnChatUserMessage(chatType, nick, msg)
 if chatType == 2 and nick == GetMe():GetName() and string.lower(msg) == "rebuff" then
 this:StartThread("usepots");
 end;
end;



Its the same for your first script with MoveToNoWait, if you have difficulties with it let me know.
04-22-2014 03:09 AM
Find all posts by this user Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Bot Alarm !! meridoX 0 2,251 12-20-2011 18:07 PM
Last Post: meridoX



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