Game Development Community

Adding variable to vehicle

by Very Interactive Person · in Torque Game Engine · 07/01/2003 (2:17 am) · 8 replies

Ok, now I got the basics of scripting... I want to advance to something more complex. But... I immidiately realize I don't understand the scripts enough to continue ;)

Here's what I want to do.
I want to add a variable to a vehicle, one I can change during the game. Where do I store it? It really needs to be a vehicle variable. If the client dismounts and another client mounts it... that new client needs to have it and not the one that dismounted.

#1
07/01/2003 (3:14 am)
From script simply set the varible. (i.e. $myVechicle.newVariable = 42). From that point on you'll be able to access it.

If you want to know the C++ side you're in the wrong forum.
#2
07/01/2003 (4:09 am)
He would need to set that in the server scripts, doing so clientside would limit it to that specific client. Alos needed would be a commandToServer() call from the client to retrieve the value.
#3
07/01/2003 (12:46 pm)
So if I have the vehicle I can simply add variables as much as I want in scripts? Like %obj.newVar =10 ? Great... I'll play with it tomorrow. And yes, Ron, it would be on the server, becuase the code I'm writing (or trying to write) will go in a trigger function.
#4
07/02/2003 (11:55 am)
This worked like a charm! Thanks a lot.
What I don't know is how I could get the variable of the vehicle on the clients screen.
Like, every time a player mounts a vehicle of that type a HUD wich displays that variable should appear on that clients screen... and when he dismounts it should dissapear.
Now, I don't expect code, but can someone share their ideas and at least tell me what files I should look at?
#5
07/02/2003 (8:29 pm)
Look into using commandtoclient
#6
07/03/2003 (3:58 am)
Ok, so something like this:

-use command to client to show a certain HUD
-use command to client to update the HUD values
-use command to client to clear the HUD

and the HUD is offcourse a GUI file.

Ok, I should be able to get this to work. Any suggestions on displaying a value on a GUI? Just a text element? Or can I use a healthbar or something to do that (without engine changes)? Beccuase that would look better then just text on the screen.
#7
07/03/2003 (4:22 am)
[edit]double post[/edit]
#8
07/04/2003 (8:44 am)
How do I get the client of a vehicle?

When I enter a trigger with a vehicle, the vehicle is %obj, right? But %obj.client doesn't seem to return me the client I need to send the command to. Is this becuase I need the client of the player that is mounted on the vehicle? Or what? Please help, my command works if I enter it in the console, commandToClient doesn't work tough.