Page 1 of 1
Updated 1.4.2 beta patch
Posted: 07 Jul 2006, 09:53
by Lapo
Hi,
we have uploaded a new version of the
1.4.2beta patch, that fixes a small bug with the error reporting system and adds a new feature in the server side event handling.
You can read all the details and download it from our beta section
p.s. = thanks to NateDog for helping with the beta testing

error in extention
Posted: 18 Jul 2006, 04:12
by mnkyhead
I am trying to use the public message logging feature, but when I start the server with the extension installed, it throws some errors.
my question is about the code - zone.setPubMsgInternalEvent(true)
it is telling me that zone is not defined. so I changed it to the zone I installed the extension for simpleChat, but it says that simpleChat is not defined.
What is this suppose to be?
here is my full file, can you look it over to see if there are any other problems? It's short
Code: Select all
/**
* Extension intialization
* This example can be used as Zone level extension
*/
function init() {
/*
enable "pubMsg" internal events
by default this event is turned off
*/
simpleChat.setPubMsgInternalEvent(true);
}
/**
* Handle internal events
*
* @param e the event object
*/
function handleInternalEvent(e) {
var d = new Date();
var currDate = d.getMonth()+"/"+d.getDate()+"/"+d.getFullYear();
var currTime = toTwelves(d.getHours(), d.getMinutes());
evtName = e.name;
if (evtName == "pubMsg") {
sourcRoom = e.room;
// the room object
senderUser = e.user;
// the sender user
message = e.msg;
// the public message
var txt = currTime+" "+senderUser+" said: "+message;
var txtFile = sourceRoom+currDate;
_server.writeFile(txtFile, txt, true);
}
}
function toTens(val) {
if (val<10) {
return "0"+val;
} else {
return String(val);
}
}
function toTwelves(hour, min) {
var amPm = "AM";
if (hour>12) {
hour = hour-12;
amPm = "PM";
} else if (hour == 0) {
hour = 12;
}
var ct = toTens(hour)+":"+toTens(min)+" "+amPm;
return ct;
}
Thanks
Russ
Posted: 18 Jul 2006, 15:11
by Lapo
This line:
Code: Select all
[code]simpleChat.setPubMsgInternalEvent(true)
;[/code]
is not correct. Where does simpleChat comes from? Unless you have declared it somewhere outside the pasted code snippet, it will of course throw an error.
In order to obtain a reference to the current zone use this code:
Code: Select all
var zone = _server.getCurrentZone()
Then you're ready for this:
Code: Select all
simpleChat.setPubMsgInternalEvent(true);
Hope it helps

AH HA
Posted: 18 Jul 2006, 18:42
by mnkyhead
Yes I know there had to be some var of zone, I just didn't know what. Thanks.
It works great once I realized the sourceRoom is the room object.
So this is a beta patch, is there going to be an offical release?
Here is my final as file..
Code: Select all
/**
* Extension intialization
* This example can be used as Zone level extension
*/
function init() {
/*
enable "pubMsg" internal events
by default this event is turned off
*/
var zone = _server.getCurrentZone()
zone.setPubMsgInternalEvent(true);
}
function destroy() {
trace("Extension destroyed");
}
function handleRequest(cmd, params, user, fromRoom)
{
// Add your code here
}
/**
* Handle internal events
*
* @param e the event object
*/
function handleInternalEvent(e) {
var zone = _server.getCurrentZone()
var d = new Date();
var currDate = d.getMonth()+"-"+d.getDate()+"-"+d.getFullYear();
var currTime = toTwelves(d.getHours(), d.getMinutes());
evtName = e.name;
if (evtName == "pubMsg") {
sourceRoom = e.room;
// the room object
senderUser = e.user;
// the sender user
msg = e.msg;
// the public message
var txt = currTime+" "+senderUser.getName()+" said: "+msg+newline;
var txtFile = sourceRoom.getName()+currDate+".txt";
trace("msg "+txt);
var ok = _server.writeFile(txtFile, txt, true);
if (ok) {
trace("File saved!");
} else {
trace("File write failed!");
}
}
}
function toTens(val) {
if (val<10) {
return "0"+val;
} else {
return String(val);
}
}
function toTwelves(hour, min) {
var amPm = "AM";
if (hour>12) {
hour = hour-12;
amPm = "PM";
} else if (hour == 0) {
hour = 12;
}
var ct = toTens(hour)+":"+toTens(min)+" "+amPm;
return ct;
}
So do you know how to send text to a new line in a text document?
Thanks
Russ
Posted: 18 Jul 2006, 19:30
by Lapo
So this is a beta patch, is there going to be an offical release?
Sure, we'll be publishing a few more beta releases before the official one.
So do you know how to send text to a new line in a text document?
Yep just add a new line "escape code", like this:
var myString = "Hello"
myString += "\n" // new line
one more issue, than its perfect
Posted: 19 Jul 2006, 14:35
by mnkyhead
First off SmartFox rocks.
now here is my problem.
I got the logging working, but I need to add to the log a registration Id that each user gets when they join the site. When the user logs into the site, there is an object set with all there info, name, id, etc. How can I get the id from my object to the user object in the chat, so I can use it in my log file?
I tried setUserVariables, but couldn't get it to work.
Posted: 20 Jul 2006, 05:51
by Lapo
Sorry but I don't get it.
Could you explain in steps what you're trying to do?
thanks
Posted: 20 Jul 2006, 13:48
by mnkyhead
I figured it out, the problem was I was trying to setUserVariables in the wrong place. but i got it to work.
Thanks
Russ