Skip to content

Commit eaa0db1

Browse files
committed
v5.3
1 parent e6a13f5 commit eaa0db1

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

scripting/TF2Sandbox-PhysicsGun.sp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#define DEBUG
44

55
#define PLUGIN_AUTHOR "BattlefieldDuck"
6-
#define PLUGIN_VERSION "5.2"
6+
#define PLUGIN_VERSION "5.3"
77

88
#include <sourcemod>
99
#include <sdkhooks>
@@ -87,6 +87,8 @@ float g_fGrabDistance[MAXPLAYERS + 1]; //Distance between the client eye and ent
8787
float g_oldfEntityPos[MAXPLAYERS + 1][3];
8888
float g_fEntityPos[MAXPLAYERS + 1][3];
8989

90+
MoveType g_mtOriginal[MAXPLAYERS + 1];
91+
9092
float g_fRotateCD[MAXPLAYERS + 1];
9193
float g_fCopyCD[MAXPLAYERS + 1];
9294

@@ -253,6 +255,7 @@ public void Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast
253255
if(client > 0 && client <= MaxClients && IsClientInGame(client))
254256
{
255257
TF2_RegeneratePlayer(client);
258+
g_mtOriginal[client] = GetEntityMoveType(client);
256259
}
257260
}
258261

@@ -338,7 +341,7 @@ float[] GetPointAimPosition(float pos[3], float angles[3], float maxtracedistanc
338341
if(TR_DidHit(trace))
339342
{
340343
int entity = TR_GetEntityIndex(trace);
341-
if (entity > MaxClients && (Build_ReturnEntityOwner(entity) == client || CheckCommandAccess(client, "sm_admin", ADMFLAG_GENERIC)))
344+
if ((Build_ReturnEntityOwner(entity) == client || CheckCommandAccess(client, "sm_admin", ADMFLAG_GENERIC)))
342345
{
343346
g_iAimingEntityRef[client] = EntIndexToEntRef(entity);
344347

@@ -377,8 +380,7 @@ public bool TraceEntityFilter(int entity, int mask, int client)
377380
return (IsValidEntity(entity)
378381
&& entity != client
379382
&& entity != EntRefToEntIndex(g_iGrabEntityRef[client])
380-
&& entity != EntRefToEntIndex(g_iGrabPointRef[client])
381-
&& MaxClients < entity);
383+
&& entity != EntRefToEntIndex(g_iGrabPointRef[client]));
382384
}
383385

384386
float[] GetAngleYOnly(const float angles[3])
@@ -754,9 +756,15 @@ stock void PhysGunSettings(int client, int &buttons, int &impulse, float vel[3],
754756
//Set entity velocity to 0
755757
char szClass[32];
756758
GetEdictClassname(iEntity, szClass, sizeof(szClass));
757-
if(StrEqual(szClass, "prop_physics") || StrEqual(szClass, "tf_dropped_weapon"))
759+
if(StrEqual(szClass, "prop_physics") || StrEqual(szClass, "tf_dropped_weapon") || (iEntity > 0 && iEntity <= MaxClients))
758760
{
759761
TeleportEntity(iEntity, NULL_VECTOR, NULL_VECTOR, ZERO_VECTOR);
762+
763+
if(iEntity > 0 && iEntity <= MaxClients && IsClientInGame(iEntity) && IsPlayerAlive(iEntity))
764+
{
765+
g_mtOriginal[iEntity] = GetEntityMoveType(iEntity);
766+
SetEntityMoveType(iEntity, MOVETYPE_NONE);
767+
}
760768
}
761769

762770
//Set entity Outline
@@ -1066,8 +1074,13 @@ stock void PhysGunSettings(int client, int &buttons, int &impulse, float vel[3],
10661074
//Apply velocity
10671075
char szClass[32];
10681076
GetEdictClassname(entity, szClass, sizeof(szClass));
1069-
if(StrEqual(szClass, "prop_physics") || StrEqual(szClass, "tf_dropped_weapon"))
1077+
if(StrEqual(szClass, "prop_physics") || StrEqual(szClass, "tf_dropped_weapon") || (entity > 0 && entity <= MaxClients))
10701078
{
1079+
if(entity > 0 && entity <= MaxClients && IsClientInGame(entity) && IsPlayerAlive(entity))
1080+
{
1081+
SetEntityMoveType(entity, g_mtOriginal[entity]);
1082+
}
1083+
10711084
float vector[3];
10721085
MakeVectorFromPoints(g_oldfEntityPos[client], g_fEntityPos[client], vector);
10731086

0 commit comments

Comments
 (0)