-
Notifications
You must be signed in to change notification settings - Fork 0
/
GatherMoreTogether.cs
76 lines (73 loc) · 2.48 KB
/
GatherMoreTogether.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using UnityEngine;
using System;
using Newtonsoft.Json;
namespace Oxide.Plugins
{
[Info("Gather More Together", "Owned", "1.0.1")]
[Description("Get more ressources when you're farming close to a team member")]
class GatherMoreTogether : RustPlugin
{
private confData config;
protected override void LoadDefaultConfig()
{
Config.WriteObject(new confData(),true);
}
private void Init()
{
config = Config.ReadObject<confData>();
}
private new void SaveConfig()
{
Config.WriteObject(config,true);
}
public class confData
{
[JsonProperty("Distance between you and your mates (in feet)")]
public float distanceMate = 32f;
[JsonProperty("Bonus percentage")]
public int bonusMate = 10;
}
void OnDispenserGather(ResourceDispenser dispenser, BaseEntity entity, Item item)
{
if (entity.ToPlayer() == null) return;
var basePlayer = entity.ToPlayer();
var currentTeam = basePlayer.currentTeam;
if(currentTeam != 0)
{
RelationshipManager.PlayerTeam team = RelationshipManager.Instance.FindTeam(currentTeam);
if (team != null)
{
var players = team.members;
if ( team.members.Count > 1 )
{
foreach (var teamMember in players)
{
if(teamMember.ToString() != basePlayer.UserIDString)
{
BasePlayer member = BasePlayer.FindByID(teamMember);
if(member != null)
{
if(Vector3.Distance(basePlayer.transform.position, member.transform.position) <= config.distanceMate)
{
item.amount = item.amount + (item.amount * config.bonusMate/100);
basePlayer.ChatMessage("You got "+config.bonusMate.ToString()+"% more because you're close to a member of your team");
}
}
}
}
}
else {
return;
}
}
else
{
return;
}
}
else {
return;
}
}
}
}