VP EVENT TELEPORT: Difference between revisions

From Virtual Paradise Wiki
Jump to navigation Jump to search
Roy Curtis (talk | contribs)
m test of event page
Sleepy E (talk | contribs)
m Fixed an incorrect link and broken example
 
(10 intermediate revisions by one other user not shown)
Line 1: Line 1:
{{SDK event page|Teleport|Received by the client when a [[vp_teleport]] is fired for that client's session number.
{{sdk event page|Teleport|A request for the receiving client to teleport to a location, sent to the client from a {{sdk function|teleport_avatar}} method.
|attributes=
|attributes=
  {{sdk attribute row|int  |avatar_session|Source session ID of the teleport request}}
  {{sdk attribute row|float |teleport_x    |Destination X coordinate}}
  {{sdk attribute row|float |teleport_y    |Destination Y coordinate}}
  {{sdk attribute row|float |teleport_z    |Destination Z coordinate}}
  {{sdk attribute row|float |teleport_pitch|Destination pitch rotation}}
  {{sdk attribute row|float |teleport_yaw  |Destination yaw rotation}}
  {{sdk attribute row|string|teleport_world|Destination world}}
|behavior=
|behavior=
* If {{sdk attribute|teleport_world}} is a blank string, it should be assumed that the client use its current world
* This event is only broadcasted to the target session; no other sessions will see it
* This event is only broadcasted to the target session; no other sessions will see it
* The teleport is not ''enforced'' by the server; the client may ignore the event and not act upon it
* The teleport is not enforced by the server; the client may ignore the event
|examples=
:''This is a minimal program example which contains no error checking''
<syntaxhighlight lang="c">
#include <vpsdk/VP.h>
#include <stdio.h>
#include <stdlib.h>
 
#define Username "User"
#define Password "1234"
#define World    "VP-Build"
 
VPInstance sdk;
 
void handle_event_teleport(VPInstance sdk)
{
    // Only teleports to given coordinates and rotation, not world
    // To teleport, we need to set our MY_* attributes to given teleport
    // attributes and change state
    vp_float_set(sdk, VP_MY_X, vp_float(sdk, VP_TELEPORT_X));
    vp_float_set(sdk, VP_MY_Y, vp_float(sdk, VP_TELEPORT_Y));
    vp_float_set(sdk, VP_MY_Z, vp_float(sdk, VP_TELEPORT_Z));
    vp_float_set(sdk, VP_MY_PITCH, vp_float(sdk, VP_TELEPORT_PITCH));
    vp_float_set(sdk, VP_MY_YAW, vp_float(sdk, VP_TELEPORT_YAW));
 
    vp_state_change(sdk);
}
 
int main(int argc, const char* argv[])
{
    vp_init(VPSDK_VERSION);
 
    sdk = vp_create();
 
    vp_connect_universe(sdk, "universe.virtualparadise.org", 57000);   
    vp_login(sdk, Username, Password, "VPBot");
    vp_enter(sdk, World);
    vp_state_change(sdk);
    vp_event_set(sdk, VP_EVENT_TELEPORT, handle_event_teleport);
   
    while(vp_wait(sdk, 1000) == 0){}
    return 0;
}
</syntaxhighlight>
|seealso=
|seealso=
}}
}}

Latest revision as of 08:45, 22 July 2018

Event set and handler snippet

vp_event_set(instance, VP_EVENT_TELEPORT, event_teleport);

void event_teleport(VPInstance instance) { }

A request for the receiving client to teleport to a location, sent to the client from a vp_teleport_avatar() method.

Attributes

Attribute Usage
VP_AVATAR_SESSION Source session ID of the teleport request
VP_TELEPORT_X Destination X coordinate
VP_TELEPORT_Y Destination Y coordinate
VP_TELEPORT_Z Destination Z coordinate
VP_TELEPORT_PITCH Destination pitch rotation
VP_TELEPORT_YAW Destination yaw rotation
VP_TELEPORT_WORLD Destination world

Behavior

  • If VP_TELEPORT_WORLD is a blank string, it should be assumed that the client use its current world
  • This event is only broadcasted to the target session; no other sessions will see it
  • The teleport is not enforced by the server; the client may ignore the event

Examples

This is a minimal program example which contains no error checking
#include <vpsdk/VP.h>
#include <stdio.h>
#include <stdlib.h>

#define Username "User"
#define Password "1234"
#define World    "VP-Build"

VPInstance sdk;

void handle_event_teleport(VPInstance sdk)
{
    // Only teleports to given coordinates and rotation, not world
    // To teleport, we need to set our MY_* attributes to given teleport
    // attributes and change state
    vp_float_set(sdk, VP_MY_X, vp_float(sdk, VP_TELEPORT_X));
    vp_float_set(sdk, VP_MY_Y, vp_float(sdk, VP_TELEPORT_Y));
    vp_float_set(sdk, VP_MY_Z, vp_float(sdk, VP_TELEPORT_Z));
    vp_float_set(sdk, VP_MY_PITCH, vp_float(sdk, VP_TELEPORT_PITCH));
    vp_float_set(sdk, VP_MY_YAW, vp_float(sdk, VP_TELEPORT_YAW));

    vp_state_change(sdk);
}

int main(int argc, const char* argv[])
{
    vp_init(VPSDK_VERSION);

    sdk = vp_create();

    vp_connect_universe(sdk, "universe.virtualparadise.org", 57000);    
    vp_login(sdk, Username, Password, "VPBot");
    vp_enter(sdk, World);
    vp_state_change(sdk);
    vp_event_set(sdk, VP_EVENT_TELEPORT, handle_event_teleport);
    
    while(vp_wait(sdk, 1000) == 0){}
    return 0;
}