Problem with the GUI
by Joshua Jewell · in Torque Game Engine · 08/09/2005 (11:51 am) · 5 replies
I have come across a problem with the GUI, and am hoping someone can at least point me in the right direction. The problem is not with creating GUI elements; I got that down pretty well. The problem is controlling who's GUI you are messing with. For example I have an ammo counter, and when a player fires, I want to display to them their current ammo through a text control. The problem is this always modifies the server's text control and not the clients. Now I got the clients text control to work by binding a change with F2. My question is what the difference is; I figure something is going on behind the scenes that I can't figure out yet, when deciding on which GUI to alter. I have the same problem with pushing GUI elements, for vehicle spawns etc. Any help in this topic would be greatly appreciated.
#2
Anyway. When you fire (onFire) you need to send the client the new value, then display that value in the clients GUI text control.
This has nothing to do with the servers value, as it's just replicated and sent. Incase you're running single player, you could make it read from the value directly, I guess.. but I still don't understand what you're saying with the "servers text control" part.
08/09/2005 (4:51 pm)
Huh? The "servers text control" doesn't sound very good. Why would you want a text control on the server, why would you want a GUI at all?Anyway. When you fire (onFire) you need to send the client the new value, then display that value in the clients GUI text control.
This has nothing to do with the servers value, as it's just replicated and sent. Incase you're running single player, you could make it read from the value directly, I guess.. but I still don't understand what you're saying with the "servers text control" part.
#3
08/09/2005 (7:32 pm)
Basically on the gameGUI or playGUI I forget which it is I added a text control. The purpose of this control is to show the client how much ammo they have left. I do this with the ammoText.setText("blah blah blah"). Now the thing is if I execute this in something like when the player hits F2 it works for the client. However, if when someone shoots I do a clientcmd, it displays this text for the server. The command line is the same, but for some reason it depends on where inside the code it is placed. So I was wondering if it takes something like who owns the function that called it to decide where it is changed at, be it the client or the server.
#4
08/09/2005 (10:36 pm)
No, there is no client or server logic in the GUI code. An instance of Torque might be connected to another instance of Torque thus implicitly making one a client or server, but the GUI system doesn't care about networking.
#5
08/12/2005 (2:57 am)
Use a client side function in commands.cs which updates this controll for the client. Then have the server call this function whenever something changes (commandtoclient). For details look at the script docs.
Associate Kyle Carter