I´m creating a room dinamically when a user enters it and putting a NPC inside.
When the last user leaves the room and just the NPC is inside, I want to leave/disconnect/kick the NPC and destroy the Room.
Everything works fine without NPC inside: create and destroy room.
The leaveroom does not work for NPC.
The kick and disconnnet works and call the userLost event, but if I put the DeleteRoom inside it, the room is not deleted. As the console shows me, it apears that the user is still inside when the lostUser is called.
jvm 1 | [loginDuplicado.as]: Delete Room:49
jvm 1 | [loginDuplicado.as]: Error when trying to destroy Room #49 // i tried to delete here (userLost)
jvm 1 | 11:57:24.452 - [ FINE ] > Removed NPC connection: java.nio.channels.SocketChannel[closed]
jvm 1 | 11:57:24.453 - [ FINE ] > User [ guest_0 ] removed // NPC
jvm 1 | 11:57:24.454 - [ INFO ] > User guest_0 has been kicked.
Code: Select all
if (evt.name == "userLost") {
...
if (usr.getVariable("_os_type").getValue() == "NPC") {
trace("call delete because PET leave the room "+evt.roomIds);
var param = new Object;
param.idRoom = evt.roomIds[0];
hDeleteRoom("",param,"","")
}
...
else if (evt.name == "userExit") { // last real user leave the room
...
} else if (evt.room.getUserCount() == 1) {
var usersList = evt.room.getAllUsers();
var user = usersList[0];
if (user.getVariable("_os_type").getValue() == "NPC") {
//_server.leaveRoom(user, idRoom);
//_server.kickUser(user, 0, "Pet kicked");
_server.disconnectUser(user);
Any help?