1818Handle armsHandle ;
1919Handle modelHandle ;
2020
21+ ConVar autoSpawnCvar = null ;
22+ bool autoSpawn = true ;
23+
2124char defaultCTFbiModels [][] = {
2225 " ctm_fbi.mdl" ,
2326 " ctm_fbi_variantA.mdl" ,
@@ -59,17 +62,21 @@ public Plugin myinfo = {
5962 name = " Arms Fix" ,
6063 author = " NomisCZ (-N-)" ,
6164 description = " Arms fix" ,
62- version = " 1.5" ,
65+ version = " 1.5.5 " ,
6366 url = " http://steamcommunity.com/id/olympic-nomis-p"
6467}
6568
6669public void OnPluginStart () {
6770
6871 HookEvent (" player_spawn" , Event_PlayerSpawn );
72+ autoSpawnCvar = CreateConVar (" sm_arms_fix_autospawn" , " 1" , " Enable auto spawn fix (automatically sets default gloves)? 0 = False, 1 = True" , _ , true , 0.0 , true , 1.0 );
73+ autoSpawnCvar .AddChangeHook (OnCvarChanged );
6974}
7075
7176public void OnConfigsExecuted () {
7277
78+ autoSpawn = autoSpawnCvar .BoolValue ;
79+
7380 PrecacheModels ();
7481 PrecacheModels (true );
7582 PrecacheArms ();
@@ -83,17 +90,26 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
8390 modelHandle = CreateGlobalForward (" ArmsFix_OnModelSafe" , ET_Ignore , Param_Cell );
8491 CreateNative (" ArmsFix_SetDefaults" , Native_SetDefault );
8592 CreateNative (" ArmsFix_HasDefaultArms" , Native_HasDefaultArms );
93+ CreateNative (" ArmsFix_SetDefaultArms" , Native_SetDefaultArms );
8694
8795 return APLRes_Success ;
8896}
8997
98+ public void OnCvarChanged (ConVar convar , const char [] oldValue , const char [] newValue )
99+ {
100+ if (convar == autoSpawnCvar ) {
101+ autoSpawn = view_as <bool >(StringToInt (newValue ));
102+ }
103+ }
104+
90105public Action Event_PlayerSpawn (Event event , const char [] name , bool dontBroadcast ) {
91106
92107 int client = GetClientOfUserId (event .GetInt (" userid" ));
93108
94109 if ((! IsValidClient (client ) && ! IsPlayerAlive (client ) || IsFakeClient (client ))) return ;
95110
96- SetDefault (client );
111+ if (autoSpawn ) SetDefault (client );
112+
97113 CallForwards (client );
98114}
99115
@@ -128,6 +144,12 @@ public int Native_SetDefault(Handle plugin, int numParams) {
128144 SetDefault (client );
129145}
130146
147+ public int Native_SetDefaultArms (Handle plugin , int numParams ) {
148+
149+ int client = GetNativeCell (1 );
150+ SetDefaultArms (client );
151+ }
152+
131153public int Native_HasDefaultArms (Handle plugin , int numParams ) {
132154
133155 int client = GetNativeCell (1 );
@@ -204,6 +226,16 @@ public void SetDefault(int client) {
204226 }
205227}
206228
229+ public void SetDefaultArms (int client ) {
230+
231+ if ((! IsValidClient (client ) && ! IsPlayerAlive (client ) || IsFakeClient (client ))) return ;
232+
233+ int clientTeam = (GetClientTeam (client ) == CS_TEAM_T ? 0 : 1 );
234+
235+ SetEntPropString (client , Prop_Send , " m_szArmsModel" , " " );
236+ SetEntPropString (client , Prop_Send , " m_szArmsModel" , defaultArms [clientTeam ]);
237+ }
238+
207239char GetNewRandomModel (int client ) {
208240
209241 char clientModel [256 ];
@@ -278,6 +310,5 @@ bool hasDefaultArms(int client) {
278310
279311 char clientModel [256 ];
280312 GetEntPropString (client , Prop_Send , " m_szArmsModel" , clientModel , sizeof (clientModel ));
281-
282313 return (StrEqual (clientModel , defaultArms [0 ]) || StrEqual (clientModel , defaultArms [1 ]) || StrEqual (clientModel , " " )) ? true : false ;
283314}
0 commit comments