Server Hooks

Hook Summary

PlayXIsPermitted(ply, instance)
Called to check whether a user can use PlayX.
PlayXMediaBegan(instance, handler, uri, start, resumeSupported, lowFramerate, handlerArgs, length)
Called after BeginMedia().
PlayXMediaBegin(instance, handler, uri, start, resumeSupported, lowFramerate, handlerArgs, length)
Called on BeginMedia().
PlayXMediaEnd(instance)
Called right before media end.
PlayXMediaEnded(instance)
Called on media end.
PlayXMediaExpire(instance, media)
Called when a piece of media has finished.
PlayXMediaOpen(instance, provider, uri, start, forceLowFramerate, useJW, result)
Called when OpenMedia() has been called on an entity.
PlayXMetadataReceive(instance, existingMedia, data)
Called when metadata is received.
PlayXRemove(instance)
Called a PlayX entity is being removed.
PlayXRepeaterSpawnFunction(ply, tr)
Called when a client requests a spawn of a PlayX repeater.
PlayXRepeaterUse(instance, activator, caller)
Called when a client does use on a PlayX repeater.
PlayXResolveProvider(provider, uri, useJW)
Called when a provider is being resolved.
PlayXSelectInstance(ply)
Called when a single main entity (for a provided client if available) is required.
PlayXShouldAutoSubscribe(ply, instance)
This hook is used to determine whether a user should be automatically subscribed to a player in the event of the user having just joined or in the event of an entity being spawned.
PlayXSpawnFunction(ply, tr)
Called when a client requests a spawn of a PlayX player.
PlayXSpawnPlayX(ply, model, repeater, mdl)
Called when a player or repeater is being spawned for a user.
PlayXSubscribe(instance, ply)
Called when a player is being subscribed to an instance.
PlayXUnsubscribe(instance, ply)
Called when a player is being unsubscribed from an instance.
PlayXUse(instance, activator, caller)
Called when a client does use on a PlayX player.

Hooks

PlayXIsPermitted

PlayXIsPermitted(ply, instance)

Called to check whether a user can use PlayX. This is called when requesting media and also when spawning a player. In the case of requesting or closing media, the entity that it is for will be passed. If you want to deny all default control mechanism, use this hook and return false.

Parameters:

  • ply - Player
  • instance - PlayX entity

Return value:

  • True/false to allow/deny

PlayXMediaBegan

PlayXMediaBegan(instance, handler, uri, start, resumeSupported, lowFramerate, handlerArgs, length)

Called after BeginMedia().

Parameters:

  • instance - PlayX entity
  • handler
  • uri
  • start
  • resumeSupported
  • lowFramerate
  • handlerArgs - Arguments for the handler, can be nil
  • length - Length of the media in seconds, can be nil

PlayXMediaBegin

PlayXMediaBegin(instance, handler, uri, start, resumeSupported, lowFramerate, handlerArgs, length)

Called on BeginMedia().

Parameters:

  • instance - PlayX entity
  • handler
  • uri
  • start
  • resumeSupported
  • lowFramerate
  • handlerArgs - Arguments for the handler, can be nil
  • length - Length of the media in seconds, can be nil

Return value:

  • Nil/true to pass or false to fail

PlayXMediaEnd

PlayXMediaEnd(instance)

Called right before media end.

Parameters:

  • instance - PlayX entity

Return value:

  • False to prevent

PlayXMediaEnded

PlayXMediaEnded(instance)

Called on media end.

Parameters:

  • instance - PlayX entity

PlayXMediaExpire

PlayXMediaExpire(instance, media)

Called when a piece of media has finished. This is only called if the length of the media was provided via the metadata functions.

Parameters:

  • instance - PlayX entity
  • media - ENT.Media

PlayXMediaOpen

PlayXMediaOpen(instance, provider, uri, start, forceLowFramerate, useJW, result)

Called when OpenMedia() has been called on an entity. Remember that BeginMedia() gets called latter, and OpenMedia() can be skipped. This hook can be used to block the media or change it.

Parameters:

  • instance - PlayX entity
  • provider - Name of provider, leave blank to auto-detect
  • uri - URI to play
  • start - Time to start the video at, in seconds
  • forceLowFramerate - Force the client side players to play at 1 FPS
  • useJW - True to allow the use of the JW player, false for otherwise, nil to default true
  • result - Result resolved

Return values:

  1. Nil/true to pass, a table to override result, or false to fail
  2. Error message in the case of failure

PlayXMetadataReceive

PlayXMetadataReceive(instance, existingMedia, data)

Called when metadata is received. A table can be returned to replace the metadata that has been received.

Parameters:

  • instance - PlayX entity
  • existingMedia - Untouched Media table
  • data - Received metadata table

Return value:

  • New data table or nil

PlayXRemove

PlayXRemove(instance)

Called a PlayX entity is being removed.

Parameters:

  • instance - PlayX entity

PlayXRepeaterSpawnFunction

PlayXRepeaterSpawnFunction(ply, tr)

Called when a client requests a spawn of a PlayX repeater. This is called directly when the entity's SpawnFunction hook is called.

Parameters:

  • ply - Player
  • tr - Trace

Return value:

  • False to prevent standard behavior

PlayXRepeaterUse

PlayXRepeaterUse(instance, activator, caller)

Called when a client does use on a PlayX repeater. The use type is SIMPLE_USE. Instead of using this hook, you can also override the entity's OnUse hook.

Parameters:

  • instance - PlayX repeater entity
  • activator - See Gmod wiki
  • caller - See Gmod wiki

PlayXResolveProvider

PlayXResolveProvider(provider, uri, useJW)

Called when a provider is being resolved.

Parameters:

  • provider
  • uri
  • useJW

Return value:

  • Nil to do nothing, or a provider

PlayXSelectInstance

PlayXSelectInstance(ply)

Called when a single main entity (for a provided client if available) is required. Since a user is provided (though not necessarily in all cases that call this hook), you can use it to choose the closest PlayX entity that a user has access to. If you have a sandbox-based gamemode and you wanted to allow the PlayX tool menu controls to work, you would have to define this hook. Also, when the bookmarks manager is used (sandbox not required), it goes through the same mechanisms that the tool panel uses, so if you want the bookmark manager to work, you have to define this hook as well. However, the client-side PlayXRequestOpenMedia hook also lets you control this process much earlier on the client, so there you could popup a dialog to select an entity if it's too ambiguous, although you would have to skip the server-side portion of this media request/control process.

Parameters:

  • ply - Player or nil

Return value:

  • PlayX entity or nil

PlayXShouldAutoSubscribe

PlayXShouldAutoSubscribe(ply, instance)

This hook is used to determine whether a user should be automatically subscribed to a player in the event of the user having just joined or in the event of an entity being spawned. By default, everyone will always be automatically subscribed, so this hook should be defined in most cases, possibly returning false all the time to prevent automatic subscription all together.

Parameters:

  • ply - Player
  • instance - PlayX entity

Return value:

  • False to deny

PlayXSpawnFunction

PlayXSpawnFunction(ply, tr)

Called when a client requests a spawn of a PlayX player. This is called directly when the entity's SpawnFunction hook is called.

Parameters:

  • ply - Player
  • tr - Trace

Return value:

  • False to prevent standard behavior

PlayXSpawnPlayX

PlayXSpawnPlayX(ply, model, repeater, mdl)

Called when a player or repeater is being spawned for a user. Normally this is called when the entity is spawned via the Entities menu of sandbox gamemodes (which can be intercepted earlier using the SpawnFunction hooks). This hook can be used to allow the spawn, prevent it, or change the position and angle that the player is spawned at.

Parameters:

  • ply - Player
  • model
  • repeater - True if for the repeater
  • mdl - Model name

Return values:

  1. Nil or true to allow, false to deny, vector to change position
  2. Error message if false, angle if vector was provided as first return

PlayXSubscribe

PlayXSubscribe(instance, ply)

Called when a player is being subscribed to an instance. Return false in order to prevent the subscription from happening.

Parameters:

  • instance - PlayX entity
  • ply - Player

Return value:

  • Nil to pass through or false to prevent

PlayXUnsubscribe

PlayXUnsubscribe(instance, ply)

Called when a player is being unsubscribed from an instance. Return false in order to prevent the unsubscription from happening.

Parameters:

  • instance - PlayX entity
  • ply - Player

Return value:

  • Nil to pass or false to prevent

PlayXUse

PlayXUse(instance, activator, caller)

Called when a client does use on a PlayX player. The use type is SIMPLE_USE. Instead of using this hook, you can also override the entity's OnUse hook.

Parameters:

  • instance - PlayX entity
  • activator - See Gmod wiki
  • caller - See Gmod wiki