Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help Steamreader/writer problem
#1
Hi again Smile
As you can see i want to be able to save points using !shop, now i rent my servers so it can't be to C: drive etc, i have access to ftp and www.

iv'e even tried to use this in C: drive to to see if it gives any errors in log etc but it doesn't, and yet doesn't seem to work at all, The current destination seems irrelevant to what i put in , whether it's C:\\mw3\\shop or what ever. Odd thing when i initially put the code in i did get a error message in log saying it couldn't find xuid 12234456 etc, but then the point wasn't working. Rock kindly help me in placing the code without c# errors but still doesn't work.

Help is appreciated.


PHP Code:
public override void OnPlayerConnect(ServerClient Client)
        {
            try
            {
                
StreamReader reader = new StreamReader(@"shop" Client.XUID ".txt");
                
ServerPrint("StatswillbeWritten2");
               
                
string read reader.ReadLine();
                
string read2 read;

                
string[] readArray read2.Split('=');
                
Points[Client.XUID] = int.Parse(readArray[1]);
            }

            catch { } 

PHP Code:
public override int OnPlayerDamaged(ServerClient AttackerServerClient Victimstring Weaponint Damage)
        {
            if (
Damage >= Victim.Other.Health && Attacker.Team != Victim.Team && Victim.XUID != Attacker.XUID)
            {
                try
                {
                    
Points[Attacker.XUID] = (((int)Points[Attacker.XUID]) + 120);
                    
StreamWriter writer = new StreamWriter(@"shop" Attacker.XUID ".txt");
                   
                  
                    
int points = (int)Points[Attacker.XUID];

                    
writer.WriteLine(Attacker.XUID "=" points.ToString());
                    
writer.Dispose();
                    
writer.Close();
                }
                catch { } 
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

Reply

#2
Replace all try... catch blocks with this:

Code:
try
{
    // blah blah.
}
catch(Exception ex)
{
    ServerPrint(ex.ToString());
}

See what comes up in the console.
[Image: 30xhrep.png]

A casual conversation between barata and I about Nukem.
Reply

#3
Thanks @master131

Here is the log error
System.IO.FileNotFoundException: Could not find file 'G:\mw3server\mw3\shop01100001045752e1.txt'.

File name: 'G:\mw3server\mw3\shop01100001045752e1.txt'

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)

at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)

at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)

at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)

at System.IO.StreamReader..ctor(String path)

at mw3zombie.mw3shop.OnPlayerConnect(ServerClient Client)
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

Reply

#4
(02-23-2013, 14:01)hillbilly Wrote: Thanks @master131

Here is the log error
System.IO.FileNotFoundException: Could not find file 'G:\mw3server\mw3\shop01100001045752e1.txt'.

File name: 'G:\mw3server\mw3\shop01100001045752e1.txt'

at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)

at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)

at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)

at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)

at System.IO.StreamReader..ctor(String path)

at mw3zombie.mw3shop.OnPlayerConnect(ServerClient Client)

(@"shop\\" + Client.XUID + ".txt");
(@"shop\\" + Attacker.XUID + ".txt");

You already tried to kill someone and look if it created the file?
Reply

#5
It wont create the txt file but even if i create it i still get this error

System.NullReferenceException: Object reference not set to an instance of an object.

at mw3zombie.mw3shop.OnPlayerConnect(ServerClient Client)
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

Reply

#6
(02-23-2013, 14:27)hillbilly Wrote: It wont create the txt file but even if i create it i still get this error

System.NullReferenceException: Object reference not set to an instance of an object.

at mw3zombie.mw3shop.OnPlayerConnect(ServerClient Client)

file name should be your xuid and the text inside should be yourxuid=points

I'm using the same code and everything is working fine for me.
Reply

#7
i did create the txt file with my xuid as it's name but i still get the error above, main point is that it wont even create the txt file to start with.

If i create the file, put in the points manually then on connect it load ok no errors, and loads the points, maybe to do with permission on creating the file and writing to it, ??
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

Reply

#8
anyone?
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

Reply

#9
Why not use the static File methods? I never bothered StreamReader and Writer
Reply

#10
tis ok for what ever reason it started to work.
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
  Help Android problem Yamato 12 8,179 04-25-2014, 04:49
Last Post: ScHmIdTy56789
  Problem with Rain Effects on Maps mitchhacker 5 4,862 10-22-2013, 00:46
Last Post: mitchhacker
  Help Liberation Problem Yamato 27 24,949 07-17-2013, 19:54
Last Post: feature
  [xna 4]Rendering problem narkos 9 5,945 07-03-2013, 19:00
Last Post: Nekochan
  Help Problem God plugin v4.0 4nonymous 1 2,728 06-22-2013, 23:25
Last Post: 8q4s8
  Help Infected Shop Plugin Problem Hallla 2 3,158 05-06-2013, 18:29
Last Post: Hallla
  problem with gsc code CheGuevara 5 5,616 04-20-2013, 15:06
Last Post: Nekochan
  problem to connect to server s.j-rez 0 2,234 04-17-2013, 18:18
Last Post: s.j-rez
  warning problem AndEEDJay 0 2,110 04-08-2013, 09:54
Last Post: AndEEDJay
  Help ADDON,PROBLEM HACK emilioxativa 5 4,831 04-03-2013, 08:16
Last Post: narkos

Forum Jump:


Users browsing this thread:
2 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.