Vp event set: Difference between revisions

From Virtual Paradise Wiki
Jump to navigation Jump to search
Sleepy E (talk | contribs)
Basic layout
 
Line 1: Line 1:
<C>int vp_event_set(VPInstance instance, int eventname, void (*event)(VPInstance sender))</C>
{{sdk method page|event_set|Register an event handler.
== Description ==
|paramex=event_name, event
Sets a handler for a specific event.
|parameters=
== Examples ==
  {{sdk parameter row|vp_callback_t  |event_name |[[:Category:SDK events|Event]] to set handler for}}
<C>void avatar_add(VPInstance instance)
  {{sdk parameter row|VPEventHandler |event     |Event handler}}
|returncodes=
|behavior=
|caveats=
|examples=
<syntaxhighlight lang="c">
void handle_avatar_add(VPInstance sdk)
{
{
    printf("%s enters.\n", vp_string(instance, VP_AVATAR_NAME));
  printf("%s enters.\n", vp_string(sdk, VP_AVATAR_NAME));
}</C>
}
<C>vp_event_set(instance, VP_EVENT_AVATAR_ADD, avatar_add);</C>


[[Category: SDK]]
int main(int argc, const char* argv[])
{
  //...
 
  vp_event_set(sdk, VP_EVENT_AVATAR_ADD, handle_avatar_add);
 
  //...
}
</syntaxhighlight>
|seealso=
}}

Latest revision as of 22:03, 13 December 2016

Method call snippet vp_event_set(instance, event_name, event);

Register an event handler.

Parameters

These are the parameters that this method requires:

Parameter Usage
VPInstance
instance
Pointer to the instance this method call is intended for
vp_callback_t
event_name
Event to set handler for
VPEventHandler
event
Event handler

Returns

This method returns a return code integer, which indicates whether the call was successful or errored for any reason:

Return code Cause
VP_RC_SUCCESS Successful call (for methods that have a registered callback, it only means the request has been sent)

Behavior

There is no special behavior for this method

Examples

void handle_avatar_add(VPInstance sdk)
{
  printf("%s enters.\n", vp_string(sdk, VP_AVATAR_NAME));
}

int main(int argc, const char* argv[])
{
  //...

  vp_event_set(sdk, VP_EVENT_AVATAR_ADD, handle_avatar_add);

  //...
}