![{L_SMILIES_SMILE} :)](./images/smilies/icon_e_smile.gif)
It is written in C#, you can download it at: http://www.virtualparadise.org/download ... net_r1.zip.
Code: Select all
using System;
namespace testbot
{
class MainClass
{
const string botname = "C# bot";
static string username;
static string password;
public static void Main(string[] args)
{
//Create a new VP SDK instance
VP.Instance bot = new VP.Instance();
//Set events
bot.EventAvatarAdd += event_avatar_add;
bot.EventChat += event_chat;
Console.Write("Username: ");
username = Console.ReadLine();
Console.Write("Password: ");
password = Console.ReadLine();
int rc = 0;
//Connect to the universe server
if((rc = bot.Connect("virtualparadise.gotdns.com", 57000)) > 0)
{
Console.WriteLine("Error: {0}({1})",(VP.ReasonCode)rc, rc);
Console.ReadLine();
return;
}
//Log in using your username and password
if((rc = bot.Login(username, password, botname)) > 0)
{
Console.WriteLine("Error: {0}({1})",(VP.ReasonCode)rc, rc);
Console.ReadLine();
return;
}
//Enter the world
if((rc = bot.Enter("VP-Build")) > 0)
{
Console.WriteLine("Error: {0}({1})",(VP.ReasonCode)rc, rc);
Console.ReadLine();
return;
}
//Position the avatar
bot.X = 1;
bot.Z = 2;
bot.State_Change();
while(true)
{
if((rc = bot.Wait(100)) > 0)
{
Console.WriteLine("Error: {0}({1})",(VP.ReasonCode)rc, rc);
Console.ReadLine();
return;
}
}
}
public static void event_avatar_add(VP.Instance sender, object data)
{
VP.AvatarData avatar = (VP.AvatarData)data;
sender.Say("Hello "+avatar.Name);
}
public static void event_chat(VP.Instance sender, object data)
{
VP.ChatMessage message = (VP.ChatMessage)data;
Console.WriteLine("{0}:\t{1}", message.User, message.Text);
}
}
}