Script v1.7.1.0
- AI
- Animals
- Contracts
- Debug
- Economy
- Effects
- Events
- Farms
- GUI
- Handtools
- I3d
- Materials
- Misc
- Objects
- Placeables
- Player
- Shop
- Sounds
- Specializations
- Triggers
- Utils
- Vehicles
- Weather
Engine v1.7.1.0
- AI
- Animation
- Camera
- Entity
- Fillplanes
- General
- I3D
- Input
- Lighting
- Math
- Network
- Node
- Overlays
- Particle System
- Physics
- Rendering
- Scenegraph
- Shape
- Sound
- Spline
- String
- Terrain Detail
- Text Rendering
- Tire Track
- XML
- general
Foundation Reference
PlayerToggleLightEvent
ParentEventFunctions
emptyNew
DescriptionCreate an empty instanceDefinition
emptyNew()Return Values
table | instance | Instance of object |
11 | function PlayerToggleLightEvent:emptyNew() |
12 | local self = Event:new(PlayerToggleLightEvent_mt) |
13 | return self |
14 | end |
new
DescriptionCreate an instanceDefinition
new(table player)Arguments
table | player | player instance |
table | instance | Instance of object |
20 | function PlayerToggleLightEvent:new(player, isActive) |
21 | self.player = player |
22 | self.isActive = isActive |
23 | return self |
24 | end |
readStream
DescriptionReads network streamDefinition
readStream(integer streamId, table connection)Arguments
integer | streamId | network stream identification |
table | connection | connection information |
30 | function PlayerToggleLightEvent:readStream(streamId, connection) |
31 | self.player = NetworkUtil.readNodeObject(streamId) |
32 | self.isActive = streamReadBool(streamId) |
33 | self:run(connection) |
34 | end |
run
DescriptionRun eventDefinition
run(table connection)Arguments
table | connection | connection information |
48 | function PlayerToggleLightEvent:run(connection) |
49 | if not connection:getIsServer() then |
50 | g_server:broadcastEvent(self, false, connection, self.player) |
51 | end |
52 | |
53 | self.player:setLightIsActive(self.isActive, true) |
54 | end |
sendEvent
DescriptionDefinitionsendEvent()Code
58 | function PlayerToggleLightEvent.sendEvent(player, active, noEventSend) |
59 | if noEventSend == nil or noEventSend == false then |
60 | if g_server ~= nil then |
61 | g_server:broadcastEvent(PlayerToggleLightEvent:new(player, active), nil, nil, player) |
62 | else |
63 | g_client:getServerConnection():sendEvent(PlayerToggleLightEvent:new(player, active)) |
64 | end |
65 | end |
66 | end |
writeStream
DescriptionWrites network streamDefinition
writeStream(integer streamId, table connection)Arguments
integer | streamId | network stream identification |
table | connection | connection information |
40 | function PlayerToggleLightEvent:writeStream(streamId, connection) |
41 | NetworkUtil.writeNodeObject(streamId, self.player) |
42 | streamWriteBool(streamId, self.isActive) |
43 | end |