- Works With
Cannon Storage gives every cannon on your server its own ammunition storage via an attached small stash. When a player mounts the cannon, ammunition automatically loads from the stash into the cannon's magazine, eliminating the need to manually reload from your inventory. While mounted, players see a text overlay above the cannon showing the total ammo count in the stash. When the cannon is destroyed, the stash drops its contents and is removed.
Returns the stash container attached to the specified cannon, or null if the cannon has no stash.
Parameters:
Counts how many items with the specified short name exist in the cannon's stash.
Parameters:
Removes a specific amount of an item from the cannon's stash.
Parameters:
Example:
Note: This method removes items starting from the end of the inventory list. If an item stack has fewer items than requested, it removes the entire stack and continues to the next matching stack until the requested amount is fulfilled or no more matching items remain.
Recommended Compatible Plugins
Cannon Storage integrates with other plugins to extend cannon functionality:- Cannon Rockets -- Allows cannons to fire rockets instead of cannonballs. Cannon Rockets automatically draws rocket ammo from the stash when needed
Configuration
JSON:
{
"Version": "1.0.0",
"Stash Inventory Size (Default: 6)": 6,
"Stash Position": {
"x": 0.4,
"y": 0.5,
"z": -0.11
},
"Stash Rotation": {
"x": 90.0,
"y": 90.0,
"z": 0.0
}
}
Stash Inventory Size-- Number of inventory slots in each cannon's stash. Default is 6Stash Position-- Where the stash spawns relative to the cannon. Adjust these coordinates to reposition the stash if it conflicts with other mods or looks wrongStash Rotation-- Rotation of the stash relative to the cannon in degrees
Localization
JSON:
{
"Hud.AmmoCount": "Ammo: {0}"
}
Developer API
API_GetStash
C#:
StashContainer API_GetStash(Cannon cannon)
Parameters:
cannon-- The cannon entity
StashContainer attached to the cannon, or nullAPI_GetAmmoCountByShortName
C#:
int API_GetAmmoCountByShortName(Cannon cannon, string shortName)
Parameters:
cannon-- The cannon entityshortName-- Item short name to search for (e.g.,"ammo.rocket.basic")
0 if none found or if the cannon has no stashAPI_TakeAmmoByShortName
C#:
bool API_TakeAmmoByShortName(Cannon cannon, string shortName, int amount)
Parameters:
cannon-- The cannon entityshortName-- Item short name to remove (e.g.,"ammo.rocket.basic")amount-- How many to remove
true if the full amount was successfully removed, false otherwiseExample:
C#:
if (CannonStorage == null)
return;
bool success = CannonStorage.Call<bool>("API_TakeAmmoByShortName", cannon, "ammo.rocket.basic", 5);
if (success)
{
Puts("Successfully took 5 rockets from cannon stash");
}