Scoping System Question
by Jacob Wood · in General Discussion · 09/23/2006 (3:47 pm) · 6 replies
This post was originally started here:
Don't Click, look at the below post
and was continued to this forum so source code can be discussed:
So my question is, as Stephen predicted, how do I change the scoping system to do meet my development needs?
Don't Click, look at the below post
and was continued to this forum so source code can be discussed:
Quote:
I also would suggest that you make the perception decision server side, and then modify the scoping to a specific client to determine if the ghost copy should be sent to that specific client at all.
FYI, as long as we don't start talking source code, or specific algorithms, this is a good topic for this forum.
Unfortunately, I can see your very next question: "how do I change the scoping system to do this?"--and that will require source code discussion, and therefore needs to do to a new, private forum.
So my question is, as Stephen predicted, how do I change the scoping system to do meet my development needs?
#2
Sounds good.
Thanks again Stefan, I hope you get a good night's sleep!
09/25/2006 (10:02 am)
Ok, so if I were to use object.clearScopeToClient to all the other clients besides the controlling one, and then scope them when they come within range of each other based on their scores, I'd be able to accomplish what I'm trying to do? Sounds good.
Thanks again Stefan, I hope you get a good night's sleep!
#3
Here's the code I'm using right now:
So basically, when I call getClientObj(); I give it the client's connection ID in the first argument, and the object ID on the server that I want to stop ghosting to that client.
Then the client takes the ghost ID of that server object and sends back the client ID of that object to the server.
Once that ID reaches the server, I use the client object and the client ID to clear the scope of that object from that particular client.
But it doesn't seem to work that way. What do you think's the problem?
09/25/2006 (11:49 am)
It seems to me like I'm doing it right, but now it just doesn't seem to work.Here's the code I'm using right now:
//==========-----------On the Server -----------------================
function getClientObj(%clientID, %serverObj)
{
%ghostID = %clientID.getGhostID(%serverObj);
commandToClient(%clientID, 'SendClientObj', %ghostID, %clientID);
}
function serverCmdClearScope(%clientObj, %clientID)
{
%clientID.clearScopeToClient(%clientObj);
}
//============----------------On the client ----------------===============
function clientCmdSendClientObj(%ghostID, %clientID)
{
%clientObj = %clientID.resolveGhostID(%ghostID);
commandToServer("ClearScope", %clientObj, %clientID);
}So basically, when I call getClientObj(); I give it the client's connection ID in the first argument, and the object ID on the server that I want to stop ghosting to that client.
Then the client takes the ghost ID of that server object and sends back the client ID of that object to the server.
Once that ID reaches the server, I use the client object and the client ID to clear the scope of that object from that particular client.
But it doesn't seem to work that way. What do you think's the problem?
#4
When sending a commandToServer, you should not specify %clientID because it is not needed. When the serverCmd function is called, it gets the client ID automatically. It's the first argument in the list, so in your case the %clientObj you get passed is a client.
You also use tags in one of your server/client calls, but quotes in the other. The console will give a warning about this, so always check the console for errors. I cannot stress this enough. :)
Another error is that you are taking the clientID from the server and try to resolve a ghost. Client and server does not share the same ID's so this wont work. Use GameConnection, ServerConnection or whatever your current connection is called. Usually the former.
Finally, your code should look like this:
Not sure I got everything in there, post again if you still have trouble. And make sure to check the console for errors :) See you.
09/26/2006 (2:15 pm)
I think the problem is that you confused the arguments a bit.When sending a commandToServer, you should not specify %clientID because it is not needed. When the serverCmd function is called, it gets the client ID automatically. It's the first argument in the list, so in your case the %clientObj you get passed is a client.
You also use tags in one of your server/client calls, but quotes in the other. The console will give a warning about this, so always check the console for errors. I cannot stress this enough. :)
Another error is that you are taking the clientID from the server and try to resolve a ghost. Client and server does not share the same ID's so this wont work. Use GameConnection, ServerConnection or whatever your current connection is called. Usually the former.
Finally, your code should look like this:
//==========-----------On the Server ----------------================
function getClientObj ( %clientID, %serverObj )
{
%ghostID = %clientID.getGhostID ( %serverObj );
commandToClient ( %clientID, 'SendClientObj', %ghostID );
}
function serverCmdClearScope ( %clientID, %clientObj )
{
%clientID.clearScopeToClient ( %clientObj );
}
//============----------------On the client ----------------===============
function clientCmdSendClientObj ( %ghostID )
{
%clientObj = GameConnection.resolveGhostID ( %ghostID );
commandToServer ( 'ClearScope', %clientObj );
}Not sure I got everything in there, post again if you still have trouble. And make sure to check the console for errors :) See you.
#5
So now when I specify a player's client ID, and the server object that I want him not to see, it'll only go invisible on his game, and not on the others.
Thank you so much for the help.
09/27/2006 (6:47 am)
WOO! Got it to work! I didn't actually have to use the scoping functions at all.//=========-------------------Server--------------------=========
function fadeClient(%clientID, %serverObj, %fadeOut)
{
%ghostID = %clientID.getGhostID(%serverObj);
commandToClient(%clientID, 'FadeMe', %ghostID, %fadeOut);
}
//=========-------------------Client--------------------=========
function clientCmdFadeMe(%ghostID, %fadeOut)
{
%clientObj = ServerConnection.resolveGhostID(%ghostID);
%clientObj.startFade(0,0,%fadeOut);
}So now when I specify a player's client ID, and the server object that I want him not to see, it'll only go invisible on his game, and not on the others.
Thank you so much for the help.
#6
Good luck.
09/27/2006 (7:05 am)
Although the above is prone to cheating, in that the client still receives updates from the server - I'm happy that you found a solution! :)Good luck.
Torque Owner Stefan Lundmark
After reading the other thread, I am not really sure what I was talking about over there. There *are* functions which deal with what you are trying to do, and they are exposed to script. They are not 100% what you want, but very close. You should be able to modify them to set normal scoping and not scope always, read description below.
(Excuse any typos, it is late and I am dead tired)
[b]object.scopeToClient ( clientID );[/b] This sets the scope of the object to the specified client as [i]'always'[/i]. This means the client will always receive updates for this object, no matter where it is or in what state it is. [b]object.clearScopeToClient ( clientID );[/b] This sets the scope of the object to the specified client as [i]'never'[/i]. This means the client will not ever know about the object and no updates will be received until it is ghosted again..Edit: Changed formatting. Scroll bars stretch horizontally.. sigh. Good night. (: