meta data for this page
Vehicles/VehicleScripts/NetworkEvents/VehicleLightingEvents.lua
This file contains all event that are relevant for VehicleLighting.
25 26 EventSetLightState = EventSetLightState or ExtensionOf(BaseEvent); 27 28 InitVanillaEvent(EventSetLightState, "EventSetLightState"); 29 30 function EventSetLightState:sendData(entity, headlight, turnLight, beaconLight) 31 streamWriteEntityId(entity); 32 33 streamBeginWriteBitwise(); 34 streamWriteUIntN(headlight, 2); 35 streamWriteUIntN(turnLight, 2); 36 streamWriteBit(beaconLight); 37 streamEndWriteBitwise(); 38 end; 39 40 function EventSetLightState:receiveData(connection) 41 local entity = streamReadEntityId(); 42 43 streamBeginReadBitwise(); 44 local headlight = streamReadUIntN(2); 45 local turnLight = streamReadUIntN(2); 46 local beaconLight = streamReadBit(); 47 streamEndReadBitwise(); 48 49 if entity ~= nil then 50 entity:setHeadlightsState(headlight, true); 51 entity:setTurnLightsState(turnLight, true); 52 entity:setBeaconLightsState(beaconLight, true); 53 end; 54 55 self:broadcastEvent(connection, entity, headlight, turnLight, beaconLight); 56 end; 57 58 59 60 EventSetCustomLight = EventSetCustomLight or ExtensionOf(BaseEvent); 61 62 InitVanillaEvent(EventSetCustomLight, "EventSetCustomLight"); 63 64 function EventSetCustomLight:sendData(entity, key, state) 65 streamWriteEntityId(entity); 66 67 streamBeginWriteBitwise(); 68 streamWriteUIntN(key, 7); 69 streamWriteBit(state); 70 streamEndWriteBitwise(); 71 end; 72 73 function EventSetCustomLight:receiveData(connection) 74 local entity = streamReadEntityId(); 75 76 streamBeginReadBitwise(); 77 local key = streamReadUIntN(7); 78 local state = streamReadBit(); 79 streamEndReadBitwise(); 80 81 if entity ~= nil then 82 entity:setCustomLightState(key, state, true); 83 end; 84 85 self:broadcastEvent(connection, entity, key, state); 86 end; 87 88 EventSetLightRotation = EventSetLightRotation or ExtensionOf(BaseEvent); 89 90 InitVanillaEvent(EventSetLightRotation, "EventSetLightRotation"); 91 92 function EventSetLightRotation:sendData(entity, key, rotY) 93 streamWriteEntityId(entity); 94 95 streamWriteUInt8(key); 96 streamWriteFloat(rotY); 97 end; 98 99 function EventSetLightRotation:receiveData(connection) 100 local entity = streamReadEntityId(); 101 102 local key = streamReadUInt8(); 103 local rotY = streamReadFloat(); 104 105 if entity ~= nil then 106 entity:setRotatableLightRotation(key, rotY, true); 107 end; 108 109 self:broadcastEvent(connection, entity, key, rotY); 110 end;
Copyright
All contents of this page may be used for modding use for Winter Resort Simulator - Season 2 only. Any use exceeding this regulation is not permitted.
Copyright (C) HR Innoways, 2021. All Rights Reserved.