Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Timers;
- using OpenMetaverse;
- namespace MyFirstBot
- {
- class MyFirstBot
- {
- static Timer _timer;
- static int fiveseconds = 0;
- public static GridClient Client = new GridClient();
- private static string first_name = "KellbossBot";
- private static string last_name = "Resident";
- private static string password = "**obscured**";
- static void Main(string[] args)
- {
- _timer = new Timer(5000);
- _timer.Elapsed += new ElapsedEventHandler(_timer_elapsed);
- _timer.Enabled = true;
- string startLocation = NetworkManager.StartLocation("Nogojiri", 178, 42, 54);
- Client.Network.LoginProgress += new EventHandler<LoginProgressEventArgs>(Network_LoginProgress);
- if (Client.Network.Login(first_name, last_name, password, "My First Bot", startLocation, "Your name"))
- {
- Console.WriteLine("I logged into Second Life!");
- }
- else
- {
- Console.WriteLine("I couldn't log in, here is why: " + Client.Network.LoginMessage);
- Console.WriteLine("press enter to close...");
- Console.ReadLine();
- }
- }
- static void Network_LoginProgress(object sender, LoginProgressEventArgs e)
- {
- if (e.Status == LoginStatus.Success)
- {
- Console.WriteLine("I'm connected to the simulator, going to greet everyone around me");
- Client.Self.Chat("Hello World!", 0, ChatType.Normal);
- }
- }
- static void _timer_elapsed(Object sender, ElapsedEventArgs e)
- {
- fiveseconds++;
- if (fiveseconds == 20)
- {
- Console.WriteLine("Now I am going to logout of SL.. Goodbye!");
- Client.Self.Chat("I'm logging out now!", 0, ChatType.Normal);
- Client.Network.Logout();
- Console.WriteLine("I am Loged out please press enter to close...");
- Console.ReadLine();
- }
- Console.WriteLine("Timer event fired; saying hello...");
- Client.Self.Chat("Hello World! I'm a robot", 0, ChatType.Normal);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment