Couple of questions.
by Jeremy Ferguson · in Torque 3D Professional · 12/29/2011 (2:22 am) · 1 replies
Hey there, I'm working on a project at the moment and I have a couple of questions.
I'm developing a money system from scratch..
I'm trying to figure out how I would go about putting variables on each Player..
for example: Player::cash would be set individually for each user.
Another one of my questions would be: What would a simple money system look like between server/client?
I'm developing a money system from scratch..
I'm trying to figure out how I would go about putting variables on each Player..
for example: Player::cash would be set individually for each user.
Another one of my questions would be: What would a simple money system look like between server/client?
About the author
Torque Owner Dennis Trevillyan
WatreGames
The easiest way to do this is with the clientCmd function which is well explained in the forums and documentation. The clientCmd function is answered on the server by serverCmd. The serverCmd function will always provide the client object and the player object will be %client.player. Just add a new variable to track the money such as %client.player.money and decrement it accordingly. Then, add the new object to inventory.
This new variable will disappear when the player leaves the game so you'll want to store it somehow. You could do this in a $Pref or use one of a couple of database options. Note that being a global variable the $Pref options may be accessible to motivated players.
Hope that helps