ShapeClass.client_onInteract
Called when a Player is interacting with the Interactable by pressing the 'Use' key (default 'E') or pressing '0–9' if the Interactable is connected to a seat. (See: Interactable.pressSeatInteractable)
Kind: Callback
Environments: Game
Game
Callback side: Client
ShapeClass:client_onInteract( character, state )
Note: If this method is defined, the player will see the interaction text "E Use" when looking at the Shape.
-- Example of interaction
function MySwitch.client_onInteract( self, character, state )
if state == true then
self.network:sendToServer( 'sv_n_toggle' )
end
end
function MySwitch.sv_n_toggle( self )
-- Toggle on and off
self.interactable.active = not self.interactable.active
end
Parameters:
| Name | Type | Description |
|---|---|---|
self |
table | The class instance. |
character |
Character | The Character of the Player that is interacting with the Interactable. |
state |
boolean | The interaction state. (true if pressed, false if released) |