C#:
---
layout: forums
title: 'Help with my AmmoGUI plugin'
breadcrumbs:
- "Plugin Development": "/forums/plugin-development.105/"
- "Rust Development": "/forums/rust-development.4/"
---
<div class="titleBar">
<h1>
<a href="{{ '/threads/help-with-my-ammogui-plugin.12801/' | prepend: site.baseurl }}">Help with my AmmoGUI plugin</a>
</h1>
<p id="pageDescription" class="muted">Discussion in '<a href="{{ '/forums/rust-development.4/' | prepend: site.baseurl }}">Rust Development</a>' started by <a class="username"
dir="auto">DylanSMR</a>, <a href="{{ '/threads/help-with-my-ammogui-plugin.12801/' | prepend: site.baseurl }}"><span class="DateTime" title="Nov 15, 2015 at 5:23 AM">Nov 15,
2015</span></a>.
</p>
</div>
<ol class="messageList" id="messageList">
<li id="post-143931" class="message" data-author="DylanSMR">
<div class="messageUserInfo">
<div class="messageUserBlock">
<div class="avatarHolder">
<span class="helper"></span>
<a class="avatar Avm" data-avatarhtml="true"><img src="{{ '/assets/styles/oxide/logo.og.png' | prepend: site.baseurl }}" width="96" height="96" alt="DylanSMR" /></a>
</div>
<h3 class="userText">
<a class="username" dir="auto">DylanSMR</a>
</h3>
<span class="arrow"></span>
</div>
</div>
<div class="messageInfo primaryContent">
<div class="messageContent">
<article>
<blockquote class="messageText SelectQuoteContainer ugc baseHtml"> So, I've been working on a small little ammoGUI based off of A3L I've got some code down but I need to
make sure this will work if I were to use it(Currently its just reading the current gun, not if its a bolt or something along those lines{Basically this will only work with a
AK atm})<br /> I might also need a bit of help with the gui later down on the line as I am not very good with them yet.<br />
<br />
<div class="bbCodeBlock bbCodeCode">
<div class="type">Code:</div>
{% raw %}<pre>
using Oxide.Core;
using Oxide.Core.Plugins;
using System;
using System.Collections.Generic;
using System.Reflection;namespace Oxide.Plugins
{
[Info("ammoGUI", "DylanSMR", 0.1, ResourceId = 1459)]
[Description("Simple New GUI with ammo.")]
public class ammoGUI : RustPlugin
{
int CurrentAmmo = this.primaryMagazine.contents;
string CurrentAmmoText; protected void OnWeaponFired()
{
Item ownerItem = this.GetOwnerItem();
if (ownerItem == null)
return;
if (CurrentAmmo => 29 && CurrentAmmo == 30)
CurrentAmmoText = "Your Magazine is Full";
else if (CurrentAmmo == 20 && CurrentAmmo => 21)
CurrentAmmoText = "Your Magazine is Half Full";
else if (CurrentAmmo == 10 && CurrentAmmo => 11)
CurrentAmmoText = "You will need to reload very soon.";
}
}
}
</pre>{% endraw %}
</div>
<div class="messageTextEndMarker"> </div>
</blockquote>
</article>
</div>
<div class="messageMeta ToggleTriggerAnchor">
<div class="privateControls">
<span class="item muted">
<span class="authorEnd"><a class="username author" dir="auto">DylanSMR</a>,</span>
<a href="{{ '/threads/help-with-my-ammogui-plugin.12801/' | prepend: site.baseurl }}" title="Permalink" class="datePermalink"><span class="DateTime"
title="Nov 15, 2015 at 5:23 AM">Nov 15, 2015</span></a>
</span>
</div>
<div class="publicControls">
<a href="{{ '/threads/help-with-my-ammogui-plugin.12801/' | prepend: site.baseurl }}" title="Permalink" class="item muted postNumber hashPermalink OverlayTrigger"
data-href="posts/143931/permalink">#1</a>
</div>
</div>
</div>
</li>
<li id="post-144122" class="message" data-author="Mughisi">
<div class="messageUserInfo">
<div class="messageUserBlock">
<div class="avatarHolder">
<span class="helper"></span>
<a class="avatar Avm" data-avatarhtml="true"><img src="{{ '/assets/styles/oxide/logo.og.png' | prepend: site.baseurl }}" width="96" height="96" alt="Mughisi" /></a>
</div>
<h3 class="userText">
<a class="username" dir="auto">Mughisi</a>
</h3>
<span class="arrow"></span>
</div>
</div>
<div class="messageInfo primaryContent">
<div class="messageContent">
<article>
<blockquote class="messageText SelectQuoteContainer ugc baseHtml"> You need to grab the amount in the OnWeaponFired hook and you should use the parameters that are passed with it,
you could have a look at my infinite ammo plugin actually to see how to grab the current amount of loaded ammunition. <div class="messageTextEndMarker"> </div>
</blockquote>
</article>
</div>
<div class="messageMeta ToggleTriggerAnchor">
<div class="privateControls">
<span class="item muted">
<span class="authorEnd"><a class="username author" dir="auto">Mughisi</a>,</span>
<a href="{{ '/threads/help-with-my-ammogui-plugin.12801/#post-144122' | prepend: site.baseurl }}" title="Permalink" class="datePermalink"><span class="DateTime"
title="Nov 16, 2015 at 7:15 AM">Nov 16, 2015</span></a>
</span>
</div>
<div class="publicControls">
<a href="{{ '/threads/help-with-my-ammogui-plugin.12801/#post-144122' | prepend: site.baseurl }}" title="Permalink" class="item muted postNumber hashPermalink OverlayTrigger"
data-href="posts/144122/permalink">#2</a>
</div>
</div>
</div>
</li>
</ol>