66using Exiled . CustomItems . API . Features ;
77using Exiled . Events . EventArgs . Player ;
88using System . ComponentModel ;
9+ using System ;
910using UnityEngine ;
1011using YamlDotNet . Serialization ;
1112using Random = System . Random ;
1213using ServerEvents = Exiled . Events . Handlers . Server ;
14+ using PlayerEvent = Exiled . Events . Handlers . Player ;
15+ using E = ExtendedItems . Utils ;
16+ using InventorySystem . Items . Usables ;
17+ using InventorySystem . Items . Usables . Scp330 ;
1318
1419namespace ExtendedItems . Items
1520{
@@ -24,7 +29,6 @@ public class Scp1162 : CustomItem
2429
2530 [ Description ( "Chance from 0 to 1 that the item will be destroyed." ) ]
2631 public float LoseChance { get ; set ; } = 0.15f ;
27-
2832 public override SpawnProperties ? SpawnProperties { get ; set ; }
2933 [ YamlIgnore ] private readonly Random _rng = new ( ) ;
3034
@@ -56,13 +60,16 @@ public class Scp1162 : CustomItem
5660 ItemType . Coin ,
5761 ItemType . Flashlight ,
5862 ItemType . Radio ,
63+ ItemType . Ammo9x19
5964
6065 ] ;
6166
67+ public Tuple < string , uint > ServerJoin { get ; set ; } = new ( "Welcome to the server!" , 10 ) ;
68+
6269 private void OnRoundStarted ( )
6370 {
6471 Room room = Room . Get ( Plugin . Instance . Config . Scp1162Room ) ;
65- Vector3 globalPos = Utils . GetGlobalCords ( Plugin . Instance . Config . Scp1162Room , new Vector3 ( 16.68f , 11.6f , 8.11f ) ) ;
72+ Vector3 globalPos = E . GetGlobalCords ( Plugin . Instance . Config . Scp1162Room , new Vector3 ( 16.68f , 11.6f , 8.11f ) ) ;
6673
6774 Quaternion rotation = room . Rotation ;
6875 Vector3 rot = new ( 0f , 1f , 0.0f ) ;
@@ -78,23 +85,28 @@ private void OnRoundStarted()
7885 protected override void SubscribeEvents ( )
7986 {
8087 ServerEvents . RoundStarted += OnRoundStarted ;
88+ PlayerEvent . PickingUpItem += OnPickingUp ;
89+ PlayerEvent . DroppingItem += OnDroppingItem ;
8190
8291 base . SubscribeEvents ( ) ;
8392 }
8493
8594 protected override void UnsubscribeEvents ( )
8695 {
8796 ServerEvents . RoundStarted -= OnRoundStarted ;
97+ PlayerEvent . PickingUpItem -= OnPickingUp ;
98+ PlayerEvent . DroppingItem -= OnDroppingItem ;
8899
89100 base . UnsubscribeEvents ( ) ;
90101 }
91102
92103 protected override void OnDroppingItem ( DroppingItemEventArgs ev )
93104 {
105+ if ( ! Check ( ev . Item ) ) return ;
94106 ev . Item . Destroy ( ) ;
95107
96108 Room room = Room . Get ( Plugin . Instance . Config . Scp1162Room ) ;
97- Vector3 globalPos = Utils . GetGlobalCords ( Plugin . Instance . Config . Scp1162Room , new Vector3 ( 16.68f , 11.6f , 8.11f ) ) ;
109+ Vector3 globalPos = E . GetGlobalCords ( Plugin . Instance . Config . Scp1162Room , new Vector3 ( 16.68f , 11.6f , 8.11f ) ) ;
98110
99111 Quaternion rotation = room . Rotation ;
100112 Vector3 rot = new ( 0f , 1f , 0.0f ) ;
@@ -111,43 +123,56 @@ protected override void OnDroppingItem(DroppingItemEventArgs ev)
111123
112124 protected override void OnPickingUp ( PickingUpItemEventArgs ev )
113125 {
126+ if ( ! Check ( ev . Pickup ) || ev . Player . NetId < 2 ) return ;
114127 ev . IsAllowed = false ;
115-
128+ int item = new ( ) ;
129+ Random candy = new ( ) ;
130+ Item Currentlyitem = ev . Player . CurrentItem ;
131+ ItemType ItemtoGive ;
116132 try
117133 {
118- Item item = ev . Player . CurrentItem ;
119- if ( item == null )
134+ if ( ev . Player . CurrentItem is null || ev . Player . CurrentItem . Type == ItemType . None )
120135 {
121- ev . Player . EnableEffect ( EffectType . SeveredHands , byte . MaxValue ) ;
136+ ev . Player . ShowHint ( "You insert your hands into SCP-1162 and lose feeling in them." , 5 ) ;
137+ ev . Player . ShowHitMarker ( 2 ) ;
138+ ev . Player . EnableEffect ( EffectType . SeveredHands ) ;
139+ return ;
122140 }
123- else
141+ else if ( Currentlyitem . Type == ItemType . SCP330 )
124142 {
125- if ( item . Type == ItemType . SCP330 )
126- {
127- ev . IsAllowed = false ;
128- ev . Player . ShowHint ( "You can't trade an SCP-330-1 instance with SCP-1162." , 5 ) ;
129- return ;
130- }
131- ev . Player . RemoveItem ( item ) ;
132- if ( _rng . NextDouble ( ) < LoseChance ) return ;
133- item = ev . Player . AddItem ( ItemTypes [ _rng . Next ( 0 , ItemTypes . Length ) ] ) ;
134-
135-
136-
137- ev . Player . CurrentItem = item ;
138-
143+ ev . Player . ShowHint ( "You put an SCP-330-1 instance in and SCP-1162 just spits it back out" ) ;
144+ return ;
145+ }
146+ ev . Player . RemoveHeldItem ( ) ;
147+ if ( _rng . NextDouble ( ) < LoseChance )
148+ {
149+ ev . Player . ShowHint ( "You insert your item into SCP-1162 and it gets destroyed." , 5 ) ;
150+ return ;
139151 }
140- return ;
152+ ItemtoGive = ItemTypes [ _rng . Next ( 0 , ItemTypes . Length ) ] ;
153+ if ( ItemtoGive == ItemType . Ammo9x19 )
154+ {
155+ var thing = candy . Next ( 0 , 6 ) ;
156+ ItemtoGive = ItemType . None ;
157+ ev . Player . TryAddCandy ( E . AddCandy ( thing ) ) ;
158+ }
159+
141160 }
142- catch
161+ catch ( Exception ex )
143162 {
144- // ignored
163+ var timeUtc = DateTime . UtcNow ;
164+ TimeZoneInfo easternZone = TimeZoneInfo . FindSystemTimeZoneById ( "Eastern Standard Time" ) ;
165+ DateTime EstTime = TimeZoneInfo . ConvertTimeFromUtc ( timeUtc , easternZone ) ;
166+ string now = EstTime . ToString ( "dd, hh:mm:ss.ff tt" ) ;
167+ Log . Error ( $ "Error: { ex } occured.") ;
168+ ev . Player . ShowHint ( $ "Something went wrong at { now } .\n please send a DM to Cactusman or Noobest1001 on Discord or make an issue on Github.", 5 ) ;
145169 }
146170
147171 base . OnPickingUp ( ev ) ;
148172 }
173+
149174
150- private void Spawn ( RoomType room , Vector3 offset )
175+ private void SpawnRoom ( RoomType room , Vector3 offset )
151176 {
152177 Room temp = Room . Get ( room ) ;
153178 Vector3 globalPos = Utils . GetGlobalCords ( room , offset ) ;
0 commit comments