King_ZZ

PlaceableSilo_NetworkSnippet

Nov 29th, 2021 (edited)
656
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.32 KB | None | 0 0
  1. --[[ functions;
  2. PlaceableSilo:getFillLevel()
  3. PlaceableSilo:setFillLevel(newFillLevel)
  4. PlaceableSilo:getHemisphereRadiusFromVolume(volume)
  5. PlaceableSilo:forceMovePlane()
  6. PlaceableSilo:setFillType(fillType)
  7.  
  8. oldFillLevel
  9. ]]
  10.            
  11. --network needed for
  12. -- item bought --done
  13. -- fill level
  14. -- fill type
  15. -- display amount
  16.  
  17. function PlaceableSilo:readStream(streamId, connection)
  18.     PlaceableSilo:superClass().readStream(self, streamId, connection);
  19. end;
  20.  
  21. function PlaceableSilo:writeStream(streamId, connection)
  22.     PlaceableSilo:superClass().writeStream(self, streamId, connection);
  23. end;
  24.  
  25. function PlaceableSilo:readUpdateStream(streamId, timestamp, connection)
  26.     PlaceableSilo:superClass().readUpdateStream(self, streamId, timestamp, connection);
  27.     if connection:getIsServer() then
  28.         self.fillLevel = streamReadFloat32(streamId);
  29.  
  30.         PlaceableSilo.forceMovePlane(self);  
  31.  
  32.         if self.fillLevel <= 0 and self.isServer then
  33.             g_currentMission.vehiclesToDelete[self] = self;
  34.         end;
  35.     end;
  36. end;
  37.  
  38. function PlaceableSilo:writeUpdateStream(streamId, connection, dirtyMask)
  39.     PlaceableSilo:superClass().writeUpdateStream(self, streamId, connection, dirtyMask);
  40.     if not connection:getIsServer() then
  41.         streamWriteFloat32(streamId, self.fillLevel);
  42.     end;
  43. end;
Add Comment
Please, Sign In to add comment