User Tools

Site Tools


scripting:reference:system_functions:playerbuildingownershipfunctions

This is an old revision of the document!


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
Parameters [PlayerID] - ID number of the player
[BuildingType] - Building type number
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
Parameters Player ID number
Building type number
WorldX, WorldY
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 buildings owned by the player
Parameters [PlayerID] - Player ID number
[Index] - Number in the list of owned buildings
Returns BuildingID or 0 if the player doesnt own that many buildings

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.1580294048.txt.gz · Last modified: 2020/01/29 04:34 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