Frogger3140

clearspambricks w/o client

Jan 16th, 2012
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.94 KB | None | 0 0
  1. function ClearSpamBricks()
  2. {
  3. if($Server::BrickCount > 0)
  4. messageAll('MsgClearBricks', "\c3CONSOLE \c0cleared spam bricks.");
  5.  
  6. //loop through all bricks
  7. %groupCount = MainBrickGroup.getCount();
  8. for(%i = 0; %i < %groupCount; %i++)
  9. {
  10. %group = MainBrickGroup.getObject(%i);
  11. %count = %group.getCount();
  12. for(%j = 0; %j < %count; %j++)
  13. {
  14. %brick = %group.getObject(%j);
  15.  
  16. //we're only interested in bricks...
  17. if(!(%brick.getType() & $TypeMasks::FxBrickAlwaysObjectType))
  18. continue;
  19.  
  20. //that are on the ground...
  21. if(%brick.getDistanceFromGround() != 0)
  22. continue;
  23.  
  24. //and planted...
  25. if(!%brick.isPlanted)
  26. continue;
  27.  
  28. //and not dead...
  29. if(%brick.isDead)
  30. continue;
  31.  
  32. %brickData = %brick.getDataBlock().getID();
  33. if(%brickData.category $= "Baseplates")
  34. {
  35. //it's a baseplate, but if it's all alone and red or has an item attached to it, it's probably still spam
  36. if(%brick.getNumUpBricks() == 0 && (%brick.getColorID() == 0 || isObject(%brick.item)) )
  37. {
  38. %brick.killBrick();
  39. }
  40. //if this is a red "plain" or "road" baseplate with an identical baseplate on top of it, it's probably spam
  41. else if(%brick.getNumUpBricks() == 1 && %brick.getColorID() == 0 && (%brickData.subCategory $= "Plain" || %brickData.subCategory $= "Road"))
  42. {
  43. %upBrick = %brick.getUpBrick(0);
  44. if(%upBrick.getDataBlock().getID() == %brickData && %upBrick.getColorID() == 0)
  45. %brick.killBrick();
  46. }
  47. }
  48. else
  49. {
  50. //not a baseplate, kill it
  51. %brick.killBrick();
  52. }
  53. }
  54. }
  55. }
  56.  
  57. function ClearFloatingBricks()
  58. {
  59. if($Server::BrickCount > 0)
  60. messageAll('MsgClearBricks', "\c3CONSOLE \c0cleared floating bricks.");
  61.  
  62. //loop through all bricks
  63. %groupCount = MainBrickGroup.getCount();
  64. for(%i = 0; %i < %groupCount; %i++)
  65. {
  66. %group = MainBrickGroup.getObject(%i);
  67. %count = %group.getCount();
  68. for(%j = 0; %j < %count; %j++)
  69. {
  70. %brick = %group.getObject(%j);
  71. if(!(%brick.getType() & $TypeMasks::FxBrickAlwaysObjectType))
  72. continue;
  73.  
  74. if(%brick.getDistanceFromGround() != 2147483647)
  75. continue;
  76.  
  77. if(!%brick.isPlanted)
  78. continue;
  79.  
  80. if(%brick.isDead)
  81. continue;
  82.  
  83. %brick.killBrick();
  84. }
  85. }
  86. }
  87.  
  88.  
  89. //clear far away bricks requires a player's coordinates, thus it is unable to be consolefied
  90.  
  91. function scheduletest()
  92. {
  93. if(isEventPending($ST))
  94. {
  95. cancel($ST);
  96. return;
  97. }
  98.  
  99. echo("time delta: "@ getSimTime() - $STTime);
  100. $STTime = getSimTime();
  101.  
  102. $ST = schedule(33,0, scheduleTest);
  103.  
  104. }
Advertisement
Add Comment
Please, Sign In to add comment