Simple greeter bot: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
m Changed universe host |
||
Line 23: | Line 23: | ||
sdk = vp_create(); | sdk = vp_create(); | ||
if(err = vp_connect_universe(sdk, "virtualparadise. | 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>
- include <vpsdk/VP.h>
- include <stdio.h>
- include <stdlib.h>
- define Username "username"
- define Password "password"
- define Botname "greeterbot"
- 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>