Simple greeter bot: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
Line 53: | Line 53: | ||
{ | { | ||
char message[100]; | char message[100]; | ||
sprintf(&message, "Hello, %s!", vp_string(VP_AVATAR_NAME)); | sprintf((char*)&message, "Hello, %s!", vp_string(sdk, VP_AVATAR_NAME)); | ||
vp_say(sdk, &message); | vp_say(sdk, (char*)&message); | ||
} | } | ||
</C> | </C> |
Revision as of 16:26, 23 October 2007
<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, "virtualparadise.gotdns.com", 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); while(1) { vp_wait(sdk, 100); } 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>