1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Output from gump to file

Discussion in 'Script Support' started by Karmageddon, Mar 16, 2019 at 11:24 AM.

  1. Karmageddon
    Offline

    Karmageddon New Member

    Joined:
    May 24, 2017
    Messages:
    28
    Likes Received:
    0
    What I want to do is be able to take text entries from a gump and output it into a text file on the server. Is this possible and what would I use to do it?
     
  2. Feeh
    Offline

    Feeh Member

    Joined:
    Apr 1, 2014
    Messages:
    61
    Likes Received:
    10
    Try this
    Code (C#):
    1. using System.IO;
    2. ...
    3.         public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
    4.         {
    5.             using (TextWriter tw = File.CreateText(Path.Combine(Environment.CurrentDirectory, "THE_TEXTFILE_NAME.txt")))
    6.             {
    7.                 tw.WriteLine($"The player {sender.Mobile.Name} sent this:");
    8.                 tw.WriteLine(info.TextEntries[0].Text);
    9.             }
     
    • Like Like x 1
  3. Karmageddon
    Offline

    Karmageddon New Member

    Joined:
    May 24, 2017
    Messages:
    28
    Likes Received:
    0
    Thank you
    --- Double Post Merged, Mar 17, 2019 at 6:16 PM ---
    Well got a chance to try it. Everything compiles but am not getting any file output. This is the code I have atm:
    Code (C#):
    1. public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
    2.         {
    3.             Mobile from = sender.Mobile;
    4.  
    5.             switch(info.ButtonID)
    6.             {
    7.                 case 0:
    8.                 {
    9.                     break;
    10.                 }
    11.                 case 1:
    12.                 {
    13.                     using (TextWriter tw = File.CreateText(Path.Combine(Environment.CurrentDirectory, "Staff_Rating.txt")))
    14.                     {
    15.                         tw.WriteLine("The player {sender.Mobile.Name} sent this:");
    16.                         tw.WriteLine(info.TextEntries[2].Text);
    17.                         tw.WriteLine(info.TextEntries[3].Text);
    18.                         tw.WriteLine(info.TextEntries[4].Text);
    19.  
    20.                         break;
    21.                     }
    22.                 }
    23.  
    24.             }
    25.         }
     
  4. Feeh
    Offline

    Feeh Member

    Joined:
    Apr 1, 2014
    Messages:
    61
    Likes Received:
    10
  5. Vorspire
    Offline

    Vorspire Vita-Nex: Core
    Admin ServUO Developer

    Joined:
    Jul 29, 2013
    Messages:
    1,088
    Likes Received:
    193
    Code (C#):
    1.  
    2. tw.WriteLine("The player {sender.Mobile.Name} sent this:");
    3.  
    -->

    Code (C#):
    1.  
    2. tw.WriteLine($"The player {sender.Mobile.Name} sent this:");
    3.  
    <-->

    Code (C#):
    1.  
    2. tw.WriteLine("The player " + sender.Mobile.Name + " sent this:");
    3.  
     
  6. Karmageddon
    Offline

    Karmageddon New Member

    Joined:
    May 24, 2017
    Messages:
    28
    Likes Received:
    0
    Vorspire server kept giving an error with the second bit of code.
     
Similar Threads: Output gump
Forum Title Date
Script Support How do I change the hue output of Sendmessage Jan 2, 2017
Mono Support How do you see the console output after you have left your session? Jan 13, 2016
Script Support On the question of world output Nov 21, 2015
Script Support Gump not showing correct string value Feb 24, 2019
Archived Bug Reports Confirmation Moongates warning gump and missing strings Feb 8, 2019
Support Multiple Instances of the same SuperGump? Jan 29, 2019
Script Support Gumps and font faces Jan 28, 2019