Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 KB | None | 0 0
  1. function ServerCmdPlantBrick(%client)
  2. {
  3. if($Game::MissionCleaningUp)
  4. return 0;
  5.  
  6. %player = %client.player;
  7. %tempBrick = %player.tempBrick;
  8.  
  9. if(!isObject(%player))
  10. return 0;
  11.  
  12. %player.playThread(3, "plant");
  13.  
  14. %mg = %client.miniGame;
  15.  
  16. if(isObject(%mg) && !%mg.EnableBuilding)
  17. return 0;
  18.  
  19. if(getBrickCount() >= getBrickLimit())
  20. {
  21. messageClient(%client, 'MsgPlantErrror_Limit');
  22.  
  23. return 0;
  24. }
  25.  
  26. if(!%client.isAdmin && !%client.isSuperAdmin && $Server::MaxBricksPerSecond > 0)
  27. {
  28. %currTime = getSimTime();
  29.  
  30. if((%client.bpsTime + 1000) < %currTime)
  31. {
  32. %client.bpsCount = 0;
  33. %client.bpsTime = %currTime;
  34. }
  35.  
  36. if(%client.bpsCount >= $Server::MaxBricksPerSecond)
  37. return 0;
  38. }
  39.  
  40. if(!isObject(%tempBrick))
  41. return 0;
  42.  
  43. %tempBrickTrans = %tempBrick.getTransform();
  44. %tempBrickPos = getWords(%tempBrickTrans, 0, 2);
  45. %brickData = %tempBrick.getDataBlock();
  46.  
  47. %brickRadius = %brickData.brickSizeY;
  48.  
  49. if(%brickData.brickSizeX > %brickData.brickSizeY)
  50. %brickRadius = %brickData.brickSizeX;
  51.  
  52. %brickRadius *= 0.25;
  53.  
  54. if($Pref::Server::TooFarDistance $= "" || $Pref::Server::TooFarDistance == 0)
  55. $Pref::Server::TooFarDistance = 50;
  56.  
  57. $Pref::Server::TooFarDistance = mClampF($Pref::Server::TooFarDistance, 20, 99999);
  58.  
  59. if(VectorDist(%tempBrickPos, %player.getPosition()) > ($Pref::Server::TooFarDistance + %brickRadius))
  60. {
  61. messageClient(%client, 'MsgPlantError_TooFar');
  62.  
  63. return 0;
  64. }
  65.  
  66. %plantBrick = new fxDTSBrick()
  67. {
  68. dataBlock = %brickData;
  69.  
  70. position = %tempBrickTrans;
  71. isPlanted = true;
  72. };
  73.  
  74. %client.brickGroup.add(%plantBrick);
  75.  
  76. %plantBrick.setTransform(%tempBrickTrans);
  77. %plantBrick.setColor(%tempBrick.getColorID());
  78. %plantBrick.setPrint(%tempBrick.getPrintID());
  79.  
  80. %plantBrick.client = %client;
  81.  
  82. %plantErrorCode = %plantBrick.plant();
  83.  
  84. if(!%plantBrick.isColliding())
  85. %plantBrick.dontCollideAfterTrust = true;
  86.  
  87. %plantBrick.setColliding(0);
  88.  
  89. if(!%plantErrorCode)
  90. {
  91. if(!$Server::LAN)
  92. {
  93. if(%plantBrick.getNumDownBricks())
  94. %plantBrick.stackBL_ID = %plantBrick.getDownBrick(0).stackBL_ID;
  95. else if(%plantBrick.getNumUpBricks())
  96. %plantBrick.stackBL_ID = %plantBrick.getUpBrick(0).stackBL_ID;
  97. else
  98. %plantBrick.stackBL_ID = %client.getBLID();
  99.  
  100. if(%plantBrick.stackBL_ID <= 0)
  101. %plant.stackBL_ID = %client.getBLID();
  102. }
  103.  
  104. %client.undoStack.push(%plantBrick TAB "PLANT");
  105.  
  106. if($Server::LAN)
  107. %plantBrick.trustCheckFinished();
  108. else
  109. %plantBrick.PlantedTrustCheck();
  110.  
  111. ServerPlay3D("brickPlantSound", %plantBrick.getTransform());
  112.  
  113. %tempBrick.setColor(%client.currentColor);
  114.  
  115. %client.bpsCount++;
  116. }
  117. else
  118. {
  119. switch(%plantErrorCode)
  120. {
  121. case 1:
  122. %plantBrick.delete();
  123.  
  124. messageClient(%client, 'MsgPlantError_Overlap');
  125.  
  126. case 2:
  127. %plantBrick.delete();
  128.  
  129. messageClient(%client, 'MsgPlantError_Float');
  130.  
  131. case 3:
  132. %plantBrick.delete();
  133.  
  134. messageClient(%client, 'MsgPlantError_Stuck');
  135.  
  136. case 4:
  137. %plantBrick.delete();
  138.  
  139. messageClient(%client, 'MsgPlantError_Unstable');
  140.  
  141. case 5:
  142. %plantBrick.delete();
  143.  
  144. messageClient(%client, 'MsgPlantError_Buried');
  145.  
  146. default:
  147. %plantBrick.delete();
  148.  
  149. messageClient(%client, 'MsgPlantError_Forbidden');
  150. }
  151. }
  152.  
  153. if(getBrickCount() <= 100 && getRayTracerProgress() <= (-1) && getRayTracerProgress() < 0 && !$Server::LAN && doesAllowConnections())
  154. startRaytracer();
  155.  
  156. return %plantBrick;
  157. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement