Would anyone be willing to make a plugin like this, I know there has been a lot of chatter on the two main rust forums.
Rust Campfires give 100 % comfort or 50 regardless
Discussion in 'Plugin Requests' started by Raven 8, Mar 1, 2017.
-
I know this isn't what you asked for, but it would feel odd making a plugin for just this. Either you could make it yourself, or this could help someone else.
Caveat, I'm new to the oxide api... just started reading over it yesterday in interest of developing plugins. This code works. What my lack of experience doesn't know, is whether or not other items trigger = heatSource aside from just the camp fire.
Code:void OnEntityEnter(TriggerBase trigger, BaseEntity entity) { if(trigger.name.Equals("heatSource") && entity.ToPlayer() != null) { entity.ToPlayer().metabolism.comfort.value = 0.5f; } }
Last edited by a moderator: Mar 1, 2017 -
Wulf Community Admin
-
I updated the snippet to include a check. Thanks for the tip Wulf.
-
Wulf Community Admin
Code:void OnEntityEnter(TriggerBase trigger, BaseEntity entity) { var player = entity.ToPlayer(); if (trigger.name.Equals("heatSource")) player?.metabolism.comfort.value= 0.5f; }
-
Error while compiling: TestPlugin.cs(21,79): error CS9030: The left-hand side of an assignment cannot contain a null propagating operator -
Wulf Community Admin
Code:void OnEntityEnter(TriggerBase trigger, BaseEntity entity) { var player = entity.ToPlayer(); if(player != null && trigger.name.Equals("heatSource")) player.metabolism.comfort.value= 0.5f; }
Code:void OnEntityEnter(TriggerBase trigger, BaseEntity entity) { var player = entity.ToPlayer(); if(!player && trigger.name.Equals("heatSource")) player.metabolism.comfort.value= 0.5f; }
-
I wish I could write code, I get a bit confused just trying to find what to modify in some of the json files or which command i need to type and where, thats why I asked if someone could do this.