Player money not loading correctly.
by Adam Troutman · in General Discussion · 08/07/2006 (10:07 am) · 28 replies
Well I am trying to load this file when the server starts up so that players will have the same amount of money they left with the problem is is that whenever I load it it seems like the $ is missing from the first line and that is causing the whole file to not be able to load and making it so that no one can get their money.
Here is the error in the log file-
rtb/server/clientcash.cs Line: 1 - Syntax error.
>>> Advanced script error report. Line 1.
>>> Some error context, with ## on sides of error halt:
ClientCash151.196.22.##1##64 = "262";
$ClientCash172.150.28.90 = "178";
$ClientCash207.119.23.41 = "37";
>>> Error report complete.
it seems to me that the missing $ is causing the problem, the $ shows up in the saved file and all though so I dont understand. here are the things to load and save the script.
echo("Exporting all clients connected to this session's cash ammount for storage.");
export("$ClientCash*", "rtb/server/clientCash.cs", False);
function loadcash(%client,%obj,%user,%amount){
echo("MONEY LOADED***************************");
%filePath = "rtb/server/clientcash.cs";
exec(%filePath);
}
I don't know a whole lot about saving and loading files so I dont understand what could be causing this and how I can fix it so any help would be appreciated.
Thanks
Here is the error in the log file-
rtb/server/clientcash.cs Line: 1 - Syntax error.
>>> Advanced script error report. Line 1.
>>> Some error context, with ## on sides of error halt:
ClientCash151.196.22.##1##64 = "262";
$ClientCash172.150.28.90 = "178";
$ClientCash207.119.23.41 = "37";
>>> Error report complete.
it seems to me that the missing $ is causing the problem, the $ shows up in the saved file and all though so I dont understand. here are the things to load and save the script.
echo("Exporting all clients connected to this session's cash ammount for storage.");
export("$ClientCash*", "rtb/server/clientCash.cs", False);
function loadcash(%client,%obj,%user,%amount){
echo("MONEY LOADED***************************");
%filePath = "rtb/server/clientcash.cs";
exec(%filePath);
}
I don't know a whole lot about saving and loading files so I dont understand what could be causing this and how I can fix it so any help would be appreciated.
Thanks
#2
that is all there is currently.
and it works when $ClientCashlocal = "750"; is the only one but then only i could play.
08/07/2006 (10:17 am)
$ClientCash207.119.23.41 = "72"; $ClientCash68.83.216.10 = "100"; $ClientCashlocal = "750";
that is all there is currently.
and it works when $ClientCashlocal = "750"; is the only one but then only i could play.
#3
08/07/2006 (10:23 am)
Well you can't define a string like that.$ClientCash207.119.23.41 = "72"; $ClientCash68.83.216.10 = "100";These two lines are giving you your error. Without seeing the rest of your code it's hard for me to help.
#4
08/07/2006 (10:25 am)
What code do you need to see, clientcash.cs only has those in it. I assume you mean the probelm is that the ip adresses are making the problem.
#5
this code is in game.cs under the function
08/07/2006 (10:28 am)
exec("./rtb/server/clientCash.cs");
%this.Money = $ClientCash[getRawIp(%this)];
if(%this.Money != NULL)
{
messageClient(%this,'',"\c2Your money was saved from the last visit");
}
else
{
%this.Money = $Pref::Server::StartMoney;
messageClient(%this,'',"\c2You were given the default money from the server");
}
messageClient(%this,'MsgUpdateMoney',"",%this.Money);
messageClient(%this,'','\c5%1', $Pref::Server::MOTD); this code is in game.cs under the function
function GameConnection::onClientEnterGame(%this)
#6
08/07/2006 (10:29 am)
Ok, that code helps. Give me a minute to read thru it.
#7
The idea is that I am trying to save the different players different amounts of money so that they will have it when the server goes down and comes back up again.
08/07/2006 (10:30 am)
It is the game called blockland, I do own torque but I didn't make this game im just messing with the script in it. The idea is that I am trying to save the different players different amounts of money so that they will have it when the server goes down and comes back up again.
#8
08/07/2006 (10:34 am)
Well at a quick glance it seems you want to be overwriting each client's pref value:$Pref::Server::StartMoney = "100";Instead of:
$ClientCash68.83.216.10 = "100";
#9
i dont think thats right, because $Pref::Server::StartMoney = "100"; is the variable set by the host for everyone if i changed the value for them it wouldnt effect them on my game it would just change their values for when they host a game.
08/07/2006 (10:37 am)
Welli dont think thats right, because $Pref::Server::StartMoney = "100"; is the variable set by the host for everyone if i changed the value for them it wouldnt effect them on my game it would just change their values for when they host a game.
#10
hmm.
08/07/2006 (10:40 am)
I think I need the ip adress to identify the player but obviously it doesn't seem to work with just having the ip added on to the global variable so is there another way I could have it in the variable so that it would work or maybe I could make a new variable like$Pref::Server::(ip adress) = "100";
hmm.
#11
From what I can see, that section of code looks for each client's cash in a client side prefs file.
If there's a value stored, it uses it. If not, it defaults to the server setting. So there must be an array somewhere on the client that stores a unique cash value. Something like:
08/07/2006 (10:45 am)
Yeah but there must be a client side pref for local players. I don't have blockland so it's hard for me to say exactly what you need to do. I'd need to see all the functions.%this.Money = $ClientCash[getRawIp(%this)];
if(%this.Money != NULL)
{
messageClient(%this,'',"\c2Your money was saved from the last visit");
}
else
{
%this.Money = $Pref::Server::StartMoney;
messageClient(%this,'',"\c2You were given the default money from the server");
}From what I can see, that section of code looks for each client's cash in a client side prefs file.
%this.Money = $ClientCash[getRawIp(%this)];
If there's a value stored, it uses it. If not, it defaults to the server setting. So there must be an array somewhere on the client that stores a unique cash value. Something like:
$ClientCash[68.83.216.10] = "100";
#12
08/07/2006 (10:54 am)
Well everyone has a clientcash.cs file and that is where it stores the money data.
#13
08/07/2006 (10:55 am)
I found this too.function serverCmdStoreCash(%client)
{
$ClientCash[getRawIp(%client)] = %client.money;
if($Pref::Server::SaveCashonExit $= 1)
{
export("$ClientCash*", "rtb/server/clientCash.cs", False);
}
}
#14
It can't be doing it like that.
I would suggest it uses an array.
Something along those lines.
08/07/2006 (10:58 am)
So by default, how does it store the $clientCash variable?$ClientCash207.119.23.41 = "72";
It can't be doing it like that.
I would suggest it uses an array.
%IP = getRawIp(%client); $ClientCash[%IP] = "72";
Something along those lines.
#15
08/07/2006 (10:59 am)
There's what you need to be looking at!$ClientCash[getRawIp(%client)] = %client.money;
#16
08/07/2006 (11:00 am)
If it were just me on the server it stores it like this. $ClientCashlocal = "750";which doesnt cause anyproblems, i assume because the pi adress is just local.
#17
I guarantee you there's a value stored on the client along the lines of:
08/07/2006 (11:06 am)
You may need to trace it back some more. I guarantee you there's a value stored on the client along the lines of:
%IP = getRawIp(%client); $ClientCash[%IP] = "72";
#18
08/07/2006 (11:08 am)
So would it work if I made a variable that was the ip and added it on the end of $clientcash instead of having the actual ip on the end?
#19
I doubt that will work though. Trace back the code some more.
08/07/2006 (11:11 am)
Maybe, try it.%IP1 = "207.119.23.41"; %IP2 = "68.83.216.10 "; $ClientCash[%IP1] = "72"; $ClientCash[%IP2] = "100";
I doubt that will work though. Trace back the code some more.
#20
08/07/2006 (11:13 am)
I caint find anything in the client code having anything to do with money. and i cant type in everyones ip so that wouldnt be practical, why wouldn't %IP = getRawIp(%client);work?
Torque Owner Tim Heldna
Use code tags if possible.