Post: MW2 Motd changer in c#
05-24-2012, 09:06 AM #1
(adsbygoogle = window.adsbygoogle || []).push({}); basically i am a noob at c#
but i have been learning and i decided to make a Motd editor
it not useful i just want to give out the source because its using hex and if people dont know then hopefully it helps Smile


    using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace MW2_Motd_Modder
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
}

private void button1_Click(object sender, EventArgs e)
{

}

private void button2_Click(object sender, EventArgs e)
{
BinaryWriter Bw = new BinaryWriter(File.OpenWrite(openFileDialog1.FileName));
for (int i = 0x4E; i <= 0x156; i++)
{
Bw.BaseStream.Position = i;
Bw.Write(textBox1.Text);
}
Bw.Close();
}
}
}


all u need is 1 text box
1 save button < the biggest script goes in there
1 open button


now i know this is nooby but its just helping people with hex lol

please dont groan :P
(adsbygoogle = window.adsbygoogle || []).push({});
05-25-2012, 03:56 AM #2
Pichu
RIP PICHU.
Originally posted by Oliver1556 View Post
basically i am a noob at c#
but i have been learning and i decided to make a Motd editor
it not useful i just want to give out the source because its using hex and if people dont know then hopefully it helps Smile


    using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace MW2_Motd_Modder
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
}

private void button1_Click(object sender, EventArgs e)
{

}

private void button2_Click(object sender, EventArgs e)
{
BinaryWriter Bw = new BinaryWriter(File.OpenWrite(openFileDialog1.FileName));
for (int i = 0x4E; i <= 0x156; i++)
{
Bw.BaseStream.Position = i;
Bw.Write(textBox1.Text);
}
Bw.Close();
}
}
}


all u need is 1 text box
1 save button < the biggest script goes in there
1 open button


now i know this is nooby but its just helping people with hex lol

please dont groan :P


When using OpenFileDialog() you can rather just create an instance of it and it is best to create a check on whether or not the person selected a file or not.

    
OpenFileDialog ofd = new OpenFileDialog();
restartdialog:
if (ofd.ShowDialog() == DialogResult.OK)
{
BinaryWriter Bw = new BinaryWriter(File.OpenWrite(ofd.FileName));
for (int i = 0x4E; i <= 0x156; i++)
{
Bw.BaseStream.Position = i;
Bw.Write(textBox1.Text);
}
Bw.Close();
}
else
{
DialogResult error = MessageBox.Show("You did not select anything! Do you wish to continue or quit the application?", "Warning", MessageBoxButtons.RetryCancel);
if (error == DialogResult.Retry)
{
goto restartdialog;
}
else
{
Close();
}
}


Rather than doing what you did, when the program loads it prompts the FileDialogBox but if he/she selects nothing and exits, then it would return to the form.

I assume too that if they didn't select anything and selected button2, then the application would crash. Rather, you can prompt the person with the dialogbox, if they choose a file then it goes through with the code normally, if they don't choose a code, then it prompts the user with an error message and allows them to retry, which sends them through the goto method or if they select no, it closes the application.
05-25-2012, 06:36 AM #3
Originally posted by Pichu View Post
When using OpenFileDialog() you can rather just create an instance of it and it is best to create a check on whether or not the person selected a file or not.

    
OpenFileDialog ofd = new OpenFileDialog();
restartdialog:
if (ofd.ShowDialog() == DialogResult.OK)
{
BinaryWriter Bw = new BinaryWriter(File.OpenWrite(ofd.FileName));
for (int i = 0x4E; i <= 0x156; i++)
{
Bw.BaseStream.Position = i;
Bw.Write(textBox1.Text);
}
Bw.Close();
}
else
{
DialogResult error = MessageBox.Show("You did not select anything! Do you wish to continue or quit the application?", "Warning", MessageBoxButtons.RetryCancel);
if (error == DialogResult.Retry)
{
goto restartdialog;
}
else
{
Close();
}
}


Rather than doing what you did, when the program loads it prompts the FileDialogBox but if he/she selects nothing and exits, then it would return to the form.

I assume too that if they didn't select anything and selected button2, then the application would crash. Rather, you can prompt the person with the dialogbox, if they choose a file then it goes through with the code normally, if they don't choose a code, then it prompts the user with an error message and allows them to retry, which sends them through the goto method or if they select no, it closes the application.


oh yea i fogot about that lol :P
05-26-2012, 07:29 PM #4
Pichu
RIP PICHU.
Originally posted by Oliver1556 View Post
oh yea i fogot about that lol :P


If you need help, just let me know and I will try my best to get back to you.
05-29-2012, 02:53 AM #5
nvm say it alreayd..
05-30-2012, 06:56 PM #6
Originally posted by SatanicAmerican View Post
nvm say it alreayd..


huh lol ? {10 f'ing chars}

The following user thanked Oliver1556 for this useful post:

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo