View Full Version : ## FORUM SUGGESTION ## + event handling in lobby question
crusader
10-05-2004, 04:13 PM
## FORUM SUGGESTION ##
Hello everyone.
What do you think of the idea of making a new subforum, where we ES users could
post questions not directly related to ES, but having to do with
game and application development?
I certainly do not mean off topic questions, but things that developers
who work on multiuser projects come across all the time. I'm sure we all can help each other
in similar problems that arise when developing a multiplayer game or
a multiuser application.
Please take that into consideration.
######################
And now I have a question that could fit into this category I just described:
I'm building a multiplayer Backgammon game. While in the lobby,
you (user A) can click on the user list and invite another user (user B) to a game.
If user B accepts the invitation, he is creating the game room (es.createGameRoom),
and sends back to user A a message, so that user A knows his invitation was accepted
and he can join the Game Room.
Keep in mind that when user B creates the Game Room, he automatically leaves
the Lobby Room and enters the new Room.
So far so good.
The problem arises when trying to implement an extra feature.
When user A invites user B, before user B accepts the invitation, if user B leaves the lobby
I trigger a notice. That is because when someone invites someone else, if the latter leaves (e.g. disconnects), I want
the former to be notified, so that he doesn't wait for an answer in vain.
Unfortunatelly, these two concepts conflict with each other. The result of the 2 combined together
is that as soon as user B accepts the invitation and creates the Game Room (and autimatically joins that room),
user A is mistakingly notified that user B left the Lobby, before the "accept invitation" message has arrived.
So, I'm asking if someone has implemented something like this that actually works, or if someone
has any ideas that might help me.
Thank you in advance and sorry for my long post!
daveganley
10-05-2004, 04:25 PM
A sub forum sounds like a great idea.
Have you checked out Jobes game book he has a multiplayer chess example with spectators? It's not exactly what you are looking for but handle a two player game. Also check out the Tic Tac Toe example that came with ES
Dave
marklar
10-05-2004, 05:08 PM
I haven't got into coding for ES yet but I think this logic might work for your problem:
Steve invites John to join the room 'Steve v John' if John then leaves the lobby you check if he has created and gone to the room 'Steve v John' if not, he's left. I don't know the order of the process but I'm guessing that the new room would be created before John leaves the lobby but not before he enters it so it's the creation you need to check not whether John is there. Unless he creates the room and then disconnects which would be very inconsiderate of him.
Re: sub forum - It couldn't possibly compete with Flashkit and I don't think it would help ES. I found out about ES through the Jobe in the games forum on Flashkit where he is very active. Him and EdMack alone are enough reason to go there :D I think it would be better for everyone if we could somehow persuade Flashkit to have a multiplayer sub forum of their games forum.
crusader
10-05-2004, 06:18 PM
Dave, thanks for your suggestions. I don't know if this feature is implemented
in those games you reffered to, but I'm gonna check.
Marklar, this is exactly what I tried to do. I just didn't post it before, trying to keep my post a bit shorter :p
Unfortunately, the userList is updated before the room is created (or maybe before the rommlist is created?),
or at least the events come out in that order.
Maybe Jobe or Mike could shed some light on this?
peterblaze
10-05-2004, 10:29 PM
Hi Crus,
As to Your main question maybe using custom variable for each user noting where she/he is at the moment could do the job. AFAIK each user must have unique name so when user log to server, join lobby, go from room to another room, You could first create (when she/he logs succesfully) user variable with her/his current location in current zone using room name (kind of pathfinder for user). User variable goes with user, ie AFAIK should cease if user disconnet from server.
AFAIK this can't be done zone-wide becouse there is no such method for listing usernames in each room. We could only retrieve number of user in each room (see: attributes.users for mehod: getRoomList).
So maybe solution with creating and watching where user is at the moment could be solution for User-to-User invitation problem You've described.
regards,
Peter
webgeek
10-05-2004, 10:54 PM
AFAIK this can't be done zone-wide becouse there is no such method for listing usernames in each room. We could only retrieve number of user in each room (see: attributes.users for mehod: getRoomList). No longer true :) I have been meaning to add that for quite some time and the soon to be released (tonight if Jobe and I can finish the testing) version 3.6 includes it. Check out my 3.6 thread in about 5 minutes to see what I mean.
As for the forum suggestion, I'll talk to Jobe about it and see what he says. I don't know that we would want to try and compete with Flashkit Games forum as it would dilute the usefulness of each. With that said, Flashkit doesn't have a multiplayer specific forum and adding one might be useful. Thanks!
crusader
10-06-2004, 02:03 PM
Thank you guys.
But I didn't really get to create the user variable! I tried the following:
es.createUserVariable("room", "Lobby");
but then when I trace(es.getUser().userVariables.room) it returns undefined.
Is that the way to create a user variable or am I using it incorrectly?
peterblaze
10-06-2004, 02:36 PM
Hi Dimistrios,
Please download this file:
http://www.electrotank.com/lab/ElectroServer.as
posted by Jobe which should fix Your problem (replace Your current ES class by this file and recompile).
This problem will be fixed in 3.6 version,
regards,
Peter
crusader
10-06-2004, 03:02 PM
Hi Peter, thanks for the reply.
I did what you told me but nothing changed...
I had forgotten to use roomOb.UserVariablesEnabled = true when I was creating the Lobby room,
but even after I did that, it's not working still.
Any thoughts?
peterblaze
10-06-2004, 04:04 PM
Hi Dimitrios,
please follow at least two threads started by Andy about user variables, I think that these threads are good examples how to deal with user variables solution with ES,
If You have further question please start new topic about that,
regards,
Peter
crusader
10-06-2004, 06:02 PM
Dah!
You know what was the problem?
I was tracing the userVariable as soon as I called es.createUserVariable and apparently
the server didn't the time to send back the change.
I delayed the trace a bit using setInterval and it's working just fine!
Thanks a lot Peter!
Cheers
peterblaze
10-06-2004, 06:27 PM
Hi Dimitrios,
also note then when using es.createUserVariable then AFAIK using posted corrected class file ES will notify that using " userVariableUpdated" so You don't need to have waitForSomeTime trick,
regards,
Peter
crusader
10-06-2004, 06:40 PM
Yeah, I know that, thanks.
But wait a minute!
How am I going to refer to a user (and his userVariables) if the user has left the room?
getUserList() only returns users in the current room and I don't know of any other way to refer to another user.
So?...
jobem
10-06-2004, 06:44 PM
Hi crus,
After the user leaves the room, as far as anyone in that room is concerned the user has left the server too. Currently you only know about who is in the room.
We are getting ready to release a server update that allows you to track users across rooms by adding them as buddies. But there is no uservariable support for that feature.
crusader
10-06-2004, 07:10 PM
Hi Jobe.
That is so incovenient...
I think this feature I am describing is quite important. It's not nice to invite someone
and wait in vain, while the user has left the lobby.
I wish you could find a workaround in your future updates.
What you're describing about the new BuddyList feature could be a solution to this (with extra fuzz of course),
but I don't know exactly how you've built this, so I can't really tell if it would really solve this problem.
So, you haven't come across this issue or implemented this feature so far?
Do you think there could be a solution with the help of a plugin? I can't think of anything doable...
Thanks
jobem
10-06-2004, 07:24 PM
Hi crus,
With this buddy system you can probably get what you want. Let me explain:
- When you challenge someone to a game send the challenge message like you already are, but also call this:
es.addBuddy("mike");
- Now, when ever anyone in your buddy list joins or leaves the server the following event is fired:
es.buddyLoggedIn = function(name) {
//This is fired when a buddy of yours logs in
};
es.buddyLoggedOut = function(name) {
//this is called when a buddy of yours logs out
};
One important and useful thing to note here is that the moment you add a buddy either buddyLoggedIn or buddyLoggedOut will be called. So you'll know if the person you challenged has left the server.
In addition, you can get the user's location like this:
function loadAUsersLocation() {
//pass in the user's name
es.getUserLocation("jobe");
}
es.userLocationLoaded = function(username, zone, room) {
//This is fired when his loacation has been received
trace(username+", "+zone+", "+room);
};
So you can find out if they are in the wrong room (if you care).
What you currently cannot do is the following:
- You cannot set it up so that an event is fired as a user hops from one room to another (unless he is leaving the room that you are in)
- You cannot get the user variable updates of a user in another room.
I believe that with the above functionality you should be able to get the results that you are looking for.
crusader
10-06-2004, 07:50 PM
Ok Jobe, that makes sense. That was how I thought it would be also.
Indeed, it seems that this could solve the issue I'm having.
But it still is sot of a 'hack', so it's not really the best solution.
It suits me fine for the moment though, since I have developed
my own BuddyList system.
I hope we'll get to see a clear solution in future updates.
Of course, I'm looking forward to this update too!
Thank you for your time.
Regards,
Dimitrios
jobem
10-06-2004, 08:21 PM
Do you think you could spell out *exactly* the functionality that you think ElectroServer is lacking? I'm not sure that I see the deficiency.
webgeek
10-06-2004, 08:40 PM
I just want to add something to Jobe's message. We are VERY open to adding features as needed so feel free to spell out exactly what would be helpful to you and how it should work. The server is currently a chat server as opposed to an IM server, so we don't have a great deal of IM functionality in there. This will probably change in the future, but it does explain the reason we are light on things like tracking users, etc. Thanks!
crusader
10-06-2004, 08:43 PM
I guess you are refering to ElectroServer with the upcoming update, not without it.
Ok, here we go.
What I mean by "hack" and "not clear solution" is that a BuddyList's purpose
is to contain "Buddies". By adding the user you are challenging to the BuddyList,
you are "making him" a Buddy, which isn't really what he's supposed to be; he's just
your opponent for that game.
Of course you can delete him from the BuddyList as soon as the game is over,
but nevertheless he is dubbed something that he is not (you buddy), even for
a short period of time (I call that a "not so clear solution").
If we want to take this even further, this little "hack" we're talking about could
conflict with other functionality, such as BuddyList Notification:
Say you want someone to be notified when he is added to someone else's BuddyList.
In the case we described earlier, this would happen everytime two people
are starting a game. Of course you may handle the event depending on
weather you are about to go into a game or not, but again this just adds
unnecessary complexity.
I hope I made this clear.
crusader
10-06-2004, 08:59 PM
Thank you Mike. I understand that, but I think we all could use some extra features!
I'm really glad to hear that you're open to adding new features!
I'm waiting for Jobe's answer, if he needs a better explanation on that I'm going to
start thinking a way this could be implemented.
peterblaze
10-07-2004, 04:22 AM
Hi Dimistrios,
What you currently cannot do is the following:
- You cannot set it up so that an event is fired as a user hops from one room to another (unless he is leaving the room that you are in)
- You cannot get the user variable updates of a user in another room.
Maybe putting some more attention to private message could do the trick?
From help:
Private messages can be sent to a user anywhere on the server. Each user has a unique username (you can't have two "john" users at the same time). So when you send a private message to "john" it will find him in any room in any zone.
I can think about such solution that You can bind sending specific private message to any user and that private message could be send to any interested user. Seems doable,
If You want example how to check if any user is currently logged into server (even in 3.5 version) please let me know. It's not ellegant one but should works,
regards,
Peter
crusader
10-07-2004, 12:24 PM
Yes Peter, that would be very nice.
Thank you!
Powered by vBulletin® Version 4.1.6 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.