Points/Cash/Money System
by Adam Gardner · in Torque 3D Professional · 12/19/2012 (4:42 pm) · 21 replies
So I've been working on a points system for zombies and it seems like if I do say %player.player.money saving the cash under a players dynamic fields it seems to get erased after respawning, is there any way to not erase the points?
#2
Like this?
12/19/2012 (4:57 pm)
%client.player.money = 500; commandToClient(%client, 'UpdateCash', %client.player.money);
Like this?
#3
12/19/2012 (5:14 pm)
@Adam That way you are still assigning it to the player. Instead do this:%client.money = 500;I did something like that in my T3D coin collection tutorial.
#4
12/19/2012 (5:52 pm)
I do the same thing %client.player.money is the same thing I thought since %client is what you said but I believe the .player. Is the class
#5
12/19/2012 (5:56 pm)
I do the same thing %client.player.money is the same thing I thought since %client is what you said but I believe the .player. Is the class
#6
12/19/2012 (5:58 pm)
When the player object is created and spawned, there is a dynamic property called .player that is used and assigned to the %client, so anything appended to that %client.player.whatever will still be created/destroyed accordingly. %client.money is what you want... unless you want persistent data if the same client connects at a later data, then it gets a bit trickier.
#7
12/19/2012 (5:59 pm)
I do the same thing %client.player.money is the same thing I thought since %client is what you said but I believe the .player. Is the class
#8
12/19/2012 (6:45 pm)
I do the same thing %client.player.money is the same thing I thought since %client is what you said but I believe the .player. Is the class
#9
12/19/2012 (6:47 pm)
Ok so that seemed to work I believe but converting to that might be hard
#10
12/19/2012 (7:06 pm)
I do the same thing %client.player.money is the same thing I thought since %client is what you said but I believe the .player. Is the class
#11
because each time a player dies u have to reassign value on player again.
for multiplayer game that is the best solution.
here is a small part:
12/19/2012 (7:19 pm)
instead of player i am saving money on gameconnection object.because each time a player dies u have to reassign value on player again.
for multiplayer game that is the best solution.
here is a small part:
function serverCmdFillAccountingInfo(%client, %moneyAmount)
{
echo("%client--"@%client);
%client.money = %moneyAmount;
echo(%client.money);
}
#12
12/19/2012 (7:20 pm)
I do the same thing %client.player.money is the same thing I thought since %client is what you said but I believe the .player. Is the class
#13
12/19/2012 (7:25 pm)
I do the same thing %client.player.money is the same thing I thought since %client is what you said but I believe the .player. Is the class
#14
12/19/2012 (7:31 pm)
I do the same thing %client.player.money is the same thing I thought since %client is what you said but I believe the .player. Is the class
#15
and change your code to store money on client object instead of player.
12/19/2012 (7:31 pm)
stop copy pasting here.and change your code to store money on client object instead of player.
#16
12/19/2012 (7:38 pm)
I do the same thing %client.player.money is the same thing I thought since %client is what you said but I believe the .player. Is the class
#17
12/19/2012 (7:39 pm)
It won't work on zombies like this. I can't find a way to update your client money. For example when I shoot the zombie I want to get 10 points From the last time attacker
#18
very much easy.because there are many way to do that .u have to choose proper one.
after lots of tries i found this one proper place to handle that:
"function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)"
go with it.but 1st save money on gameconnection instead of player.each time a player die a new one created but there is always only 1 gameconnection untill u stop playing.so use last one to store scores
12/19/2012 (7:47 pm)
" I shoot the zombie I want to get 10 points From the last time attacker"very much easy.because there are many way to do that .u have to choose proper one.
after lots of tries i found this one proper place to handle that:
"function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)"
go with it.but 1st save money on gameconnection instead of player.each time a player die a new one created but there is always only 1 gameconnection untill u stop playing.so use last one to store scores
#19
12/19/2012 (9:38 pm)
How do I do the %client.money under Armor::damage ? Thats the part I'm stuck at and thanks a ton for the help and it was double posting because I was on my Iphone sorry about that.
#20
%obj is the id of the object being damaged
%courceObject is the id of the object causing damage
%position is the current3d world transform where this takes place
%damage is the amount of damage that gets applied
%damageType is a string name for the type of damage, whether bullet, explosion, suicide, drowning, lava, etc...
I'm assuming that you're wanting the person causing the damage to get money. That person is the sourceObject. Since we know that at spawn/creation the player object and client connection both have pointers to each other:
You may notice that the damage() method already tries to resolve the client id for both objects involved... you may want to follow the existing example and have an exception for AI.
12/20/2012 (2:30 am)
Quote:Look at the parameters (arguments) available to the damage() method:
How do I do the %client.money under Armor::damage ? Thats the part I'm stuck at
Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)%this is the datablock id
%obj is the id of the object being damaged
%courceObject is the id of the object causing damage
%position is the current3d world transform where this takes place
%damage is the amount of damage that gets applied
%damageType is a string name for the type of damage, whether bullet, explosion, suicide, drowning, lava, etc...
I'm assuming that you're wanting the person causing the damage to get money. That person is the sourceObject. Since we know that at spawn/creation the player object and client connection both have pointers to each other:
%sourceObject.client.money
You may notice that the damage() method already tries to resolve the client id for both objects involved... you may want to follow the existing example and have an exception for AI.
%sourceClient = %sourceObject ? %sourceObject.client : 0;
if (isObject(%client))
{
// do something since this is a person and not a bot
// %sourceClient.money++ for example
}
Torque Owner Jeff Raab
[ghc]games