scripting:reference:system_functions:playerbuildingownershipfunctions
This is an old revision of the document!
Table of Contents
Building Ownership functions
Functions allowing you to query and manipulate the ownership of buildings
sysPlayerGetNumBuildingsOfType
| Format | sysPlayerGetNumBuildingsOfType ( PlayerID, BuildingType ) |
|---|---|
| Description | Returns the number of buildings of a particular type that the specified player currently owns |
| Returns | Number owned |
Example:
Event( "Custom", "CountBuildings" )
{
$numOwned = sysPlayerGetNumBuildingsOfType( $gPlayerID, 10 )
*msg %PLAYER% You currently own $numOwned type 10 buildings
}
sysPlayerGetNearestOwnedBuildingOfType
| Format | sysPlayerGetNearestOwnedBuildingOfType ( PlayerID, BuildingType, WorldX, WorldY ) |
|---|---|
| Description | Locates the nearest building of the specified type owned by the player. If no WorldX, WorldY is specified, the players current position is used instead |
| Returns | BuildingID or 0 if the player doesn't own a building of that type |
Example:
Function FindNearestBuildingOfType( $buildingType )
{
$buildingID = sysPlayerGetNearestOwnedBuildingOfType( $gPlayerID, $buildingType )
if ( $buildingID == 0 )
{
*msg %PLAYER% You don't own any type $buildingType buildings
}
else
{
$buildingName = sysGetBuildingName( $buildingID )
*msg %PLAYER% The nearest type $buildingType building that you own is $buildingName
}
}
sysPlayerGetOwnedBuilding
| Format | sysPlayerGetOwnedBuilding ( PlayerID, Index ) |
|---|---|
| Description | Used to get the IDs of a specific building owned by the player |
| Returns | BuildingID or 0 if the player doesnt own that many buildings |
| Notes |
Example:
Function SendOwnedBuildingsList( $playerID )
{
$playerName = sysGetPlayerName( $playerID )
$loop = 1
while( $loop < 10 )
{
$buildingID = sysPlayerGetOwnedBuilding( $playerID, $loop )
// No more buildings
if ( $buildingID == 0 )
{
return
}
$buildingName = sysGetBuildingName( $buildingID )
*msg $playerName Building $loop : ID = $buildingID ( $buildingName )
$loop += 1
}
}
scripting/reference/system_functions/playerbuildingownershipfunctions.1581068974.txt.gz · Last modified: (external edit)
