server log

Started by MEGAMIND, Jun 25, 2018, 06:24 AM

Previous topic - Next topic

MEGAMIND

how can we get a serverlog or chat log in form of .txt or .log?

Sir. Cucuruchito

Commando Miami 80's
IP: 206.189.97.12:8192


MEGAMIND

Quote from: Ququr_Uxcho on Jun 25, 2018, 06:36 AM
Quote from: MEGAMIND on Jun 25, 2018, 06:24 AMhow can we get a serverlog or chat log in form of .txt or .log?

You can use the files functions. References:
Squirrel Wiki: http://www.squirrel-lang.org/squirreldoc/stdlib/stdiolib.html?highlight=file#the-file-class
Public Beta src (line 31): https://bitbucket.org/stormeus/vl8-pb400/src/97957ce06cf26e3210bae62523b1e5c619e99cfd/LibMisc.nut?at=master&fileviewer=file-view-default#LibMisc.nut-31
thanks dude but how do u preffer working with this is there any example available in wiki? and is this function still present in rel006?
function TXTAddLine(filename, text)
{
local fhnd = file(filename, "a+");
foreach(char in text)
fhnd.writen(char, 'c');

fhnd.writen('\n', 'c');
fhnd=null;
}

Sir. Cucuruchito

#3
Quote from: MEGAMIND on Jun 25, 2018, 06:41 AM
Quote from: Ququr_Uxcho on Jun 25, 2018, 06:36 AM
Quote from: MEGAMIND on Jun 25, 2018, 06:24 AMhow can we get a serverlog or chat log in form of .txt or .log?

You can use the files functions. References:
Squirrel Wiki: http://www.squirrel-lang.org/squirreldoc/stdlib/stdiolib.html?highlight=file#the-file-class
Public Beta src (line 31): https://bitbucket.org/stormeus/vl8-pb400/src/97957ce06cf26e3210bae62523b1e5c619e99cfd/LibMisc.nut?at=master&fileviewer=file-view-default#LibMisc.nut-31
thanks dude but how do u preffer working with this is there any example available in wiki? and is this function still present in rel006?
function TXTAddLine(filename, text)
{
local fhnd = file(filename, "a+");
foreach(char in text)
fhnd.writen(char, 'c');

fhnd.writen('\n', 'c');
fhnd=null;
}

This function doesn't depend on the server version. It is integrated on Squirrel Language.
Actually, I am working with this function to read files or write in them.

The previous lines write letter by letter in the file. You need a open file:
local fhnd = file(filename, "a+");
The a+ means append. So, this example serves you perfectly.
Commando Miami 80's
IP: 206.189.97.12:8192


rww

function onPlayerJoin(p)
{
TXDAddLine("Logs.txt",p.Name+" connected to the server. IP: "+p.IP+", UID: "+p.UniqueID+", UID2: "+p.UniqueID2);
return 1;
}

function TXTAddLine(filename, text)
{
 local fhnd = file(filename, "a+");
 foreach(char in text)
  fhnd.writen(char, 'c');
 
 fhnd.writen('\n', 'c');
 fhnd=null;
}
Join to Irrelevant Club Discord: https://discord.gg/MsPPZ5uV4X