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?
using System.IO;
...
public override void OnResponse( Server.Network.NetState sender, RelayInfo info )
{
using (TextWriter tw = File.CreateText(Path.Combine(Environment.CurrentDirectory, "THE_TEXTFILE_NAME.txt")))
{
tw.WriteLine($"The player {sender.Mobile.Name} sent this:");
tw.WriteLine(info.TextEntries[0].Text);
}
public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
{
Mobile from = sender.Mobile;
switch(info.ButtonID)
{
case 0:
{
break;
}
case 1:
{
using (TextWriter tw = File.CreateText(Path.Combine(Environment.CurrentDirectory, "Staff_Rating.txt")))
{
tw.WriteLine("The player {sender.Mobile.Name} sent this:");
tw.WriteLine(info.TextEntries[2].Text);
tw.WriteLine(info.TextEntries[3].Text);
tw.WriteLine(info.TextEntries[4].Text);
break;
}
}
}
}
case 1:
{
if (!Directory.Exists("Logs"))
Directory.CreateDirectory("Logs");
var directory = Path.Combine("Logs", "Rating");
if (!Directory.Exists(directory))
Directory.CreateDirectory(directory);
try
{
using (TextWriter tw = File.CreateText(Path.Combine(directory, "" + info.TextEntries[1].Text + "_Rating.txt")))
{
tw.Flush();
tw.WriteLine("The player " + sender.Mobile.Name + " sent this rating");
tw.WriteLine("Staff Member:" + info.TextEntries[1].Text + " ");
tw.WriteLine("Rating:" + info.TextEntries[2].Text + " ");
tw.WriteLine("Comments:" + info.TextEntries[3].Text + " ");
}
}
catch
{
}
break;
}
We use essential cookies to make this site work, and optional cookies to enhance your experience.