User Tools

Site Tools


scripting:reference:system_functions:playerbuildingownershipfunctions

Building Ownership functions

Functions allowing you to query and manipulate the ownership of buildings

sysPlayerGetNumBuildingsOwned

Format sysPlayerGetNumBuildingsOwned ( PlayerID )
Description Returns the number of buildings the specified player currently owns
Returns Number owned

Example:

Event( "Custom", "CountBuildings" )
{
    $numOwned = sysPlayerGetNumBuildingsOfType( $gPlayerID )
    *msg %PLAYER% You currently own $numOwned 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
}

sysPlayerGetNumBuildingsOfBuildSkill

Format sysPlayerGetNumBuildingsOfBuildSkill ( PlayerID, Skill Name/Num )
Description Returns the number of buildings the specified player currently owns that require the specified build skill
Returns Number owned

Example:

Event( "Custom", "CountBuildings" )
{
    $numOwned = sysPlayerGetNumBuildingsOfBuildSkill ( $gPlayerID, "Baker" )
    *msg %PLAYER% You currently own $numOwned buildings that require the Baker skill to construct
}

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.txt · Last modified: 2023/07/18 04:15 by mit

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki