The online racing simulator
Retrieving User Stats
Hello,
On my Cruise Insim you can buy flowers and toys and sell them at houses.
That works and the selling also works. I want to make it that you can leave the server and re join and still have your flowers/toys. When you leave my server It Does save the flower/toy stats in the user.txt file but when you join it won't fetch that data.

static public int GetUserFlowers(string Username)
{
StreamReader Sr = new StreamReader(UserInfo + "\\" + Username + ".txt");

string line = null;
while ((line = Sr.ReadLine()) != null)
{
if (line.Substring(0, 6) == "Flowers")
{
string[] Msg = line.Split('=');
Sr.Close();
return int.Parse(Msg[1].Trim());
}
}
Sr.Close();
return 0;
}

Also this is my User File BTW

WORKS - Cash = 495031
WORKS - BBal = 1000
WORKS - Cars = UF1 XFG
WORKS - Distance = 1002441
WORKS - Health = 100
WORKS - Stat = 1
DOESN'T WORK - Flowers = 20
DOESN'T WORK - Toys = 0
DOESN'T WORK - JobsCompleted = 0
DOESN'T WORK - JobsAccepted = 0
DOESN'T WORK - FlowersSold = 0
DOESN'T WORK - ToysSold = 0

By DOESN'T WORK it saves it like i said but it won't read it and apply it to the users flowers etc on the server.

I am using LFS_External

Thanks
#2 - amp88
Ok. It works now - well i think.

How can i set the flowers in the user file to the C.Flowers Byte?????
#5 - amp88
Quote from amp88 :Good.



You're welcome.

Hang On.. LOL

It still won't retrieve the stats. Or how do i tell it to put the thing in the Connectionsfgbzdfgbfgb.Flowers Byte Thing?
did u forget the NewConn to load those ints?
Quote from stuntguy3000 :

if (line.Substring(0, 6) == "Flowers")


line.Substring(n, 6) will never equal "Flowers"
When is that ever useful in a language? That just seems to be overtly obtuse and for no reason then to just be obtuse! This is another area that I feel that PHP excels, comparing data. == checks that the bits are the same, whereas === checks that the bits and the data type are the same.
Quote from broken :What amp88 said.
line.Substring(n, 6) will never equal "Flowers"

its suppose to be

F L O W E R S
1 2 3 4 5 6 7 ?
Quote from Dygear :When is that ever useful in a language? That just seems to be overtly obtuse and for no reason then to just be obtuse! This is another area that I feel that PHP excels, comparing data. == checks that the bits are the same, whereas === checks that the bits and the data type are the same.

Well the reason it won't work is because "Flowers" is seven characters in length, but he's only checking the first six characters of the substring.

Substring has its uses, mainly for slicing ranges out of strings, but in C# you would normally do:

if (line.StartsWith("Flowers"))
{

}

Or if you're worried about internationalisation:

if (line.StartsWith("Flowers", StringComparison.InvariantCulture))
{

}

C# doesn't need '===' because it is strongly typed. We have '==' for reference comparison and 'is' for type comparison.
Quote from broken :What amp88 said.
line.Substring(n, 6) will never equal "Flowers"

Quote from skywatcher122 :its suppose to be

F L O W E R S
1 2 3 4 5 6 7 ?

Have you passed first grade yet? Can you make difference between the numbers?

Go ask your application if it sees Flowers in 6 letters. I think it sees Flower. Go and wonder why it doesn't want to find your Flowers then.
i know about it :P
just some trollers do
Quote from broken :Have you passed first grade yet? Can you make difference between the numbers?

Go ask your application if it sees Flowers in 6 letters. I think it sees Flower. Go and wonder why it doesn't want to find your Flowers then.

FAIL - that doesn't solve the problem for the other ones.

Toys
JobsCompleted
JobsAccepted
ToysSold
FlowersSold
I HAVE STARTED A NEW INSIM.
Its Still LFS_External. When i add the JobsCompleted Thing nothing works. no hud/commands work.

i need to
//NewConn.JobsCompleted = FileInfo.GetUserJBS_Completed(NCN.UName);

to get the insim to work? HELP!

static public int GetUserJBS_Completed(string Username)
{
StreamReader Sr = new StreamReader(UserInfo + "\\" + Username + ".txt");

string line = null;
while ((line = Sr.ReadLine()) != null)
{
if (line.Substring(0, 14) == "Jobs Completed")
{
string[] Msg = line.Split('=');
Sr.Close();
return int.Parse(Msg[1].Trim());
}
}
Sr.Close();
return 0;
}

Sorry, but I helped you and all you seemed to say back to me was "FAIL". Don't expect anything more from me.

On top of that, if you follow the logic, it will work. But maybe you're lacking common sense, and that, I can not fix.
its like tomatoes and potatoes...I'll end up this supporting since you are lacking some common sense (no offense)
Quote from skywatcher122 :its like tomatoes and potatoes...I'll end up this supporting since you are lacking some common sense (no offense)

Quote from DarkTimes :Well the reason it won't work is because "Flowers" is seven characters in length, but he's only checking the first six characters of the substring.

So, then a more helpful answer in the first place would be that the string length of Flowers is not 6, but 7.

Quote from DarkTimes :Substring has its uses, mainly for slicing ranges out of strings, but in C# you would normally do:

if (line.StartsWith("Flowers"))
{

}

Or if you're worried about internationalisation:

if (line.StartsWith("Flowers", StringComparison.InvariantCulture))
{

}


I think the StartsWith one would work better, in this case at least. I assume there is an EndsWith as well? Is there a good online resource for looking this information up that might be a good to post so people can help them self first, and ask questions later? (That's really not a bad idea, start a programming resource thread for all of the languages.)

Quote from DarkTimes :C# doesn't need '===' because it is strongly typed. We have '==' for reference comparison and 'is' for type comparison.

Yeah, I was not quite groking that it should of been 7 not 6 in the first place, and I thought that you could not check the string object against just a string without some extra vodo.
Quote from Dygear :Is there a good online resource for looking this information up that might be a good to post so people can help them self first, and ask questions later?

Yes, it's called MSDN. Here is the System.String class.

Note in Visual Studio if you place your mouse over a class and press F1 it will take you to the documentation for that object automatically.
im a friend of stuntguy3000 but i need hes help i can change only some things

FGED GREDG RDFGDR GSFDG