Forum in READ ONLY mode! All questions and discussions on Discord official server, invite link: https://discord.gg/VxsGzJ7

Journal storage

Only for requests.
Post Reply
lestatzero
Posts: 5
Joined: 16.05.2014 23:01

Journal storage

Post by lestatzero »

Ok .. I am new to this and am looking for a way to scan and save journal information based on a few specific things.

I have a program that works great in easyuo script that exports the information to my sql database but I would like to have something that does this right from Stealth Client so I do not have to load the script in easyuo.

My Easyuo Script is as follows:

Code: Select all

set %symb [       ;use [ for global and < for guild
set %newLine #journal

loop:
scanJournal 1
if %newLine <> #journal
{
set %temp #journal
str pos %temp < p
str Left %temp 1
if #STRRES = %symb
{
set %string #journal
loop2:
str Pos %string _
set %pos #strRes
str Del %string #strRes 1
str Ins #strRes #spc %pos
set %string #strRes
str Count %string _
if #strRes > 0
  goto loop2
gosub phpsend localhost /wchat.php
set *NOTETEMP %string
set %newLine #journal
;menu List Select mainBuffer %index
}
}
goto loop:
halt


sub phpsend
set #sendheader Content-type: , #spc , application/x-www-form-urlencoded$
send httppost %1 %2 textarea= , %string ;<br>
return
This is looking for world chat or guild chat on a player run shard not OSI NO IRC .

Is there someone that can help rewrite this . If it can be linked directly to Sql database that would be even better then i would not need the http post section ..

All of my information is stored in a sql database for me to output using php .
Thanks in advance for any help
drabadan
Expert
Expert
Posts: 730
Joined: 13.12.2012 17:35
Contact:

Re: Journal storage

Post by drabadan »

hi, i'm not good at easy uo. But i can try to help, as far as i understood - you want to parse journal by some condition, and then handle this message to sql database.
I'd try to solve all of this with stealth's events.
Here some little example where i'm handling specific journal message. It's about expirience added to my char after some action, i wanted to count it, for having some info about what's better to leveling.
So, here's the code:

Code: Select all

procedure TestEvSpeech(Text,SenderName:String;SenderID:Cardinal);
var 
 Sl : TStringList; 
 CurrTime : TDateTime;
 AverExpPerSec, tmpExp : Double; 
begin
 SL := TStringList.Create;
 If(BMSearch(0,Text,'единиц опыта')>0)then //message i was looking for in chat;
  begin
   Inc(ExpCounter);
   StrBreakApart(Text, ' ', SL);   
   currExp := StrToInt(SL[2]) + currExp;
   CurrTime := Now;
   tmpExp := currExp;
   CurrTime := CurrTime - StartTime;   
   AverExpPerSec := tmpExp/TimeParser(TimeToStr(CurrTime));  
   AddToSystemJournal('Exp gained: ' + IntToStr(currExp) + '; Average Exp: ' + IntToStr(currExp/ExpCounter) + '; Exp/sec: ' + FloatToStrF(AverExpPerSec, ffNumber, 4, 2) + '; Time elapsed: ' + TimeToStr(CurrTime));     
  end;
 SL.Free;   
end;
If you'r ok with pascal script - it won't be so tough to you to figure out what's all about.
If not - we will talk much longer!
lestatzero
Posts: 5
Joined: 16.05.2014 23:01

Re: Journal storage

Post by lestatzero »

Yea I am new to writing using pascal script in this fashion... \

The script I quoted does the following.

Scan journal for the [ character or the < character ( these 2 both indicate either public chat or guild chat ) they are at the start of the journal line the next

If [ is in LastJournalMessage ( at the start ) then I want to save it to sql database else continue searching.

Same if for < is in LastJournalMessage (at the start ) then i want to save it to a different table in my sql database ... I am not sure if i can use Pascal to connect directly to my database or if i have to use the httppost method to do this...

Once information has been exported to database then we can release it no need to save it any further ... I do not need to save it local or anything ... ...

I have been trying to play with the LastJournalMessage method but have been getting Stealth out of memory errors that crash stealth ...

Thanks for the assistance in this ..

Lestat
drabadan
Expert
Expert
Posts: 730
Joined: 13.12.2012 17:35
Contact:

Re: Journal storage

Post by drabadan »

lestatzero wrote:Yea I am new to writing using pascal script in this fashion... \

The script I quoted does the following.

Scan journal for the [ character or the < character ( these 2 both indicate either public chat or guild chat ) they are at the start of the journal line the next

If [ is in LastJournalMessage ( at the start ) then I want to save it to sql database else continue searching.

Same if for < is in LastJournalMessage (at the start ) then i want to save it to a different table in my sql database ... I am not sure if i can use Pascal to connect directly to my database or if i have to use the httppost method to do this...

Once information has been exported to database then we can release it no need to save it any further ... I do not need to save it local or anything ... ...

I have been trying to play with the LastJournalMessage method but have been getting Stealth out of memory errors that crash stealth ...

Thanks for the assistance in this ..

Lestat
You can use outer scripts, you can write any script with delphi. There would be no problem to connect it with db.

Here some little example, it's closer to your situation:

Code: Select all

program Logger;

procedure JournalHandler(Text, SenderName : String; SenderID : Cardinal);
begin
 if BMSearch(0, Text, '>') > 0 then
  AddToSystemJournal('Public message ' + Text); //instead of this you can store info anyhow you like;
 if BMSearch(0, Text, '[') > 0 then
  AddToSystemJournal('Guild message' + Text);
end;

begin
 SetEventProc(evUnicodeSpeech, 'JournalHandler');
 while true do wait(300);
end.
User avatar
Vizit0r
Developer
Developer
Posts: 3958
Joined: 24.03.2005 17:05
Contact:

Re: Journal storage

Post by Vizit0r »

for connection to DB in PS script you cau use DB dll's
But, as for me, using of external script will be more useful here
"Пишите код так, как будто сопровождать его будет склонный к насилию психопат, который знает, где вы живете". (с) Макконнелл, "Совершенный код".
lestatzero
Posts: 5
Joined: 16.05.2014 23:01

Re: Journal storage

Post by lestatzero »

drabadan wrote:
lestatzero wrote:Yea I am new to writing using pascal script in this fashion... \

The script I quoted does the following.

Scan journal for the [ character or the < character ( these 2 both indicate either public chat or guild chat ) they are at the start of the journal line the next

If [ is in LastJournalMessage ( at the start ) then I want to save it to sql database else continue searching.

Same if for < is in LastJournalMessage (at the start ) then i want to save it to a different table in my sql database ... I am not sure if i can use Pascal to connect directly to my database or if i have to use the httppost method to do this...

Once information has been exported to database then we can release it no need to save it any further ... I do not need to save it local or anything ... ...

I have been trying to play with the LastJournalMessage method but have been getting Stealth out of memory errors that crash stealth ...

Thanks for the assistance in this ..

Lestat
You can use outer scripts, you can write any script with delphi. There would be no problem to connect it with db.

Here some little example, it's closer to your situation:

Code: Select all

program Logger;

procedure JournalHandler(Text, SenderName : String; SenderID : Cardinal);
begin
 if BMSearch(0, Text, '>') > 0 then
  AddToSystemJournal('Public message ' + Text); //instead of this you can store info anyhow you like;
 if BMSearch(0, Text, '[') > 0 then
  AddToSystemJournal('Guild message' + Text);
end;

begin
 SetEventProc(evUnicodeSpeech, 'JournalHandler');
 while true do wait(300);
end.

Wow The above script works to export data to the systemJournal rather quickley so how would i go about either exporting it thorugh the http post like i do in my script or how wld i make a proseadure to export it directly to database all i need is the "text" i dont need the Guild message or Public Message part the database lables everything for me it also time stamps it etc ..

Thanks for the help.

Lestat
drabadan
Expert
Expert
Posts: 730
Joined: 13.12.2012 17:35
Contact:

Re: Journal storage

Post by drabadan »

So maybe you post here some example string, and what exactly you want to extract from it.
lestatzero
Posts: 5
Joined: 16.05.2014 23:01

Re: Journal storage

Post by lestatzero »

drabadan wrote:So maybe you post here some example string, and what exactly you want to extract from it.

Sure thing

Code: Select all

program Logger;

procedure JournalHandler(Text, SenderName : String; SenderID : Cardinal);
VAR
SL : TStringList;
begin
 if BMSearch(0, Text, '[') > 0 then
  begin
  if BMSearch(0, Text, '[safebet') = 0 then
  AddToSystemJournal('Wchat ' + Text); // I want to export the Text here (all of it )
  end;
 if BMSearch(0, Text, '<GW>') > 0 then
  AddToSystemJournal('Gchat ' + Text); // I want to export this to a different table
 if BMSearch(0, Text, 'has opened your message') > 0 then
  AddToSystemJournal('PM INFO - ' + Text); 
  if BMSearch(0, Text, 'PartyChatMsg:') > 0 then
    AddToSystemJournal(Text); 
 if BMSearch(0, Text, 'Please wecome our newest member to our shard,') > 0 then // Here is a bit more difficult... I want to export the entire name (anything after the above search (as players names can be more than 1 word )  after the UOsay i want to export the entire name to a database table.
    begin
    SL := TStringList.Create;
    StrBreakApart(Text, ' ', SL);
    AddToSystemJournal('Newest Member - ' + SL.Strings[9]);
    UOsay('[c Welcome to Excelsior ' + SL.Strings[9] + ' type "[C" to chat in World Chat') 

    SL.Free;   
    end;
 
  end;
  

begin
 SetEventProc(evUnicodeSpeech, 'JournalHandler');
 while true do wait(300);
end.
Commented sections are what I am looking to export as of right now ... the php scripts i am using will work at address localhost/wchat.php and localhost/gchat.php respectivly they need only one input called "textarea=" All of the http_post php pages are already set up and working so If that will be easiear than directly connecting to the db then that is the way I am willing to go since it works using easyuo but it crashes easyuo after some time (around a day or so of running) ...


Thanks again.

Lestat
drabadan
Expert
Expert
Posts: 730
Joined: 13.12.2012 17:35
Contact:

Re: Journal storage

Post by drabadan »

Code: Select all

HTTP_Body
function HTTP_Body : String

HTTP_Get
procedure HTTP_Get(URL : String);

HTTP_Header
function HTTP_Header : String;

HTTP_Post
function HTTP_Post(URL : String; PostData: TStringList) : String;
I can see that you'r ok with scripting, so i think you'll figure out how to use it!
This functions are in stealth already, so just use it.
However, i would advise you to use external scripts and make a complete application for that, maybe it will found another people who would like to use or improve it. It can be yousefull for those who like to get a complete info of any shard, on my expirience i saw a man who stored id's of players in excel table.

P.S. Also it seems that you'r from stuff of some shard, isn't it easier to use inner sphere scripts?
lestatzero
Posts: 5
Joined: 16.05.2014 23:01

Re: Journal storage

Post by lestatzero »

Yea I saw those Functions in the documentation section .... The only issue is I do not see any reference with example script to use them .. I have played around with several different things and nothings working ..

in my origional script that I use in easyuo

Code: Select all

sub phpsend 
set #sendheader Content-type: , #spc , application/x-www-form-urlencoded$ /Set the Static Variable #sendheader 
send httppost %1 %2 textarea= , %string ;<br>   /sets up the httpost function with 2 variables for url and sets the website s textarea (defined as textarea for the name of the input on php page for submission ) to be equlil to  the String var
return
This sub is overly simplistic ... I call it every time I get a true... However I cannot figure out how to do the same basic thing using the methods provided to me ...

I wld assume i would do something like

Code: Select all

HTTP_Header('Content-type: application/x-www-form-urlencoded$');
HTTP_Post('localhost/test.php, textarea = Text);

I have not been able to figure out the right format to set post to post data to php site in a "defined" field for correct injection to my sql database ... the info i want to input is a string of the result text with a

Code: Select all

 if BMSearch(0, Text, '[') > 0 then
I truly appricate all the help you guys have given so far ... The search routien works great ...

End result I would like to just output info to one of several differnet database tables (via http_Post) once filtered .

Lestat
Post Reply