Items
Namespace: Synapse.Api.Items
This is an object which represents an Item (on the Map, in the Inventory, as grenade or not yet spawned)
- None => The only SynapseItem with the ID -1
- AllItems => All existing Items and their Serials
- ID => The ItemId of the Item
- ItemType => The Actually ItemType which is used
- ItemCategory => The ItemCategory of the ItemType
- TierFlags => The TierFlags of the Item
- IsCustomItem => If the Item is an custom Item
- Name => The Name of the Item
- Serial => The Serial of this Item. Every Item has a own Serial ID that is only assigned to that Item
- Weight => The Weight of the Item
- State => The Current state of the Item
- ItemHolder => The Player which holds the Item currently in his Inventory (is null if nobody has it)
- Durabillity => The durabillity of the Item
- Scale => The Scale of the item
- Position => The Position of the Item (when a Player holds it it is obviously the Player Position as well)
- Rotation => The rotation of the Item
- ItemGameObject => The Gameobject of the Item
- ItemBase => The ItemBase object of the Item when it is in an Inventory
- ItemnPickupBase => The PickupBase of the Item when it is on the map
- ItemData => A Dictionary to store Data inside of an Item
- WeaponAttachments => The attachments of the item when it is a weapon
Since there are many diffent types of items with individual code there are some API objects to interact with they special features
You can access it with SynapseItem.Throwable
Fields:
- FuseTime => The Time until the Item explodes
- ThrowableItem => The gameobject component for Thrownprojecties
Methods:
Fuse()
=> Activates the grenade when it is currently on the MapDestroyProjectile()
=> Destroys the Item and therefore let it explodes (It is recommended to destroy the object afterwards)
PickUp(Player)
=> Gives the Player this ItemDrop(Vector3)
=> Drops it at the PositionDrop()
=> Drops the Item by the ItemHolder(if it has no ItemHolder at the Position stored in Position)Despawn()
=> Despawns the Item (you can Spawn it again with Drop())DespawnItemBase()
=> Despawns the ItemBase of the ItemDespawnPickup()
=> Despawns the Pickup of the ItemDestroy()
=> Destroys the Item and remove it from the Map entire.
It's really easy to create
SynapseItem
by using it's constructorExample:
new SynapseItem(ItemType.Coin)
//or you can use the Id of the Coin which would be 35
new SynapseItem(35)
If you want to drop the Item on the map, you may use the one of these methods.
Vector 3 pos = ...; //Some Position of course ... would throw a Error
//Method 1
var item = new SynapseItem(ItemType.Coin, pos);
//Method 2
var item = new SynapseItem(ItemType.Coin);
item.Drop(pos);
//Methode 3
var item = new SynapseItem(ItemType.Coin);
item.Position = pos;
item.Drop();
If you want to give the item a player, you may use one of these methods.
Player player = ...; // Some player of course ... would throw a Error
//Method 1
new SynapseItem(ItemType.Coin, player);
//Method2
var item = new SynapseItem(ItemType.Coin);
item.PickUp(player);
//Method3
var item = new SynapseItem(ItemType.Coin);
player.Inventory.AddItem(item);
In order to create a Custom Item you have to register it first.
You can do this through the ItemManager which you can get with
SynapseController.Server.ItemManager
or Server.Get.ItemManager
.Create a
CustomItemInformations
object (Namespace: Synapse.Api.Items) and use the method RegisterCustomItem()
in the ItemManager with this.Example:
using Synapse.Api;
using Synapse.Api.Plugin;
namespace FirstPlugin
{
[PluginInformation(
Name = "FirstPlugin",
Author = "Dimenzio",
Description = "My First Awesome Plugin",
LoadPriority = int.MinValue,
SynapseMajor = 2,
SynapseMinor = 6,
SynapsePatch = 1,
Version = "v.1.0.0"
)]
public class PluginClass : AbstractPlugin
{
public override void Load()
{
var info = new Synapse.Api.Items.CustomItemInformations()
{
BasedItemType = ItemType.GunUSP, //The ItemType which is it based on (implementing new models is not possible)
ID = 100, //You can take all Values for the ID except for the ones which is already used by the vanilla Items (0-35)
Name = "CustomWeapon" //The Name for your Item
};
Server.Get.ItemManager.RegisterCustomItem(info);
}
}
}
After this you can simply create the item with
new SynapseItem(100)
. If you want to find out if a SynapseItem is your new Item you can check it with item.ID.Note: It's recommended to register the Item in your
Load()
Method of your PluginClass so that its early registeredLast modified 1yr ago