Advertisement
FocusedWolf

SentryLimit - With minimal comments

Sep 1st, 2011
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.19 KB | None | 0 0
  1. Script.Load("../ns2/lua/NS2Utility.lua")
  2.  
  3. local kSentryBuildRadius = 21 //WARNING: don't set to large because it will limit sentry building in adjacent rooms.
  4. local kMaxSentryInArea = 4
  5.  
  6. local base_CheckBuildEntityRequirements //if you're a server admin you can just have "local base_CheckBuildEntityRequirements = CheckBuildEntityRequirements"
  7. if not base_CheckBuildEntityRequirements then //This if statement is to prevent a issue with code reloads that only occurs when modders save changes to this file while ns2 is running.
  8.     base_CheckBuildEntityRequirements = CheckBuildEntityRequirements
  9. end
  10.  
  11. local sentryClassName = "Sentry"
  12. local sentryErrorMessage = "Warning: Too many Sentries!"
  13. local _GetEntitiesWithinRange = GetEntitiesWithinRange
  14. local _Count = table.count
  15. function CheckBuildEntityRequirements(techId, position, player, ignoreEntity)
  16.  
  17.     // Check if the entity is a Sentry
  18.     if kTechId.Sentry == techId and _Count(_GetEntitiesWithinRange(sentryClassName, position, kSentryBuildRadius)) >= kMaxSentryInArea then
  19.         return false, sentryErrorMessage //legalBuild, errorString
  20.     end
  21.  
  22.     return base_CheckBuildEntityRequirements(techId, position, player, ignoreEntity)
  23.  
  24. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement