C#:
---
layout: forums
title: 'Error with my plugin'
breadcrumbs:
- "Game Discussion": "/categories/game-discussion.106/"
- "Rust Discussion": "/forums/rust-discussion.23/"
---
<div class="titleBar">
<h1>
<a href="{{ '/threads/error-with-my-plugin.11092/' | prepend: site.baseurl }}">Error with my plugin</a>
</h1>
<p id="pageDescription" class="muted">Discussion in '<a href="{{ '/forums/rust-discussion.23/' | prepend: site.baseurl }}">Rust Discussion</a>' started by <a class="username"
dir="auto">DylanSMR</a>, <a href="{{ '/threads/error-with-my-plugin.11092/' | prepend: site.baseurl }}"><span class="DateTime" title="Aug 14, 2015 at 5:12 AM">Aug 14, 2015</span></a>.
</p>
</div>
<ol class="messageList" id="messageList">
<li id="post-120022" 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 after spending a bit of time developing a plugin. I ran into a problem. :<br /> : It gives me a error every
time I load and the error its giving me isn't making that much since. :<br /> : If I could get some help on this that would be great <img
src="{{ '/assets/styles/default/xenforo/clear.png' | prepend: site.baseurl }}" class="mceSmilieSprite mceSmilie8" alt=":D" title="Big Grin :D" /> :<br /> : <a href="http://pastebin.com/6QqMPh6R"
target="_blank" class="externalLink" rel="nofollow">http://pastebin.com/6QqMPh6R</a> :<br /> : The error is at the very bottom. :<br />
<br /> : Thanks in advance! : <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/error-with-my-plugin.11092/' | prepend: site.baseurl }}" title="Permalink" class="datePermalink"><span class="DateTime"
title="Aug 14, 2015 at 5:12 AM">Aug 14, 2015</span></a>
</span>
</div>
<div class="publicControls">
<a href="{{ '/threads/error-with-my-plugin.11092/' | prepend: site.baseurl }}" title="Permalink" class="item muted postNumber hashPermalink OverlayTrigger"
data-href="posts/120022/permalink">#1</a>
</div>
</div>
</div>
</li>
<li id="post-120023" class="message staff" data-author="Wulf">
<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="Wulf" /></a>
</div>
<h3 class="userText">
<a class="username" dir="auto" itemprop="name">Wulf</a>
<em class="userBanner bannerRed wrapped" itemprop="title"><span class="before"></span><strong>Community Admin</strong><span class="after"></span></em>
</h3>
<span class="arrow"></span>
</div>
</div>
<div class="messageInfo primaryContent">
<div class="messageContent">
<article>
<blockquote class="messageText SelectQuoteContainer ugc baseHtml"> The error is saying... on Line 235, you have an unexpected symbol. Open the plugin up in Visual Studio and it
will show you these. <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">Wulf</a>,</span>
<a href="{{ '/threads/error-with-my-plugin.11092/#post-120023' | prepend: site.baseurl }}" title="Permalink" class="datePermalink"><span class="DateTime"
title="Aug 14, 2015 at 5:14 AM">Aug 14, 2015</span></a>
</span>
</div>
<div class="publicControls">
<a href="{{ '/threads/error-with-my-plugin.11092/#post-120023' | prepend: site.baseurl }}" title="Permalink" class="item muted postNumber hashPermalink OverlayTrigger"
data-href="posts/120023/permalink">#2</a>
</div>
</div>
</div>
</li>
<li id="post-120141" 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 wrote that plugin and it works. But now I have a problem with this plugin.<br /> I wrote this section almost
exactly as the infinite ammo plugin and it gives me a error.<br />
<br />
<a href="http://pastebin.com/QVfVv8Wc" target="_blank" class="externalLink" rel="nofollow">http://pastebin.com/QVfVv8Wc</a><br />
<br /> --Error--<br /> [Oxide] 8:44 AM [Error] IncreasedClipSize.cs(77,52): error CS0131: The left-handed side of an assignment must be a variable, a property or an
indexer.<br />
<br /> :Visual Studio: didnt report any errors so im not sure<br /> [DOUBLEPOST=1439560205][/DOUBLEPOST]I realised I messed up "Projectile" with "Weapon" at
line 77 but that didnt make a difference to my error. <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/error-with-my-plugin.11092/#post-120141' | prepend: site.baseurl }}" title="Permalink" class="datePermalink"><span class="DateTime"
title="Aug 14, 2015 at 2:48 PM">Aug 14, 2015</span></a>
</span>
</div>
<div class="publicControls">
<a href="{{ '/threads/error-with-my-plugin.11092/#post-120141' | prepend: site.baseurl }}" title="Permalink" class="item muted postNumber hashPermalink OverlayTrigger"
data-href="posts/120141/permalink">#3</a>
</div>
</div>
</div>
</li>
<li id="post-120153" class="message" data-author="Reneb">
<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="Reneb" /></a>
</div>
<h3 class="userText">
<a class="username" dir="auto">Reneb</a>
</h3>
<span class="arrow"></span>
</div>
</div>
<div class="messageInfo primaryContent">
<div class="messageContent">
<article>
<blockquote class="messageText SelectQuoteContainer ugc baseHtml"> your plugin is just wrong everywhere XD<br /> if (weapon == rifle.ak) how can that work ^^?<br /> if
(weapon.primaryMagazine.contents = weapon.primaryMagazine.capacity - Config["AkClipSize"])<br /> same ^^<br /> [DOUBLEPOST=1439562310][/DOUBLEPOST]checkItem item =
player.GetActiveItme();<br /> checkItem ????? this is not a variable<br /> GetActiveItme? GetActivateItem?<br /> BaseProjetcile? BaseProjectile<br />
<br /> fix your plugin ... there is 1 error per line m8<br /> [DOUBLEPOST=1439562348][/DOUBLEPOST]weapon.primary.Magazine.contents ? weapon.primaryMagazine.contents<br />
[DOUBLEPOST=1439562379][/DOUBLEPOST]void checkItem(BasePlayer player, string command, string[] args) ?<br /> checkItem(); ? no variables?<br />
[DOUBLEPOST=1439562941][/DOUBLEPOST]Fixed part of your plugin so it at least works<br />
<div class="bbCodeBlock bbCodeCode">
<div class="type">Code:</div>
{% raw %}<pre>using System;
using System.Collections.Generic;
using Oxide.Core;namespace Oxide.Plugins
{
[Info("IncreasedClipSize", "DylanSMR", "0.0.1", ResourceId = 9823)]
class IncreasedClipSize : RustPlugin
{
protected override void LoadDefaultConfig()
{ PrintWarning("Creating a new configuration file.");
Config.Clear();
Config["AkClipSize"] = 30;
Config["BoltClipSize"] = 20;
Config["SemiAutoClipSize"] = 25;
Config["RevolverClipSize"] = 25;
Config["RocketLauncherClipSize"] = 2;
Config["PumpShotgunClipSize"] = 18;
Config["HuntingBowClipSize"] = 2;
Config["EokaPistolClipSize"] = 2;
Config["WaterPipeClipSize"] = 2;
Config["CustomSMGClipSize"] = 50;
Config["ThompsonClipSize"] = 45; Config["Empty"] = 0; Config["Reload"] = "Clip size low, be prepared to reloaded."; SaveConfig();
} class StoredData
{
public HashSet<PlayerInfo> Players = new HashSet<PlayerInfo>(); public StoredData()
{
}
} class PlayerInfo
{
public string UserId; public PlayerInfo()
{
} public PlayerInfo(BasePlayer player)
{
UserId = player.userID.ToString();
}
} StoredData storedData; private void OnWeaponFired(BaseProjectile projectile, BasePlayer player, ItemModProjectile projectilemod, ProtoBuf.ProjectileShoot projectiles)
{
checkItem(player, projectile);
}
private void checkItem(BasePlayer player, BaseProjectile projectile)
{
var info = new PlayerInfo(player);
Item item = player.GetActiveItem();
if (item != null)
{
var weapon = item.GetHeldEntity() as BaseProjectile;
Puts(weapon.gameObject.name);
if (weapon.gameObject.name == "assets/bundled/prefabs/weapons/rifle/ak47u.weapon.prefab")
{
//if (storedData.Players.Contains(info))
Puts(weapon.primaryMagazine.contents.ToString());
Puts(weapon.primaryMagazine.capacity.ToString());
if (weapon.primaryMagazine.contents == weapon.primaryMagazine.capacity - (int)Config["AkClipSize"])
{ Puts(weapon.primaryMagazine.contents.ToString());
weapon.primaryMagazine.contents = weapon.primaryMagazine.capacity;
weapon.SendNetworkUpdateImmediate();
storedData.Players.Add(info);
}
//if (!storedData.Players.Contains(info)) return;
/*
if (weapon.primaryMagazine.contents == (int)Config["Empty"])
{
storedData.Players.Remove(info);
Interface.GetMod().DataFileSystem.WriteObject("IncreasedClipSizeData", storedData);
}*/
}
}
}
}
}</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">Reneb</a>,</span>
<a href="{{ '/threads/error-with-my-plugin.11092/#post-120153' | prepend: site.baseurl }}" title="Permalink" class="datePermalink"><span class="DateTime"
title="Aug 14, 2015 at 3:22 PM">Aug 14, 2015</span></a>
</span>
</div>
<div class="publicControls">
<a href="{{ '/threads/error-with-my-plugin.11092/#post-120153' | prepend: site.baseurl }}" title="Permalink" class="item muted postNumber hashPermalink OverlayTrigger"
data-href="posts/120153/permalink">#4</a>
</div>
</div>
</div>
</li>
</ol>