Dynamic variables on player crashing game
by Wesley W Frosolone · in Torque Game Engine · 02/02/2004 (6:07 am) · 5 replies
I modified the player class in the C++ code to store variables that will be unique to each player. I declared the variables in the private section of the class, I added set/get methods for the variables in the public, and I added a Consolecommand for each of them. I setup a netmask for when they change.
In the game.cs script, in the createplayer function, I can set all the variables just fine. After that, however, if I try to set more than one variable with a player reference, the game locks up.
I?ve tried setting them in a function called by createPlayer (or whichever function that is called that finally sets the players control object), and it will crash if I set more than one variable. I tried doing a server command, and it will crash there if I do any at all. I tried doing a client command, which is called by a server command which passes it a player reference, and it crashes if I set more than one variable. If I try calling two separate server commands, one right after the other, which call two separate client commands, it crashes.
What gives? Do I have to schedule it so that the updates aren?t all run at once? But then why does it work when the player is first created? Does it have something to do with setting the control object (I noticed one of the masks checks if the object is controlled by a client...).
I will post the code when I get home. In the mean time, does anyone have any idea of what may be wrong?
In the game.cs script, in the createplayer function, I can set all the variables just fine. After that, however, if I try to set more than one variable with a player reference, the game locks up.
I?ve tried setting them in a function called by createPlayer (or whichever function that is called that finally sets the players control object), and it will crash if I set more than one variable. I tried doing a server command, and it will crash there if I do any at all. I tried doing a client command, which is called by a server command which passes it a player reference, and it crashes if I set more than one variable. If I try calling two separate server commands, one right after the other, which call two separate client commands, it crashes.
What gives? Do I have to schedule it so that the updates aren?t all run at once? But then why does it work when the player is first created? Does it have something to do with setting the control object (I noticed one of the masks checks if the object is controlled by a client...).
I will post the code when I get home. In the mean time, does anyone have any idea of what may be wrong?
#2
02/02/2004 (9:25 am)
Check out Daniel Nielsen's resource www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=2698 to see how he did it.
#3
As for the ghosted instance... How do I tell if a given reference refers to the ghost or the real object? Is it simply a matter of where in the scripts the reference is being used?
One thing I forgot to mention in the inital post was that it is only setting variables that cause it to crash in all of those locations. Getting them works fine in all cases.
The resource linked to in the previous post is what I used to begin with. After i finnished his resource, I simply copied all his code and modified it to use different variables.
02/02/2004 (9:28 am)
The mask bits are at 7 or 8 (once again, will post code when I get home...). I realize there is a hard limit of 32. Found that out while looking for an answer to this problem. As for the ghosted instance... How do I tell if a given reference refers to the ghost or the real object? Is it simply a matter of where in the scripts the reference is being used?
One thing I forgot to mention in the inital post was that it is only setting variables that cause it to crash in all of those locations. Getting them works fine in all cases.
The resource linked to in the previous post is what I used to begin with. After i finnished his resource, I simply copied all his code and modified it to use different variables.
#4
Alternatively, check out this resource by Nathan Davies www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4852 to see how to differentiate between client and server objects.
Edit: to post url.
02/02/2004 (10:06 am)
NetObjects have a isGhost() function which you can query. I'm not too sure if that is exposed to script, however.Alternatively, check out this resource by Nathan Davies www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=4852 to see how to differentiate between client and server objects.
Edit: to post url.
#5
Thanks
07/06/2004 (10:52 am)
This post is a few months old, but im curious if you ever solved this problem. I am having the exact same issue.Thanks
Associate Kyle Carter