Game Development Community

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?

#1
12/31/2011 (8:34 am)
@Jeremy, the client should be limited to displaying the game and allowing the player to interact with the virtual world. As an example the player selects an object and decides to purchase it. The client provides the interface to select the object and to select the option purchase it. The client would then send a message to the server to decrement the players money and add the item to the inventory.

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