-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKnockOut.cs
More file actions
53 lines (52 loc) · 1.58 KB
/
KnockOut.cs
File metadata and controls
53 lines (52 loc) · 1.58 KB
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
using Oxide.Core;
using Rust;
using System;
using UnityEngine;
namespace Oxide.Plugins
{
[Info("KnockOut", "Owned", "1.0.1")]
[Description("Knock out others players with your rock !")]
class KnockOut : RustPlugin
{
const string permissionName = "knockout.use";
private static System.Random random = new System.Random();
private void Init()
{
permission.RegisterPermission(permissionName, this);
}
void OnEntityTakeDamage(BaseEntity entity, HitInfo info)
{
if (entity == null || info == null)
{
return;
}
if (entity is BasePlayer)
{
if (info.Initiator != null)
{
BasePlayer playerInitiator = info.Initiator as BasePlayer;
if (!permission.UserHasPermission(playerInitiator.UserIDString, permissionName)) return;
var hitArea = info?.boneArea ?? (HitArea) (-1);
if((int)hitArea != -1)
{
if(hitArea.ToString() == "Head")
{
if(info.WeaponPrefab != null)
{
var weapon = info.WeaponPrefab.ShortPrefabName;
if(weapon.ToString() == "rock.entity")
{
if (random.Next(0, 2) == 0)
{
BasePlayer player = entity as BasePlayer;
player.StartSleeping();
}
}
}
}
}
}
}
}
}
}