33using CounterStrikeSharp . API ;
44using CounterStrikeSharp . API . Modules . Commands ;
55using CounterStrikeSharp . API . Modules . Admin ;
6- using System . Data ;
76
87namespace FunMatchPlugin ;
98
109public class FunMatchPlugin : BasePlugin
1110{
1211 public override string ModuleName => "Fun Match Plugin" ;
13- public override string ModuleVersion => "1.0.4 " ;
12+ public override string ModuleVersion => "1.0.5 " ;
1413 public override void Load ( bool hotReload )
1514 {
1615 Console . WriteLine ( "Fun Match Plugin Load!" ) ;
@@ -34,6 +33,10 @@ public override void Load(bool hotReload)
3433 FunLists . Add ( funToTheMoon ) ;
3534 FunWNoStop funWNoStop = new FunWNoStop ( this ) ;
3635 FunLists . Add ( funWNoStop ) ;
36+ FunDropWeaponOnShoot funDropWeaponOnShoot = new ( ) ;
37+ FunLists . Add ( funDropWeaponOnShoot ) ;
38+ FunChangeWeaponOnShoot funChangeWeaponOnShoot = new ( ) ;
39+ FunLists . Add ( funChangeWeaponOnShoot ) ;
3740 }
3841
3942 public void LoadRandomFun ( )
@@ -74,6 +77,9 @@ public void LoadFunByName(string name)
7477 private List < FunBaseClass > FunLists = new List < FunBaseClass > ( ) ;
7578 private bool EnableRandom = true ;
7679
80+ private GameEventHandler < EventRoundStart > ? ManualLoadHander ;
81+ private int ManualLoadIndex = - 1 ;
82+
7783 [ GameEventHandler ]
7884 public HookResult OnRoundStart ( EventRoundStart @event , GameEventInfo info )
7985 {
@@ -99,23 +105,32 @@ public void OnLoadFunCommand(CCSPlayerController? player, CommandInfo commandInf
99105 commandInfo . ReplyToCommand ( $ "Invalid num. pls input num from { 1 } - { FunLists . Count } ") ;
100106 return ;
101107 }
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+ } ) ;
103123 }
104124
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 ) ]
107127 [ RequiresPermissions ( "@css/root" ) ]
108128 public void OnUnLoadFunCommand ( CCSPlayerController ? player , CommandInfo commandInfo )
109129 {
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 } ") ;
119134 }
120135
121136 [ ConsoleCommand ( "fun_lists" , "Lists Avaliable Fun" ) ]
0 commit comments