Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ServerCmdPlantBrick(%client)
- {
- if($Game::MissionCleaningUp)
- return 0;
- %player = %client.player;
- %tempBrick = %player.tempBrick;
- if(!isObject(%player))
- return 0;
- %player.playThread(3, "plant");
- %mg = %client.miniGame;
- if(isObject(%mg) && !%mg.EnableBuilding)
- return 0;
- if(getBrickCount() >= getBrickLimit())
- {
- messageClient(%client, 'MsgPlantErrror_Limit');
- return 0;
- }
- if(!%client.isAdmin && !%client.isSuperAdmin && $Server::MaxBricksPerSecond > 0)
- {
- %currTime = getSimTime();
- if((%client.bpsTime + 1000) < %currTime)
- {
- %client.bpsCount = 0;
- %client.bpsTime = %currTime;
- }
- if(%client.bpsCount >= $Server::MaxBricksPerSecond)
- return 0;
- }
- if(!isObject(%tempBrick))
- return 0;
- %tempBrickTrans = %tempBrick.getTransform();
- %tempBrickPos = getWords(%tempBrickTrans, 0, 2);
- %brickData = %tempBrick.getDataBlock();
- %brickRadius = %brickData.brickSizeY;
- if(%brickData.brickSizeX > %brickData.brickSizeY)
- %brickRadius = %brickData.brickSizeX;
- %brickRadius *= 0.25;
- if($Pref::Server::TooFarDistance $= "" || $Pref::Server::TooFarDistance == 0)
- $Pref::Server::TooFarDistance = 50;
- $Pref::Server::TooFarDistance = mClampF($Pref::Server::TooFarDistance, 20, 99999);
- if(VectorDist(%tempBrickPos, %player.getPosition()) > ($Pref::Server::TooFarDistance + %brickRadius))
- {
- messageClient(%client, 'MsgPlantError_TooFar');
- return 0;
- }
- %plantBrick = new fxDTSBrick()
- {
- dataBlock = %brickData;
- position = %tempBrickTrans;
- isPlanted = true;
- };
- %client.brickGroup.add(%plantBrick);
- %plantBrick.setTransform(%tempBrickTrans);
- %plantBrick.setColor(%tempBrick.getColorID());
- %plantBrick.setPrint(%tempBrick.getPrintID());
- %plantBrick.client = %client;
- %plantErrorCode = %plantBrick.plant();
- if(!%plantBrick.isColliding())
- %plantBrick.dontCollideAfterTrust = true;
- %plantBrick.setColliding(0);
- if(!%plantErrorCode)
- {
- if(!$Server::LAN)
- {
- if(%plantBrick.getNumDownBricks())
- %plantBrick.stackBL_ID = %plantBrick.getDownBrick(0).stackBL_ID;
- else if(%plantBrick.getNumUpBricks())
- %plantBrick.stackBL_ID = %plantBrick.getUpBrick(0).stackBL_ID;
- else
- %plantBrick.stackBL_ID = %client.getBLID();
- if(%plantBrick.stackBL_ID <= 0)
- %plant.stackBL_ID = %client.getBLID();
- }
- %client.undoStack.push(%plantBrick TAB "PLANT");
- if($Server::LAN)
- %plantBrick.trustCheckFinished();
- else
- %plantBrick.PlantedTrustCheck();
- ServerPlay3D("brickPlantSound", %plantBrick.getTransform());
- %tempBrick.setColor(%client.currentColor);
- %client.bpsCount++;
- }
- else
- {
- switch(%plantErrorCode)
- {
- case 1:
- %plantBrick.delete();
- messageClient(%client, 'MsgPlantError_Overlap');
- case 2:
- %plantBrick.delete();
- messageClient(%client, 'MsgPlantError_Float');
- case 3:
- %plantBrick.delete();
- messageClient(%client, 'MsgPlantError_Stuck');
- case 4:
- %plantBrick.delete();
- messageClient(%client, 'MsgPlantError_Unstable');
- case 5:
- %plantBrick.delete();
- messageClient(%client, 'MsgPlantError_Buried');
- default:
- %plantBrick.delete();
- messageClient(%client, 'MsgPlantError_Forbidden');
- }
- }
- if(getBrickCount() <= 100 && getRayTracerProgress() <= (-1) && getRayTracerProgress() < 0 && !$Server::LAN && doesAllowConnections())
- startRaytracer();
- return %plantBrick;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement