donateObject()

(info) Other great resources: Official JS API docs, Scripting Forum

donateObject()

Transfer an object to another player...

Hopefully this function will be renamed transferObject() in keeping with eventObjectTransfer().

 

Syntax

var success = donateObject(gameObj, to);

Parameters

Parameter

Type

Mandatory

Notes

Game Version

gameObj

Game object

The object to transfer.

Currently, you can only transfer a Droid object.

3.2

to

Number

The ID of the player who you want to transfer the object to.

3.2

Return value

Value

Type

Notes

Game Version

true

Boolean

The object was successfully transferred.

3.2

false

Boolean

The object could not be transferred because the recipient has reached their droid limits.

3.2

<error>

Error

Invalid parameters or object/player not found.

3.2

Notes

If your script is requesting an object, it should check that it's not reached it's limits for that object first.

If you want to check whether the other player has reached their limits before you try to transfer an object, use getDroidLimit() or getStructureLimit().

Both players will receive eventObjectTransfer() after the object is transferred.

Example

Transfer a truck to player 4
var truck = enumDroid( me, DROID_CONSTRUCT )[0];   donateObject( truck, 4 );