Simple greeter bot: Difference between revisions

From Virtual Paradise Wiki
Jump to navigation Jump to search
mNo edit summary
Oliver (talk | contribs)
m Changed universe host
Line 23: Line 23:
     sdk = vp_create();
     sdk = vp_create();


     if(err = vp_connect_universe(sdk, "virtualparadise.gotdns.com", 57000))
     if(err = vp_connect_universe(sdk, "universe.virtualparadise.org", 57000))
     {
     {
         printf("Couldn't connect to universe(reason %d)", err);
         printf("Couldn't connect to universe(reason %d)", err);

Revision as of 15:06, 17 June 2012

<C>

  1. include <vpsdk/VP.h>
  2. include <stdio.h>
  3. include <stdlib.h>
  1. define Username "username"
  2. define Password "password"
  3. define Botname "greeterbot"
  4. define Worldname "VP-Gate"

void event_avatar_add(VPInstance sdk);

int main(int argc, char ** argv) {

   int err;
   if(err = vp_init(VPSDK_VERSION))
   {
       printf("Couldn't initialize VP API(reason %d)", err);
       return 1;
   }
   VPInstance sdk;
   sdk = vp_create();
   if(err = vp_connect_universe(sdk, "universe.virtualparadise.org", 57000))
   {
       printf("Couldn't connect to universe(reason %d)", err);
       return 1;
   }
   
   if(err = vp_login(sdk, Username, Password, Botname))
   {
       printf("Couldn't login(reason %d)", err);
       return 1;
   }
   
   if(err = vp_enter(sdk, Worldname))
   {
       printf("Couldn't enter world(reason %d)", err);
       return 1;
   }
   
   vp_event_set(sdk, VP_EVENT_AVATAR_ADD, event_avatar_add);
   
   vp_state_change(sdk);
   
   while(vp_wait(sdk, 1000) == 0){}
   return 0;

}

void event_avatar_add(VPInstance sdk) {

   char message[100];
   sprintf((char*)&message, "Hello, %s!", vp_string(sdk, VP_AVATAR_NAME));
   vp_say(sdk, (char*)&message);

} </C>