/*
Logs.inc v1.0
Logs Staff, player or script cmd in differents files using
Andromeda UO's utilsdate available at http://groups.yahoo.com/group/pol-scriptforum/files/.
Author: Developer Beaud.
Email: DeveloperBeaud@gmail.com
TODO:
Add the scriptname to LogScriptEv returned string.
*/
use os;
use uo;
use datafile;
Include "include/utilsDate";
/*
LogCMD(text)
Stores strings in a txt file located in X/data/ds/logs/
param text: That string will be logged in its user element an sorted by cmdlevel
Example: LogCMD("Banned " + who.name + "'s account for cheating");
Notes: It might be usefull to manage a descent staff team.
*/
function LogCMD(who, text)
var timedate := PolCore().systime;
timedate := CDateStr(timedate) + " " + CTimeStr(timedate);
var path;
Case(who.cmdlevel)
0: path := "logs/players";
1: path := "logs/counselors";
2: path := "logs/seers";
3: path := "logs/gamemasters";
4: path := "logs/admins";
5: path := "logs/developers";
Endcase
var ldata := OpenDataFile( path );
If(!ldata)
ldata := CreateDataFile( path );
Endif
var log := ldata.FindElement(who.acctname);
if(!log)
log := ldata.CreateElement(who.acctname);
else
endif
log.setprop(CInt(timedate), text);
UnloadDataFile(path);
endfunction
/*
LogScriptEv(text)
Stores strings in a txt file located in X/data/ds/logs/
param text: That string will be looged in its script element.
Example: LogScriptEv("Banned " + who.name + "'s account for inactivity");
Notes: It might be usefull if you need to locate which script is banning
which were banned.
*/
function LogScriptEv(text)
var timedate := PolCore().systime;
timedate := CDateStr(timedate) + " " + CTimeStr(timedate);
var path := "logs/ScriptEv";
var ldata := OpenDataFile( path );
If(!ldata)
ldata := CreateDataFile( path );
Endif
var log := ldata.FindElement("polcore");
if(!log)
log := ldata.CreateElement("polcore");
endif
log.setprop(CInt(timedate), text);
UnloadDataFile(path);
endfunction
Even if there is no */data/ds/logs/*.txt
It read it and doesn't Create the datafile.
Just adding an entry to datafile.txt like that doesn't create the datafile. Not that I've ever been able to get it to do anyway, I just tried several different ways to be sure. You need to create the datafile in code.
Mithril I hope you aren't referring to his last post, because that's not what he asked.
I had this problem too when I first started using datafiles. I forget what I did to fix it. Anyway check out regionspawner package, it has code using datafile.em. Use that as a referrance to fix your problem.
Sorry, i surely meant package
First delete the stuff you have written into the datastore.txt while
the server is down.
Second i think the package is called "logs" where you have this script.
Use this code and the files will be stored in data/ds/..
/*
Logs.inc v1.0
Logs Staff, player or script cmd in differents files using
Andromeda UO's utilsdate available at http://groups.yahoo.com/group/pol-scriptforum/files/.
Author: Developer Beaud.
Email: DeveloperBeaud@gmail.com
TODO:
Add the scriptname to LogScriptEv returned string.
*/
use os;
use uo;
use datafile;
Include "include/utilsDate";
/*
LogCMD(text)
Stores strings in a txt file located in X/data/ds/logs/
param text: That string will be logged in its user element an sorted by cmdlevel
Example: LogCMD("Banned " + who.name + "'s account for cheating");
Notes: It might be usefull to manage a descent staff team.
*/
function LogCMD(who, text)
var timedate := PolCore().systime;
timedate := CDateStr(timedate) + " " + CTimeStr(timedate);
var path;
Case(who.cmdlevel)
0: path := "players";
1: path := "counselors";
2: path := "seers";
3: path := "gamemasters";
4: path := "admins";
5: path := "developers";
Endcase
var ldata := OpenDataFile( path );
If(!ldata)
ldata := CreateDataFile( path );
Endif
var log := ldata.FindElement(who.acctname);
if(!log)
log := ldata.CreateElement(who.acctname);
else
endif
log.setprop(CInt(timedate), text);
UnloadDataFile(path);
endfunction
/*
LogScriptEv(text)
Stores strings in a txt file located in X/data/ds/logs/
param text: That string will be looged in its script element.
Example: LogScriptEv("Banned " + who.name + "'s account for inactivity");
Notes: It might be usefull if you need to locate which script is banning
which were banned.
*/
function LogScriptEv(text)
var timedate := PolCore().systime;
timedate := CDateStr(timedate) + " " + CTimeStr(timedate);
var path := "ScriptEv";
var ldata := OpenDataFile( path );
If(!ldata)
ldata := CreateDataFile( path );
Endif
var log := ldata.FindElement("polcore");
if(!log)
log := ldata.CreateElement("polcore");
endif
log.setprop(CInt(timedate), text);
UnloadDataFile(path);
endfunction
Actually this script is an include located in */scripts/include/...
I use the function is some script to log who used which cmd for X reason..
I have no pkg at all, all I want is a log file created somewhere, I was using "logs/*" because I though it would create it in */data/ds/logs/... But all along this topic you guys talked about pkgs an script, Its just a function located in an include file, I don't get it oO.. I just can't make a .log or a .txt out of this function.
That stuff was created in datastore.txt from the function, I never edited any file..
I have no logs pkg it was just a path i wanted the file to be in, I though it */data/ds/ + path..
That fileaccess interest me though If there is a way to specify the path, the file extention as well it would be better than a simple text file in */data/ds/...
Damn i should not post if i am tired
The above was not quite correct, i edited it. But nevertheless, if this is an include file in scripts/include/ it won't work imho. It has to be in a package to create these datafiles.
If you want to use file.em functions, it will look something that way, e.g.