Vice City: Multiplayer

VC:MP Discussion => Support => Topic started by: MEGAMIND on Jun 25, 2018, 06:24 AM

Title: server log
Post by: MEGAMIND on Jun 25, 2018, 06:24 AM
how can we get a serverlog or chat log in form of .txt or .log?
Title: Re: server log
Post by: Sir. Cucuruchito 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
Title: Re: server log
Post by: 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;
}
Title: Re: server log
Post by: Sir. Cucuruchito on Jun 25, 2018, 06:54 AM
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.
Title: Re: server log
Post by: rww on Jun 25, 2018, 06:59 AM
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;
}