Lineage 2 Tower Forum

Full Version: Script that read the chat messages
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys.
Is there a way to create a script that reads the chat messages?
I am playing a server that have a captcha validation by random time... But when captcha appears, I get a message from system like this: "You have 90 seconds to choose the correct..."

So I want to create a script that when this dialog appears, a alert sound starts... With this I can hear the alert and click in the correct alternative.


Thx.
idk if correct is code, dont have even normal editor, to make work u need:
1. add sound with name alarm.wav in tower temp folder
2. edit string bwllow in code, it will search a part of text, so u dont need full text
3. type ig /alarm

if u know bit lua u will make it work gl

    LUA Programming
function OnCreate()
	this:RegisterCommand("alarm", CommandChatType.CHAT_ALLY, CommandAccessLevel.ACCESS_ME);
	AlarmStatus = false;
	LastAlarmTime = 0;
	LastAlarmT = 10;
 
	CheckSound = GetDir() .. "\\temp\\alarm.wav";
end;
 
 
 
function OnCommand_alarm(vCommandChatType, vNick, vCommandParam)
	if (AlarmStatus == false) then
		AlarmStatus = true;
		ShowToClient(tostring(os.date("%X")),"Alarm Plugin ON",3 );
	else
		AlarmStatus = false;
		PeopleInPartyCount = nil
		ShowToClient(tostring(os.date("%X")),"Alarm Plugin OFF",3);
	end;
end;
 
 
function FindSubStringInString(thesub,thestring) 
	for x = 1, 1 + string.len(thestring)-string.len(thesub),1 do
		if (string.sub(thestring,x,x+string.len(thesub)-1) == thesub) then
			return true;
		end;
	end;
	return false;
end;
 
 
function OnChatUserMessage(chatType, nick, msg)
	if (AlarmStatus == true) then
		Message = string.lower(msg); -- Converts message to lower case letters.
		Message = Message:gsub("^%s*(.-)%s*$", "%1"); -- Trimming message of spaces on start.
		if FindSubStringInString("ur string to search",Message) then-- edit here
			if (LastAlarmTime + LastAlarmT < os.time()) then
				PlaySound(CheckSound);
			end;
		end;
	end;
end;

(08-13-2016 11:17 AM)TheQQmaster Wrote: [ -> ]idk if correct is code, dont have even normal editor, to make work u need:
1. add sound with name alarm.wav in tower temp folder
2. edit string bwllow in code, it will search a part of text, so u dont need full text
3. type ig /alarm

if u know bit lua u will make it work gl

    LUA Programming
function OnCreate()
	this:RegisterCommand("alarm", CommandChatType.CHAT_ALLY, CommandAccessLevel.ACCESS_ME);
	AlarmStatus = false;
	LastAlarmTime = 0;
	LastAlarmT = 10;
 
	CheckSound = GetDir() .. "\\temp\\alarm.wav";
end;
 
 
 
function OnCommand_alarm(vCommandChatType, vNick, vCommandParam)
	if (AlarmStatus == false) then
		AlarmStatus = true;
		ShowToClient(tostring(os.date("%X")),"Alarm Plugin ON",3 );
	else
		AlarmStatus = false;
		PeopleInPartyCount = nil
		ShowToClient(tostring(os.date("%X")),"Alarm Plugin OFF",3);
	end;
end;
 
 
function FindSubStringInString(thesub,thestring) 
	for x = 1, 1 + string.len(thestring)-string.len(thesub),1 do
		if (string.sub(thestring,x,x+string.len(thesub)-1) == thesub) then
			return true;
		end;
	end;
	return false;
end;
 
 
function OnChatUserMessage(chatType, nick, msg)
	if (AlarmStatus == true) then
		Message = string.lower(msg); -- Converts message to lower case letters.
		Message = Message:gsub("^%s*(.-)%s*$", "%1"); -- Trimming message of spaces on start.
		if FindSubStringInString("ur string to search",Message) then-- edit here
			if (LastAlarmTime + LastAlarmT < os.time()) then
				PlaySound(CheckSound);
			end;
		end;
	end;
end;


Man, thx for the solution. It works fine. But the problem now is other Smile
It appears that function OnChatUserMessage its between client and server. Because it, all this work does not work... I guess the message that I said is generated only in my game (maybe by gameguard...). In this case i need to get the local messages, for example, messages that only me can see, Messages like Tower messages (System: Bot on).

Thx a lot.
Where is problem ?

    LUA Programming
function OnChatSystemMessage(id, msg)
	--Event called some system message show up on chat (id - integer, msg - string).
end;

(08-15-2016 08:02 AM)TheQQmaster Wrote: [ -> ]Where is problem ?

    LUA Programming
function OnChatSystemMessage(id, msg)
	--Event called some system message show up on chat (id - integer, msg - string).
end;


So... I will try to explain...
It appears that the dialog who shows the captcha is the same dialog from the Tutorial... When we start the game with a new character, the Tutorial Dialog appears, and We can't catch his content.
Yesterday I tried OnChatSystemMessage, and i get success. But the problem persist with tutorial dialog.

Look, I guess the problem that i cant catch the captcha html is the same problem that i can't catch the html from l2tower box... Its appears that I can't get local htmls, but i can get incomming html.

When I Log into game, after character selection, the game show:

" Espoliador: Vote us every day. "

Espoliador is my nick! And i can't get this message, i don't know why... And when I get captcha moment is:

"Espoliador: you have 30 seconds to choose the correct..."

It appears a local message (generated from gameguard, i guess it), like messages generated from l2tower, who's we can read but we can't catch....
which server l2tower still support guys ?
nice
How many Chat-types variables exist? Is there a command to include all of them? I mean what someting like chattype= ALL etc...
I am looking for a similar solution like the thread starter.
Reference URL's