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 ...)
 

Jakkee

Retired Staff
Retired Staff
Plugin Developer
Jul 28, 2014
1,465
932
113
Australia
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?
 

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
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.
 

mikec

Master Of All That I Survey
Retired Staff
Trusted Member
Jul 12, 2014
296
152
28
Los Angeles, California, USA
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:

.phase

Member
Member
Jul 29, 2014
58
12
8
Southern California
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

DreTaX

Probably knows the answer...
Administrator
Jun 29, 2014
4,093
4,784
113
At your house.
github.com
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)
 

.phase

Member
Member
Jul 29, 2014
58
12
8
Southern California
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.
 

ggblade

Member
Member
Aug 14, 2014
29
0
6
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:

mikec

Master Of All That I Survey
Retired Staff
Trusted Member
Jul 12, 2014
296
152
28
Los Angeles, California, USA
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.
 

.phase

Member
Member
Jul 29, 2014
58
12
8
Southern California
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.
 

mikec

Master Of All That I Survey
Retired Staff
Trusted Member
Jul 12, 2014
296
152
28
Los Angeles, California, USA
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.
 

balu92

Retired Staff
Retired Staff
Trusted Member
Jul 11, 2014
338
75
28
34
In IronPython module, i check in the damageEvent for the lifestatus enum to raise an OnEntityDestroyed event instead the OnEntityHurt
 
  • Like
Reactions: mikec