3
3
#define DEBUG
4
4
5
5
#define PLUGIN_AUTHOR " BattlefieldDuck"
6
- #define PLUGIN_VERSION " 5.0 "
6
+ #define PLUGIN_VERSION " 5.1 "
7
7
8
8
#include <sourcemod>
9
9
#include <sdkhooks>
@@ -61,6 +61,7 @@ enum PhysicsGunSequence
61
61
Handle g_hSyncHints ;
62
62
63
63
ConVar g_cvbCanGrabBuild ;
64
+ ConVar g_cvbFullDuplicate ;
64
65
65
66
int g_iModelIndex ;
66
67
int g_iHaloIndex ;
@@ -95,6 +96,7 @@ public void OnPluginStart()
95
96
RegAdminCmd (" sm_physicsgun" , Command_EquipPhysicsGun , 0 , " Equip a Physics Gun" );
96
97
97
98
g_cvbCanGrabBuild = CreateConVar (" sm_tf2sb_physgun_cangrabbuild" , " 0" , " Enable/disable grabbing buildings" , 0 , true , 0.0 , true , 1.0 );
99
+ g_cvbFullDuplicate = CreateConVar (" sm_tf2sb_physgun_fullduplicate" , " 0" , " Enable/disable full duplicate feature - Disable = Only prop_dynamic" , 0 , true , 0.0 , true , 1.0 );
98
100
99
101
HookEvent (" player_spawn" , Event_PlayerSpawn );
100
102
@@ -142,20 +144,37 @@ public void OnClientPutInServer(int client)
142
144
143
145
public void OnClientDisconnect (int client )
144
146
{
147
+ //Kill Grab Point
145
148
int iGrabPoint = EntRefToEntIndex (g_iGrabPointRef [client ]);
146
149
if (iGrabPoint != INVALID_ENT_REFERENCE && iGrabPoint != 0 )
147
150
{
148
151
AcceptEntityInput (iGrabPoint , " Kill" );
149
152
}
153
+
154
+ //Kill Grab Outline
155
+ int iGrabOutline = EntRefToEntIndex (g_iGrabOutlineRef [client ]);
156
+ if (iGrabOutline != INVALID_ENT_REFERENCE && iGrabOutline != 0 )
157
+ {
158
+ AcceptEntityInput (iGrabOutline , " Kill" );
159
+ }
160
+
161
+ //Kill Grab Glow
162
+ int iGrabGlow = EntRefToEntIndex (g_iGrabGlowRef [client ]);
163
+ if (iGrabGlow != INVALID_ENT_REFERENCE && iGrabGlow != 0 )
164
+ {
165
+ AcceptEntityInput (iGrabGlow , " Kill" );
166
+ }
150
167
}
151
168
169
+ //Block sound when client IN_ATTACK
170
+ #define SOUND_BLOCK " common/wpn_denyselect.wav"
152
171
public Action SoundHook (int clients [64 ], int & numClients , char sample [PLATFORM_MAX_PATH ], int & entity , int & channel , float & volume , int & level , int & pitch , int & flags , char soundEntry [PLATFORM_MAX_PATH ], int & seed )
153
172
{
154
173
for (int i = 1 ; i <= MaxClients ; i ++ )
155
174
{
156
175
if (IsClientInGame (i ) && IsPlayerAlive (i ) && IsHoldingPhysicsGun (i ))
157
176
{
158
- if (StrEqual (sample , " common/wpn_denyselect.wav " ))
177
+ if (StrEqual (sample , SOUND_BLOCK ))
159
178
{
160
179
return Plugin_Stop ;
161
180
}
@@ -188,17 +207,8 @@ public Action Command_EquipPhysicsGun(int client, int args)
188
207
return Plugin_Continue ;
189
208
}
190
209
191
- Build_PrintToChat (client , " You have equipped a Physics Gun (Sandbox version)!" );
192
-
193
- //Set physics gun as Active Weapon
194
- int weapon = GetPlayerWeaponSlot (client , WEAPON_SLOT );
195
- if (IsValidEntity (weapon ))
196
- {
197
- SetEntPropEnt (client , Prop_Send , " m_hActiveWeapon" , weapon );
198
- }
199
-
200
210
//Credits: FlaminSarge
201
- weapon = CreateEntityByName (" tf_weapon_builder" );
211
+ int weapon = CreateEntityByName (" tf_weapon_builder" );
202
212
if (IsValidEntity (weapon ))
203
213
{
204
214
SetEntityModel (weapon , MODEL_PHYSICSGUNWM );
@@ -223,7 +233,12 @@ public Action Command_EquipPhysicsGun(int client, int args)
223
233
TF2_RemoveWeaponSlot (client , WEAPON_SLOT );
224
234
DispatchSpawn (weapon );
225
235
226
- EquipPlayerWeapon (client , weapon );
236
+ EquipPlayerWeapon (client , weapon );
237
+
238
+ //Set physics gun as Active Weapon
239
+ SetEntPropEnt (client , Prop_Send , " m_hActiveWeapon" , weapon );
240
+
241
+ Build_PrintToChat (client , " You have equipped a Physics Gun (Sandbox version)!" );
227
242
}
228
243
229
244
return Plugin_Continue ;
@@ -441,52 +456,30 @@ int TF2_EquipWearable(int client, int entity)
441
456
if (g_hSdkEquipWearable != INVALID_HANDLE ) SDKCall (g_hSdkEquipWearable , client , entity );
442
457
}
443
458
444
- bool HasOutline (int iEnt )
459
+ int CreateOutline (int entity )
445
460
{
446
- int index = - 1 ;
447
- while (( index = FindEntityByClassname ( index , " tf_glow " )) != - 1 )
461
+ int ent = CreateEntityByName ( " tf_glow " ) ;
462
+ if ( IsValidEntity ( ent ) )
448
463
{
449
- if (GetEntPropEnt (index , Prop_Send , " m_hTarget" ) == iEnt )
450
- {
451
- return true ;
452
- }
453
- }
454
-
455
- return false ;
456
- }
464
+ char oldEntName [256 ];
465
+ GetEntPropString (entity , Prop_Data , " m_iName" , oldEntName , sizeof (oldEntName ));
466
+
467
+ char strName [128 ], strClass [64 ];
468
+ GetEntityClassname (entity , strClass , sizeof (strClass ));
469
+ Format (strName , sizeof (strName ), " %s%i " , strClass , EntIndexToEntRef (entity ));
470
+ DispatchKeyValue (entity , " targetname" , strName );
471
+ DispatchKeyValue (ent , " target" , strName );
472
+
473
+ DispatchKeyValue (ent , " Mode" , " 0" );
474
+ DispatchKeyValue (ent , " GlowColor" , " 135 224 230 255" );
475
+
476
+ DispatchSpawn (ent );
457
477
458
- int CreateOutline (int iEnt )
459
- {
460
- if (! HasOutline (iEnt ))
461
- {
462
- char oldEntName [64 ];
463
- GetEntPropString (iEnt , Prop_Data , " m_iName" , oldEntName , sizeof (oldEntName ));
478
+ AcceptEntityInput (ent , " Enable" );
464
479
465
- char strName [126 ], strClass [64 ];
466
- GetEntityClassname (iEnt , strClass , sizeof (strClass ));
467
- Format (strName , sizeof (strName ), " %s%i " , strClass , iEnt );
468
- DispatchKeyValue (iEnt , " targetname" , strName );
480
+ SetEntPropString (entity , Prop_Data , " m_iName" , oldEntName );
469
481
470
- int ent = CreateEntityByName (" tf_glow" );
471
- if (IsValidEntity (ent ))
472
- {
473
- DispatchKeyValue (ent , " targetname" , " GrabOutline" );
474
- DispatchKeyValue (ent , " target" , strName );
475
- DispatchKeyValue (ent , " Mode" , " 0" );
476
-
477
- char strColor [18 ];
478
- Format (strColor , sizeof (strColor ), " %i %i %i %i " , 135 , 224 , 230 , 255 );
479
- DispatchKeyValue (ent , " GlowColor" , strColor );
480
-
481
- DispatchSpawn (ent );
482
-
483
- AcceptEntityInput (ent , " Enable" );
484
-
485
- //Change name back to old name because we don't need it anymore.
486
- SetEntPropString (iEnt , Prop_Data , " m_iName" , oldEntName );
487
-
488
- return ent ;
489
- }
482
+ return ent ;
490
483
}
491
484
492
485
return - 1 ;
@@ -544,6 +537,11 @@ int Duplicator(int iEntity)
544
537
szClass = " prop_physics_override" ;
545
538
}
546
539
540
+ if (! g_cvbFullDuplicate .BoolValue )
541
+ {
542
+ szClass = " prop_dynamic_override" ;
543
+ }
544
+
547
545
GetEntPropString (iEntity , Prop_Data , " m_ModelName" , szModel , sizeof (szModel ));
548
546
GetEntPropVector (iEntity , Prop_Send , " m_vecOrigin" , fOrigin );
549
547
GetEntPropVector (iEntity , Prop_Data , " m_angRotation" , fAngles );
0 commit comments