3
3
using CounterStrikeSharp . API ;
4
4
using CounterStrikeSharp . API . Modules . Commands ;
5
5
using CounterStrikeSharp . API . Modules . Admin ;
6
- using System . Data ;
7
6
8
7
namespace FunMatchPlugin ;
9
8
10
9
public class FunMatchPlugin : BasePlugin
11
10
{
12
11
public override string ModuleName => "Fun Match Plugin" ;
13
- public override string ModuleVersion => "1.0.4 " ;
12
+ public override string ModuleVersion => "1.0.5 " ;
14
13
public override void Load ( bool hotReload )
15
14
{
16
15
Console . WriteLine ( "Fun Match Plugin Load!" ) ;
@@ -34,6 +33,10 @@ public override void Load(bool hotReload)
34
33
FunLists . Add ( funToTheMoon ) ;
35
34
FunWNoStop funWNoStop = new FunWNoStop ( this ) ;
36
35
FunLists . Add ( funWNoStop ) ;
36
+ FunDropWeaponOnShoot funDropWeaponOnShoot = new ( ) ;
37
+ FunLists . Add ( funDropWeaponOnShoot ) ;
38
+ FunChangeWeaponOnShoot funChangeWeaponOnShoot = new ( ) ;
39
+ FunLists . Add ( funChangeWeaponOnShoot ) ;
37
40
}
38
41
39
42
public void LoadRandomFun ( )
@@ -74,6 +77,9 @@ public void LoadFunByName(string name)
74
77
private List < FunBaseClass > FunLists = new List < FunBaseClass > ( ) ;
75
78
private bool EnableRandom = true ;
76
79
80
+ private GameEventHandler < EventRoundStart > ? ManualLoadHander ;
81
+ private int ManualLoadIndex = - 1 ;
82
+
77
83
[ GameEventHandler ]
78
84
public HookResult OnRoundStart ( EventRoundStart @event , GameEventInfo info )
79
85
{
@@ -99,23 +105,32 @@ public void OnLoadFunCommand(CCSPlayerController? player, CommandInfo commandInf
99
105
commandInfo . ReplyToCommand ( $ "Invalid num. pls input num from { 1 } - { FunLists . Count } ") ;
100
106
return ;
101
107
}
102
- LoadFunByIndex ( num - 1 ) ;
108
+ if ( ManualLoadHander is not null )
109
+ {
110
+ commandInfo . ReplyToCommand ( $ "Alraedy loaded { ManualLoadIndex + 1 } Manually, Pls !fun_load first") ;
111
+ return ;
112
+ }
113
+ ManualLoadIndex = num - 1 ;
114
+ LoadFunByIndex ( ManualLoadIndex ) ;
115
+ RegisterEventHandler ( ManualLoadHander = ( @event , info ) =>
116
+ {
117
+ UnLoadFunByIndex ( ManualLoadIndex ) ;
118
+ Server . NextFrame ( ( ) => {
119
+ LoadFunByIndex ( ManualLoadIndex ) ;
120
+ } ) ;
121
+ return HookResult . Continue ;
122
+ } ) ;
103
123
}
104
124
105
- [ ConsoleCommand ( "!fun_load" , "UnLoad fun by num " ) ]
106
- [ CommandHelper ( minArgs : 1 , usage : "[num] " , whoCanExecute : CommandUsage . CLIENT_AND_SERVER ) ]
125
+ [ ConsoleCommand ( "!fun_load" , "UnLoad fun Manually " ) ]
126
+ [ CommandHelper ( minArgs : 0 , usage : "" , whoCanExecute : CommandUsage . CLIENT_AND_SERVER ) ]
107
127
[ RequiresPermissions ( "@css/root" ) ]
108
128
public void OnUnLoadFunCommand ( CCSPlayerController ? player , CommandInfo commandInfo )
109
129
{
110
-
111
- int num ;
112
- int . TryParse ( commandInfo . GetArg ( 1 ) , out num ) ;
113
- if ( num <= 0 || num > FunLists . Count )
114
- {
115
- commandInfo . ReplyToCommand ( $ "Invalid num. pls input num from { 1 } - { FunLists . Count } ") ;
116
- return ;
117
- }
118
- UnLoadFunByIndex ( num - 1 ) ;
130
+ UnLoadFunByIndex ( ManualLoadIndex ) ;
131
+ DeregisterEventHandler ( ManualLoadHander ! ) ;
132
+ ManualLoadHander = null ;
133
+ commandInfo . ReplyToCommand ( $ "Unloaded { ManualLoadIndex + 1 } ") ;
119
134
}
120
135
121
136
[ ConsoleCommand ( "fun_lists" , "Lists Avaliable Fun" ) ]
0 commit comments