Solved plugin errors

ggblade

Member
Member
Aug 14, 2014
29
0
6
after running the server fine for a week, we now have certain errors just popping up every so many minutes. fills up the entire console...

error in question:
JavaScript:
[9/6/2014 2:41:03 AM] [Error] [MagmaPlugin] Error invoking function On_EntityHurt in BuildCalc plugin.
[9/6/2014 2:41:03 AM] [Exception] [ Plugin->Invoke | Plugin->OnEntityHurt | Hooks->EntityHurt | StructureComponent->OnHurt | Component->SendMessage | TakeDamage->Hurt | TakeDamage->HurtShared | TakeDamage->HurtShared | TakeDamage->HurtSelf | StructureMaster->DoDecay | Schedule->ThinkInstance | Schedule->Process | Callbacks->RunDecayThink | UpdateDelegate->Invoke | Callbacks->FirePreUpdate | NetPreUpdate->LateUpdate | ]
System.ArgumentNullException: null key
Parameter name: key
at System.Collections.Hashtable.get_Item (object) <0x00158>
at Fougerite.DataStore.Get (string,object) <0x00056>
at (wrapper dynamic-method) Jint.Marshal.ProxyHelper.jsWrapper (Jint.Native.IGlobal,Jint.Native.JsInstance,Jint.Native.JsInstance[]) <0x0010c>
at Jint.Native.NativeMethod.Execute (Jint.Expressions.IJintVisitor,Jint.Native.JsDictionaryObject,Jint.Native.JsInstance[]) <0x00039>
at Jint.ExecutionVisitor.ExecuteFunction (Jint.Native.JsFunction,Jint.Native.JsDictionaryObject,Jint.Native.JsInstance[],System.Type[]) <0x0033c>
at Jint.ExecutionVisitor.Visit (Jint.Expressions.MethodCall) <0x0042c>
at Jint.Expressions.MethodCall.Accept (Jint.Expressions.IStatementVisitor) <0x0001e>
at Jint.ExecutionVisitor.Visit (Jint.Expressions.MemberExpression) <0x0003e>
at Jint.Expressions.MemberExpression.Accept (Jint.Expressions.IStatementVisitor) <0x0001e>
at Jint.ExecutionVisitor.Visit (Jint.Expressions.BinaryExpression) <0x00031>
at Jint.Expressions.BinaryExpression.Accept (Jint.Expressions.IStatementVisitor) <0x0001e>
at Jint.ExecutionVisitor.Visit (Jint.Expressions.BinaryExpression) <0x00031>
at Jint.Expressions.BinaryExpression.Accept (Jint.Expressions.IStatementVisitor) <0x0001e>
at Jint.ExecutionVisitor.Visit (Jint.Expressions.IfStatement) <0x0001c>
at Jint.Expressions.IfStatement.Accept (Jint.Expressions.IStatementVisitor) <0x0001e>
at Jint.ExecutionVisitor.Visit (Jint.Expressions.BlockStatement) <0x000b4>
at Jint.Expressions.BlockStatement.Accept (Jint.Expressions.IStatementVisitor) <0x0001e>
at Jint.ExecutionVisitor.Visit (Jint.Expressions.BlockStatement) <0x000b4>
at Jint.Expressions.BlockStatement.Accept (Jint.Expressions.IStatementVisitor) <0x0001e>
at Jint.Native.JsFunction.Execute (Jint.Expressions.IJintVisitor,Jint.Native.JsDictionaryObject,Jint.Native.JsInstance[]) <0x0008c>
at Jint.ExecutionVisitor.ExecuteFunction (Jint.Native.JsFunction,Jint.Native.JsDictionaryObject,Jint.Native.JsInstance[],System.Type[]) <0x0033c>
at Jint.ExecutionVisitor.ExecuteFunction (Jint.Native.JsFunction,Jint.Native.JsDictionaryObject,Jint.Native.JsInstance[]) <0x0001b>
at Jint.JintEngine.CallFunction (Jint.Native.JsFunction,object[]) <0x00066>
at Jint.JintEngine.CallFunction (string,object[]) <0x00094>
at MagmaPlugin.Plugin.Invoke (string,object[]) <0x0002b>
it gives it for every plugin that uses the on_entityhurt.
started out this morning, has not stopped doing it (tried restarting, reloading ...)
 
after running the server fine for a week, we now have certain errors just popping up every so many minutes. fills up the entire console...

error in question:
JavaScript:
[9/6/2014 2:41:03 AM] [Error] [MagmaPlugin] Error invoking function On_EntityHurt in BuildCalc plugin.
[9/6/2014 2:41:03 AM] [Exception] [ Plugin->Invoke | Plugin->OnEntityHurt | Hooks->EntityHurt | StructureComponent->OnHurt | Component->SendMessage | TakeDamage->Hurt | TakeDamage->HurtShared | TakeDamage->HurtShared | TakeDamage->HurtSelf | StructureMaster->DoDecay | Schedule->ThinkInstance | Schedule->Process | Callbacks->RunDecayThink | UpdateDelegate->Invoke | Callbacks->FirePreUpdate | NetPreUpdate->LateUpdate | ]
System.ArgumentNullException: null key
Parameter name: key
at System.Collections.Hashtable.get_Item (object) <0x00158>
at Fougerite.DataStore.Get (string,object) <0x00056>
at (wrapper dynamic-method) Jint.Marshal.ProxyHelper.jsWrapper (Jint.Native.IGlobal,Jint.Native.JsInstance,Jint.Native.JsInstance[]) <0x0010c>
at Jint.Native.NativeMethod.Execute (Jint.Expressions.IJintVisitor,Jint.Native.JsDictionaryObject,Jint.Native.JsInstance[]) <0x00039>
at Jint.ExecutionVisitor.ExecuteFunction (Jint.Native.JsFunction,Jint.Native.JsDictionaryObject,Jint.Native.JsInstance[],System.Type[]) <0x0033c>
at Jint.ExecutionVisitor.Visit (Jint.Expressions.MethodCall) <0x0042c>
at Jint.Expressions.MethodCall.Accept (Jint.Expressions.IStatementVisitor) <0x0001e>
at Jint.ExecutionVisitor.Visit (Jint.Expressions.MemberExpression) <0x0003e>
at Jint.Expressions.MemberExpression.Accept (Jint.Expressions.IStatementVisitor) <0x0001e>
at Jint.ExecutionVisitor.Visit (Jint.Expressions.BinaryExpression) <0x00031>
at Jint.Expressions.BinaryExpression.Accept (Jint.Expressions.IStatementVisitor) <0x0001e>
at Jint.ExecutionVisitor.Visit (Jint.Expressions.BinaryExpression) <0x00031>
at Jint.Expressions.BinaryExpression.Accept (Jint.Expressions.IStatementVisitor) <0x0001e>
at Jint.ExecutionVisitor.Visit (Jint.Expressions.IfStatement) <0x0001c>
at Jint.Expressions.IfStatement.Accept (Jint.Expressions.IStatementVisitor) <0x0001e>
at Jint.ExecutionVisitor.Visit (Jint.Expressions.BlockStatement) <0x000b4>
at Jint.Expressions.BlockStatement.Accept (Jint.Expressions.IStatementVisitor) <0x0001e>
at Jint.ExecutionVisitor.Visit (Jint.Expressions.BlockStatement) <0x000b4>
at Jint.Expressions.BlockStatement.Accept (Jint.Expressions.IStatementVisitor) <0x0001e>
at Jint.Native.JsFunction.Execute (Jint.Expressions.IJintVisitor,Jint.Native.JsDictionaryObject,Jint.Native.JsInstance[]) <0x0008c>
at Jint.ExecutionVisitor.ExecuteFunction (Jint.Native.JsFunction,Jint.Native.JsDictionaryObject,Jint.Native.JsInstance[],System.Type[]) <0x0033c>
at Jint.ExecutionVisitor.ExecuteFunction (Jint.Native.JsFunction,Jint.Native.JsDictionaryObject,Jint.Native.JsInstance[]) <0x0001b>
at Jint.JintEngine.CallFunction (Jint.Native.JsFunction,object[]) <0x00066>
at Jint.JintEngine.CallFunction (string,object[]) <0x00094>
at MagmaPlugin.Plugin.Invoke (string,object[]) <0x0002b>
it gives it for every plugin that uses the on_entityhurt.
started out this morning, has not stopped doing it (tried restarting, reloading ...)
What plugins are you using?
 
after running the server fine for a week, we now have certain errors just popping up every so many minutes. fills up the entire console...

error in question:
JavaScript:
[9/6/2014 2:41:03 AM] [Error] [MagmaPlugin] Error invoking function On_EntityHurt in BuildCalc plugin.
[9/6/2014 2:41:03 AM] [Exception] [ Plugin->Invoke | Plugin->OnEntityHurt | Hooks->EntityHurt | StructureComponent->OnHurt | Component->SendMessage | TakeDamage->Hurt | TakeDamage->HurtShared | TakeDamage->HurtShared | TakeDamage->HurtSelf | StructureMaster->DoDecay | Schedule->ThinkInstance | Schedule->Process | Callbacks->RunDecayThink | UpdateDelegate->Invoke | Callbacks->FirePreUpdate | NetPreUpdate->LateUpdate | ]
System.ArgumentNullException: null key
Parameter name: key
at System.Collections.Hashtable.get_Item (object) <0x00158>
at Fougerite.DataStore.Get (string,object) <0x00056>
at (wrapper dynamic-method) Jint.Marshal.ProxyHelper.jsWrapper (Jint.Native.IGlobal,Jint.Native.JsInstance,Jint.Native.JsInstance[]) <0x0010c>
at Jint.Native.NativeMethod.Execute (Jint.Expressions.IJintVisitor,Jint.Native.JsDictionaryObject,Jint.Native.JsInstance[]) <0x00039>
at Jint.ExecutionVisitor.ExecuteFunction (Jint.Native.JsFunction,Jint.Native.JsDictionaryObject,Jint.Native.JsInstance[],System.Type[]) <0x0033c>
at Jint.ExecutionVisitor.Visit (Jint.Expressions.MethodCall) <0x0042c>
at Jint.Expressions.MethodCall.Accept (Jint.Expressions.IStatementVisitor) <0x0001e>
at Jint.ExecutionVisitor.Visit (Jint.Expressions.MemberExpression) <0x0003e>
at Jint.Expressions.MemberExpression.Accept (Jint.Expressions.IStatementVisitor) <0x0001e>
at Jint.ExecutionVisitor.Visit (Jint.Expressions.BinaryExpression) <0x00031>
at Jint.Expressions.BinaryExpression.Accept (Jint.Expressions.IStatementVisitor) <0x0001e>
at Jint.ExecutionVisitor.Visit (Jint.Expressions.BinaryExpression) <0x00031>
at Jint.Expressions.BinaryExpression.Accept (Jint.Expressions.IStatementVisitor) <0x0001e>
at Jint.ExecutionVisitor.Visit (Jint.Expressions.IfStatement) <0x0001c>
at Jint.Expressions.IfStatement.Accept (Jint.Expressions.IStatementVisitor) <0x0001e>
at Jint.ExecutionVisitor.Visit (Jint.Expressions.BlockStatement) <0x000b4>
at Jint.Expressions.BlockStatement.Accept (Jint.Expressions.IStatementVisitor) <0x0001e>
at Jint.ExecutionVisitor.Visit (Jint.Expressions.BlockStatement) <0x000b4>
at Jint.Expressions.BlockStatement.Accept (Jint.Expressions.IStatementVisitor) <0x0001e>
at Jint.Native.JsFunction.Execute (Jint.Expressions.IJintVisitor,Jint.Native.JsDictionaryObject,Jint.Native.JsInstance[]) <0x0008c>
at Jint.ExecutionVisitor.ExecuteFunction (Jint.Native.JsFunction,Jint.Native.JsDictionaryObject,Jint.Native.JsInstance[],System.Type[]) <0x0033c>
at Jint.ExecutionVisitor.ExecuteFunction (Jint.Native.JsFunction,Jint.Native.JsDictionaryObject,Jint.Native.JsInstance[]) <0x0001b>
at Jint.JintEngine.CallFunction (Jint.Native.JsFunction,object[]) <0x00066>
at Jint.JintEngine.CallFunction (string,object[]) <0x00094>
at MagmaPlugin.Plugin.Invoke (string,object[]) <0x0002b>
it gives it for every plugin that uses the on_entityhurt.
started out this morning, has not stopped doing it (tried restarting, reloading ...)
System.ArgumentNullException:null key
Parameter name: key

BuildCalc <---- Something is null in the event.
 
JavaScript:
function GetNameByOwnerID(OwnerID)
{
        var ownerName = DataStore.Get("buildcalc_names", OwnerID);
        if(ownerName != undefined)

Use if(ownerName != null). The DataStore will never give you a Javascript undefined value. It will give you a null value if the key or value don't exist.

JavaScript:
EachEntity.OwnerID.ToString()

OwnerID, GameID, SteamID properties for Fougerite game objects are strings already. No need to call ToString on them.

JavaScript:
if((DataStore.Get('destroy_toggle', e.Attacker.SteamID) == 1) && e.Entity != null)

That line is throwing the exception in DataStore.Get. Check e.Attacker.SteamID != null before using it as a DataStore key. Sometimes you can avoid an exception if you wrap the suspect value with String(e.Attacker.SteamID). That will convert the null value to the string "null" in Magma's Javascript engine. "null" keys will just overwrite each others values, so don't rely on "null" as a key for anything. ;)
 
Last edited by a moderator:
It's building decay that's triggering the events. That's why you didn't see it on at first. Decay didn't set in because of player activity.

If you don't want decay on, just turn it off in the Rust++ cfg. If you do want it on, you'd have to go into each hook and implement fixes as mikec has suggested above.
 
  • Agree
Reactions: mikec
It's building decay that's triggering the events. That's why you didn't see it on at first. Decay didn't set in because of player activity.

If you don't want decay on, just turn it off in the Rust++ cfg. If you do want it on, you'd have to go into each hook and implement fixes as mikec has suggested above.
Code:
function GetNameByOwnerID(OwnerID)
{
        var ownerName = DataStore.Get("buildcalc_names", OwnerID);
        if(ownerName != undefined)

Use if(ownerName != null). The DataStore will never give you a Javascript undefined value. It will give you a null value if the key or value don't exist.

Code:
EachEntity.OwnerID.ToString()

OwnerID, GameID, SteamID properties for Fougerite game objects are strings already. No need to call ToString on them.

Code:
if((DataStore.Get('destroy_toggle', e.Attacker.SteamID) == 1) && e.Entity != null)

That line is throwing the exception in DataStore.Get. Check e.Attacker.SteamID != null before using it as a DataStore key. Sometimes you can avoid an exception if you wrap the suspect value with String(e.Attacker.SteamID). That will convert the null value to the string "null" in Magma's Javascript engine. "null" keys will just overwrite each others values, so don't rely on "null" as a key for anything. ;)
the weird thing is ive been using it for a while. only yesterday those errors started showing up.

coundt put the code of the plugin here so had to use pastebin.
http://pastebin.com/P39QRYu9
You may also simply use:

JavaScript:
if (!HurtEvent.IsDecay)
 
You may also simply use:

JavaScript:
if (!HurtEvent.IsDecay)

I need to update my thread on this topic, but !IsDecay alone didn't resolve the errors. Since we're checking for Attacker.SteamID, we need to handle null instances of that. This cleaned things up for me:

JavaScript:
if(e.Attacker.SteamID != null && !e.IsDecay){}

The general idea is: be mindful of what you're checking for in your functions, and whether it may return a null value that is unhandled.
 
yeah it probably was triggered by decay, never thought about it seeying as in rustpp its set as "decay=false"
but im getting reports of buildings dissapearing, even buildings that are used. weird seeying as shacks and barricades havent decayed at all.
 
Last edited:
I'm aware that there is a problem with decay and Rust++ not turning it off as it used to. I am not sure what the problem is, but I too have seen structures decay that should not have.

I think we should not let every module and plugin take a swing at DecayEvents. In fact, I think there should be only One component that receives DecayEvents and HurtEvents, and other components that want the result can query that component.

If a Hurt or Decay event happens and one plugin erases the damage taken, and another component increases damage taken, what is the result?

I don't fucking know.
 
If a Hurt or Decay event happens and one plugin erases the damage taken, and another component increases damage taken, what is the result?

I do know that if you're trying to destroy the object when it has already been destroyed, you get something like this:
[DEBUG] EntityHurt EX: System.ArgumentOutOfRangeException: Argument is out of range.
Parameter name: viewID
at #=qjg$mq9k6hZwR1eaAS3eQ4dux$3oD_j8CRZte$f$nFV0=.#=q_Qzpdx1nKdRDW3UUCjFBPQ== (NetworkViewID #=q6VPpaR6MnRo4OuvCFrexrw==) [0x00000] in <filename unknown>:0
at #=qZti1eKpmgEiH8RyJbFvrtbtjuOoTgnfxK4EfJn_O0Rw=.#=qu2Lphmm3gCnUyjdHQVE_rQ== (NetworkViewID #=q9DtzaERUA77kylGcxnoirQ==) [0x00000] in <filename unknown>:0
at uLink.Network.Destroy (NetworkViewID viewID) [0x00000] in <filename unknown>:0
at NetCull.Destroy (NetworkViewID viewID) [0x00000] in <filename unknown>:0
at Fougerite.Entity.Destroy () [0x00000] in <filename unknown>:0

This is the error message that repeats for every bullet from a shotgun blast that isn't the initial bullet that triggers and removes the object. Seems that every pellet in the shell strikes the object at once, and triggers the hook, but only one instance can be completed by the function.

I filtered out HurtEvent.WeaponName != "Shotgun" to avoid this particular problem, as it seems unavoidable.
 
Yeah, we can't blindly call every Hurt or Decay hook. In the shotgun case, we can check the weapon type and only call hooks on the first hit. If the game object is destroyed in a hook, either don't call the rest, or pass a entity with a property indicating it was already destroyed. Entity.Destroy() could also be smarter about this.
 
In IronPython module, i check in the damageEvent for the lifestatus enum to raise an OnEntityDestroyed event instead the OnEntityHurt
 
  • Like
Reactions: mikec