scripting:reference:system_functions:townfunctions
This is an old revision of the document!
Table of Contents
Town information and control functions
Town Functions
sysGetNearestTown
sysTownGetRelationship
sysTownGetNumBuildingsOfType
Format | sysTownGetNumBuildingsOfType( TownBuildingID, BuildingType ) |
---|---|
Description | Returns the number of buildings of this type currently exist within the specified town. Useful for when you want to script a system that limits the number of a particular type of building per town |
Returns | Number of this type of building in the town |
Example:
Event( "PlaceAnyBuilding", "" ) { $nBuildingType = $gParam[1] $nearestTownID = sysGetNearestTown( $gPlayerWorldX, $gPlayerWorldY ) $numInTown = sysTownGetNumBuildingsOfType( $nearestTownID, $nBuildingType ) if ( $numInTown >= 3 ) { *msg %PLAYER% There can only be 3 of each type of building in each town CancelTransaction() } else { $valid = sysIsBuildingPositionValid( $nBuildingType ) if ( $valid = 1 ) { $buildingName = sysGetTextEntry() $constrAmount = -1 $didAdd = sysAddBuildingWorld( $nBuildingType,$gPlayerID,$gPlayerWorldX,$gPlayerWorldY,$buildingName,$constrAmount ) } } }
scripting/reference/system_functions/townfunctions.1581067521.txt.gz · Last modified: 2020/02/07 03:25 by mit